pg.ddx.io psycopg/psycopg GitHub issues and pull requests
help / color / mirror / Atom feed[psycopg/psycopg] PR #953: test(numpy): fix integer type handling harder
3+ messages / 3 participants
[nested] [flat]
* [psycopg/psycopg] PR #953: test(numpy): fix integer type handling harder
@ 2024-11-12 20:41 "cjwatson (@cjwatson)" <noreply+cjwatson@github.com>
0 siblings, 0 replies; 3+ messages in thread
From: cjwatson (@cjwatson) @ 2024-11-12 20:41 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
https://numpy.org/devdocs/release/1.18.0-notes.html#different-c-numeric-types-of-the-same-size-have-... indicates that we can't just compare class identity even if the classes refer to a data type with the same signedness and bit length.
According to
https://numpy.org/devdocs/user/basics.types.html#relationship-between-numpy-data-types-and-c-data-ty..., `intc` and `uintc` are always 32-bit.
https://numpy.org/devdocs/reference/arrays.scalars.html#numpy.int_ and https://numpy.org/devdocs/reference/arrays.scalars.html#numpy.uint indicate that `int_` and `uint` are 32-bit or 64-bit depending on the platform.
Fixes: #945
inline patch 1: tests/types/test_numpy.py (+13/-11 lines) download inline-1.patch
diff --git a/tests/types/test_numpy.py b/tests/types/test_numpy.py
index 86e007831..382daa5f4 100644
--- a/tests/types/test_numpy.py
+++ b/tests/types/test_numpy.py
@@ -29,24 +29,26 @@ def _get_arch_size() -> int:
return psize
-def test_classes_identities():
- # Check if we know the class identities correctly. Maybe on different
+def test_integer_types():
+ # Check if we know the integer types correctly. Maybe on different
# platforms they are different.
size = _get_arch_size()
- assert np.byte is np.int8
- assert np.ubyte is np.uint8
+ assert np.byte(0).dtype == np.int8(0).dtype
+ assert np.ubyte(0).dtype == np.uint8(0).dtype
- assert np.short is np.int16
- assert np.ushort is np.uint16
+ assert np.short(0).dtype == np.int16(0).dtype
+ assert np.ushort(0).dtype == np.uint16(0).dtype
+
+ assert np.uintc(0).dtype == np.uint32(0).dtype
+ assert np.intc(0).dtype == np.int32(0).dtype
if size == 32:
- assert np.uint is np.uint32
- assert np.uintc is np.uint32
- assert np.intc is np.int32
+ assert np.uint(0).dtype == np.uint32(0).dtype
+ assert np.int_(0).dtype == np.int32(0).dtype
else:
- assert np.uint is np.uint64
- assert np.int_ is np.int64
+ assert np.uint(0).dtype == np.uint64(0).dtype
+ assert np.int_(0).dtype == np.int64(0).dtype
@pytest.mark.parametrize(
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [psycopg/psycopg] PR #953: test(numpy): fix integer type handling harder
@ 2026-11-18 22:09 "df7cb (@df7cb)" <noreply+df7cb@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: df7cb (@df7cb) @ 2026-11-18 22:09 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
@dvarrazzo The Debian psycopg3 package has been carrying this patch for two years now, would you consider merging it?
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [psycopg/psycopg] PR #953: test(numpy): fix integer type handling harder
@ 2026-11-19 11:57 "dvarrazzo (@dvarrazzo)" <noreply+dvarrazzo@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: dvarrazzo (@dvarrazzo) @ 2026-11-19 11:57 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Hello, sorry for the late action on this, it slipped below my radar.
I think the main issue is that we have no 32 bits build, I wasn't expecting 32 bits build to be produced (hence #1501 too).
I will try to insert some 32 bits representative in CI and to keep the build clean.
^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-19 11:57 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12 20:41 [psycopg/psycopg] PR #953: test(numpy): fix integer type handling harder "cjwatson (@cjwatson)" <noreply+cjwatson@github.com>
2026-11-18 22:09 ` "df7cb (@df7cb)" <noreply+df7cb@github.com>
2026-11-19 11:57 ` "dvarrazzo (@dvarrazzo)" <noreply+dvarrazzo@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox