diff --git a/src/arpes/analysis/derivative.py b/src/arpes/analysis/derivative.py index 540668e7..b782d815 100644 --- a/src/arpes/analysis/derivative.py +++ b/src/arpes/analysis/derivative.py @@ -176,7 +176,7 @@ def warpped_filter(arr: xr.DataArray): """ assert isinstance(arr, xr.DataArray) assert alpha > 0 - dim = dim if dim else str(arr.dims[0]) + dim = dim or str(arr.dims[0]) smooth_ = _nothing_to_array if smooth_fn is None else smooth_fn arr = smooth_(arr) d_arr = arr.differentiate(dim) @@ -301,7 +301,7 @@ def warpped_filter(arr: xr.DataArray): The nth derivative data. """ assert isinstance(arr, xr.DataArray) - dim = dim if dim else str(arr.dims[0]) + dim = dim or str(arr.dims[0]) smooth_ = _nothing_to_array if smooth_fn is None else smooth_fn dn_arr = smooth_(arr) for _ in range(order): diff --git a/src/arpes/analysis/filters.py b/src/arpes/analysis/filters.py index b2d93bdd..d256d692 100644 --- a/src/arpes/analysis/filters.py +++ b/src/arpes/analysis/filters.py @@ -170,7 +170,7 @@ def savitzky_golay_filter( # noqa: PLR0913 """ data = data if isinstance(data, xr.DataArray) else normalize_to_spectrum(data) axis = data.dims.index(dim) if dim else -1 - dim = dim if dim else data.dims[0] + dim = dim or data.dims[0] coords_diffs = np.diff(data.coords[dim]) assert np.allclose(coords_diffs, coords_diffs[0], rtol=1e-5, atol=1e-6), ( f"The coordinates must be equally spaced. Consider to use interpolation. f{coords_diffs}" diff --git a/src/arpes/analysis/general.py b/src/arpes/analysis/general.py index 24941a98..16df7c59 100644 --- a/src/arpes/analysis/general.py +++ b/src/arpes/analysis/general.py @@ -104,9 +104,7 @@ def normalize_by_fermi_distribution( assert isinstance(distrib, np.ndarray) # don't boost by more than 90th percentile of input, by default max_gain = ( - max_gain - if max_gain - else min( + max_gain or min( float(np.mean(data.values, dtype=np.float64)), float(np.percentile(data.values, 10)), ) diff --git a/src/arpes/configuration/workspace.py b/src/arpes/configuration/workspace.py index cf88bd15..27227b6e 100644 --- a/src/arpes/configuration/workspace.py +++ b/src/arpes/configuration/workspace.py @@ -50,7 +50,7 @@ def __init__(self, workspace_name: str = "") -> None: self.workspace_name = workspace_name self._active = bool(workspace_name) - def __enter__(self) -> "WorkspaceManager": + def __enter__(self) -> "WorkspaceManager": # noqa: PYI034 """Enter the runtime context for the WorkspaceManager. Returns: diff --git a/src/arpes/plotting/ui/base.py b/src/arpes/plotting/ui/base.py index 42838d60..3d1bc9ba 100644 --- a/src/arpes/plotting/ui/base.py +++ b/src/arpes/plotting/ui/base.py @@ -192,8 +192,8 @@ def image_with_pointer( data = fix_xarray_to_fit_with_holoview(data) max_coords = data.G.argmax_coords() - posx = posx if posx else PointerX(x=max_coords[data.dims[0]]) - posy = posy if posy else PointerY(y=max_coords[data.dims[1]]) + posx = posx or PointerX(x=max_coords[data.dims[0]]) + posy = posy or PointerY(y=max_coords[data.dims[1]]) assert isinstance(posx, PointerX) assert isinstance(posy, PointerY) diff --git a/src/arpes/plotting/ui/profile.py b/src/arpes/plotting/ui/profile.py index 9f9e5d18..443c71f9 100644 --- a/src/arpes/plotting/ui/profile.py +++ b/src/arpes/plotting/ui/profile.py @@ -159,8 +159,8 @@ def profile_view( kwargs.setdefault("profile_view_height", 100) max_coords = data.G.argmax_coords() - posx = posx if posx else PointerX(x=max_coords[data.dims[0]]) - posy = posy if posy else PointerY(y=max_coords[data.dims[1]]) + posx = posx or PointerX(x=max_coords[data.dims[0]]) + posy = posy or PointerY(y=max_coords[data.dims[1]]) plot_lim = get_plot_lim(data, log=kwargs["log"]) diff --git a/src/arpes/xarray_extensions/accessor/base.py b/src/arpes/xarray_extensions/accessor/base.py index 5721c7c8..0b313d2c 100644 --- a/src/arpes/xarray_extensions/accessor/base.py +++ b/src/arpes/xarray_extensions/accessor/base.py @@ -279,7 +279,7 @@ def enumerate_iter_coords( which shows the relationship between pixel position and physical (like "eV" and "phi"). """ assert isinstance(self._obj, xr.DataArray | xr.Dataset) - dim_names = dim_names if dim_names else tuple(self._obj.dims) + dim_names = dim_names or tuple(self._obj.dims) dim_names = [dim_names] if isinstance(dim_names, str) else dim_names coords_list = [self._obj.coords[d].values for d in dim_names] for indices in itertools.product(*[range(len(c)) for c in coords_list]): @@ -302,7 +302,7 @@ def iter_coords( Iterator of the physical position like ("eV" and "phi") {'phi': -0.2178031280148764, 'eV': 9.002} """ - dim_names = dim_names if dim_names else tuple(self._obj.dims) + dim_names = dim_names or tuple(self._obj.dims) dim_names = [dim_names] if isinstance(dim_names, str) else dim_names the_iterator: Iterator = itertools.product(*[self._obj.coords[d].values for d in dim_names]) the_iterator = always_reversible(the_iterator) if reverse else the_iterator diff --git a/src/arpes/xarray_extensions/accessor/property.py b/src/arpes/xarray_extensions/accessor/property.py index ab625ddc..bc163795 100644 --- a/src/arpes/xarray_extensions/accessor/property.py +++ b/src/arpes/xarray_extensions/accessor/property.py @@ -325,7 +325,7 @@ def energy_notation(self) -> EnergyNotation: if notation.lower() in final_notations: self._obj.attrs["energy_notation"] = "Final" return EnergyNotation.FINAL - if notation.lower() in {"binding"}: + if notation.lower() == "binding": self._obj.attrs["energy_notation"] = "Binding" return EnergyNotation.BINDING msg = f"Invalid energy notation found: {notation!r}"