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 9 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
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
steps:
- uses: actions/[email protected]
- name: Set up Python${{ matrix.python-version }}
Expand Down Expand Up @@ -93,9 +93,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 Expand Up @@ -143,8 +140,8 @@ jobs:
strategy:
matrix:
include:
- tox-env: py310
python-version: "3.10"
- tox-env: py311
python-version: "3.11"
defaults:
run:
shell: bash -l {0}
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
rev: v3.15.0
hooks:
- id: pyupgrade
args: ['--py38-plus']
args: ['--py39-plus']
exclude: 'xclim/core/indicator.py'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -33,15 +33,15 @@ repos:
- id: yamllint
args: [ '--config-file=.yamllint.yaml' ]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
rev: 23.12.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.1.8
hooks:
- id: ruff
- repo: https://github.com/pycqa/flake8
Expand All @@ -54,9 +54,9 @@ repos:
rev: 1.7.1
hooks:
- id: nbqa-black
additional_dependencies: [ 'black==23.11.0' ]
additional_dependencies: [ 'black==23.12.0' ]
- id: nbqa-pyupgrade
args: [ '--py38-plus' ]
args: [ '--py39-plus' ]
- id: nbqa-isort
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
Expand All @@ -69,9 +69,9 @@ repos:
hooks:
- id: blackdoc
exclude: '(xclim/indices/__init__.py|docs/installation.rst)'
additional_dependencies: [ 'black==23.11.0' ]
additional_dependencies: [ 'black==23.12.0' ]
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.2
rev: 0.27.3
hooks:
- id: check-github-workflows
- id: check-readthedocs
Expand Down
13 changes: 6 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ Ready to contribute? Here's how to set up `xclim` for local development.

3. 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]"

4. Create a branch for local development::

Expand Down Expand Up @@ -163,10 +163,9 @@ 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 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 @@ -242,7 +241,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.

5. The pull request should work for Python 3.8, 3.9, 3.10, and 3.11 as well as raise test coverage.
5. The pull request should work for Python 3.9, 3.10, and 3.11 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 .
7 changes: 3 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ channels:
- conda-forge
- defaults
dependencies:
- python >=3.8
- python >=3.9,<3.12
Zeitsperre marked this conversation as resolved.
Show resolved Hide resolved
- astroid
- boltons >=20.1
- bottleneck >=1.3.1
- cf_xarray >=0.6.1
- cftime >=1.4.1
- Click >=8.1
- dask >=2.6.0
- importlib-resources # For Python3.8
- jsonpickle
- lmoments3
- numba
- numpy >=1.16
- pandas >=0.23,<2.2
- pandas >=2.1 # This should be raised to Pandas 2.2 when released
- pint >=0.9
- poppler >=0.67
- pyyaml
- scikit-learn >=0.21.3
- scipy >=1.2
- statsmodels
- xarray >=2022.06.0,<2023.11.0
- xarray >=2023.11.0
aulemahal marked this conversation as resolved.
Show resolved Hide resolved
# Extras
- eofs
- flox
Expand Down
30 changes: 14 additions & 16 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,41 +23,39 @@ 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",
# "Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Atmospheric Science"
]
dynamic = ["description", "version"]
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'",
# This should be raised to Pandas 2.2 when released
"pandas>=2.1",
"pint>=0.10",
"pyyaml",
"scikit-learn>=0.21.3",
"scipy>=1.2",
"statsmodels",
"xarray>=2022.06.0,<2023.11.0"
"xarray>=2023.11.0"
]

[project.optional-dependencies]
dev = [
# Dev tools and testing
"black >=23.3.0",
"black >=23.12.0",
"blackdoc",
"bump2version",
"coverage[toml]",
Expand All @@ -67,6 +65,7 @@ dev = [
"h5netcdf",
"ipython",
"mypy",
"nbconvert",
"nbqa",
"nbval",
"netCDF4 >=1.4",
Expand Down Expand Up @@ -115,10 +114,10 @@ xclim = "xclim.cli:cli"

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

[tool.coverage.run]
Expand Down Expand Up @@ -165,12 +164,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 @@ -218,13 +217,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
3 changes: 2 additions & 1 deletion tests/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def test_convert_calendar_360_days_random():
[
("standard", "noleap", "D"),
("noleap", "default", "4H"),
("noleap", "all_leap", "M"),
("noleap", "all_leap", "M"), # Do we want "MS" or "ME"?
("360_day", "noleap", "D"),
("noleap", "360_day", "D"),
],
Expand All @@ -416,6 +416,7 @@ def test_convert_calendar_missing(source, target, freq):
np.linspace(0, 1, src.size), dims=("time",), coords={"time": src}
)
out = convert_calendar(da_src, target, missing=0, align_on="date")
# FIXME: Do we want to raise an error here for "M"? Do we want "ME" or "MS"?
assert xr.infer_freq(out.time) == freq
if source == "360_day":
assert out.time[-1].dt.day == 31
Expand Down
3 changes: 2 additions & 1 deletion tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def test_common_time(self, tas_series, date_range, random):
db["time"] = db.time + pd.Timedelta(30, "min")
with pytest.raises(
ValidationError,
match=r"All inputs have the same frequency \(H\), but they are not anchored on the same minutes",
# FIXME: Do we want to emit warnings when frequency code is changed within the function?
match=r"All inputs have the same frequency \(h\), but they are not anchored on the same minutes",
):
datachecks.check_common_time([db, da])
4 changes: 2 additions & 2 deletions tests/test_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import gc
import json
from inspect import signature
from typing import Tuple, Union
from typing import Union

import dask
import numpy as np
Expand Down Expand Up @@ -487,7 +487,7 @@ def test_signature():
assert sig.return_annotation == xr.DataArray

sig = signature(xclim.atmos.wind_speed_from_vector)
assert sig.return_annotation == Tuple[xr.DataArray, xr.DataArray]
assert sig.return_annotation == tuple[xr.DataArray, xr.DataArray]


def test_doc():
Expand Down
Loading
Loading