Skip to content

Commit b896008

Browse files
committed
Re-work test_order
1 parent cabb093 commit b896008

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

tests/test_array.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,9 +1241,11 @@ async def test_data_ignored_params(store: Store) -> None:
12411241
await create_array(store, data=data, shape=None, dtype=data.dtype, overwrite=True)
12421242

12431243
@staticmethod
1244-
@pytest.mark.parametrize("order_config", ["C", "F", None])
1244+
@pytest.mark.parametrize("order", ["C", "F", None])
1245+
@pytest.mark.parametrize("with_config", [True, False])
12451246
def test_order(
1246-
order_config: MemoryOrder | None,
1247+
order: MemoryOrder | None,
1248+
with_config: bool,
12471249
zarr_format: ZarrFormat,
12481250
store: MemoryStore,
12491251
) -> None:
@@ -1252,28 +1254,29 @@ def test_order(
12521254
value, and that for zarr v2 arrays, the ``order`` field in the array metadata is set correctly.
12531255
"""
12541256
config: ArrayConfigLike = {}
1255-
if order_config is None:
1257+
if order is None:
12561258
config = {}
12571259
expected = zarr.config.get("array.order")
12581260
else:
1259-
config = {"order": order_config}
1260-
expected = order_config
1261+
config = {"order": order}
1262+
expected = order
1263+
1264+
if not with_config:
1265+
# Test without passing config parameter
1266+
config = None
1267+
1268+
arr = zarr.create_array(
1269+
store=store,
1270+
shape=(2, 2),
1271+
zarr_format=zarr_format,
1272+
dtype="i4",
1273+
order=order,
1274+
config=config,
1275+
)
12611276
if zarr_format == 2:
1262-
arr = zarr.create_array(
1263-
store=store,
1264-
shape=(2, 2),
1265-
zarr_format=zarr_format,
1266-
dtype="i4",
1267-
order=expected,
1268-
config=config,
1269-
)
1270-
# guard for type checking
1271-
assert arr.metadata.zarr_format == 2
12721277
assert arr.metadata.order == expected
1273-
else:
1274-
arr = zarr.create_array(
1275-
store=store, shape=(2, 2), zarr_format=zarr_format, dtype="i4", config=config
1276-
)
1278+
assert arr.order == expected
1279+
12771280
vals = np.asarray(arr)
12781281
if expected == "C":
12791282
assert vals.flags.c_contiguous

0 commit comments

Comments
 (0)