Skip to content

Harmonize Datatype equality checks#1854

Merged
franzpoeschel merged 13 commits intoopenPMD:devfrom
franzpoeschel:fix-datatype-equality
Mar 4, 2026
Merged

Harmonize Datatype equality checks#1854
franzpoeschel merged 13 commits intoopenPMD:devfrom
franzpoeschel:fix-datatype-equality

Conversation

@franzpoeschel
Copy link
Contributor

@franzpoeschel franzpoeschel commented Feb 26, 2026

currently

We override operator==(Datatype, Datatype) such that it checks Datatype equality by representation on the platform. However, in some places, our loadChunk / storeChunk API still manually implements this check, with slight implementation differences.

with this pr

This PR merges those differences into the operator==() implementation and uses that consistently.

Also:

  • Adds a missing type check for store_chunk / load_chunk in our Python API

  • Adds non-template type comparison operators

  • Maybe add a further overload to Dataset constructor, to avoid this weirdness:

        e_chargeDensity_x.reset_dataset(DS(np.dtype(np.int_), [10]))

    EDIT: done separately on Numpy Datatype: Enable np.dtype() type conversions #1856

@franzpoeschel franzpoeschel force-pushed the fix-datatype-equality branch from dae3b6b to 1ed5125 Compare March 2, 2026 12:45
rerun ci
@franzpoeschel franzpoeschel force-pushed the fix-datatype-equality branch from 1ed5125 to 2268c24 Compare March 2, 2026 14:46
@franzpoeschel franzpoeschel requested a review from ax3l March 3, 2026 10:21
!isSameFloatingPoint<T>(getDatatype()) &&
!isSameComplexFloatingPoint<T>(getDatatype()) &&
!isSameChar<T>(getDatatype()))
if (dtype != getDatatype())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (dtype != getDatatype())
if (!isSame(dtype, getDatatype()))

@franzpoeschel franzpoeschel enabled auto-merge (squash) March 4, 2026 10:04
@franzpoeschel franzpoeschel merged commit cf3e1c5 into openPMD:dev Mar 4, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant