Exemple #1
0
 def test_floordiv(self):
     for key, arr in self.arrays.items():
         for key2, arr2 in self.arrays.items():
             nzarr1 = nzarray2d(arr)
             nzarr2 = nzarray2d(arr2)
             sumnp = div0(arr, arr2).astype(int)
             sumnz = nzarr1 // nzarr2
             summix = nzarr1 // arr2
             self.assertTrue((sumnz.full() == sumnp).all(), f"{key} failed")
             self.assertTrue((summix.full() == sumnp).all(), f"{key} failed")
             self.assertTrue(
                     ((nzarr1 // 2).full() == arr // 2).all(), f"{key} failed"
                     )
Exemple #2
0
 def test_sub(self):
     for key, arr in self.arrays.items():
         for key2, arr2 in self.arrays.items():
             nzarr1 = nzarray2d(arr)
             nzarr2 = nzarray2d(arr2)
             sumnp = arr - arr2
             sumnz = nzarr1 - nzarr2
             summix = nzarr1 - arr2
             self.assertTrue((sumnz.full() == sumnp).all(), f"{key} failed")
             self.assertTrue((summix.full() == sumnp).all(), f"{key} failed")
             self.assertTrue(
                     ((nzarr1 - 2).full() == arr - 2).all(), f"{key} failed"
                     )
Exemple #3
0
 def test_mul(self):
     for key, arr in self.arrays.items():
         for key2, arr2 in self.arrays.items():
             nzarr1 = nzarray2d(arr)
             nzarr2 = nzarray2d(arr2)
             sumnp = arr * arr2
             sumnz = nzarr1 * nzarr2
             summix = nzarr1 * arr2
             self.assertTrue((sumnz.full() == sumnp).all(), f"{key} failed with {key2}")
             self.assertTrue((summix.full() == sumnp).all(), f"{key} failed with {key2}")
             self.assertTrue(
                     ((nzarr1 * 2).full() == arr * 2).all(), f"{key} failed with {key2}"
                     )
Exemple #4
0
 def test_slice(self):
     for key, arr in self.arrays.items():
         nzarr1 = nzarray2d(arr)
         print(f"key: {key}, corners: {nzarr1.corners}")
         self.assertEqual(nzarr1[0,0], arr[0,0], f"{key} failed")
         self.assertEqual(nzarr1[-1,0], arr[-1,0], f"{key} failed")
         self.assertEqual(nzarr1[50,50], arr[50,50], f"{key} failed")
         self.assertEqual(nzarr1[25, 25], arr[25, 25], f"{key} failed")
         self.assertEqual(nzarr1[66, 32], arr[66, 32], f"{key} failed")
         self.assertTrue((nzarr1[30:50] == arr[30:50]).all(), f"{key} failed")
         self.assertTrue((nzarr1[30:-50] == arr[30:-50]).all(), f"{key} failed")
         self.assertTrue((nzarr1[-30:50] == arr[-30:50]).all(), f"{key} failed")
         self.assertTrue((nzarr1[-30:-50] == arr[-30:-50]).all(), f"{key} failed")
         self.assertTrue((nzarr1[:] == arr[:]).all(), f"{key} failed")
         self.assertTrue((nzarr1[50:] == arr[50:]).all(), f"{key} failed")
         self.assertTrue((nzarr1[:30] == arr[:30]).all(), f"{key} failed")
         self.assertTrue((nzarr1[arr > 1] == arr[arr > 1]).all(), f"{key} failed")
         self.assertTrue((nzarr1[10:30, 20:50] == arr[10:30, 20:50]).all(), f"{key} failed")
         self.assertTrue((nzarr1[60:70, 30:50] == arr[60:70, 30:50]).all(), f"{key} failed")
         self.assertTrue((nzarr1[60:70, 40:50] == arr[60:70, 40:50]).all(), f"{key} failed")
Exemple #5
0
 def get_arrs(self, key):
     arrnz = nzarray2d()
     arrnz.from_hdf5(self.file[key])
     arr = arrnz.full()
     nzarr = nzarray2d(grp=self.file[key], lazy=True)
     return nzarr, arr
Exemple #6
0
 def prep_nzarray(self, arr, key):
     nzarr1 = nzarray2d(arr=arr)
     self.file.create_group(key)
     nzarr1.to_hdf5(self.file[key])
     self.arrays.append(key)
Exemple #7
0
 def test_init(self):
     for key, arr in self.arrays.items():
         nzarr = nzarray2d(arr)
         self.assertEqual(nzarr.shape, arr.shape, f"{key} failed")
         self.assertTrue((nzarr.full() == arr).all(), f"{key} failed")