Skip to content

Commit

Permalink
TST: tests for arrays and tables
Browse files Browse the repository at this point in the history
  • Loading branch information
genematx committed Sep 4, 2024
1 parent dc5620c commit 0eaaed7
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions tiled/_tests/test_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,65 +174,65 @@ def test_zarr_integration(server, fs):
assert len(set(grp.array_keys())) == 1


# @pytest.mark.parametrize(
# "suffix, path",
# [
# ("", "random_2d"),
# ("", "nested/array/random_2d"),
# ("nested", "array/random_2d"),
# ("nested/array", "random_2d"),
# ("nested/array/random_2d", ""),
# ],
# )
# @pytest.mark.parametrize("slash", ["", "/"])
# def test_zarr_groups(suffix, path, slash, server, fs):
# expected = array_cases["random_2d"]
# url = f"http://localhost:{server.port}/zarr/v2/{suffix}{slash}"
# arr = zarr.open(fs.get_mapper(url), mode="r")
# if path:
# arr = arr[path]
# assert numpy.array_equal(arr[...], expected)


# @pytest.mark.parametrize("kind", list(array_cases))
# def test_array_dtypes(kind, server, fs):
# expected = array_cases[kind]
# url = f"http://localhost:{server.port}/zarr/v2/nested/array"
# grp = zarr.open(fs.get_mapper(url), mode="r")
# actual = grp[kind][...]
# assert numpy.array_equal(actual, expected)


# @pytest.mark.parametrize("kind", list(scalar_cases))
# def test_scalar_dtypes(kind, server, fs):
# expected = scalar_cases[kind]
# url = f"http://localhost:{server.port}/zarr/v2/scalar"
# grp = zarr.open(fs.get_mapper(url), mode="r")
# actual = grp[kind][...]
# assert numpy.array_equal(actual, expected)


# @pytest.mark.parametrize("kind", list(cube_cases))
# def test_cube_cases(kind, server, fs):
# expected = cube_cases[kind]
# url = f"http://localhost:{server.port}/zarr/v2/nested/cube"
# grp = zarr.open(fs.get_mapper(url), mode="r")
# actual = grp[kind][...]
# assert numpy.array_equal(actual, expected)


# def test_infinity(server, fs):
# url = f"http://localhost:{server.port}/zarr/v2/inf/example"
# actual = zarr.open(fs.get_mapper(url), mode="r")[...]
# mask = numpy.isnan(arr_with_inf)
# assert numpy.array_equal(actual[~mask], arr_with_inf[~mask])
# assert numpy.isnan(actual[mask]).all()


# def test_shape_with_zero(server, fs):
# url = f"http://localhost:{server.port}/zarr/v2/zero/example"
# actual = zarr.open(fs.get_mapper(url), mode="r")[...]
# assert numpy.array_equal(actual, arr_with_zero_dim)
@pytest.mark.parametrize(
"suffix, path",
[
("", "random_2d"),
("", "nested/array/random_2d"),
("nested", "array/random_2d"),
("nested/array", "random_2d"),
("nested/array/random_2d", ""),
],
)
@pytest.mark.parametrize("slash", ["", "/"])
def test_zarr_groups(suffix, path, slash, server, fs):
expected = array_cases["random_2d"]
url = f"http://localhost:{server.port}/zarr/v2/{suffix}{slash}"
arr = zarr.open(fs.get_mapper(url), mode="r")
if path:
arr = arr[path]
assert numpy.array_equal(arr[...], expected)


@pytest.mark.parametrize("kind", list(array_cases))
def test_array_dtypes(kind, server, fs):
expected = array_cases[kind]
url = f"http://localhost:{server.port}/zarr/v2/nested/array"
grp = zarr.open(fs.get_mapper(url), mode="r")
actual = grp[kind][...]
assert numpy.array_equal(actual, expected)


@pytest.mark.parametrize("kind", list(scalar_cases))
def test_scalar_dtypes(kind, server, fs):
expected = scalar_cases[kind]
url = f"http://localhost:{server.port}/zarr/v2/scalar"
grp = zarr.open(fs.get_mapper(url), mode="r")
actual = grp[kind][...]
assert numpy.array_equal(actual, expected)


@pytest.mark.parametrize("kind", list(cube_cases))
def test_cube_cases(kind, server, fs):
expected = cube_cases[kind]
url = f"http://localhost:{server.port}/zarr/v2/nested/cube"
grp = zarr.open(fs.get_mapper(url), mode="r")
actual = grp[kind][...]
assert numpy.array_equal(actual, expected)


def test_infinity(server, fs):
url = f"http://localhost:{server.port}/zarr/v2/inf/example"
actual = zarr.open(fs.get_mapper(url), mode="r")[...]
mask = numpy.isnan(arr_with_inf)
assert numpy.array_equal(actual[~mask], arr_with_inf[~mask])
assert numpy.isnan(actual[mask]).all()


def test_shape_with_zero(server, fs):
url = f"http://localhost:{server.port}/zarr/v2/zero/example"
actual = zarr.open(fs.get_mapper(url), mode="r")[...]
assert numpy.array_equal(actual, arr_with_zero_dim)


def test_dataframe_group(server, fs):
Expand Down

0 comments on commit 0eaaed7

Please sign in to comment.