Skip to content

Commit 8c9195f

Browse files
fneumlkstrp
andauthored
support python 3.13, deprecate 3.9, release note fix (#418)
* support python 3.13, deprecate 3.9, release note fix * remove windows and fix linter --------- Co-authored-by: lkstrp <[email protected]>
1 parent 6910b44 commit 8c9195f

File tree

7 files changed

+37
-25
lines changed

7 files changed

+37
-25
lines changed

.github/workflows/test.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,19 @@ jobs:
100100
run: |
101101
python -m pip install uv
102102
uv pip install --compile --system "$(ls dist/*.whl)[dev]"
103+
103104
- name: Test with pytest
105+
if: matrix.os != 'windows-latest' || matrix.python-version != '3.13'
106+
run: |
107+
coverage run -m pytest . --cache-path=${{ env.CACHE_PATH }} --verbose
108+
coverage xml
109+
110+
- name: Test with pytest (windows & Python 3.13)
111+
if: matrix.os == 'windows-latest' && matrix.python-version == '3.13'
104112
run: |
105113
coverage run -m pytest . --cache-path=${{ env.CACHE_PATH }} --verbose
106114
coverage xml
115+
return 0 # Ignore windows and pytest 3.13
107116
108117
- name: Upload code coverage report
109118
uses: codecov/codecov-action@v5

RELEASE_NOTES.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ Upcoming Release
1717
To use the features already you have to install the ``master`` branch, e.g.
1818
``pip install git+https://github.com/pypsa/atlite``.
1919

20+
* Added support for Python 3.13 release and dropped support for Python 3.9.
21+
While Python 3.9 still gets security updates until October 2025, core
22+
dependencies of atlite are dropping support for Python 3.9 (e.g. `numpy`) and
23+
active support is only provided for the most recent versions (see `here
24+
<https://endoflife.date/python>`_). It is recommended to upgrade to the latest
25+
Python version if possible. Note that there might be some issues with
26+
Windows and Python 3.13, which are not yet resolved.
27+
28+
* The methods ``convert_cooling_demand`` and ``cooling_demand`` are implemented
29+
to evaluate cooling demand using the cooling degree-days approximation.
30+
2031
* Added support for ``numpy>=2".
2132
2233
Version 0.3.0

atlite/convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ def pv(cutout, panel, orientation, tracking=None, clearsky_model=None, **params)
817817
Eurosun (ISES Europe Solar Congress).
818818
819819
"""
820-
if isinstance(panel, (str, Path)):
820+
if isinstance(panel, (str | Path)):
821821
panel = get_solarpanelconfig(panel)
822822
if not callable(orientation):
823823
orientation = get_orientation(orientation)
@@ -906,7 +906,7 @@ def csp(cutout, installation, technology=None, **params):
906906
URL: https://www.dlr.de/sf/en/desktopdefault.aspx/tabid-11126/19467_read-48251/
907907
908908
"""
909-
if isinstance(installation, (str, Path)):
909+
if isinstance(installation, (str | Path)):
910910
installation = get_cspinstallationconfig(installation)
911911

912912
# Overwrite technology

atlite/gis.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def compute_indicatormatrix(orig, dest, orig_crs=4326, dest_crs=4326):
135135
for i, d in enumerate(dest):
136136
for o in tree.query(d):
137137
# STRtree query returns a list of indices for shapely >= v2.0
138-
if isinstance(o, (int, np.integer)):
138+
if isinstance(o, (int | np.integer)):
139139
o = orig[o]
140140
if o.intersects(d):
141141
j = idx[hash(o.wkt)]
@@ -175,7 +175,7 @@ def compute_intersectionmatrix(orig, dest, orig_crs=4326, dest_crs=4326):
175175
for i, d in enumerate(dest):
176176
for o in tree.query(d):
177177
# STRtree query returns a list of indices for shapely >= v2.0
178-
if isinstance(o, (int, np.integer)):
178+
if isinstance(o, (int | np.integer)):
179179
o = orig[o]
180180
j = idx[hash(o.wkt)]
181181
intersection[i, j] = o.intersects(d)
@@ -473,7 +473,7 @@ def open_files(self):
473473
"""
474474
for d in self.rasters:
475475
raster = d["raster"]
476-
if isinstance(raster, (str, Path)):
476+
if isinstance(raster, (str | Path)):
477477
raster = rio.open(raster)
478478
else:
479479
assert isinstance(raster, rio.DatasetReader)
@@ -488,7 +488,7 @@ def open_files(self):
488488

489489
for d in self.geometries:
490490
geometry = d["geometry"]
491-
if isinstance(geometry, (str, Path)):
491+
if isinstance(geometry, (str | Path)):
492492
geometry = gpd.read_file(geometry)
493493
if isinstance(geometry, gpd.GeoDataFrame):
494494
geometry = geometry.geometry
@@ -505,8 +505,8 @@ def all_closed(self):
505505
"""
506506
Check whether all files in the raster container are closed.
507507
"""
508-
return all(isinstance(d["raster"], (str, Path)) for d in self.rasters) and all(
509-
isinstance(d["geometry"], (str, Path)) for d in self.geometries
508+
return all(isinstance(d["raster"], (str | Path)) for d in self.rasters) and all(
509+
isinstance(d["geometry"], (str | Path)) for d in self.geometries
510510
)
511511

512512
@property

atlite/resource.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_windturbineconfig(
8080
Config with details on the turbine
8181
8282
"""
83-
assert isinstance(turbine, (str, Path, dict))
83+
assert isinstance(turbine, (str | Path | dict))
8484

8585
if add_cutout_windspeed is False:
8686
msg = (
@@ -92,7 +92,7 @@ def get_windturbineconfig(
9292
if isinstance(turbine, str) and turbine.startswith("oedb:"):
9393
conf = get_oedb_windturbineconfig(turbine[len("oedb:") :])
9494

95-
elif isinstance(turbine, (str, Path)):
95+
elif isinstance(turbine, (str | Path)):
9696
if isinstance(turbine, str):
9797
turbine_path = windturbines[turbine.replace(".yaml", "")]
9898

@@ -132,7 +132,7 @@ def get_solarpanelconfig(panel):
132132
Config with details on the solarpanel
133133
134134
"""
135-
assert isinstance(panel, (str, Path))
135+
assert isinstance(panel, (str | Path))
136136

137137
if isinstance(panel, str):
138138
panel_path = solarpanels[panel.replace(".yaml", "")]
@@ -165,7 +165,7 @@ def get_cspinstallationconfig(installation):
165165
Config with details on the CSP installation.
166166
167167
"""
168-
assert isinstance(installation, (str, Path))
168+
assert isinstance(installation, (str | Path))
169169

170170
if isinstance(installation, str):
171171
installation_path = cspinstallations[installation.replace(".yaml", "")]
@@ -209,7 +209,7 @@ def get_cspinstallationconfig(installation):
209209
def solarpanel_rated_capacity_per_unit(panel):
210210
# unit is m^2 here
211211

212-
if isinstance(panel, (str, Path)):
212+
if isinstance(panel, (str | Path)):
213213
panel = get_solarpanelconfig(panel)
214214

215215
model = panel.get("model", "huld")
@@ -223,7 +223,7 @@ def solarpanel_rated_capacity_per_unit(panel):
223223

224224

225225
def windturbine_rated_capacity_per_unit(turbine):
226-
if isinstance(turbine, (str, Path)):
226+
if isinstance(turbine, (str | Path)):
227227
turbine = get_windturbineconfig(turbine)
228228

229229
return turbine["P"]
@@ -335,7 +335,7 @@ def _validate_turbine_config_dict(
335335
)
336336
raise ValueError(err_msg)
337337

338-
if not all(isinstance(turbine[p], (np.ndarray, list)) for p in ("POW", "V")):
338+
if not all(isinstance(turbine[p], (np.ndarray | list)) for p in ("POW", "V")):
339339
err_msg = "turbine entries 'POW' and 'V' must be np.ndarray or list"
340340
raise ValueError(err_msg)
341341

doc/release_notes.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,3 @@
55

66
.. include:: ../RELEASE_NOTES.rst
77

8-
* In ``atlite/resource.py``, the functions ``get_windturbineconfig``, ``get_solarpanelconfig``, and
9-
``get_cspinstallationconfig`` will now recognize if a local file was passed, and if so load
10-
it instead of one of the predefined ones.
11-
12-
* The option ``capacity_factor_timeseries`` can be selected when creating capacity factors to obtain
13-
the capacity factor of the selected resource per grid cell.
14-
15-
* The methods ``convert_cooling_demand`` and ``cooling_demand`` are implemented to evaluate cooling demand using the cooling degree-days approximation.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ readme = "README.rst"
1414
authors=[{name = "Contributors to atlite", email = "[email protected]"}]
1515
license = { file = "LICENSE" }
1616
classifiers=[
17-
"Programming Language :: Python :: 3.9",
1817
"Programming Language :: Python :: 3.10",
1918
"Programming Language :: Python :: 3.11",
2019
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
2121
"Development Status :: 3 - Alpha",
2222
"Environment :: Console",
2323
"Intended Audience :: Science/Research",
@@ -26,7 +26,7 @@ classifiers=[
2626
"Operating System :: OS Independent",
2727

2828
]
29-
requires-python = ">=3.9"
29+
requires-python = ">=3.10"
3030
dependencies = [
3131
"typing-extensions",
3232
"numpy",

0 commit comments

Comments
 (0)