From 58064179193be753092a8b3fd8dfc18d98f9fb15 Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Fri, 12 Jan 2024 19:02:14 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20=20Dont=20use=20"dir"=20that=20i?= =?UTF-8?q?s=20built-in.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arpes/endstations/__init__.py | 21 +++++++++++++-------- arpes/xarray_extensions.py | 6 +++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/arpes/endstations/__init__.py b/arpes/endstations/__init__.py index b14e9b75..4607b102 100644 --- a/arpes/endstations/__init__.py +++ b/arpes/endstations/__init__.py @@ -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: @@ -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. @@ -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) @@ -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 diff --git a/arpes/xarray_extensions.py b/arpes/xarray_extensions.py index 747c84b1..2cbdcecf 100644 --- a/arpes/xarray_extensions.py +++ b/arpes/xarray_extensions.py @@ -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: @@ -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, @@ -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))