Skip to content

Commit

Permalink
Use one-liner to fetch dict key
Browse files Browse the repository at this point in the history
Gabe suggested using a nice one-liner to get
the CalibratedAxis from the dict instead of
the if/else statement.
  • Loading branch information
elevans committed Apr 14, 2023
1 parent 0f175dd commit 61a814c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/imagej/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ def _cal_axis_to_str(cls, axis: "jc.CalibratedAxis") -> str:
if not isinstance(axis, JClass):
axis = axis.__class__

if axis in cls._calibrated_axis_types.keys():
return cls._calibrated_axis_types[axis]
else:
return "unknown"
return cls._calibrated_axis_types.get(axis, "unknown")

@classmethod
def _str_to_cal_axis(cls, axis: str) -> "jc.CalibratedAxis":
Expand Down

0 comments on commit 61a814c

Please sign in to comment.