Skip to content

Commit

Permalink
test the base class (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Jul 11, 2024
1 parent 7b60107 commit 0646851
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions sparse_numeric_table/tests/test_SparseNumericTable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import sparse_numeric_table as snt
import numpy as np



def test_dtypes():
prng = np.random.Generator(np.random.MT19937(seed=1337))
table = snt.testing.make_example_table(prng=prng, size=1000)
dtypes = table.dtypes
for lk in table:
assert dtypes[lk] == table[lk].dtype


def test_shapes():
prng = np.random.Generator(np.random.MT19937(seed=1337))
table = snt.testing.make_example_table(prng=prng, size=1000)
shapes = table.shapes
for lk in table:
assert shapes[lk] == table[lk].shape


def test_info():
prng = np.random.Generator(np.random.MT19937(seed=1337))
table = snt.testing.make_example_table(prng=prng, size=1000)

txt = table.info()

assert txt

for lk in table:
assert lk in txt
for ck in table[lk].dtype.names:
assert ck in txt


def test_repr():
prng = np.random.Generator(np.random.MT19937(seed=1337))
table = snt.testing.make_example_table(prng=prng, size=1000)

txt = repr(table)
assert txt
assert "SparseNumericTable" in txt

0 comments on commit 0646851

Please sign in to comment.