Skip to content

Commit

Permalink
Make .filter() on Cases, Iterations and Realizations return a new obj…
Browse files Browse the repository at this point in the history
…ect of the same class and not the base class (SearchContext).
  • Loading branch information
rwiker committed Nov 26, 2024
1 parent 5f42dec commit 44cbf4d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/fmu/sumo/explorer/objects/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ def _maybe_prefetch(self, index):

async def _maybe_prefetch_async(self, index):
return

def filter(self, **kwargs):
sc = super().filter(**kwargs)
uuids = sc.uuids
return Cases(self, uuids)

4 changes: 4 additions & 0 deletions src/fmu/sumo/explorer/objects/iterations.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ async def get_object_async(

return obj

def filter(self, **kwargs):
sc = super().filter(**kwargs)
uuids = sc.uuids
return Iterations(self, uuids)
4 changes: 4 additions & 0 deletions src/fmu/sumo/explorer/objects/realizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ async def get_object_async(

return obj

def filter(self, **kwargs):
sc = super().filter(**kwargs)
uuids = sc.uuids
return Realizations(self, uuids)
4 changes: 2 additions & 2 deletions tests/test_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ def test_seismic_case_by_uuid(explorer: Explorer, seismic_case_uuid: str):
assert "SEGYTraceHeader" in channel_list

def test_grids_and_properties(explorer: Explorer):
cases_with_grids = explorer.grids.cases.filter(status="keep").cases
cases_with_gridprops = explorer.grid_properties.cases.filter(status="keep").cases
cases_with_grids = explorer.grids.cases.filter(status="keep")
cases_with_gridprops = explorer.grid_properties.cases.filter(status="keep")
cgs=set([case.uuid for case in cases_with_grids])
cgps=set([case.uuid for case in cases_with_gridprops])
assert cgs==cgps
Expand Down

0 comments on commit 44cbf4d

Please sign in to comment.