def test_slices(w, h, d): data = np.ndarray(shape=(w, h, d), dtype=np.float32) for i in range(w): for j in range(h): for k in range(d): data[i, j, k] = (i * 1) + (j * 1000) + (k * 1000000) guid = upload_cube(data) c = client.client(API_ADDR, AUTH_CLIENT) cube = c.cube(guid) tolerance = 1e-1 for i in range(w): assert np.allclose(cube.slice(0, cube.dim0[i]), data[i, :, :], atol=tolerance) for i in range(h): assert np.allclose(cube.slice(1, cube.dim1[i]), data[:, i, :], atol=tolerance) for i in range(d): assert np.allclose(cube.slice(2, cube.dim2[i]), data[:, :, i], atol=tolerance)
def test_list_cubes(cube): c = client.client(API_ADDR, AUTH_CLIENT) assert cube in c.list_cubes()
def test_dimensions(cube): c = client.client(API_ADDR, AUTH_CLIENT) assert c.cube(cube).dim0 == [1, 2] assert c.cube(cube).dim1 == [1, 2] assert c.cube(cube).dim2 == [0, 4000]
def test_cube_404(cube): c = client.client(API_ADDR, AUTH_CLIENT) with pytest.raises(RuntimeError) as e: c.cube("not_found").dim0 assert "404" in str(e.value)