def test_fl_pos_valid_time_manager_get_fl_pos_valid_times_with_gap_at_start( self): gaps_margin = 0.0001 mock_array = np.ndarray(dtype='float', shape=[ 10, ]) array = [1, 3, 5, 6, 7, 8, 9, 10, 11, 12] for i, number in enumerate(array): mock_array[i] = number mock_series = MagicMock() mock_series.timestamps = mock_array mock_nwb = MagicMock(spec=NWBFile) mock_nwb.processing['behavior'].data_interfaces[ 'position'].spatial_series = { 'series': mock_series } mock_metadata = {'times_period_multiplier': 1.5} fl_pos_valid_time_manager = FlPosValidTimeManager(mock_metadata) fl_pos_valid_times = fl_pos_valid_time_manager.get_fl_pos_valid_times( nwb_content=mock_nwb, gaps_margin=gaps_margin) self.assertEqual(len(fl_pos_valid_times), 1) self.assertEqual(round(fl_pos_valid_times[0].start_time, 4), 5 + gaps_margin) self.assertEqual(round(fl_pos_valid_times[0].stop_time, 4), 12 - gaps_margin)
def test_fl_pos_valid_time_manager_get_fl_pos_valid_times_failed_due_to_None_param( self): gaps_margin = 0.0001 mock_metadata = {'times_period_multiplier': 1.5} fl_pos_valid_time_manager = FlPosValidTimeManager(mock_metadata) fl_pos_valid_time_manager.get_fl_pos_valid_times( nwb_content=None, gaps_margin=gaps_margin)
def test_fl_pos_valid_time_manager_get_fl_pos_valid_times_failed_due_to_lack_of_timestamps( self): gaps_margin = 0.0001 mock_series = MagicMock() mock_nwb = MagicMock(spec=NWBFile) mock_nwb.processing['behavior'].data_interfaces[ 'position'].spatial_series = { 'series': mock_series } mock_metadata = {'times_period_multiplier': 1.5} fl_pos_valid_time_manager = FlPosValidTimeManager(mock_metadata) fl_pos_valid_time_manager.get_fl_pos_valid_times( nwb_content=mock_nwb, gaps_margin=gaps_margin)
class PosValidTimeOriginator: def __init__(self, metadata): self.fl_pos_valid_time_manager = FlPosValidTimeManager(metadata) self.pos_valid_time_injector = PosValidTimeInjector() def make(self, nwb_content): logger.info('POS valid times: Building') pos_valid_times = self.fl_pos_valid_time_manager.get_fl_pos_valid_times( nwb_content) logger.info('POS valid times: Injecting') self.pos_valid_time_injector.inject_all(pos_valid_times, nwb_content)
def __init__(self, metadata): self.fl_pos_valid_time_manager = FlPosValidTimeManager(metadata) self.pos_valid_time_injector = PosValidTimeInjector()