apply_tone_operation

apply_tone_operation(
    operation: Callable[..., Tone],
    tone: Tone,
    *args,
    expected: type = Tone,
    **kwargs,
)

Returns operation(tone, *args, **kwargs), checking the result is an expected Tone.

The one validation used by every transform/transform_tones implementation, so they all fail the same way when handed an operation that does not produce a Tone.

>>> from openmusickit.systems.wsmn.tonal.symbols import C, M3
>>> from openmusickit.systems.wsmn.tonal.tonal_vector import TonalVector
>>> apply_tone_operation(TonalVector.transpose, C, M3)
TonalVector((2, 4))
>>> apply_tone_operation(str, C)
Traceback (most recent call last):
...
TypeError: `operation` must return a Tone, but returned 'TonalVector((0, 0)) # C' for TonalVector((0, 0)).