diff --git a/.github/workflows/plugin_test.yaml b/.github/workflows/plugin_test.yaml index a30967303..6b1b2e459 100644 --- a/.github/workflows/plugin_test.yaml +++ b/.github/workflows/plugin_test.yaml @@ -36,6 +36,9 @@ jobs: - plugin: pynxtools-xps branch: main tests_to_run: tests/. + - plugin: pynxtools-xrd + branch: main + tests_to_run: tests/. # - plugin: pynxtools-apm # branch: main # tests_to_run: tests/. diff --git a/src/pynxtools/dataconverter/helpers.py b/src/pynxtools/dataconverter/helpers.py index e9b35dffb..768fdbed0 100644 --- a/src/pynxtools/dataconverter/helpers.py +++ b/src/pynxtools/dataconverter/helpers.py @@ -577,23 +577,47 @@ def is_value_valid_element_of_enum(value, elist) -> Tuple[bool, list]: NUMPY_FLOAT_TYPES = (np.half, np.float16, np.single, np.double, np.longdouble) NUMPY_INT_TYPES = (np.short, np.intc, np.int_) NUMPY_UINT_TYPES = (np.ushort, np.uintc, np.uint) - +# np int for np version 1.26.0 +np_int = ( + np.intc, + np.int_, + np.intp, + np.int8, + np.int16, + np.int32, + np.int64, + np.uint8, + np.uint16, + np.uint32, + np.uint64, + np.unsignedinteger, + np.signedinteger, +) +np_float = (np.float16, np.float32, np.float64, np.floating) +np_bytes = (np.bytes_, np.byte, np.ubyte) +np_char = (np.str_, np.char.chararray, *np_bytes) +np_bool = (np.bool_,) +np_complex = (np.complex64, np.complex128, np.cdouble, np.csingle) NEXUS_TO_PYTHON_DATA_TYPES = { "ISO8601": (str,), - "NX_BINARY": (bytes, bytearray, np.byte, np.ubyte, np.ndarray), - "NX_BOOLEAN": (bool, np.ndarray, np.bool_), - "NX_CHAR": (str, np.ndarray, np.char.chararray), + "NX_BINARY": ( + bytes, + bytearray, + np.ndarray, + *np_bytes, + ), + "NX_BOOLEAN": (bool, np.ndarray, *np_bool), + "NX_CHAR": (str, np.ndarray, *np_char), "NX_DATE_TIME": (str,), - "NX_FLOAT": (float, np.ndarray, np.floating), - "NX_INT": (int, np.ndarray, np.signedinteger), + "NX_FLOAT": (float, np.ndarray, *np_float), + "NX_INT": (int, np.ndarray, *np_int), "NX_UINT": (np.ndarray, np.unsignedinteger), "NX_NUMBER": ( int, float, np.ndarray, - np.signedinteger, - np.unsignedinteger, - np.floating, + *np_int, + *np_float, dict, ), "NX_POSINT": ( @@ -601,8 +625,18 @@ def is_value_valid_element_of_enum(value, elist) -> Tuple[bool, list]: np.ndarray, np.signedinteger, ), # > 0 is checked in is_valid_data_field() - "NX_COMPLEX": (complex, np.ndarray, np.cdouble, np.csingle), + "NX_COMPLEX": (complex, np.ndarray, *np_complex), "NXDL_TYPE_UNAVAILABLE": (str,), # Defaults to a string if a type is not provided. + "NX_CHAR_OR_NUMBER": ( + str, + int, + float, + np.ndarray, + *np_char, + *np_int, + *np_float, + dict, + ), } diff --git a/tests/dataconverter/test_helpers.py b/tests/dataconverter/test_helpers.py index ddbcb2351..b8fed848d 100644 --- a/tests/dataconverter/test_helpers.py +++ b/tests/dataconverter/test_helpers.py @@ -261,6 +261,11 @@ def fixture_filled_test_data(template, tmp_path): ] TEMPLATE["optional"]["/@default"] = "Some NXroot attribute" +# "The value at /ENTRY[my_entry]/NXODD_name[nxodd_name]/in" +# "t_value should be one of: (, , )," +# " as defined in the NXDL as NX_INT." + # pylint: disable=too-many-arguments @pytest.mark.parametrize( @@ -274,9 +279,14 @@ def fixture_filled_test_data(template, tmp_path): ), ( "The value at /ENTRY[my_entry]/NXODD_name[nxodd_name]/in" - "t_value should be one of: (, , )," - " as defined in the NXDL as NX_INT." + "t_value should be one of: (, , , ," + " , , , , , " + ", , , , , ), as defined in " + "the NXDL as NX_INT." ), id="string-instead-of-int", ),