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

Fix for issue #770. Try to convert to float first, and if that fails convert to bytes #771

Merged
merged 1 commit into from
Oct 12, 2022

Conversation

eblis
Copy link

@eblis eblis commented Sep 27, 2022

Alternatively I see that another method is used further up in the codebase, starting on line 3400:

                all_bytes = True
                for v in ret.tolist():
                    if not isinstance(v, bytes):
                        all_bytes = False
                        break

                if not all_bytes:
                    try:
                        ret = ret.astype("f8")
                    except:
                        if not as_object:
                            ret = np.array(
                                [np.nan if isinstance(v, bytes) else v for v in ret]
                            )

                else:
                    ret = ret.astype(bytes)

We could use this check to see if we need to convert to float or bytes, but I wouldn't iterate over all items if we can help it.

@danielhrisca
Copy link
Owner

The output array must have a numeric dtype or 'S' dtype.
Mixing bytes and float values would result in an 'O' dtype output array (object dtype).

@danielhrisca danielhrisca changed the base branch from master to development October 5, 2022 10:12
@danielhrisca danielhrisca merged commit b3860b1 into danielhrisca:development Oct 12, 2022
@danielhrisca
Copy link
Owner

thank you @eblis

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

Successfully merging this pull request may close these issues.

None yet

2 participants