def test_reverse_directions(self): bc = BrainCoordinates(nxyz=(6, 7, 8), xyz0=[50, 60, 70], dxyz=[-10, -10, -10]) self.assertTrue(bc.i2x(0) == 50 and bc.i2x(bc.nx - 1) == 0) self.assertTrue(bc.i2y(0) == 60 and bc.i2y(bc.ny - 1) == 0) self.assertTrue(np.all(bc.i2z(np.array([0, 1])) == np.array([70, 60]))) bc = BrainCoordinates(nxyz=(6, 7, 8), xyz0=[50, 60, 70], dxyz=-10) self.assertTrue(bc.dx == bc.dy == bc.dz == -10)
def test_brain_coordinates(self): vshape = (6, 7, 8) bc = BrainCoordinates(vshape) self.assertTrue(bc.i2x(0) == 0) self.assertTrue(bc.i2x(6) == 6) self.assertTrue(bc.nx == 6) self.assertTrue(bc.ny == 7) self.assertTrue(bc.nz == 8) # test array functions in_out = [([6, 7, 8], np.array([6, 7, 8])), (np.array([6, 7, 8]), np.array([6, 7, 8])), (np.array([[6, 7, 8], [6, 7, 8]]), np.array([[6, 7, 8], [6, 7, 8]])), ] for io in in_out: self.assertTrue(np.all(bc.xyz2i(io[0]) == io[1])) self.assertTrue(np.all(bc.i2xyz(io[1]) == io[0]))