diff --git a/km3io/tools.py b/km3io/tools.py index 300da0e105b47c469e9d775aac68baca226fcb65..3bc0ee049b7399625b428e1e93730d23b89dfe5b 100644 --- a/km3io/tools.py +++ b/km3io/tools.py @@ -781,16 +781,18 @@ def is_CC(fobj): if all(len_w2lists <= 7): # old nu file have w2list of len 7. usr = fobj.events.mc_tracks.usr_names cc_flag = usr[:, 0][:, 3] - out = (cc_flag == b'cc') # not very reliable, found NC files with cc flag! + out = cc_flag == b"cc" # not very reliable, found NC files with cc flag! else: if "gseagen" in program.lower(): cc_flag = w2list[:, kw2gsg.W2LIST_GSEAGEN_CC] - out = (cc_flag > 0) + out = cc_flag > 0 if "genhen" in program.lower(): cc_flag = w2list[:, kw2gen.W2LIST_GENHEN_CC] - out = (cc_flag > 0) + out = cc_flag > 0 else: - raise ValueError(f"simulation program {fobj.header.simul.program} is not implemented.") + raise ValueError( + f"simulation program {fobj.header.simul.program} is not implemented." + ) - return out \ No newline at end of file + return out diff --git a/tests/test_tools.py b/tests/test_tools.py index 7f325e7eb55f9e7716aa8fdf705d15ffa6d340cb..c79fe97b925bb3811f53b22b98546672adead76f 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -31,7 +31,9 @@ from km3io.tools import ( ) OFFLINE_FILE = OfflineReader(data_path("offline/km3net_offline.root")) -GENHEN_OFFLINE_FILE = OfflineReader(data_path("offline/mcv5.1.genhen_anumuNC.sirene.jte.jchain.aashower.sample.root")) +GENHEN_OFFLINE_FILE = OfflineReader( + data_path("offline/mcv5.1.genhen_anumuNC.sirene.jte.jchain.aashower.sample.root") +) GSEAGEN_OFFLINE_FILE = OfflineReader(data_path("offline/numucc.root")) @@ -528,6 +530,7 @@ class TestUnfoldIndices(unittest.TestCase): with self.assertRaises(IndexError): unfold_indices(data, indices) + class TestIsCC(unittest.TestCase): def test_is_CC(self): NC_file = is_CC(GENHEN_OFFLINE_FILE)