Skip to content

Commit c6decab

Browse files
committed
Fix up pandas-indexing dependency
1 parent b458c0c commit c6decab

File tree

5 files changed

+58
-10
lines changed

5 files changed

+58
-10
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Some suggested options:
3838
and we won't reply to any issues
3939
-->
4040

41-
- prototype: the project is just starting up and the code is all prototype
41+
- development: the project is actively being worked on
4242

4343
<!--- --8<-- [end:description] -->
4444

@@ -89,6 +89,20 @@ The (non-locked) version of gcages can be installed with
8989
pip install gcages
9090
```
9191

92+
Additional dependencies can be installed using
93+
94+
=== "pip"
95+
```sh
96+
# To add the dependencies required to run processing like AR6
97+
pip install 'gcages[ar6]'
98+
99+
# To add progress bar-related dependencies
100+
pip install 'gcages[progress]'
101+
102+
# To add all optional dependencies
103+
pip install 'gcages[full]'
104+
```
105+
92106
### For developers
93107

94108
For development, we rely on [uv](https://docs.astral.sh/uv/)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Issues = "https://github.com/openscm/gcages/issues"
4242
[project.optional-dependencies]
4343
ar6 = [
4444
"aneris-iamc>=0.4.2 ; python_full_version >= '3.10'",
45+
"pandas-indexing>=0.6.3",
4546
"scipy>=1.13.0",
4647
]
4748
progress = [

requirements-docs-locked.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cycler==0.12.1 ; python_full_version >= '3.10'
2323
debugpy==1.8.11
2424
decorator==5.1.1
2525
defusedxml==0.7.1
26-
deprecated==1.2.18 ; python_full_version >= '3.10'
26+
deprecated==1.2.18
2727
et-xmlfile==2.0.0 ; python_full_version >= '3.10'
2828
exceptiongroup==1.2.2 ; python_full_version < '3.11'
2929
executing==2.1.0
@@ -91,7 +91,7 @@ overrides==7.7.0
9191
packaging==24.2
9292
paginate==0.5.7
9393
pandas==2.2.3
94-
pandas-indexing==0.6.3 ; python_full_version >= '3.10'
94+
pandas-indexing==0.6.3
9595
pandas-openscm==0.3.2
9696
pandocfilters==1.5.1
9797
parso==0.8.4
@@ -150,6 +150,6 @@ wcwidth==0.2.13
150150
webcolors==24.11.1
151151
webencodings==0.5.1
152152
websocket-client==1.8.0
153-
wrapt==1.17.2 ; python_full_version >= '3.10'
153+
wrapt==1.17.2
154154
xlrd==2.0.1 ; python_full_version >= '3.10'
155155
zipp==3.21.0 ; python_full_version < '3.10'

src/gcages/ar6/pre_processing.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@
1010
from typing import TYPE_CHECKING, Callable
1111

1212
import pandas as pd
13-
import pandas_indexing as pix # type: ignore
1413
from attrs import define
1514
from pandas_openscm.parallelisation import ParallelOpConfig, apply_op_parallel_progress
1615

1716
from gcages.assertions import assert_only_working_on_variable_unit_variations
18-
19-
# from gcages.parallelisation import (
20-
# assert_only_working_on_variable_unit_variations,
21-
# run_parallel,
22-
# )
17+
from gcages.exceptions import MissingOptionalDependencyError
2318
from gcages.units_helpers import strip_pint_incompatible_characters_from_units
2419

2520
if TYPE_CHECKING:
@@ -61,6 +56,13 @@ def add_conditional_sums(
6156
:
6257
`indf` with conditional sums added if all enabling conditions were fulfilled.
6358
"""
59+
try:
60+
import pandas_indexing as pix
61+
except ImportError as exc:
62+
raise MissingOptionalDependencyError(
63+
"add_conditional_sums", requirement="pandas_indexing"
64+
) from exc
65+
6466
assert_only_working_on_variable_unit_variations(indf)
6567

6668
if copy_on_entry:
@@ -121,6 +123,13 @@ def reclassify_variables(
121123
:
122124
`indf`, reclassified as needed.
123125
"""
126+
try:
127+
import pandas_indexing as pix
128+
except ImportError as exc:
129+
raise MissingOptionalDependencyError(
130+
"reclassify_variables", requirement="pandas_indexing"
131+
) from exc
132+
124133
assert_only_working_on_variable_unit_variations(indf)
125134

126135
if copy_on_entry:
@@ -167,6 +176,13 @@ def condtionally_remove_variables(
167176
:
168177
`indf` with variables removed according to this function's logic.
169178
"""
179+
try:
180+
import pandas_indexing as pix
181+
except ImportError as exc:
182+
raise MissingOptionalDependencyError(
183+
"condtionally_remove_variables", requirement="pandas_indexing"
184+
) from exc
185+
170186
assert_only_working_on_variable_unit_variations(indf)
171187

172188
if copy_on_entry:
@@ -214,6 +230,13 @@ def drop_variables_if_identical(
214230
:
215231
`indf` with variables removed according to this function's logic.
216232
"""
233+
try:
234+
import pandas_indexing as pix
235+
except ImportError as exc:
236+
raise MissingOptionalDependencyError(
237+
"drop_variables_if_identical", requirement="pandas_indexing"
238+
) from exc
239+
217240
assert_only_working_on_variable_unit_variations(indf)
218241

219242
if copy_on_entry:
@@ -443,6 +466,13 @@ def __call__(self, in_emissions: pd.DataFrame) -> pd.DataFrame:
443466
:
444467
Pre-processed emissions
445468
"""
469+
try:
470+
import pandas_indexing as pix
471+
except ImportError as exc:
472+
raise MissingOptionalDependencyError(
473+
"AR6PreProcessor.__call__", requirement="pandas_indexing"
474+
) from exc
475+
446476
# TODO:
447477
# - enable optional checks for:
448478
# - only known variable names are in the output

uv.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)