Beispiel #1
0
 def test_convert_scalar_to_float(self):
     migrations.enable_migrations(True)
     self.assertTrue(
         scalars_equal(self.scalar_float,
                       migrations.maybe_get_float(self.scalar_float)))
     self.assertTrue(
         scalars_equal(self.scalar_float,
                       migrations.maybe_get_float(self.scalar_int)))
Beispiel #2
0
 def test_convert_list_to_float(self):
     migrations.enable_migrations(True)
     self.assertTrue(
         lists_equal(self.list_of_floats,
                     migrations.maybe_get_float(self.list_of_floats)))
     self.assertTrue(
         lists_equal(self.list_of_floats,
                     migrations.maybe_get_float(self.list_of_ints)))
Beispiel #3
0
 def test_convert_array_to_float(self):
     migrations.enable_migrations(True)
     self.assertTrue(
         arrays_equal(self.array_of_floats,
                      migrations.maybe_get_float(self.array_of_floats)))
     self.assertTrue(
         arrays_equal(self.array_of_floats,
                      migrations.maybe_get_float(self.array_of_ints)))
Beispiel #4
0
 def payload_values(self) -> numpy.ndarray:
     """
     Returns the time synchronization exchanges as a numpy ndarray of integers.
     :return: The time synchronization exchanges as a numpy ndarray of integers.
     """
     return migrations.maybe_get_float(
         self._unevenly_sampled_channel.get_payload(api900_pb2.TIME_SYNCHRONIZATION))
Beispiel #5
0
 def timestamps_microseconds_utc(self) -> numpy.ndarray:
     """
     Returns a list of ascending timestamps that associate with each sample value
     :return: A list of ascending timestamps that associate with each sample value
     """
     return migrations.maybe_get_float(
         self._unevenly_sampled_channel.timestamps_microseconds_utc)
 def get_payload(self, channel_type: int) -> numpy.ndarray:
     """
     Returns a deinterleaved payload of a given channel type or an empty array.
     :param channel_type: The channel type to extract/deinterleave from the payload.
     :return: A numpy array of floats or ints of a single channel type.
     """
     idx = self.channel_index(channel_type)
     if idx < 0:
         return reader_utils.empty_array()
     try:
         payload: numpy.ndarray = reader_utils.deinterleave_array(
             self.payload, idx, len(self.channel_types))
         return migrations.maybe_get_float(payload)
     except exceptions.ReaderException:
         return reader_utils.empty_array()
Beispiel #7
0
 def test_no_migrations(self):
     migrations.enable_migrations(False)
     self.assertTrue(
         arrays_equal(self.array_of_ints,
                      migrations.maybe_get_float(self.array_of_ints)))
     self.assertTrue(
         arrays_equal(self.array_of_floats,
                      migrations.maybe_get_float(self.array_of_floats)))
     self.assertTrue(
         lists_equal(self.list_of_ints,
                     migrations.maybe_get_float(self.list_of_ints)))
     self.assertTrue(
         lists_equal(self.list_of_floats,
                     migrations.maybe_get_float(self.list_of_floats)))
     self.assertTrue(
         scalars_equal(self.scalar_int,
                       migrations.maybe_get_float(self.scalar_int)))
     self.assertTrue(
         scalars_equal(self.scalar_float,
                       migrations.maybe_get_float(self.scalar_float)))
     self.assertTrue(
         scalars_equal(self.scalar_str,
                       migrations.maybe_get_float(self.scalar_str)))
 def first_sample_timestamp_epoch_microseconds_utc(self) -> int:
     """
     Return the first sample timestamp in microseconds since the epoch UTC.
     :return: The first sample timestamp in microseconds since the epoch UTC.
     """
     return migrations.maybe_get_float(self._evenly_sampled_channel.first_sample_timestamp_epoch_microseconds_utc)
Beispiel #9
0
 def test_bad_data(self):
     migrations.enable_migrations(True)
     self.assertTrue(scalars_equal(None, migrations.maybe_get_float(None)))
     self.assertTrue(
         scalars_equal(self.scalar_str,
                       migrations.maybe_get_float(self.scalar_str)))