Skip to content

Commit

Permalink
💄 Dont use "dir" that is built-in.
Browse files Browse the repository at this point in the history
  • Loading branch information
arafune committed Jan 12, 2024
1 parent c5d9409 commit 5806417
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
21 changes: 13 additions & 8 deletions arpes/endstations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,25 @@ def find_first_file(

patterns = [re.compile(m.format(file)) for m in cls._SEARCH_PATTERNS]

for dir in dir_options:
for directory in dir_options:
try:
files = cls.files_for_search(dir)
files = cls.files_for_search(directory)

if cls._USE_REGEX:
for p in patterns:
for f in files:
m = p.match(os.path.splitext(f)[0])
if m is not None and m.string == os.path.splitext(f)[0]:
return os.path.join(dir, f)
return os.path.join(directory, f)
else:
for f in files:
if os.path.splitext(file)[0] == os.path.splitext(f)[0]:
return os.path.join(dir, f)
return os.path.join(directory, f)
if allow_soft_match:
matcher = os.path.splitext(f)[0].split("_")[-1]
try:
if int(matcher) == int(file):
return os.path.join(dir, f) # soft match
return os.path.join(directory, f) # soft match
except ValueError:
pass
except FileNotFoundError:
Expand Down Expand Up @@ -589,8 +589,10 @@ def load_SES_nc(
Args:
scan_desc: Dictionary with extra information to attach to the xr.Dataset, must contain
the location of the file robust_dimension_labels: safety control, used to load despite
possibly malformed dimension names
the location of the file
robust_dimension_labels: safety control, used to load despite possibly malformed
dimension names
kwargs: kwargs, unused currently
Returns:
Loaded data.
Expand Down Expand Up @@ -777,6 +779,9 @@ def load_single_frame(
4. Unwinding different scan conventions to common formats
5. Handling early scan termination
"""
if kwargs:
for k, v in kwargs.items():
logger.info(f"load_SES_nc: unused kwargs, k: {k}, value : {v}")
# Use dimension labels instead of
self.trace("Opening FITS HDU list.")
hdulist = fits.open(frame_path, ignore_missing_end=True)
Expand Down Expand Up @@ -942,7 +947,7 @@ def clean_key_name(k: str) -> str:
attrs=attrs,
)

def prep_spectrum(data: xr.DataArray):
def prep_spectrum(data: xr.DataArray) -> xr.DataArray:
# don't do center pixel inference because the main chamber
# at least consistently records the offset from the edge
# of the recorded window
Expand Down
6 changes: 3 additions & 3 deletions arpes/xarray_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@ def transform(
assert isinstance(dest, xr.DataArray)
return dest

def map(self, fn: Callable, **kwargs: Incomplete) -> xr.DataArray: # noqa: A003
def map(self, fn: Callable, **kwargs: Incomplete) -> xr.DataArray:
"""[TODO:summary].
Args:
Expand Down Expand Up @@ -2826,7 +2826,7 @@ def iter_coords(
for ts in itertools.product(*[self._obj.coords[d].values for d in dim_names]):
yield dict(zip(dim_names, ts, strict=True))

def range( # noqa: A003
def range(
self,
*,
generic_dim_names: bool = True,
Expand Down Expand Up @@ -3035,7 +3035,7 @@ class ARPESDatasetFitToolAccessor:
def __init__(self, xarray_obj: DataType) -> None:
self._obj = xarray_obj

def eval(self, *args: Incomplete, **kwargs: Incomplete) -> xr.DataArray: # noqa: A003
def eval(self, *args: Incomplete, **kwargs: Incomplete) -> xr.DataArray:
assert isinstance(self._obj, xr.Dataset)
return self._obj.results.G.map(lambda x: x.eval(*args, **kwargs))

Expand Down

0 comments on commit 5806417

Please sign in to comment.