small test to demonstrate alternative Table init

This commit is contained in:
Philip Eisenlohr 2022-07-08 18:01:36 +02:00
parent b7d807db01
commit 7082eab366
1 changed files with 11 additions and 0 deletions

View File

@ -38,6 +38,17 @@ class TestTable:
d = default.get('F') d = default.get('F')
assert np.allclose(d,1.0) and d.shape[1:] == (3,3) assert np.allclose(d,1.0) and d.shape[1:] == (3,3)
def test_empty_init(self):
N = 3
D = dict(
scal=np.arange(10),
vctr=np.arange(10*N).reshape((10,N)),
)
t = Table()
for label,data in D.items():
t = t.set(label,data)
assert np.allclose(t.get('scal').flatten()*3,t.get('vctr')[:,0])
def test_set(self,default): def test_set(self,default):
d = default.set('F',np.zeros((5,3,3)),'set to zero').get('F') d = default.set('F',np.zeros((5,3,3)),'set to zero').get('F')
assert np.allclose(d,0.0) and d.shape[1:] == (3,3) assert np.allclose(d,0.0) and d.shape[1:] == (3,3)