예제 #1
0
 def test_decoder_1d_ulong(self):
     data = numpy.random.randint(1, high=100, size=[10, ], dtype='uint64')
     ts = 1234
     source = 'test_1d_histo'
     buff = create_hs00(data=data, timestamp=ts, source=source)
     histogram = self.decoder.decode(buff)
     assert histogram is not None
     assert (histogram == data).all()
예제 #2
0
 def test_decoder_1d_float(self):
     data = numpy.random.random(size=[10, ])
     ts = 1234
     source = 'test_1d_histo'
     buff = create_hs00(data=data.astype('float32'), timestamp=ts,
                        source=source)
     histogram = self.decoder.decode(buff)
     assert histogram is not None
     assert (histogram == data).all()
예제 #3
0
 def test_1d_encoded_buffer(self):
     data = numpy.random.randint(1, high=100, size=[10, ], dtype='uint32')
     ts = 1234
     source = 'test_1d_histo'
     buff = create_hs00(data=data, timestamp=ts, source=source)
     histogram = EventHistogram.EventHistogram.GetRootAsEventHistogram(
         buff, 0)
     assert histogram.Source().decode('utf-8') == source
     assert histogram.Timestamp() == ts
     assert histogram.DataType() == Array.Array.ArrayUInt
예제 #4
0
 def test_decoder_1d_uint(self):
     data = numpy.random.randint(1, high=100, size=[10, ], dtype='uint32')
     ts = 1234
     src = 'test_1d_histo'
     buff = create_hs00(data=data, timestamp=ts, source=src)
     histogram = self.decoder.decode(buff)
     assert histogram is not None
     value, timestamp, source = histogram
     assert (value == data).all()
     assert timestamp == ts
     assert source == src
예제 #5
0
 def test_consume_serialized_messages(self):
     """
     Creates a set of (timestamp, flatbuffer image array) and feed them
     into the detector. Test that `doReadArray` returns the last image,
     unbuffered.
     """
     raw = {}
     timestamps = numpy.random.randint(1e9, high=8e9, size=10)
     for ts in timestamps:
         raw[ts] = numpy.random.randint(1,
                                        high=100,
                                        size=[
                                            5,
                                            5,
                                        ],
                                        dtype='uint32')
     messages = {}
     for ts, data in raw.items():
         messages[ts] = create_hs00(data=numpy.array(data),
                                    timestamp=ts,
                                    source='test_histo')
     self.image_channel.new_messages_callback(messages)
     assert (raw[max(timestamps)] == self.detector.readArrays(LIVE)).all()