reboost 0.6.1__tar.gz → 0.6.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. {reboost-0.6.1 → reboost-0.6.2}/PKG-INFO +1 -1
  2. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/_version.py +2 -2
  3. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/build_hit.py +9 -6
  4. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/utils.py +46 -1
  5. {reboost-0.6.1 → reboost-0.6.2}/src/reboost.egg-info/PKG-INFO +1 -1
  6. {reboost-0.6.1 → reboost-0.6.2}/src/reboost.egg-info/SOURCES.txt +1 -0
  7. reboost-0.6.2/tests/hit/configs/foward_only.yaml +9 -0
  8. {reboost-0.6.1 → reboost-0.6.2}/tests/hit/test_build_hit.py +18 -0
  9. {reboost-0.6.1 → reboost-0.6.2}/tests/test_utils.py +8 -0
  10. {reboost-0.6.1 → reboost-0.6.2}/LICENSE +0 -0
  11. {reboost-0.6.1 → reboost-0.6.2}/README.md +0 -0
  12. {reboost-0.6.1 → reboost-0.6.2}/pyproject.toml +0 -0
  13. {reboost-0.6.1 → reboost-0.6.2}/setup.cfg +0 -0
  14. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/__init__.py +0 -0
  15. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/build_evt.py +0 -0
  16. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/build_glm.py +0 -0
  17. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/cli.py +0 -0
  18. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/core.py +0 -0
  19. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/hpge/__init__.py +0 -0
  20. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/hpge/psd.py +0 -0
  21. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/hpge/surface.py +0 -0
  22. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/hpge/utils.py +0 -0
  23. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/iterator.py +0 -0
  24. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/log_utils.py +0 -0
  25. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/math/__init__.py +0 -0
  26. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/math/functions.py +0 -0
  27. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/math/stats.py +0 -0
  28. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/__init__.py +0 -0
  29. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/cli.py +0 -0
  30. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/convolve.py +0 -0
  31. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/create.py +0 -0
  32. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/evt.py +0 -0
  33. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/mapview.py +0 -0
  34. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/numba_pdg.py +0 -0
  35. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/optmap/optmap.py +0 -0
  36. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/profile.py +0 -0
  37. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/shape/__init__.py +0 -0
  38. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/shape/cluster.py +0 -0
  39. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/shape/group.py +0 -0
  40. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/shape/reduction.py +0 -0
  41. {reboost-0.6.1 → reboost-0.6.2}/src/reboost/units.py +0 -0
  42. {reboost-0.6.1 → reboost-0.6.2}/src/reboost.egg-info/dependency_links.txt +0 -0
  43. {reboost-0.6.1 → reboost-0.6.2}/src/reboost.egg-info/entry_points.txt +0 -0
  44. {reboost-0.6.1 → reboost-0.6.2}/src/reboost.egg-info/not-zip-safe +0 -0
  45. {reboost-0.6.1 → reboost-0.6.2}/src/reboost.egg-info/requires.txt +0 -0
  46. {reboost-0.6.1 → reboost-0.6.2}/src/reboost.egg-info/top_level.txt +0 -0
  47. {reboost-0.6.1 → reboost-0.6.2}/tests/conftest.py +0 -0
  48. {reboost-0.6.1 → reboost-0.6.2}/tests/evt/test_evt.py +0 -0
  49. {reboost-0.6.1 → reboost-0.6.2}/tests/glm/test_build_glm.py +0 -0
  50. {reboost-0.6.1 → reboost-0.6.2}/tests/hit/configs/args.yaml +0 -0
  51. {reboost-0.6.1 → reboost-0.6.2}/tests/hit/configs/basic.yaml +0 -0
  52. {reboost-0.6.1 → reboost-0.6.2}/tests/hit/configs/geom.gdml +0 -0
  53. {reboost-0.6.1 → reboost-0.6.2}/tests/hit/configs/hit_config.yaml +0 -0
  54. {reboost-0.6.1 → reboost-0.6.2}/tests/hit/configs/pars.yaml +0 -0
  55. {reboost-0.6.1 → reboost-0.6.2}/tests/hit/configs/reshape.yaml +0 -0
  56. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/simulation/gammas.mac +0 -0
  57. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/simulation/geometry.gdml +0 -0
  58. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/simulation/make_dt_map.jl +0 -0
  59. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/simulation/make_geom.py +0 -0
  60. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/test_current.py +0 -0
  61. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/test_dt_heuristic.py +0 -0
  62. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/test_files/drift_time_maps.lh5 +0 -0
  63. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/test_files/internal_electron.lh5 +0 -0
  64. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/test_hpge_map.py +0 -0
  65. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/test_r90.py +0 -0
  66. {reboost-0.6.1 → reboost-0.6.2}/tests/hpge/test_surface.py +0 -0
  67. {reboost-0.6.1 → reboost-0.6.2}/tests/test_cli.py +0 -0
  68. {reboost-0.6.1 → reboost-0.6.2}/tests/test_core.py +0 -0
  69. {reboost-0.6.1 → reboost-0.6.2}/tests/test_math.py +0 -0
  70. {reboost-0.6.1 → reboost-0.6.2}/tests/test_optmap.py +0 -0
  71. {reboost-0.6.1 → reboost-0.6.2}/tests/test_optmap_dets.gdml +0 -0
  72. {reboost-0.6.1 → reboost-0.6.2}/tests/test_profile.py +0 -0
  73. {reboost-0.6.1 → reboost-0.6.2}/tests/test_shape.py +0 -0
  74. {reboost-0.6.1 → reboost-0.6.2}/tests/test_units.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reboost
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Summary: New LEGEND Monte-Carlo simulation post-processing
5
5
  Author-email: Manuel Huber <info@manuelhu.de>, Toby Dixon <toby.dixon.23@ucl.ac.uk>, Luigi Pertoldi <gipert@pm.me>
6
6
  Maintainer: The LEGEND Collaboration
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.6.1'
21
- __version_tuple__ = version_tuple = (0, 6, 1)
20
+ __version__ = version = '0.6.2'
21
+ __version_tuple__ = version_tuple = (0, 6, 2)
@@ -235,6 +235,7 @@ def build_hit(
235
235
  files = utils.get_file_dict(stp_files=stp_files, glm_files=glm_files, hit_files=hit_files)
236
236
 
237
237
  output_tables = {}
238
+ output_tables_names = set()
238
239
 
239
240
  # iterate over files
240
241
  for file_idx, (stp_file, glm_file) in enumerate(zip(files.stp, files.glm)):
@@ -363,16 +364,12 @@ def build_hit(
363
364
  # now write
364
365
  if files.hit[file_idx] is not None:
365
366
  # get modes to write with
366
- new_hit_file = (file_idx == 0) or (
367
- files.hit[file_idx] != files.hit[file_idx - 1]
368
- )
369
-
370
367
  wo_mode = utils.get_wo_mode(
371
368
  group=group_idx,
372
369
  out_det=out_det_idx,
373
370
  in_det=in_det_idx,
374
371
  chunk=chunk_idx,
375
- new_hit_file=new_hit_file,
372
+ new_hit_file=utils.is_new_hit_file(files, file_idx),
376
373
  overwrite=overwrite,
377
374
  )
378
375
  # write the file
@@ -390,6 +387,8 @@ def build_hit(
390
387
  hit_table, output_tables[out_detector]
391
388
  )
392
389
 
390
+ output_tables_names.add(out_detector)
391
+
393
392
  # forward some data, if requested
394
393
  # possible improvement: iterate over data if it's a lot
395
394
  if "forward" in config and files.hit[file_idx] is not None:
@@ -400,12 +399,16 @@ def build_hit(
400
399
 
401
400
  for obj in obj_list:
402
401
  try:
402
+ wo_mode = utils.get_wo_mode_forwarded(
403
+ output_tables_names, utils.is_new_hit_file(files, file_idx), overwrite
404
+ )
403
405
  lh5.write(
404
406
  lh5.read(obj, stp_file),
405
407
  obj,
406
408
  files.hit[file_idx],
407
- wo_mode="write_safe" if file_idx == 0 else "append",
409
+ wo_mode=wo_mode,
408
410
  )
411
+ output_tables_names.add(obj)
409
412
  except LH5EncodeError as e:
410
413
  msg = f"cannot forward object {obj} as it has been already processed by reboost"
411
414
  raise RuntimeError(msg) from e
@@ -51,7 +51,9 @@ def get_wo_mode(
51
51
  chunk
52
52
  the chunk index
53
53
  new_hit_file
54
- a flag of whether we are writing a new hit file
54
+ a flag of whether we are writing a new hit file. This does not indicate whether
55
+ the file already exists on disk, but whether the file name is different from the
56
+ last written chunk for this detector.
55
57
  overwrite
56
58
  a flag of whether to overwrite the old file.
57
59
 
@@ -75,6 +77,49 @@ def get_wo_mode(
75
77
  return "append"
76
78
 
77
79
 
80
+ def get_wo_mode_forwarded(
81
+ written_tables: set[str], new_hit_file: bool, overwrite: bool = False
82
+ ) -> str:
83
+ """Get the mode for lh5 file writing for forwarded tables tahat will be copied without chunking.
84
+
85
+ If we are writing a new output file and no other tables had been written yet, then
86
+ the mode "overwrite_file" is used if the overwrite flag is set, otherwise the mode
87
+ "write_safe" is used.
88
+
89
+ Otherwise "append" is used.
90
+
91
+ Parameters
92
+ ----------
93
+ written_tables
94
+ a set of already written table names, also including other table names of
95
+ non-forwarded (i.e. processed) tables.
96
+ new_hit_file
97
+ a flag of whether we are writing a new hit file. This does not indicate whether
98
+ the file already exists on disk, but whether the file name is different from the
99
+ last written chunk for this forwarded table.
100
+ overwrite
101
+ a flag of whether to overwrite the old file.
102
+
103
+ Returns
104
+ -------
105
+ the mode for IO
106
+ """
107
+ if not new_hit_file:
108
+ return "append"
109
+ if overwrite and len(written_tables) == 0:
110
+ return "overwrite_file"
111
+ return "write_safe"
112
+
113
+
114
+ def is_new_hit_file(files: AttrsDict, file_idx: int) -> bool:
115
+ """Return whether the hit file with the given index is a "new" hit file.
116
+
117
+ A new file is either the first file written, or when the previous file index has a
118
+ different file name.
119
+ """
120
+ return (file_idx == 0) or (files.hit[file_idx] != files.hit[file_idx - 1])
121
+
122
+
78
123
  def get_file_dict(
79
124
  stp_files: list[str] | str,
80
125
  glm_files: list[str] | str | None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reboost
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Summary: New LEGEND Monte-Carlo simulation post-processing
5
5
  Author-email: Manuel Huber <info@manuelhu.de>, Toby Dixon <toby.dixon.23@ucl.ac.uk>, Luigi Pertoldi <gipert@pm.me>
6
6
  Maintainer: The LEGEND Collaboration
@@ -54,6 +54,7 @@ tests/glm/test_build_glm.py
54
54
  tests/hit/test_build_hit.py
55
55
  tests/hit/configs/args.yaml
56
56
  tests/hit/configs/basic.yaml
57
+ tests/hit/configs/foward_only.yaml
57
58
  tests/hit/configs/geom.gdml
58
59
  tests/hit/configs/hit_config.yaml
59
60
  tests/hit/configs/pars.yaml
@@ -0,0 +1,9 @@
1
+ processing_groups:
2
+ - name: all
3
+
4
+ detector_mapping: []
5
+
6
+ hit_table_layout: "reboost.shape.group.group_by_time(STEPS, 10)"
7
+
8
+ forward:
9
+ - /vtx
@@ -107,6 +107,24 @@ def test_reshape(test_gen_lh5_flat, tmptestdir):
107
107
  assert lh5.read("vtx", outfile) == Table({"evtid": Array([0, 1])})
108
108
 
109
109
 
110
+ def test_only_forward(test_gen_lh5_flat, tmptestdir):
111
+ outfile = f"{tmptestdir}/basic_hit_foward_only.lh5"
112
+
113
+ for _ in range(2): # test that overwriting the output file works.
114
+ reboost.build_hit(
115
+ f"{Path(__file__).parent}/configs/foward_only.yaml",
116
+ args={},
117
+ stp_files=test_gen_lh5_flat,
118
+ glm_files=None,
119
+ hit_files=outfile,
120
+ out_field="stp",
121
+ overwrite=True,
122
+ )
123
+
124
+ # check the outputs
125
+ assert lh5.read("vtx", outfile) == Table({"evtid": Array([0, 1])})
126
+
127
+
110
128
  def test_basic(test_gen_lh5, tmptestdir):
111
129
  outfile = f"{tmptestdir}/basic_hit.lh5"
112
130
 
@@ -17,6 +17,7 @@ from reboost.utils import (
17
17
  get_function_string,
18
18
  get_table_names,
19
19
  get_wo_mode,
20
+ get_wo_mode_forwarded,
20
21
  merge_dicts,
21
22
  )
22
23
 
@@ -125,6 +126,13 @@ def test_wo_mode():
125
126
  assert get_wo_mode(0, 0, 1, 1, True, overwrite=False) == "append"
126
127
  assert get_wo_mode(0, 0, 1, 0, False, overwrite=False) == "append"
127
128
 
129
+ assert get_wo_mode_forwarded({}, True, overwrite=True) == "overwrite_file"
130
+ assert get_wo_mode_forwarded({"a"}, True, overwrite=True) == "write_safe"
131
+ assert get_wo_mode_forwarded({}, True, overwrite=False) == "write_safe"
132
+ assert get_wo_mode_forwarded({"a"}, True, overwrite=False) == "write_safe"
133
+ assert get_wo_mode_forwarded({}, False, overwrite=False) == "append"
134
+ assert get_wo_mode_forwarded({"a"}, False, overwrite=False) == "append"
135
+
128
136
 
129
137
  def test_get_files_dict():
130
138
  # simplest case - all are str
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes