Skip to content

Commit b94896d

Browse files
test: Replace unsigned integer types with signed equivalents
Replace all uses of uint8, uint16, uint32, uint64 with their signed counterparts in test schemas, following the removal of unsigned types from core types. Changes: - uint8 → int16 (larger signed type for unsigned 8-bit range) - uint16 → int32 (larger signed type for unsigned 16-bit range) - uint32 → int64 (larger signed type for unsigned 32-bit range) - int unsigned → int64 (native type replacement) Updated files: - tests/schema_simple.py: E.M.id_m - tests/schema_type_aliases.py: Remove unsigned types from test table - tests/schema.py: Auto.id, Ephys.Channel.channel - tests/schema_university.py: Student.student_id, Course.course - tests/integration/test_type_aliases.py: Remove unsigned type tests - tests/integration/test_hidden_job_metadata.py: All uint8 → int16 Note: test_blob.py and test_blob_matlab.py unchanged (testing numpy dtypes in serialization, not DataJoint table definitions). Part of v2.0 core type system revision.
1 parent 1d6fd3b commit b94896d

File tree

6 files changed

+13
-37
lines changed

6 files changed

+13
-37
lines changed

tests/integration/test_hidden_job_metadata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def schema_job_metadata(connection_test, prefix):
1818

1919
class Source(dj.Lookup):
2020
definition = """
21-
source_id : uint8
21+
source_id : int16
2222
---
2323
value : float32
2424
"""
@@ -49,7 +49,7 @@ def make(self, key):
4949

5050
class ManualTable(dj.Manual):
5151
definition = """
52-
manual_id : uint8
52+
manual_id : int16
5353
---
5454
data : float32
5555
"""
@@ -64,7 +64,7 @@ class ComputedWithPart(dj.Computed):
6464
class Detail(dj.Part):
6565
definition = """
6666
-> master
67-
detail_idx : uint8
67+
detail_idx : int16
6868
---
6969
detail_value : float32
7070
"""
@@ -237,7 +237,7 @@ def test_no_metadata_when_disabled(self, connection_test, prefix):
237237

238238
class Source(dj.Lookup):
239239
definition = """
240-
source_id : uint8
240+
source_id : int16
241241
"""
242242
contents = [(1,), (2,)]
243243

tests/integration/test_type_aliases.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ class TestTypeAliasPatterns:
1818
("float32", "FLOAT32"),
1919
("float64", "FLOAT64"),
2020
("int64", "INT64"),
21-
("uint64", "UINT64"),
2221
("int32", "INT32"),
23-
("uint32", "UINT32"),
2422
("int16", "INT16"),
25-
("uint16", "UINT16"),
2623
("int8", "INT8"),
27-
("uint8", "UINT8"),
2824
("bool", "BOOL"),
2925
],
3026
)
@@ -41,13 +37,9 @@ def test_type_alias_pattern_matching(self, alias, expected_category):
4137
("float32", "float"),
4238
("float64", "double"),
4339
("int64", "bigint"),
44-
("uint64", "bigint unsigned"),
4540
("int32", "int"),
46-
("uint32", "int unsigned"),
4741
("int16", "smallint"),
48-
("uint16", "smallint unsigned"),
4942
("int8", "tinyint"),
50-
("uint8", "tinyint unsigned"),
5143
("bool", "tinyint"),
5244
],
5345
)
@@ -102,13 +94,9 @@ def test_heading_preserves_type_aliases(self, schema_type_aliases):
10294
assert "float32" in heading_str
10395
assert "float64" in heading_str
10496
assert "int64" in heading_str
105-
assert "uint64" in heading_str
10697
assert "int32" in heading_str
107-
assert "uint32" in heading_str
10898
assert "int16" in heading_str
109-
assert "uint16" in heading_str
11099
assert "int8" in heading_str
111-
assert "uint8" in heading_str
112100
assert "bool" in heading_str
113101

114102

@@ -125,13 +113,9 @@ def test_insert_and_fetch(self, schema_type_aliases):
125113
val_float32=3.14,
126114
val_float64=2.718281828,
127115
val_int64=9223372036854775807, # max int64
128-
val_uint64=18446744073709551615, # max uint64
129116
val_int32=2147483647, # max int32
130-
val_uint32=4294967295, # max uint32
131117
val_int16=32767, # max int16
132-
val_uint16=65535, # max uint16
133118
val_int8=127, # max int8
134-
val_uint8=255, # max uint8
135119
val_bool=1, # boolean true
136120
)
137121

@@ -142,25 +126,21 @@ def test_insert_and_fetch(self, schema_type_aliases):
142126
assert abs(fetched["val_float32"] - test_data["val_float32"]) < 0.001
143127
assert abs(fetched["val_float64"] - test_data["val_float64"]) < 1e-9
144128
assert fetched["val_int64"] == test_data["val_int64"]
145-
assert fetched["val_uint64"] == test_data["val_uint64"]
146129
assert fetched["val_int32"] == test_data["val_int32"]
147-
assert fetched["val_uint32"] == test_data["val_uint32"]
148130
assert fetched["val_int16"] == test_data["val_int16"]
149-
assert fetched["val_uint16"] == test_data["val_uint16"]
150131
assert fetched["val_int8"] == test_data["val_int8"]
151-
assert fetched["val_uint8"] == test_data["val_uint8"]
152132
assert fetched["val_bool"] == test_data["val_bool"]
153133

154134
def test_insert_primary_key_with_aliases(self, schema_type_aliases):
155135
"""Test using type aliases in primary key."""
156136
table = TypeAliasPrimaryKey()
157137
table.delete()
158138

159-
table.insert1(dict(pk_int32=100, pk_uint16=200, value="test"))
160-
fetched = (table & dict(pk_int32=100, pk_uint16=200)).fetch1()
139+
table.insert1(dict(pk_int32=100, pk_int16=200, value="test"))
140+
fetched = (table & dict(pk_int32=100, pk_int16=200)).fetch1()
161141

162142
assert fetched["pk_int32"] == 100
163-
assert fetched["pk_uint16"] == 200
143+
assert fetched["pk_int16"] == 200
164144
assert fetched["value"] == "test"
165145

166146
def test_nullable_type_aliases(self, schema_type_aliases):

tests/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class TTestNoExtra(dj.Manual):
6767

6868
class Auto(dj.Lookup):
6969
definition = """
70-
id : uint8
70+
id : int16
7171
---
7272
name :varchar(12)
7373
"""
@@ -195,7 +195,7 @@ class Ephys(dj.Imported):
195195
class Channel(dj.Part):
196196
definition = """ # subtable containing individual channels
197197
-> master
198-
channel :uint8 # channel number within Ephys
198+
channel :int16 # channel number within Ephys
199199
----
200200
voltage : <blob>
201201
current = null : <blob> # optional current to test null handling

tests/schema_simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class H(dj.Part):
143143
class M(dj.Part):
144144
definition = """ # test part_integrity cascade
145145
-> E
146-
id_m : uint16
146+
id_m : int32
147147
---
148148
-> E.H
149149
"""

tests/schema_type_aliases.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@ class TypeAliasTable(dj.Manual):
1515
val_float32 : float32 # 32-bit float
1616
val_float64 : float64 # 64-bit float
1717
val_int64 : int64 # 64-bit signed integer
18-
val_uint64 : uint64 # 64-bit unsigned integer
1918
val_int32 : int32 # 32-bit signed integer
20-
val_uint32 : uint32 # 32-bit unsigned integer
2119
val_int16 : int16 # 16-bit signed integer
22-
val_uint16 : uint16 # 16-bit unsigned integer
2320
val_int8 : int8 # 8-bit signed integer
24-
val_uint8 : uint8 # 8-bit unsigned integer
2521
val_bool : bool # boolean value
2622
"""
2723

@@ -30,7 +26,7 @@ class TypeAliasPrimaryKey(dj.Manual):
3026
definition = """
3127
# Table with type alias in primary key
3228
pk_int32 : int32
33-
pk_uint16 : uint16
29+
pk_int16 : int16
3430
---
3531
value : varchar(100)
3632
"""

tests/schema_university.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class Student(dj.Manual):
77
definition = """
8-
student_id : int unsigned # university-wide ID number
8+
student_id : int64 # university-wide ID number
99
---
1010
first_name : varchar(40)
1111
last_name : varchar(40)
@@ -41,7 +41,7 @@ class StudentMajor(dj.Manual):
4141
class Course(dj.Manual):
4242
definition = """
4343
-> Department
44-
course : int unsigned # course number, e.g. 1010
44+
course : int64 # course number, e.g. 1010
4545
---
4646
course_name : varchar(200) # e.g. "Neurobiology of Sensation and Movement."
4747
credits : decimal(3,1) # number of credits earned by completing the course

0 commit comments

Comments
 (0)