Skip to content

Commit

Permalink
generatemde single quotes replaced by double for json (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpatrou authored Feb 6, 2025
1 parent b4a8b69 commit c5e276b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/shiver/models/generate_dgs_mde.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def PyExec(self): # pylint: disable=too-many-branches
mask_btp_inputs = self.getPropertyValue("MaskInputs")
# check if the string is not empty
if mask_btp_inputs:
btp_pars_list = json.loads(mask_btp_inputs)
btp_pars_list = json.loads(mask_btp_inputs.replace("'", '"'))
# check if the btp_pars_list has items
if len(btp_pars_list) > 0:
if not __mask:
Expand Down
17 changes: 17 additions & 0 deletions tests/models/test_generatemde.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ def test_convert_dgs_to_single_mde_mask():
assert md1.getNEvents() == 415


def test_convert_dgs_to_single_mde_mask_single_quotes():
"""Test for MaskWorkspace option ConvertDGSToSingleMDE with single-quouted pixels"""

raw_data_folder = os.path.join(os.path.dirname(__file__), "../data/raw")

# custom mask
md1 = GenerateDGSMDE(
Filenames=os.path.join(raw_data_folder, "HYS_178921.nxs.h5"),
MaskInputs="[{'Bank': '1', 'Tube': '1', 'Pixel': '1-8'}]",
Ei=25.0,
T0=112.0,
TimeIndependentBackground="Default",
)

assert md1.getNEvents() == 24750


def test_convert_dgs_to_single_mde_mask_empty():
"""Test for MaskInputs empty option ConvertDGSToSingleMDE"""

Expand Down

0 comments on commit c5e276b

Please sign in to comment.