Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pre-commit and minor fixes #68

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.4.2
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.1.0
hooks:
- id: flake8
language_version: python3
Expand Down
15 changes: 10 additions & 5 deletions unseen/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ def random_resample(
)
]
args_sub = [
xr.concat(
[obj.isel({dim: random_sample}) for random_sample in random_samples],
dim=dim,
(
xr.concat(
[
obj.isel({dim: random_sample})
for random_sample in random_samples
],
dim=dim,
)
if dim in obj.dims
else obj
)
if dim in obj.dims
else obj
for obj in args_sub
]

Expand Down
2 changes: 1 addition & 1 deletion unseen/eva.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _fit(
covariate = _format_covariate(data, covariate, stationary, core_dim)

# Input core dimensions
if hasattr(covariate, core_dim):
if core_dim is not None and hasattr(covariate, core_dim):
# Covariate has the same core dimension as data
input_core_dims = [[core_dim], [core_dim]]
else:
Expand Down
7 changes: 3 additions & 4 deletions unseen/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,8 @@ def _fix_metadata(ds, metadata_file):

if "rename" in metadata_dict:
for orig_var, target_var in metadata_dict["rename"].items():
try:
if orig_var in ds:
ds = ds.rename({orig_var: target_var})
except ValueError:
pass

if "drop_coords" in metadata_dict:
for drop_coord in metadata_dict["drop_coords"]:
Expand All @@ -472,7 +470,8 @@ def _fix_metadata(ds, metadata_file):

if "units" in metadata_dict:
for var, units in metadata_dict["units"].items():
ds[var].attrs["units"] = units
if var in ds.data_vars:
ds[var].attrs["units"] = units

return ds

Expand Down
Loading