Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generatemde single quotes replaced by double for json #151

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 warning on line 242 in src/shiver/models/generate_dgs_mde.py

View check run for this annotation

Codecov / codecov/patch

src/shiver/models/generate_dgs_mde.py#L242

Added line #L242 was not covered by tests
# 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