diff --git a/src/musiclib/noteset.py b/src/musiclib/noteset.py index a0fec3a5..b205192f 100644 --- a/src/musiclib/noteset.py +++ b/src/musiclib/noteset.py @@ -300,62 +300,3 @@ def subsets(noteset: NoteSet, min_notes: int = 1) -> frozenset[NoteSet]: for notes in itertools.combinations(noteset, n_subset): out.add(NoteSet(frozenset(notes))) return frozenset(out) - - -class ComparedNoteSets(Cached, ReprSVGMixin): - """ - this is compared scale - local terminology: left scale is compared to right - left is kinda parent, right is kinda child - """ - - def __init__(self, left: NoteSet, right: NoteSet) -> None: - if not (isinstance(left, NoteSet) and isinstance(right, NoteSet)): - raise TypeError(f'expected NoteSet, got {type(left)} and {type(right)}') - self.left = left - self.right = right - self.key = left, right - self.shared_notes = frozenset(left.notes) & frozenset(right.notes) - self.new_notes = frozenset(right.notes) - frozenset(left.notes) - self.del_notes = frozenset(left.notes) - frozenset(right.notes) - - def __eq__(self, other: object) -> bool: - if not isinstance(other, ComparedNoteSets): - raise TypeError - return self.key == other.key - - def __hash__(self) -> int: - return hash(self.key) - - def __str__(self) -> str: - return f'{self.left} | {self.right}' - - def __repr__(self) -> str: - return f'ComparedNoteSets({self})' - - def svg_piano(self, **kwargs: Any) -> svg.SVG: - from musiclib.svg.card import Piano - kwargs = pickle.loads(pickle.dumps(kwargs)) # faster than copy.deepcopy - setdefault_path( - kwargs, - 'regular_piano_kwargs.note_colors', - dict.fromkeys(self.del_notes, config.RED) | - dict.fromkeys(self.new_notes, config.GREEN) | - dict.fromkeys(self.shared_notes, config.BLUE), - ) - setdefault_path(kwargs, 'header_kwargs.title', str(self)) - return Piano(**kwargs).svg - - def svg_plane_piano(self, **kwargs: Any) -> svg.SVG: - from musiclib.svg.card import PlanePiano - kwargs = pickle.loads(pickle.dumps(kwargs)) # faster than copy.deepcopy - n0 = Note(config.chromatic_notes[0]) - setdefault_path(kwargs, 'header_kwargs.title', str(self)) - kwargs.setdefault( - 'interval_colors', - dict.fromkeys([n - n0 for n in self.del_notes], config.RED) | - dict.fromkeys([n - n0 for n in self.new_notes], config.GREEN) | - dict.fromkeys([n - n0 for n in self.shared_notes], config.BLUE), - ) - kwargs.setdefault('interval_text', FromIntervalDict({n - n0: str(n) for n in CHROMATIC_NOTESET}, abstract=True)) - return PlanePiano(**kwargs).svg diff --git a/tests/noteset_test.py b/tests/noteset_test.py index 18c9768c..28474ed6 100644 --- a/tests/noteset_test.py +++ b/tests/noteset_test.py @@ -6,7 +6,6 @@ from musiclib.interval import AbstractInterval from musiclib.note import Note from musiclib.note import SpecificNote -from musiclib.noteset import ComparedNoteSets from musiclib.noteset import NoteSet from musiclib.scale import Scale @@ -237,14 +236,3 @@ def test_subtract_types(): noteset.subtract('C', SpecificNote('D', 1)) # type: ignore[arg-type] with pytest.raises(TypeError): noteset.subtract('D1', Note('C')) # type: ignore[arg-type] - - -def test_compared(): - left = Scale.from_name('C', 'major').noteset - right = Scale.from_name('A', 'minor').noteset - assert ComparedNoteSets(left, right).shared_notes == frozenset(left.notes) - - right = Scale.from_name('C', 'mixolydian').noteset - c = ComparedNoteSets(left, right) - assert c.new_notes == frozenset({Note('b')}) - assert c.del_notes == frozenset({Note('B')}) diff --git a/tests/svg/repr_svg_test.py b/tests/svg/repr_svg_test.py index c1c0f844..df58f60a 100644 --- a/tests/svg/repr_svg_test.py +++ b/tests/svg/repr_svg_test.py @@ -3,7 +3,6 @@ import pytest from colortool import Color from musiclib import config -from musiclib.noteset import ComparedNoteSets from musiclib.noteset import NoteSet from musiclib.noteset import SpecificNoteSet from musiclib.scale import Scale @@ -95,26 +94,6 @@ def test_svg_scale(kind, svg_method, title, subtitle, title_href, background_col svg_helper(svg, class_, title, subtitle, title_href, background_color) -@pytest.mark.parametrize( - ('scale0', 'scale1'), [ - (Scale.from_name('C', 'major'), Scale.from_name('f', 'phrygian')), - (Scale.from_name('A', 'major'), Scale.from_name('f', 'phrygian')), - ], -) -@pytest.mark.parametrize('svg_method', ['svg_piano', 'svg_plane_piano']) -@pytest.mark.parametrize('title', [None, TITLE]) -@pytest.mark.parametrize('subtitle', [None, SUBTITLE]) -@pytest.mark.parametrize('title_href', [None, TITLE_HREF]) -@pytest.mark.parametrize('background_color', [BACKGROUND_COLOR]) -def test_svg_compared_notesets(scale0, scale1, svg_method, title, subtitle, title_href, background_color): - if title is None and title_href is not None: - pytest.skip('title_href requires title') - class_ = ('cls1', 'cls2') - kw = kw_helper(class_, title, subtitle, title_href, background_color, svg_method) - svg = str(getattr(ComparedNoteSets(scale0.noteset, scale1.noteset), svg_method)(**kw)) - svg_helper(svg, class_, title, subtitle, title_href, background_color) - - @pytest.mark.parametrize( 'sns', [ SpecificNoteSet.from_str('C1_E1_f1'),