def test_default_settings(self): pm = modules.PointMaker(max_n_hits=4) result = pm.process(self.input_blob_1)["samples"] self.assertTupleEqual(pm.finish()["hit_infos"], ("t0", "time", "x")) target = np.array([[0.1, 1, 4], [0.2, 2, 5], [0.3, 3, 6]], dtype="float32") np.testing.assert_array_equal(result, target)
def test_input_blob_time_window_nhits(self): result = modules.PointMaker( max_n_hits=4, hit_infos=("x", "time"), time_window=[1, 2], dset_n_hits="EventInfo", ).process(self.input_blob_1)["EventInfo"] print(result) self.assertEqual(result["n_hits_intime"], 2)
def test_default_settings_fixed_length(self): pm = modules.PointMaker(max_n_hits=4, fixed_length=True) result = pm.process(self.input_blob_1)["samples"] self.assertTupleEqual(pm.finish()["hit_infos"], ("t0", "time", "x", "is_valid")) target = np.array( [[[0.1, 1, 4, 1], [0.2, 2, 5, 1], [0.3, 3, 6, 1], [0, 0, 0, 0]]], dtype="float32", ) np.testing.assert_array_equal(result, target)
def test_input_blob_time_window(self): result = modules.PointMaker( max_n_hits=4, hit_infos=("x", "time"), time_window=[1, 2], dset_n_hits=None, ).process(self.input_blob_1)["samples"] target = np.array([[[4, 1, 1], [5, 2, 1], [0, 0, 0], [0, 0, 0]]], dtype="float32") np.testing.assert_array_equal(result, target)
def test_input_blob_1(self): pm = modules.PointMaker( max_n_hits=4, hit_infos=("x", "time"), time_window=None, dset_n_hits=None, ) result = pm.process(self.input_blob_1)["samples"] self.assertTupleEqual(pm.finish()["hit_infos"], ("x", "time", "is_valid")) target = np.array([[[4, 1, 1], [5, 2, 1], [6, 3, 1], [0, 0, 0]]], dtype="float32") np.testing.assert_array_equal(result, target)
def test_input_blob_1_max_n_hits(self): input_blob_long = { "Hits": kp.Table({ "x": np.random.rand(1000).astype("float32"), }) } result = modules.PointMaker( max_n_hits=10, hit_infos=("x", ), time_window=None, dset_n_hits=None, ).process(input_blob_long)["samples"] self.assertSequenceEqual(result.shape, (1, 10, 2)) self.assertTrue( all(np.isin(result[0, :, 0], input_blob_long["Hits"]["x"])))