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

"jsontoh5 data/json/comp_complex.json" error #73

Open
ajelenak opened this issue Mar 6, 2022 · 0 comments
Open

"jsontoh5 data/json/comp_complex.json" error #73

ajelenak opened this issue Mar 6, 2022 · 0 comments

Comments

@ajelenak
Copy link
Contributor

ajelenak commented Mar 6, 2022

jsontoh5 data/json/comp_complex.json command fails with this error:

ValueError: setting an array element with a sequence.

The error comes when converting this dataset's value (relevant HDF5/JSON content only) to a NumPy array:

        "a4afebb4-9b72-11ec-b0a3-8c8590747994": {
            "alias": [
                "/phony_compound_var"
            ],
            "shape": {
                "class": "H5S_SIMPLE",
                "dims": [
                    2
                ]
            },
            "type": {
                "class": "H5T_COMPOUND",
                "fields": [
                    {
                        "name": "yy",
                        "type": {
                            "base": {
                                "class": "H5T_COMPOUND",
                                "fields": [
                                    {
                                        "name": "x",
                                        "type": {
                                            "class": "H5T_COMPOUND",
                                            "fields": [
                                                {
                                                    "name": "i",
                                                    "type": {
                                                        "base": "H5T_STD_I16LE",
                                                        "class": "H5T_INTEGER"
                                                    }
                                                },
                                                {
                                                    "name": "j",
                                                    "type": {
                                                        "base": "H5T_STD_I32LE",
                                                        "class": "H5T_INTEGER"
                                                    }
                                                }
                                            ]
                                        }
                                    },
                                    {
                                        "name": "y",
                                        "type": {
                                            "base": {
                                                "base": "H5T_IEEE_F64LE",
                                                "class": "H5T_FLOAT"
                                            },
                                            "class": "H5T_ARRAY",
                                            "dims": [
                                                2
                                            ]
                                        }
                                    }
                                ]
                            },
                            "class": "H5T_ARRAY",
                            "dims": [
                                2
                            ]
                        }
                    }
                ]
            },
            "value": [
                [
                    [
                        [
                            [
                                1,
                                200000
                            ],
                            [
                                -100000.285657,
                                3.1415926
                            ]
                        ],
                        [
                            [
                                2,
                                400000
                            ],
                            [
                                200000.151617,
                                273.15
                            ]
                        ]
                    ]
                ],
                [
                    [
                        [
                            [
                                3,
                                600000
                            ],
                            [
                                -200000.285657,
                                6.1415926
                            ]
                        ],
                        [
                            [
                                4,
                                800000
                            ],
                            [
                                400000.151617,
                                476.15
                            ]
                        ]
                    ]
                ]
            ]
        }

jsontoh5 version of the value as a Python object is:

[((((1, 200000), (-100000.285657, 3.1415926)), ((2, 400000), (200000.151617, 273.15))),), ((((3, 600000), (-200000.285657, 6.1415926)), ((4, 800000), (400000.151617, 476.15))),)]

The NumPy dataset's value (from h5py) is:

[([((1, 200000), [-1.00000286e+05,  3.14159260e+00]), ((2, 400000), [ 2.00000152e+05,  2.73150000e+02])],), ([((3, 600000), [-2.00000286e+05,  6.14159260e+00]), ((4, 800000), [ 4.00000152e+05,  4.76150000e+02])],)]

They differ in how the H5T_ARRAY components of the dataset's value are converted. jsontoh5 exclusively uses tuples while NumPy prefers the list in this case. The dataset's NumPy dtype in both cases is the same:

dtype([('yy', [('x', [('i', '<i2'), ('j', '<i4')]), ('y', '<f8', (2,))], (2,))])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant