Skip to content

Commit

Permalink
Use pattern matching for get_status_message
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Nov 20, 2024
1 parent 2a40bed commit 225aec4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/ert/analysis/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ def status(self) -> ObservationStatus:
return ObservationStatus.OUTLIER
return ObservationStatus.ACTIVE

def get_status(self) -> str:
if self.status == ObservationStatus.MISSING_RESPONSE:
return "Deactivated, missing response(es)"
if self.status == ObservationStatus.STD_CUTOFF:
return f"Deactivated, ensemble std ({self.response_std:.3f}) > STD_CUTOFF"
if self.status == ObservationStatus.OUTLIER:
return "Deactivated, outlier"
return "Active"
def get_status_message(self) -> str:
match self.status:
case ObservationStatus.MISSING_RESPONSE:
return "Deactivated, missing response(es)"
case ObservationStatus.STD_CUTOFF:
return (
f"Deactivated, ensemble std ({self.response_std:.3f}) > STD_CUTOFF"
)
case ObservationStatus.OUTLIER:
return "Deactivated, outlier"
case ObservationStatus.ACTIVE:
return "Active"


class SmootherSnapshot(BaseModel):
Expand Down Expand Up @@ -79,7 +83,7 @@ def csv(self) -> List[List[Any]]:
step.obs_scaling * step.obs_std,
step.response_mean,
step.response_std,
step.get_status(),
step.get_status_message(),
]
)
return data
Expand Down

0 comments on commit 225aec4

Please sign in to comment.