Skip to content

Commit 33e90c6

Browse files
authored
Fix python depedencies and apply formatting to make CI work again (#175)
* rm wave dependency, upperbound mireval version, format to fix tests * also put a constraint on mirdata
1 parent b9894fc commit 33e90c6

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed

basic_pitch/commandline_printing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def generating_file_message(output_type: str) -> None:
4343
"""
4444
print(f"\n\n{DEFAULT_PRINT_INDENT}Creating {output_type.replace('_', ' ').lower()}...")
4545

46+
4647
def file_saved_confirmation(output_type: str, save_path: Union[pathlib.Path, str]) -> None:
4748
"""Print a confirmation that the file was saved succesfully
4849
@@ -54,6 +55,7 @@ def file_saved_confirmation(output_type: str, save_path: Union[pathlib.Path, str
5455
emoji = OUTPUT_EMOJIS.get(output_type, "")
5556
print(f"{DEFAULT_PRINT_INDENT}{emoji} Saved to {save_path}")
5657

58+
5759
def failed_to_save(output_type: str, save_path: Union[pathlib.Path, str]) -> None:
5860
"""Print a failure to save message
5961
@@ -64,6 +66,7 @@ def failed_to_save(output_type: str, save_path: Union[pathlib.Path, str]) -> Non
6466
"""
6567
print(f"\n🚨 Failed to save {output_type.replace('_', ' ').lower()} to {save_path} \n")
6668

69+
6770
@contextmanager
6871
def no_tf_warnings() -> Iterator[None]:
6972
"""

basic_pitch/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from enum import Enum
2121

2222

23-
SEMITONES_PER_OCTAVE = 12 # for frequency bin calculations
23+
SEMITONES_PER_OCTAVE = 12 # for frequency bin calculations
2424

2525
FFT_HOP = 256
2626
N_FFT = 8 * FFT_HOP

basic_pitch/inference.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def predict(self, x: npt.NDArray[np.float32]) -> Dict[str, npt.NDArray[np.float3
189189
DEFAULT_OVERLAPPING_FRAMES = 30
190190
DEFAULT_MIDI_VELOCITY_SCALE = 127
191191

192+
192193
def window_audio_file(
193194
audio_original: npt.NDArray[np.float32], hop_size: int
194195
) -> Iterable[Tuple[npt.NDArray[np.float32], Dict[str, float]]]:

basic_pitch/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ def onset_loss(
119119
return lambda x, y: transcription_loss(x, y, label_smoothing=label_smoothing)
120120

121121

122-
def loss(label_smoothing: float = DEFAULT_LABEL_SMOOTHING, weighted: bool = False, positive_weight: float = DEFAULT_POSITIVE_WEIGHT) -> Dict[str, Any]:
122+
def loss(
123+
label_smoothing: float = DEFAULT_LABEL_SMOOTHING,
124+
weighted: bool = False,
125+
positive_weight: float = DEFAULT_POSITIVE_WEIGHT,
126+
) -> Dict[str, Any]:
123127
"""Creates a keras-compatible dictionary of loss functions to calculate
124128
the loss for the contour, note and onset posteriorgrams.
125129

basic_pitch/nn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def __init__(
4949
self.bins_per_semitone = bins_per_semitone
5050
self.harmonics = harmonics
5151
self.shifts = [
52-
int(tf.math.round(SEMITONES_PER_OCTAVE * self.bins_per_semitone * log_base_b(float(h), 2))) for h in self.harmonics
52+
int(tf.math.round(SEMITONES_PER_OCTAVE * self.bins_per_semitone * log_base_b(float(h), 2)))
53+
for h in self.harmonics
5354
]
5455
self.n_output_freqs = n_output_freqs
5556

basic_pitch/note_creation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ def note_events_to_midi(
257257
if not pitch_bend:
258258
continue
259259
pitch_bend_times = np.linspace(start_time, end_time, len(pitch_bend))
260-
pitch_bend_midi_ticks = np.round(np.array(pitch_bend) * PITCH_BEND_SCALE / CONTOURS_BINS_PER_SEMITONE).astype(int)
260+
pitch_bend_midi_ticks = np.round(np.array(pitch_bend) * PITCH_BEND_SCALE / CONTOURS_BINS_PER_SEMITONE).astype(
261+
int
262+
)
261263
# This supports pitch bends up to 2 semitones
262264
# If we estimate pitch bends above/below 2 semitones, crop them here when adding them to the midi file
263265
pitch_bend_midi_ticks[pitch_bend_midi_ticks > N_PITCH_BEND_TICKS - 1] = N_PITCH_BEND_TICKS - 1
@@ -270,7 +272,7 @@ def note_events_to_midi(
270272

271273

272274
def drop_overlapping_pitch_bends(
273-
note_events_with_pitch_bends: List[Tuple[float, float, int, float, Optional[List[int]]]]
275+
note_events_with_pitch_bends: List[Tuple[float, float, int, float, Optional[List[int]]]],
274276
) -> List[Tuple[float, float, int, float, Optional[List[int]]]]:
275277
"""Drop pitch bends from any notes that overlap in time with another note"""
276278
note_events = sorted(note_events_with_pitch_bends)

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ classifiers = [
2020
dependencies = [
2121
"coremltools; platform_system == 'Darwin'",
2222
"librosa>=0.8.0",
23-
"mir_eval>=0.6",
23+
# TODO: mir_eval 0.8.1+ introduces fixes to sonification that broke our tests
24+
# Likely we'd like to adapt the tests to release the constraint
25+
"mir_eval>=0.6,<=0.8.0",
2426
"numpy>=1.18",
2527
"onnxruntime; platform_system == 'Windows' and python_version < '3.11'",
2628
"pretty_midi>=0.2.9",
@@ -55,7 +57,9 @@ bp-download = "basic_pitch.data.download:main"
5557
data = [
5658
"basic_pitch[tf,test]",
5759
"apache_beam",
58-
"mirdata",
60+
# TODO: mirdata 0.3.9 moves dataset indexes files which breaks our tests
61+
# Adapt our codebase to release that constraint
62+
"mirdata<=0.3.8",
5963
"smart_open",
6064
"sox",
6165
"ffmpeg-python"
@@ -65,7 +69,6 @@ test = [
6569
"coverage>=5.0.2",
6670
"pytest>=6.1.1",
6771
"pytest-mock",
68-
"wave",
6972
"mido"
7073
]
7174
tf = [

0 commit comments

Comments
 (0)