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

Drop Python3.8, support Pandas v2.2, reduce Warnings #1565

Merged
merged 50 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
de79e09
pre-commit update
Zeitsperre Dec 18, 2023
28d7c0e
drop all Python3.8 in top-level
Zeitsperre Dec 18, 2023
839585f
pyupgrade fixes
Zeitsperre Dec 18, 2023
08ae98d
include tests in ruff checks
Zeitsperre Dec 18, 2023
fc84c89
limit to Python3.11
Zeitsperre Dec 18, 2023
8853ec0
drop Python3.8
Zeitsperre Dec 18, 2023
1ee9d24
fix import, fix docs
Zeitsperre Dec 18, 2023
edde1e2
small signature adjustments, docstring fixes
Zeitsperre Dec 18, 2023
f911164
safer Python calls
Zeitsperre Dec 18, 2023
6fe7566
update read-the-docs package name
Zeitsperre Jan 3, 2024
dc21fb0
Merge branch 'master' into drop-python38
Zeitsperre Jan 3, 2024
288346f
Merge branch 'master' into drop-python38
Zeitsperre Jan 10, 2024
084dc96
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 10, 2024
a4b4c35
Merge branch 'master' into drop-python38
Zeitsperre Jan 22, 2024
8c7dcfb
fix toml error
Zeitsperre Jan 22, 2024
08b2289
small adjustments to frequencies
Zeitsperre Jan 22, 2024
b01c6ce
Add fixme notice about silently failing tests
Zeitsperre Jan 22, 2024
91a7030
remove deprecated winter_storm indice and indicator
Zeitsperre Jan 22, 2024
ffc6ad8
raise version pins on numpy, scipy, and pandas; remove legacy version…
Zeitsperre Jan 22, 2024
ee43930
update CHANGES.rst
Zeitsperre Jan 22, 2024
6e7c832
Merge branch 'master' into drop-python38
Zeitsperre Jan 22, 2024
c37c487
Apply suggestions from code review
Zeitsperre Jan 23, 2024
a27aa62
Merge branch 'master' into drop-python38
Zeitsperre Jan 23, 2024
109bd5a
merge topd22 commit 1
aulemahal Jan 22, 2024
b6718fd
Merge branch 'master' into drop-python38
aulemahal Jan 23, 2024
da806bb
reduce test warnings, fix some docstrings, add pyarrow to dependencie…
Zeitsperre Jan 23, 2024
25bcf0b
docstring fixes and warnings reduction
Zeitsperre Jan 23, 2024
276dd4d
silence numba.vectorize decorator warnings
Zeitsperre Jan 23, 2024
d4dcff0
investigate weekofyear FutureWarning
Zeitsperre Jan 23, 2024
c7eab8b
Remove deprecated code - remove warnings - avoid using YE with cftime
aulemahal Jan 23, 2024
d1ce1dd
Merge branch 'drop-python38' of github.com:Ouranosinc/xclim into drop…
aulemahal Jan 23, 2024
389e26d
remove debugging leftover
aulemahal Jan 23, 2024
e8e85e2
silence pint-related warnings, add note on how to eventually resolve
Zeitsperre Jan 23, 2024
dd68994
remove noqa
Zeitsperre Jan 23, 2024
bad864f
ignore division by zero errors in to_additive_space
Zeitsperre Jan 23, 2024
2c8ecec
handle pint string formatting, point to ongoing issue upstream
Zeitsperre Jan 23, 2024
5946c61
filter DeprecationWarnings stemming from pint value string formatting
Zeitsperre Jan 23, 2024
57ce43f
fix rl for xr 2024.01
aulemahal Jan 23, 2024
bad8f84
Remove mention of older scipy in tests
aulemahal Jan 23, 2024
ab481ca
Remove debugging print
aulemahal Jan 23, 2024
a7a3d1e
Merge branch 'master' into drop-python38
Zeitsperre Jan 24, 2024
21c966d
Merge branch 'master' into drop-python38
Zeitsperre Jan 25, 2024
d0d9422
Apply suggestions from code review
Zeitsperre Jan 25, 2024
cb97a9c
Merge branch 'master' into drop-python38
Zeitsperre Jan 25, 2024
5f59e31
remove Python3.8-backported library
Zeitsperre Jan 25, 2024
e54626c
Merge branch 'master' into drop-python38
Zeitsperre Jan 26, 2024
69f1e6b
update CHANGES.rst
Zeitsperre Jan 26, 2024
d679f7b
update pyupgrade style
Zeitsperre Jan 26, 2024
ca84199
Update CHANGES.rst
Zeitsperre Jan 29, 2024
8bd6efc
Merge branch 'master' into drop-python38
Zeitsperre Jan 29, 2024
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
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
steps:
- name: Harden Runner
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
Expand Down Expand Up @@ -115,9 +115,6 @@ jobs:
strategy:
matrix:
include:
- tox-env: py38-coverage-eofs
python-version: "3.8"
markers: -m 'not slow'
- tox-env: py39-coverage-sbck-eofs
python-version: "3.9"
markers: -m 'not slow'
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Contributors to this version: Juliette Lavoie (:user:`juliettelavoie`), Pascal B

Announcements
^^^^^^^^^^^^^
* `xclim` no longer supports Python3.8. (:issue:`1268`, :pull:`1565`).
* `xclim` now officially supports Python3.12 (requires `numba>=0.59.0`). (:pull:`1613`).
* `xclim` now adheres to the `Semantic Versioning 2.0.0 <https://semver.org/>`_ specification. (:issue:`1556`, :pull:`1569`).
* The `xclim` repository now uses `GitHub Discussions <https://github.com/Ouranosinc/xclim/discussions>`_ to offer help for users, coordinate translation efforts, and support general Q&A for the `xclim` community. The `xclim` `Gitter` room has been deprecated in favour of GitHub Discussions. (:issue:`1571`, :pull:`1572`).
Expand All @@ -21,9 +22,13 @@ New features and enhancements

Breaking changes
^^^^^^^^^^^^^^^^
* With pandas 2.2 and xarray 2023.11.0, many frequency strings where changed : Y becomes YE, M -> ME, Q -> QE. A and AS are removed. T, L, U, N become min, ms, us and ns.
* `bump2version` has been replaced with `bump-my-version` to bump the version number using configurations set in the `pyproject.toml` file. (:issue:`1557`, :pull:`1569`).
* `xclim`'s units registry and units formatting are now extended from `cf-xarray`. The exponent sign "^" is now never added in the ``units`` attribute. For example, square meters are given as "m2" instead of "m^2" by xclim, both are still accepted as input. (:issue:`1010`, :pull:`1590`).
* `yamale` is now listed as a core dependency (was previously listed in the `dev` installation recipe). (:issue:`1595`, :pull:`1596`).
* The indice and indicator for ``winter_storm`` has been removed (deprecated since `xclim` v0.46.0 in favour of ``snd_storm_days``). (:pull:`1565`).
* `xclim` base dependencies have risen to `pandas>=2.2.0` and `xarray>=2023.11.0` to reflect changes to time frequency codes introduced in `pandas==2.2.0`. (:issue:`1534`, :pull:`1565`; see also: `pydata/xarray GH/8394 <https://github.com/pydata/xarray/issues/8394>`_).
* `xclim` has dropped support for `scipy` version below v1.9.0 and `numpy` versions below v1.20.0. (:pull:`1565`).

Bug fixes
^^^^^^^^^
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ Ready to contribute? Here's how to set up `xclim` for local development.

#. Create a development environment. We recommend using ``conda``::

$ conda create -n xclim python=3.8 --file=environment.yml
$ pip install -e .[dev]
$ conda create -n xclim python=3.9 --file=environment.yml
Zeitsperre marked this conversation as resolved.
Show resolved Hide resolved
$ python -m pip install -e ".[dev]"

#. Create a branch for local development::

Expand Down Expand Up @@ -162,10 +162,10 @@ Ready to contribute? Here's how to set up `xclim` for local development.

Alternatively, one can use ``$ tox`` to run very specific testing configurations, as GitHub Workflows would do when a Pull Request is submitted and new commits are pushed::

$ tox -e py38 # run tests on Python 3.8
$ tox -e py39-upstream-doctest # run tests on Python 3.9, including doctests, with upstream dependencies
$ tox -e py310 -- -m "not slow # run tests on Python 3.10, excluding "slow" marked tests
$ tox -e py311 # run tests on Python 3.11
$ tox -e py39 # run tests on Python 3.9
$ tox -e py310-upstream-doctest # run tests on Python 3.10, including doctests, with upstream dependencies
$ tox -e py311 -- -m "not slow # run tests on Python 3.11, excluding "slow" marked tests
Zeitsperre marked this conversation as resolved.
Show resolved Hide resolved
$ tox -e py312-numba -- -m "not slow # run tests on Python 3.12, installing upstream `numba`, excluding "slow" marked tests
$ tox -e notebooks_doctests # run tests using the base Python on doctests and evaluate all notebooks
$ tox -e offline # run tests using the base Python, excluding tests requiring internet access

Expand Down Expand Up @@ -243,7 +243,7 @@ Before you submit a pull request, please follow these guidelines:
If you aren't accustomed to writing documentation in reStructuredText (`.rst`), we encourage you to spend a few minutes going over the
incredibly well-summarized `reStructuredText Primer`_ from the sphinx-doc maintainer community.

#. The pull request should work for Python 3.8, 3.9, 3.10, and 3.11 as well as raise test coverage.
#. The pull request should work for Python 3.9, 3.10, 3.11, and 3.12 as well as raise test coverage.
Pull requests are also checked for documentation build status and for `PEP8`_ compliance.

The build statuses and build errors for pull requests can be found at: https://github.com/Ouranosinc/xclim/actions
Expand Down
5 changes: 0 additions & 5 deletions docs/explanation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ Why use xclim?
Purpose
=======

.. important::

The content of this section is actively being developed in the forthcoming paper submission to JOSS.
This section will be updated and finalized when the wording has been agreed upon in :pull:`250`

`xclim` aims to position itself as a climate services tool for any researchers interested in using Climate and Forecast Conventions (`CF-Conventions <https://cfconventions.org/>`_) compliant datasets to perform climate analyses. This tool is optimized for working with Big Data in the climate science domain and can function as an independent library for one-off analyses in *Jupyter Notebooks* or as a backend engine for performing climate data analyses via **Web Processing Services** (`WPS <https://www.ogc.org/standard/wps/>`_; e.g. `Finch <https://github.com/bird-house/finch>`_). It was primarily developed targeting Earth and Environmental Science audiences and researchers, originally for calculating climate indicators for the Canadian government web service `ClimateData.ca <https://climatedata.ca/>`_.

The primary domains that `xclim` is built for are in calculating climate indicators, performing statistical correction / bias adjustment of climate model output variables or simulations, and in performing climate model simulation ensemble statistics.
Expand Down
14 changes: 7 additions & 7 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To install `xclim` via `pip`, run this command in your terminal:

.. code-block:: shell

$ pip install xclim
$ python -m pip install xclim

If you don't have `pip`_ installed, this `Python installation guide`_ can guide you through the process.

Expand Down Expand Up @@ -55,7 +55,7 @@ Both of these libraries are available on PyPI and conda-forge:

.. code-block:: shell

$ pip install flox clisops
$ python -m pip install flox clisops
# Or, alternatively:
$ conda install -c conda-forge flox clisops

Expand All @@ -70,7 +70,7 @@ For convenience, these libraries can be installed alongside `xclim` using the fo

.. code-block:: shell

$ pip install -r requirements_upstream.txt
$ python -m pip install -r requirements_upstream.txt

Or, alternatively:

Expand Down Expand Up @@ -105,13 +105,13 @@ Afterwards, `SBCK` can be installed from PyPI using `pip`:

.. code-block:: shell

$ pip install SBCK
$ python -m pip install SBCK

Another experimental function :py:indicator:`xclim.sdba.property.first_eof` makes use of the `eofs`_ library, which is available on both PyPI and conda-forge:

.. code-block:: shell

$ pip install eofs
$ python -m pip install eofs
# or alternatively,
$ conda install -c conda-forge eofs

Expand Down Expand Up @@ -145,7 +145,7 @@ Once you have extracted a copy of the source, you can install it with pip:

.. code-block:: shell

$ pip install -e ".[dev]"
$ python -m pip install -e ".[dev]"

Alternatively, you can also install a local development copy via `flit`_:

Expand All @@ -166,4 +166,4 @@ To create a conda environment including `xclim`'s dependencies and several optio

$ conda env create -n my_xclim_env python=3.8 --file=environment.yml
$ conda activate my_xclim_env
(my_xclim_env) $ pip install -e .
(my_xclim_env) $ python -m pip install -e .
11 changes: 6 additions & 5 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- conda-forge
- defaults
dependencies:
- python >=3.8
- python >=3.9
- astroid
- boltons >=20.1
- bottleneck >=1.3.1
Expand All @@ -16,15 +16,16 @@ dependencies:
- jsonpickle
- lmoments3
- numba
- numpy >=1.16
- pandas >=0.23,<2.2
- numpy >=1.20.0
- pandas >=2.2.0
- pint >=0.9
- poppler >=0.67
- pyarrow # Strongly encouraged for Pandas v2.2.0+
- pyyaml
- scikit-learn >=0.21.3
- scipy >=1.2
- scipy >=1.10.0
Zeitsperre marked this conversation as resolved.
Show resolved Hide resolved
- statsmodels
- xarray >=2022.06.0,<2023.11.0
- xarray >=2023.11.0
- yamale
# Extras
- eofs
Expand Down
33 changes: 15 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ maintainers = [
{name = "Pascal Bourgault", email = "[email protected]"}
]
readme = {file = "README.rst", content-type = "text/x-rst"}
requires-python = ">=3.8.0"
requires-python = ">=3.9.0"
keywords = ["xclim", "xarray", "climate", "climatology", "bias correction", "ensemble", "indicators", "analysis"]
license = {file = "LICENSE"}
classifiers = [
Expand All @@ -23,7 +23,6 @@ classifiers = [
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -35,31 +34,29 @@ dependencies = [
"boltons>=20.1",
"bottleneck>=1.3.1",
# cf-xarray is differently named on conda-forge
"cf-xarray>=0.6.1,<0.8.5; python_version == '3.8'",
"cf-xarray>=0.6.1; python_version >= '3.9'",
"cf-xarray>=0.6.1",
"cftime>=1.4.1",
"Click>=8.1",
"dask[array]>=2.6",
"importlib-resources; python_version == '3.8'",
"jsonpickle",
"lmoments3>=1.0.5",
"numba",
"numpy>=1.16",
"pandas>=0.23,<2.0; python_version == '3.8'",
"pandas>=0.23,<2.2; python_version >= '3.9'",
"numpy>=1.20.0",
"pandas>=2.2",
"pint>=0.10",
"pyarrow", # Strongly encouraged for pandas v2.2.0+
"pyyaml",
"scikit-learn>=0.21.3",
"scipy>=1.2",
"scipy>=1.9.0",
"statsmodels",
"xarray>=2022.06.0,<2023.11.0",
"xarray>=2023.11.0",
"yamale"
]

[project.optional-dependencies]
dev = [
# Dev tools and testing
"black >=23.3.0",
"black >=23.12.0",
"blackdoc",
"bump-my-version",
"codespell",
Expand All @@ -70,6 +67,7 @@ dev = [
"h5netcdf",
"ipython",
"mypy",
"nbconvert",
"nbqa",
"nbval",
"netCDF4 >=1.4",
Expand Down Expand Up @@ -117,10 +115,10 @@ xclim = "xclim.cli:cli"

[tool.black]
target-version = [
"py38",
"py39",
"py310",
"py311"
"py311",
"py312"
]

[tool.bumpversion]
Expand Down Expand Up @@ -197,12 +195,12 @@ exclude = [

[tool.isort]
profile = "black"
py_version = 38
py_version = 39
append_only = true
add_imports = "from __future__ import annotations"

[tool.mypy]
python_version = 3.8
python_version = 3.9
show_error_codes = true
warn_return_any = true
warn_unused_configs = true
Expand Down Expand Up @@ -250,13 +248,12 @@ markers = [
[tool.ruff]
src = ["xclim"]
line-length = 150
target-version = "py38"
target-version = "py39"
exclude = [
".git",
"docs",
"build",
".eggs",
"tests"
".eggs"
]
ignore = [
"D205",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def prsnd_series():
def pr_hr_series():
"""Return precipitation hourly time series."""
_pr_hr_series = partial(
test_timeseries, start="1/1/2000", variable="pr", units="kg m-2 s-1", freq="1H"
test_timeseries, start="1/1/2000", variable="pr", units="kg m-2 s-1", freq="h"
)
return _pr_hr_series

Expand Down
2 changes: 1 addition & 1 deletion tests/test_atmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def test_wind_power_potential_from_3h_series():
from xclim.testing.helpers import test_timeseries

w = test_timeseries(
np.ones(96) * 15, variable="sfcWind", start="7/1/2000", units="m s-1", freq="3H"
np.ones(96) * 15, variable="sfcWind", start="7/1/2000", units="m s-1", freq="3h"
)
out = atmos.wind_power_potential(wind_speed=w)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_bootstrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class Test_bootstrap:
"var,p,index,freq, cftime",
(
["tas", 98, tg90p, "MS", False],
["tasmin", 98, tn90p, "A-JUL", False],
["tasmax", 98, tx90p, "Q-APR", False],
["tasmax", 98, tx90p, "Q-APR", True],
["tasmin", 98, tn90p, "YS-JUL", False],
["tasmax", 98, tx90p, "QS-APR", False],
["tasmax", 98, tx90p, "QS-APR", True],
["tasmin", 2, tn10p, "MS", False],
["tasmax", 2, tx10p, "YS", False],
["tasmax", 2, tx10p, "YS", True],
Expand Down
Loading