Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
- name: ruff
run: poetry run ruff check src tests scripts
- name: mypy
run: poetry run mypy src --install-types --non-interactive
# - name: docs-linting
# run: poetry run blacken-docs --check docs/source/notebooks/*.md
run: |
poetry run mypy src --install-types --non-interactive || true
poetry run mypy src
- name: docs
run: poetry run sphinx-build --keep-going -b html docs/source docs/build

Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ repos:
entry: found Copier update rejection files; review them and remove them
language: fail
files: "\\.rej$"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.263'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.6'
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/psf/black
rev: '23.3.0'
rev: '23.11.0'
hooks:
- id: black
# additional to the above, apply black to doctests in source code
Expand Down
2 changes: 1 addition & 1 deletion notebooks/exploratory/300_build_aus_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _extract_aus_subset(data):
dim="sector",
)

ds = ds.rename({list(ds.data_vars.keys())[0]: variable})
ds = ds.rename({list(ds.data_vars.keys())[0]: variable}) # noqa: RUF015

assert ds[variable].attrs["units"] == "kg m-2 s-1"
area = area_grid(ds.lat, ds.lon)
Expand Down
3,631 changes: 1,841 additions & 1,790 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ seaborn = { version = "*", optional = true }
jupytext = { version = "1.14.5", optional = true }
papermill = { version = "*", optional = true }
python-dotenv = { version = "*", optional = true }
scmdata = "^0.15.0"
scmdata = "^0.16.1"
cattrs = "^22.2.0"
xarray = "^2023.5.0"
rioxarray = "^0.14.1"
Expand Down Expand Up @@ -78,11 +78,11 @@ sphinx-copybutton = "^0.5.2"
[tool.poetry.group.dev.dependencies]
pytest-cov = "^4.0.0"
coverage = "^7.2.0"
black = "23.3.0"
black = "23.11.0"
blackdoc = "0.3.8"
commitizen = "^3.1.1"
mypy = "^1.2.0"
ruff = "0.0.264"
mypy = "^1.7.0"
ruff = "0.1.6"
pre-commit = "^3.3.1"
joblib = "*"

Expand Down
3 changes: 2 additions & 1 deletion src/spaemis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class PointSourceMethod:
name: ClassVar[Literal["point_source"]] = "point_source"


ScalerMethod = Union[
ScalerMethod = Union[ # noqa: UP007
ExcludeScaleMethod,
ProxyMethod,
RelativeChangeMethod,
Expand Down Expand Up @@ -328,6 +328,7 @@ def get_path(
target directory
rel_path
Path within ``output_dir``

Returns
-------
Path of the output file
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/input_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def load(self, variable_id: str, source_id: str) -> xr.Dataset:
Variable identifier
source_id
Source identifier

Returns
-------
All of the available data for the given variable and source identifiers
Expand Down
2 changes: 1 addition & 1 deletion src/spaemis/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _create_output_data(
def _process_slice(
output_ds: xr.Dataset,
inventory: EmissionsInventory,
timeseries: scmdata.ScmRun,
timeseries: dict[str, scmdata.ScmRun],
variable_config: VariableScalerConfig,
year: int,
) -> None:
Expand Down
6 changes: 3 additions & 3 deletions src/spaemis/scaling/point_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import logging
import os
from typing import Any
from typing import Any, cast

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -106,8 +106,8 @@ def __call__(
portion_in_domain = num_valid_points / float(num_points)
logger.info(f"{num_valid_points} / {num_points} points sources are in domain.")

amount = ts.values.squeeze() * portion_in_domain
unit = ts.get_unique_meta("unit", True)
amount = float(ts.values.squeeze() * portion_in_domain)
unit = cast(str, ts.get_unique_meta("unit", True))
return apply_amount(amount, unit, scaled)

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions src/spaemis/scaling/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The proxy must cover the area of interest of the emissions timeseries
"""
import logging
from typing import Any
from typing import Any, cast

import scmdata
import xarray as xr
Expand Down Expand Up @@ -192,8 +192,8 @@ def __call__(
)
proxy_interp = proxy.interp(lat=data.lat, lon=data.lon)

unit = ts.get_unique_meta("unit", True)
amount = ts.values.squeeze() * region_share
unit = cast(str, ts.get_unique_meta("unit", True))
amount = float(ts.values.squeeze() * region_share)
return apply_amount(amount, unit, proxy_interp)

@classmethod
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def covers(dataarray: xr.DataArray, dim: str, value: float) -> bool:
Check if a dimension of a DataArray can be interpolated for a given value

If this check fails an extrapolation will be required

Parameters
----------
dataarray
Expand Down