Repository: mir-evaluation/mir_eval
Issue: update   numpy dependency
Root cause: External Dependency Breakage

Hello!
As you know, your project is on Debian.

Recently, one of your code's dependencies was updated, in this case "numpy".

As debian is constantly updating its packages, mir-herval also needed to make some changes to some parts of its code in order to keep it building normally.

This issue is described in this article:
https://levelup.gitconnected.com/fix-attributeerror-module-numpy-has-no-attribute-float-d7d68c5a4971

Below is part of the code that needed updates:
```
Index: mir-eval/mir_eval/segment.py
===================================================================
--- mir-eval.orig/mir_eval/segment.py
+++ mir-eval/mir_eval/segment.py
@@ -540,7 +540,7 @@ def _contingency_matrix(reference_indice
     return scipy.sparse.coo_matrix((np.ones(ref_class_idx.shape[0]),
                                     (ref_class_idx, est_class_idx)),
                                    shape=(n_ref_classes, n_est_classes),
-                                   dtype=np.int).toarray()
+                                   dtype=int).toarray()
 
 
 def _adjusted_rand_index(reference_indices, estimated_indices):
@@ -720,7 +720,7 @@ def _entropy(labels):
     if len(labels) == 0:
         return 1.0
     label_idx = np.unique(labels, return_inverse=True)[1]
-    pi = np.bincount(label_idx).astype(np.float)
+    pi = np.bincount(label_idx).astype(float)
     pi = pi[pi > 0]
     pi_sum = np.sum(pi)
     # log(a / b) should be calculated as log(a) - log(b) for

Index: mir-eval/mir_eval/chord.py
===================================================================
--- mir-eval.orig/mir_eval/chord.py
+++ mir-eval/mir_eval/chord.py
@@ -510,7 +510,7 @@ def encode(chord_label, reduce_extended_
         semitone_bitmap += scale_degree_to_bitmap(scale_degree,
                                                   reduce_extended_chords)
 
-    semitone_bitmap = (semitone_bitmap > 0).astype(np.int)
+    semitone_bitmap = (semitone_bitmap > 0).astype(int)
     if not semitone_bitmap[bass_number] and strict_bass_intervals:
         raise InvalidChordException(
             "Given bass scale degree is absent from this chord: "
@@ -544,8 +544,8 @@ def encode_many(chord_labels, reduce_ext
 
     """
     num_items = len(chord_labels)
-    roots, basses = np.zeros([2, num_items], dtype=np.int)
-    semitones = np.zeros([num_items, 12], dtype=np.int)
+    roots, basses = np.zeros([2, num_items], dtype=int)
+    semitones = np.zeros([num_items, 12], dtype=int)
     local_cache = dict()
     for i, label in enumerate(chord_labels):
         result = local_cache.get(label, None)
@@ -749,7 +749,7 @@ def thirds(reference_labels, estimated_l
 
     eq_roots = ref_roots == est_roots
     eq_thirds = ref_semitones[:, 3] == est_semitones[:, 3]
-    comparison_scores = (eq_roots * eq_thirds).astype(np.float)
+    comparison_scores = (eq_roots * eq_thirds).astype(float)
 
     # Ignore 'X' chords
     comparison_scores[np.any(ref_semitones < 0, axis=1)] = -1.0
@@ -797,7 +797,7 @@ def thirds_inv(reference_labels, estimat
     eq_root = ref_roots == est_roots
     eq_bass = ref_bass == est_bass
     eq_third = ref_semitones[:, 3] == est_semitones[:, 3]
-    comparison_scores = (eq_root * eq_third * eq_bass).astype(np.float)
+    comparison_scores = (eq_root * eq_third * eq_bass).astype(float)
 
     # Ignore 'X' chords
     comparison_scores[np.any(ref_semitones < 0, axis=1)] = -1.0
@@ -845,7 +845,7 @@ def triads(reference_labels, estimated_l
     eq_roots = ref_roots == est_roots
     eq_semitones = np.all(
         np.equal(ref_semitones[:, :8], est_semitones[:, :8]), axis=1)
-    comparison_scores = (eq_roots * eq_semitones).astype(np.float)
+    comparison_scores = (eq_roots * eq_semitones).astype(float)
 
     # Ignore 'X' chords
     comparison_scores[np.any(ref_semitones < 0, axis=1)] = -1.0
@@ -894,7 +894,7 @@ def triads_inv(reference_labels, estimat
     eq_basses = ref_bass == est_bass
     eq_semitones = np.all(
         np.equal(ref_semitones[:, :8], est_semitones[:, :8]), axis=1)
-    comparison_scores = (eq_roots * eq_semitones * eq_basses).astype(np.float)
+    comparison_scores = (eq_roots * eq_semitones * eq_basses).astype(float)
 
     # Ignore 'X' chords
     comparison_scores[np.any(ref_semitones < 0, axis=1)] = -1.0
@@ -941,7 +941,7 @@ def tetrads(reference_labels, estimated_
 
     eq_roots = ref_roots == est_roots
     eq_semitones = np.all(np.equal(ref_semitones, est_semitones), axis=1)
-    comparison_scores = (eq_roots * eq_semitones).astype(np.float)
+    comparison_scores = (eq_roots * eq_semitones).astype(float)
 
     # Ignore 'X' chords
     comparison_scores[np.any(ref_semitones < 0, axis=1)] = -1.0
@@ -989,7 +989,7 @@ def tetrads_inv(reference_labels, estima
     eq_roots = ref_roots == est_roots
     eq_basses = ref_bass == est_bass
     eq_semitones = np.all(np.equal(ref_semitones, est_semitones), axis=1)
-    comparison_scores = (eq_roots * eq_semitones * eq_basses).astype(np.float)
+    comparison_scores = (eq_roots * eq_semitones * eq_basses).astype(float)
 
     # Ignore 'X' chords
     comparison_scores[np.any(ref_semitones < 0, axis=1)] = -1.0
@@ -1035,7 +1035,7 @@ def root(reference_labels, estimated_lab
     validate(reference_labels, estimated_labels)
     ref_roots, ref_semitones = encode_many(reference_labels, False)[:2]
     est_roots = encode_many(estimated_labels, False)[0]
-    comparison_scores = (ref_roots == est_roots).astype(np.float)
+    comparison_scores = (ref_roots == est_roots).astype(float)
 
     # Ignore 'X' chords
     comparison_scores[np.any(ref_semitones < 0, axis=1)] = -1.0
@@ -1087,7 +1087,7 @@ def mirex(reference_labels, estimated_la
     eq_chroma = (ref_chroma * est_chroma).sum(axis=-1)
 
     # Chroma matching for set bits
-    comparison_scores = (eq_chroma >= min_intersection).astype(np.float)
+    comparison_scores = (eq_chroma >= min_intersection).astype(float)
 
     # No-chord matching; match -1 roots, SKIP_CHORDS dropped next
     no_root = np.logical_and(ref_data[0] == -1, est_data[0] == -1)
@@ -1150,7 +1150,7 @@ def majmin(reference_labels, estimated_l
     eq_root = ref_roots == est_roots
     eq_quality = np.all(np.equal(ref_semitones[:, :8],
                                  est_semitones[:, :8]), axis=1)
-    comparison_scores = (eq_root * eq_quality).astype(np.float)
+    comparison_scores = (eq_root * eq_quality).astype(float)
 
     # Test for Major / Minor / No-chord
     is_maj = np.all(np.equal(ref_semitones[:, :8], maj_semitones), axis=1)
@@ -1217,7 +1217,7 @@ def majmin_inv(reference_labels, estimat
     eq_root_bass = (ref_roots == est_roots) * (ref_bass == est_bass)
     eq_semitones = np.all(np.equal(ref_semitones[:, :8],
                                    est_semitones[:, :8]), axis=1)
-    comparison_scores = (eq_root_bass * eq_semitones).astype(np.float)
+    comparison_scores = (eq_root_bass * eq_semitones).astype(float)
 
     # Test for Major / Minor / No-chord
     is_maj = np.all(np.equal(ref_semitones[:, :8], maj_semitones), axis=1)
@@ -1280,7 +1280,7 @@ def sevenths(reference_labels, estimated
 
     eq_root = ref_roots == est_roots
     eq_semitones = np.all(np.equal(ref_semitones, est_semitones), axis=1)
-    comparison_scores = (eq_root * eq_semitones).astype(np.float)
+    comparison_scores = (eq_root * eq_semitones).astype(float)
 
     # Test for reference chord inclusion
     is_valid = np.array([np.all(np.equal(ref_semitones, semitones), axis=1)
@@ -1335,7 +1335,7 @@ def sevenths_inv(reference_labels, estim
 
     eq_roots_basses = (ref_roots == est_roots) * (ref_basses == est_basses)
     eq_semitones = np.all(np.equal(ref_semitones, est_semitones), axis=1)
-    comparison_scores = (eq_roots_basses * eq_semitones).astype(np.float)
+    comparison_scores = (eq_roots_basses * eq_semitones).astype(float)
 
     # Test for Major / Minor / No-chord
     is_valid = np.array([np.all(np.equal(ref_semitones, semitones), axis=1)

Index: mir-eval/tests/test_beat.py
===================================================================
--- mir-eval.orig/tests/test_beat.py
+++ mir-eval/tests/test_beat.py
@@ -19,9 +19,9 @@ SCORES_GLOB = 'data/beat/output*.json'
 
 def test_trim_beats():
     # Construct dummy beat times [0., 1., ...]
-    dummy_beats = np.arange(10, dtype=np.float)
+    dummy_beats = np.arange(10, dtype=float)
     # We expect trim_beats to remove all beats < 5s
-    expected_beats = np.arange(5, 10, dtype=np.float)
+    expected_beats = np.arange(5, 10, dtype=float)
     assert np.allclose(mir_eval.beat.trim_beats(dummy_beats), expected_beats)
 
 
@@ -51,7 +51,7 @@ def __unit_test_beat_function(metric):
     nose.tools.assert_raises(ValueError, metric, beats, beats)
 
     # Valid beats which are the same produce a score of 1 for all metrics
-    beats = np.arange(10, dtype=np.float)
+    beats = np.arange(10, dtype=float)
     assert np.allclose(metric(beats, beats), 1)
 
 
Index: mir-eval/tests/test_onset.py
===================================================================
--- mir-eval.orig/tests/test_onset.py
+++ mir-eval/tests/test_onset.py
@@ -43,7 +43,7 @@ def __unit_test_onset_function(metric):
     nose.tools.assert_raises(ValueError, metric, onsets, onsets)
 
     # Valid onsets which are the same produce a score of 1 for all metrics
-    onsets = np.arange(10, dtype=np.float)
+    onsets = np.arange(10, dtype=float)
     assert np.allclose(metric(onsets, onsets), 1)
 
 
Index: mir-eval/mir_eval/beat.py
===================================================================
--- mir-eval.orig/mir_eval/beat.py
+++ mir-eval/mir_eval/beat.py
@@ -386,14 +386,14 @@ def p_score(reference_beats,
     estimated_beats = np.array(estimated_beats - offset)
     reference_beats = np.array(reference_beats - offset)
     # Get the largest time index
-    end_point = np.int(np.ceil(np.max([np.max(estimated_beats),
+    end_point = int(np.ceil(np.max([np.max(estimated_beats),
                                        np.max(reference_beats)])))
     # Make impulse trains with impulses at beat locations
     reference_train = np.zeros(end_point*sampling_rate + 1)
-    beat_indices = np.ceil(reference_beats*sampling_rate).astype(np.int)
+    beat_indices = np.ceil(reference_beats*sampling_rate).astype(int)
     reference_train[beat_indices] = 1.0
     estimated_train = np.zeros(end_point*sampling_rate + 1)
-    beat_indices = np.ceil(estimated_beats*sampling_rate).astype(np.int)
+    beat_indices = np.ceil(estimated_beats*sampling_rate).astype(int)
     estimated_train[beat_indices] = 1.0
     # Window size to take the correlation over
     # defined as .2*median(inter-annotation-intervals)
```

:+1: to this - should be an easy update if anyone wants to prep a PR?

+1, PRs welcome!

Think this is resolved now (but might be wrong).

Related https://github.com/craffel/mir_eval/issues/366

I am the maintainer of your package on Debian.

Notice that you made several changes to mir_eval.

Debian robots track your changes here
https://github.com/craffel/mir_eval/releases

However, this url states that the last change was on 02/16/2022.

Would you be able to release a new version with all these changes, so that I can update mir_eval?

Grateful!
Nilson F. Silva


________________________________
De: Colin Raffel ***@***.***>
Enviado: segunda-feira, 25 de março de 2024 15:54
Para: craffel/mir_eval ***@***.***>
Cc: Nilsonfsilva ***@***.***>; Author ***@***.***>
Assunto: Re: [craffel/mir_eval] update numpy dependency (Issue #352)


Closed #352<https://github.com/craffel/mir_eval/issues/352> as completed via #370<https://github.com/craffel/mir_eval/pull/370>.

—
Reply to this email directly, view it on GitHub<https://github.com/craffel/mir_eval/issues/352#event-12239163597>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AVZIS74TNUBQYJ5FYIDFWM3Y2BXFRAVCNFSM6AAAAAAT5PICL2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGIZTSMJWGM2TSNY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>


@Nilsonfsilva There's a milestone set up for the next release, and I'm working on it.

I'll be waiting!


Nilson F. Silva


________________________________
De: Brian McFee ***@***.***>
Enviado: segunda-feira, 25 de março de 2024 16:57
Para: craffel/mir_eval ***@***.***>
Cc: Nilsonfsilva ***@***.***>; Mention ***@***.***>
Assunto: Re: [craffel/mir_eval] update numpy dependency (Issue #352)


@Nilsonfsilva<https://github.com/Nilsonfsilva> There's a milestone set up for the next release, and I'm working on it.

—
Reply to this email directly, view it on GitHub<https://github.com/craffel/mir_eval/issues/352#issuecomment-2018801061>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AVZIS74T4VQUQDCH6D56RS3Y2B6RTAVCNFSM6AAAAAAT5PICL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJYHAYDCMBWGE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>