@@ -52,6 +52,48 @@ def test_type_error_on_wrong_dtype():
5252 assert len (qt ) == 0
5353
5454
55+ def test_non_default_dtype_insert_many ():
56+ qt = QuadTree (BOUNDS , capacity = 8 , track_objects = True , dtype = "f64" )
57+ points = np .array ([[10 , 10 ], [20 , 20 ], [30 , 30 ]], dtype = np .float64 )
58+ n = qt .insert_many (points )
59+ assert n == 3
60+ assert len (qt ) == 3
61+
62+ raw = qt .query ((0 , 0 , 40 , 40 ), as_items = False )
63+
64+ assert len (raw ) == 3
65+ # ids and positions match
66+ m_raw = {t [0 ]: (t [1 ], t [2 ]) for t in raw }
67+ for t in raw :
68+ assert (t [1 ], t [2 ]) == m_raw [t [0 ]]
69+
70+
71+ def test_non_default_quadtree_dtype_with_default_numpy_dtype_raises ():
72+ qt = QuadTree (BOUNDS , capacity = 8 , track_objects = True , dtype = "f64" )
73+ points = np .array ([[10 , 10 ], [20 , 20 ], [30 , 30 ]], dtype = np .float32 ) # Wrong dtype
74+ with pytest .raises (TypeError ):
75+ qt .insert_many (points )
76+ assert len (qt ) == 0
77+
78+
79+ def test_unspported_quadtree_dtype_insert_many_raises ():
80+ qt = QuadTree (BOUNDS , capacity = 8 , track_objects = True , dtype = "i32" )
81+ points = np .array ([[10 , 10 ], [20 , 20 ], [30 , 30 ]], dtype = np .float32 ) # Wrong dtype
82+ with pytest .raises (TypeError ):
83+ qt .insert_many (points )
84+ assert len (qt ) == 0
85+
86+ points = np .array (
87+ [[10 , 10 ], [20 , 20 ], [30 , 30 ]], dtype = np .uint32
88+ ) # unsupported dtype
89+ with pytest .raises (TypeError ):
90+ qt .insert_many (points )
91+
92+ # QT is also unsupported
93+ with pytest .raises (TypeError ):
94+ qt = QuadTree (BOUNDS , capacity = 8 , track_objects = True , dtype = "u32" )
95+
96+
5597def test_insert_empty_numpy_array ():
5698 qt = QuadTree (BOUNDS , capacity = 8 , track_objects = True )
5799 points = np .empty ((0 , 2 ), dtype = np .float32 )
0 commit comments