Add tests
This commit is contained in:
parent
e1fe03d236
commit
b868903a81
2 changed files with 32 additions and 9 deletions
12
gentest.py
Normal file
12
gentest.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def main():
|
||||||
|
for endianness in "<>":
|
||||||
|
for typ in "fiu":
|
||||||
|
for size in "48":
|
||||||
|
dtype=endianness + typ + size
|
||||||
|
arr = np.zeros((2,3,4), dtype=dtype)
|
||||||
|
np.save(f"test{dtype}.npy", arr)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
29
tests.bqn
29
tests.bqn
|
@ -1,11 +1,5 @@
|
||||||
⟨SaveNpy,LoadNpy⟩←•Import"npy.bqn"
|
⟨SaveNpy,LoadNpy⟩←•Import"npy.bqn"
|
||||||
|
|
||||||
a←3‿4‿5•rand.Range 0
|
|
||||||
"testbqn.npy"SaveNpy a
|
|
||||||
b←LoadNpy"testbqn.npy"
|
|
||||||
! a≡○≢b
|
|
||||||
! a≡b
|
|
||||||
|
|
||||||
floatArr←2‿3•rand.Range 0
|
floatArr←2‿3•rand.Range 0
|
||||||
intArr←50-˜2‿3•rand.Range 100
|
intArr←50-˜2‿3•rand.Range 100
|
||||||
uintArr←2‿3•rand.Range 100
|
uintArr←2‿3•rand.Range 100
|
||||||
|
@ -14,6 +8,23 @@ uintArr←2‿3•rand.Range 100
|
||||||
"test_int.npy"SaveNpy intArr
|
"test_int.npy"SaveNpy intArr
|
||||||
"test_uint.npy"SaveNpy uintArr
|
"test_uint.npy"SaveNpy uintArr
|
||||||
|
|
||||||
floatArr≡LoadNpy"test_float.npy"
|
! floatArr≡LoadNpy"test_float.npy"
|
||||||
intArr≡LoadNpy"test_int.npy"
|
! intArr≡LoadNpy"test_int.npy"
|
||||||
uintArr≡LoadNpy"test_uint.npy"
|
! uintArr≡LoadNpy"test_uint.npy"
|
||||||
|
|
||||||
|
# Supported dtypes
|
||||||
|
ref←2‿3‿4⥊0
|
||||||
|
! ref≡LoadNpy"test<f8.npy"
|
||||||
|
! ref≡LoadNpy"test<i4.npy"
|
||||||
|
! ref≡LoadNpy"test<u4.npy"
|
||||||
|
# Unsupported dtypes, should raise an error
|
||||||
|
! LoadNpy⎊1"test<f4.npy"
|
||||||
|
! LoadNpy⎊1"test<i8.npy"
|
||||||
|
! LoadNpy⎊1"test<u8.npy"
|
||||||
|
! LoadNpy⎊1"test>f4.npy"
|
||||||
|
! LoadNpy⎊1"test>f8.npy"
|
||||||
|
! LoadNpy⎊1"test>i4.npy"
|
||||||
|
! LoadNpy⎊1"test>i8.npy"
|
||||||
|
! LoadNpy⎊1"test>u4.npy"
|
||||||
|
! LoadNpy⎊1"test>u8.npy"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue