openPMD / openPMD-validator

:ballot_box_with_check: Validator and Example Scripts
ISC License
4 stars 8 forks source link

Windows: no numpy float128 #63

Closed ax3l closed 2 years ago

ax3l commented 2 years ago

On Windows:

module 'numpy' has no attribute `float128`. Did you mean `float16`?

Probably Windows numpy calls long doubles differently.

First seen by @ldoyle :+1:

ax3l commented 2 years ago

Classic problem: https://github.com/quantumlib/Cirq/issues/1511#issuecomment-481427402

We should use use the named types over the fixed byte ones: https://en.cppreference.com/w/cpp/language/types

On Windows, long double is not 128 bit but usually something like 80 bit.

ax3l commented 2 years ago

Fix via #65

ldoyle commented 2 years ago

Thanks for the quick fix! I also quickly checked online and an alternative approach might be to use isinstance(value, np.floating) for a generic approach. See examples in:

https://stackoverflow.com/questions/28292542/how-to-check-if-a-number-is-a-np-float64-or-np-float32-or-np-float16

However this would require a refactor of test_attr and seems more complicated than your fix.

ax3l commented 2 years ago

Thanks!

That's good to know in case we start to support more exotic floating point numbers that are not part of the fundamental C language types.