Skip to content

Fix datetime64 dtype assertion for big-endian platforms - #5833

Open
Vikram12301 wants to merge 1 commit into
plotly:mainfrom
Vikram12301:fix-big-endian-datetime64-dtype-assertion
Open

Vikram12301 wants to merge 1 commit into
plotly:mainfrom
Vikram12301:fix-big-endian-datetime64-dtype-assertion

Conversation

@Vikram12301

Copy link
Copy Markdown

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.dtype instead, 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])
  • Verified the failure mode directly: on a big-endian host, np.dtype("datetime64[ns]") (unmarked/native) does not equal the literal "<M8[ns]", but always equals another unmarked datetime64[ns] dtype — which is why comparing against dates_array.dtype is 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).

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

No deployments
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.

datetime64 dtype test assertion hardcodes little-endian, fails on big-endian platforms

1 participant