def test_units_property_mutation(self): with open_sample(samples.bxr, "r") as f: group = f.get_channel_group(0) units = group.units u = units[5] units[5] = u + 20 self.assertEqual(u, group.units[5])
def test_get_channel_group(self): with open_sample(samples.bxr, "r") as f: group = f.get_channel_group(0) self.assertEqual("Group 1", group.name) self.assertRaises(KeyError, f.get_channel_group, 5) group = f.get_channel_group("Group 1") self.assertRaises(KeyError, f.get_channel_group, "Group 2") self.assertEqual(183, len(group.channels))
def test_description(self): with open_sample(samples.brw, "r") as f: descr = f.description self.assertIs(str, type(descr), "Description should be of type str.") with open_sample_copy(samples.brw) as f: f.description = "BRW-File Level3 - Hi, I'm Elfo" descr = f.description with open_sample_copy(samples.bxr) as f: f.description = "BXR-File Level2 - Hi, I'm Elfo" descr = f.description self.assertEqual(descr, "BXR-File Level2 - Hi, I'm Elfo")
def test_recording_vars(self): with open_sample(samples.bxr, "r") as f: vars = ( "BitDepth", "ExperimentType", "MaxVolt", "MinVolt", "NRecFrames", "SamplingRate", "SignalInversion", ) values = (12, 0, 4125.0, -4125.0, 8028300, 17855.5020, 1.0) props = ( "bit_depth", "experiment_type", "max_volt", "min_volt", "n_frames", "sampling_rate", "signal_inversion", "duration", ) prop_values = (12, 0, 4125.0, -4125.0, 8028300, 17855.5020, 1.0, 449.6261) for var, value in zip(vars, values): with self.subTest(recording_variable=var): if type(value) is float: self.assertAlmostEqual(value, f.get_recording_variable(var), places=3) else: self.assertEqual(value, f.get_recording_variable(var)) for prop, value in zip(props, prop_values): with self.subTest(property=prop): if type(value) is float: self.assertAlmostEqual(value, getattr(f, prop), places=3) else: self.assertEqual(value, getattr(f, prop))
def test_visible_property(self): with open_sample(samples.bxr, "r") as f: group = f.get_channel_group(0) self.assertIs(True, group.visible)
def test_units_property(self): with open_sample(samples.bxr, "r") as f: units = f.get_channel_group(0).units self.assertEqual(70, len(units)) self.assertIs(numpy.ndarray, type(units))
def test_channels_property_mutation(self): with open_sample(samples.bxr, "r") as f: group = f.get_channel_group(0) channels = group.channels channels.append("trash") self.assertEqual(183, len(group.channels))
def test_channels_property(self): with open_sample(samples.bxr, "r") as f: channels = f.get_channel_group(0).channels self.assertEqual(183, len(channels)) self.assertIs(bwpy.Channel, type(channels[0]))
def test_name_property(self): with open_sample(samples.bxr, "r") as f: group = f.get_channel_group(0) self.assertEqual("Group 1", group.name)
def test_get_channel_groups(self): with open_sample(samples.bxr, "r") as f: groups = f.get_channel_groups() self.assertEqual("Group 1", groups[0]._name) self.assertEqual(1, len(groups))
def test_raw_recording_info(self): with open_sample(samples.bxr, "r") as f: raw = f.get_raw_recording_info() self.assertIsNotNone(raw)
def test_channel_groups_prop(self): with open_sample(samples.bxr, "r") as f: groups = f.channel_groups self.assertEqual(1, len(groups)) self.assertIs(bwpy.ChannelGroup, type(groups[0]))
def test_guid(self): with open_sample(samples.brw, "r") as f: guid = f.guid self.assertIs(str, type(guid), "GUID should be of type str.") self.assertEqual("cfef184e-a0ea-41af-976b-45dcec62d561", guid)
def test_version(self): with open_sample(samples.brw, "r") as f: version = f.version self.assertEqual(numpy.int32, type(version)) self.assertEqual(version, 320)
def test_write_description(self): with open_sample(samples.brw, "r") as f: with self.assertRaises(RuntimeError): f.description = "Hi, I'm Elfo"
def test_color_property(self): with open_sample(samples.bxr, "r") as f: group = f.get_channel_group(0) self.assertIs(tuple, type(group.color)) self.assertEqual(4, len(group.color))
def test_channel_group_names(self): with open_sample(samples.bxr, "r") as f: names = f.get_channel_group_names() self.assertEqual(["Group 1"], names)
def test_missing_recording_var(self): with open_sample(samples.bxr, "r") as f: with self.assertRaises(KeyError): f.get_recording_variable("ThisReallyShouldntExistInHere")