Skip to content
Merged
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
10 changes: 9 additions & 1 deletion tests/nexus_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_field_errors_with_different_unit_handles_them_individually(nxroot) -> N

@pytest.mark.parametrize(
('value', 'type_'),
[(1.2, np.float32), (123, np.int32), ('abc', str), (True, np.bool_)],
[(1.2, np.float32), (123, np.int32), ('abc', str)],
)
def test_field_is_returned_as_python_object_if_shape_empty_and_no_unit(
nxroot, value, type_
Expand All @@ -237,6 +237,14 @@ def test_field_is_returned_as_python_object_if_shape_empty_and_no_unit(
assert field == type_(value)


def test_field_is_returned_as_python_object_if_shape_empty_and_no_unit_bool(nxroot):
nxroot['field1'] = sc.scalar(True, unit=None, dtype=bool)
field = nxroot['field1'][()]
# could be either type depending on Scipp version
assert isinstance(field, (np.bool_ | bool))
assert field


@pytest.mark.parametrize('value', [1.2, 123, True, 'abc'])
def test_field_is_returned_as_variable_if_shape_empty_and_unit(nxroot, value) -> None:
nxroot['field1'] = sc.scalar(value, unit='K')
Expand Down
Loading