Repository navigation
Fix datetime64 dtype assertion for big-endian platforms - #5833
Open
Vikram12301 wants to merge 1 commit into
Open
Vikram12301 wants to merge 1 commit into
Vikram12301 wants to merge 1 commit into
Conversation
The test hardcoded the little-endian dtype literal "<M8[ns]", which fails on big-endian platforms where numpy naturally produces big-endian arrays from this conversion path. Compare against dates_array.dtype directly instead, which is endian-agnostic.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5832
Summary
The read-side dtype check in two tests hardcodes the little-endian dtype literal
"<M8[ns]". On big-endian platforms (e.g. z/OS/s390x), numpy's datetime64 arrays naturally resolve to big-endian native order, so this assertion fails there even though the validator's behavior is correct.This compares against
dates_array.dtypeinstead, which always reflects the host's native byte order — matching what the validator actually produces on any platform, and consistent with how the other dtype checks in this file already work (e.g.assert res.dtype == numeric_pandas.dtype).Testing
pytest tests/test_plotly_utils/validators/test_pandas_series_input.py: 88 passed (verified on little-endian; this is a no-op there since native order already equals<M8[ns])np.dtype("datetime64[ns]")(unmarked/native) does not equal the literal"<M8[ns]", but always equals another unmarkeddatetime64[ns]dtype — which is why comparing againstdates_array.dtypeis platform-independent while the old literal wasn't. I don't have big-endian hardware on hand to literally reproduce the original failure, but the underlying numpy byte-order mechanism is straightforward and I've reasoned through it directly (details in the linked issue).