1
1
from __future__ import annotations
2
2
3
+ import warnings
4
+
3
5
import awkward as ak
4
6
import numpy as np
5
7
import pandas as pd
11
13
12
14
def test_init ():
13
15
tbl = Table ()
14
- assert tbl .size == 1024
16
+ assert not tbl .size
15
17
assert tbl .loc == 0
16
18
17
19
tbl = Table (size = 10 )
@@ -68,6 +70,11 @@ def test_add_column():
68
70
tbl = Table ()
69
71
tbl .add_column ("a" , lgdo .Array (np .array ([1 , 2 , 3 ])), use_obj_size = True )
70
72
assert tbl .size == 3
73
+ with warnings .catch_warnings (record = True ) as w :
74
+ warnings .simplefilter ("always" )
75
+ tbl .add_column ("b" , lgdo .Array (np .array ([1 , 2 , 3 , 4 ])))
76
+ assert len (w ) == 1
77
+ assert issubclass (w [- 1 ].category , UserWarning )
71
78
72
79
73
80
def test_join ():
@@ -88,7 +95,7 @@ def test_join():
88
95
89
96
90
97
def test_view_as ():
91
- tbl = Table (4 )
98
+ tbl = Table (3 )
92
99
tbl .add_column ("a" , lgdo .Array (np .array ([1 , 2 , 3 ]), attrs = {"units" : "m" }))
93
100
tbl .add_column ("b" , lgdo .Array (np .array ([[0 , 1 , 2 ], [3 , 4 , 5 ], [6 , 7 , 8 ]])))
94
101
tbl .add_column (
@@ -102,8 +109,8 @@ def test_view_as():
102
109
"d" ,
103
110
lgdo .Table (
104
111
col_dict = {
105
- "a" : lgdo .Array (np .array ([2 , 4 , 6 , 8 ]), attrs = {"units" : "m" }),
106
- "b" : lgdo .Array (np .array ([[1 , 1 ], [2 , 4 ], [3 , 9 ], [ 4 , 16 ] ])),
112
+ "a" : lgdo .Array (np .array ([2 , 4 , 6 ]), attrs = {"units" : "m" }),
113
+ "b" : lgdo .Array (np .array ([[1 , 1 ], [2 , 4 ], [3 , 9 ]])),
107
114
}
108
115
),
109
116
)
0 commit comments