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

Incorrect array size validation for vec3 in Python bindings #1941

Open
markdjwilliams opened this issue Dec 14, 2024 · 1 comment
Open

Incorrect array size validation for vec3 in Python bindings #1941

markdjwilliams opened this issue Dec 14, 2024 · 1 comment

Comments

@markdjwilliams
Copy link

I believe there's a typo in the Python bindings which impacts writing vec3 attributes into OpenEXR headers from numpy arrays.

if (a.ndim() == 1 && a.size() == 2)

    else if (py::isinstance<py::array_t<T>>(object))
    {
        auto a = object.cast<py::array_t<T>>();
        if (a.ndim() == 1 && a.size() == 2)
        {
            auto p = static_cast<T*>(a.request().ptr);
            v.x = p[0];
            v.y = p[1];
            v.z = p[2];
            return true;
        }
    }

The 2 should be a 3 for it to correctly detect arrays of the correct size.

@cary-ilm
Copy link
Member

cary-ilm commented Dec 19, 2024

Thanks for the catch, yes, apparently a copy/paste error from objectToV2. And unfortunately the bug was specific to float but the test only validated double. Should be fixed in #1945.

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

2 participants