def test_can_slice_frequency_dim_with_start_and_end_hz(self): scale = LinearScale(FrequencyBand(0, 100), 10) arr = ArrayWithUnits( np.zeros((13, 10)), [IdentityDimension(), FrequencyDimension(scale)]) sliced = arr[:, Hertz(20):Hertz(80)] self.assertEqual((13, 7), sliced.shape)
def test_can_slice_frequency_dim_with_negative_stop_hz(self): scale = LinearScale(FrequencyBand(0, 100), 10) arr = ArrayWithUnits( np.zeros((13, 10)), [IdentityDimension(), FrequencyDimension(scale)]) sliced = arr[:, :-Hertz(20)] self.assertEqual((13, 8), sliced.shape) self.assertEqual( FrequencyDimension(LinearScale(FrequencyBand(0, 80), 8)), sliced.dimensions[-1])
def test_can_negate_hertz(self): hz = -Hertz(10) self.assertIsInstance(hz, Hertz)
def test_get_slice_converts_hz_based_slice_to_integer_based_slice(self): scale = LinearScale(FrequencyBand(0, 100), 10) slce = scale.get_slice(slice(Hertz(0), Hertz(20))) self.assertEqual(slice(0, 2), slce)