Uh oh!
There was an error while loading. Please reload this page.
get_elements fails on empty SpatialData - #205
Conversation
aeisenbarth
commented
Jan 9, 2024
An alternative solution is to remove the exception in |
aeisenbarth
commented
Jan 9, 2024
I would have preferred to add the test case as an additional parametrization of It's an interesting workaround to the problem of selecting a fixture by name and parametrizing it, since the # conftest.py@pytest.fixture
…
defsdata(request) ->SpatialData:
request.param: dictname=request.param.pop("name") # TODO: here we would need to provide a defaultifname=="full":
…
else:
s=request.getfixturevalue(name)
ifcallable(s):
kwargs=request.params=s(**kwargs)
# print(f"request.param = {request.param}")returns# test_pp.py@pytest.mark.parametrize("sdata, keys", [ (dict(name="empty"), []), (dict(name="get_sdata_with_multiple_images", share_coordinate_system="all"), "data1"), (dict(name="get_sdata_with_multiple_images", share_coordinate_system="all"), ["data1"]), (dict(name="get_sdata_with_multiple_images", share_coordinate_system="all"), ["data1", "data2"]), ],indirect=["sdata"])deftest_can_subset_to_zero_or_more_images(sdata, keys):
"""Tests whether a subset of images can be selected from the sdata object."""clipped_sdata=sdata.pp.get_elements(keys)
assertlist(clipped_sdata.images.keys()) == ([keys] ifisinstance(keys, str) elsekeys)Note that the "sdata" is now not the name for the |
LucaMarconato
commented
Jan 9, 2024
Hi @aeisenbarth, I leave the I have just added an API that is similar to |
timtreis
commented
Jan 12, 2024
Agreeing with Luca here, moving |
LucaMarconato
commented
Jul 13, 2024
I believe now |
aeisenbarth
commented
Jul 13, 2024
Yes, for myself, this is obsolete now and can be closed. |
When SpatialData has no elements and I select no elements from it, I expected it to be a valid operation. However, an error is raised:
This is because the implementation tries to get coordinate system names, which are bound on the existence of elements.
While it is unlikely users will want this rare use case, when I test my own code systematically with a matrix of edge cases, this issue makes my tests fail and I have to add workarounds.