1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
|
[project]
authors = [{ name = "xarray Developers", email = "xarray@googlegroups.com" }]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering",
]
description = "N-D labeled arrays and datasets in Python"
dynamic = ["version"]
license = "Apache-2.0"
name = "xarray"
readme = "README.md"
requires-python = ">=3.11"
dependencies = ["numpy>=1.26", "packaging>=24.1", "pandas>=2.2"]
# We don't encode minimum requirements here (though if we can write a script to
# generate the text from `min_deps_check.py`, that's welcome...). We do add
# `numba>=0.54` here because of https://github.com/astral-sh/uv/issues/7881;
# note that it's not a direct dependency of xarray.
[project.optional-dependencies]
accel = [
"scipy>=1.13",
"bottleneck",
"numbagg>=0.8",
"numba>=0.59",
"flox>=0.9",
"opt_einsum",
"numpy<2.3", # numba has not updated yet: https://github.com/numba/numba/issues/10105
]
complete = ["xarray[accel,etc,io,parallel,viz]"]
io = [
"netCDF4>=1.6.0",
"h5netcdf",
"pydap",
"scipy>=1.13",
"zarr>=2.18",
"fsspec",
"cftime",
"pooch",
]
etc = ["sparse>=0.15"]
parallel = ["dask[complete]"]
viz = ["cartopy>=0.23", "matplotlib", "nc-time-axis", "seaborn"]
types = [
"pandas-stubs",
"scipy-stubs",
"types-PyYAML",
"types-Pygments",
"types-colorama",
"types-decorator",
"types-defusedxml",
"types-docutils",
"types-networkx",
"types-pexpect",
"types-psutil",
"types-pycurl",
"types-openpyxl",
"types-python-dateutil",
"types-pytz",
"types-setuptools",
]
[dependency-groups]
dev = [
"hypothesis",
"jinja2",
"mypy",
"pre-commit",
"pytest",
"pytest-cov",
"pytest-env",
"pytest-mypy-plugins",
"pytest-timeout",
"pytest-xdist",
"pytest-asyncio",
"ruff>=0.8.0",
"sphinx",
"sphinx_autosummary_accessors",
"xarray[complete,types]",
]
[project.urls]
Documentation = "https://docs.xarray.dev"
SciPy2015-talk = "https://www.youtube.com/watch?v=X0pAhJgySxk"
homepage = "https://xarray.dev/"
issue-tracker = "https://github.com/pydata/xarray/issues"
source-code = "https://github.com/pydata/xarray"
[project.entry-points."xarray.chunkmanagers"]
dask = "xarray.namedarray.daskmanager:DaskManager"
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=77.0.3", "setuptools-scm>=8"]
[tool.setuptools.packages.find]
include = ["xarray*"]
[tool.setuptools_scm]
fallback_version = "9999"
[tool.coverage.run]
omit = [
"*/xarray/tests/*",
"*/xarray/compat/dask_array_compat.py",
"*/xarray/compat/npcompat.py",
"*/xarray/compat/pdcompat.py",
"*/xarray/namedarray/pycompat.py",
"*/xarray/core/types.py",
]
source = ["xarray"]
[tool.coverage.report]
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]
[tool.mypy]
enable_error_code = ["ignore-without-code", "redundant-self", "redundant-expr"]
exclude = ['build', 'xarray/util/generate_.*\.py']
files = "xarray"
show_error_context = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
# Much of the numerical computing stack doesn't have type annotations yet.
[[tool.mypy.overrides]]
ignore_missing_imports = true
module = [
"affine.*",
"bottleneck.*",
"cartopy.*",
"cf_units.*",
"cfgrib.*",
"cftime.*",
"cloudpickle.*",
"cubed.*",
"cupy.*",
"fsspec.*",
"h5netcdf.*",
"h5py.*",
"iris.*",
"mpl_toolkits.*",
"nc_time_axis.*",
"netCDF4.*",
"netcdftime.*",
"numcodecs.*",
"opt_einsum.*",
"pint.*",
"pooch.*",
"pyarrow.*",
"pydap.*",
"scipy.*",
"seaborn.*",
"setuptools",
"sparse.*",
"toolz.*",
"zarr.*",
"numpy.exceptions.*", # remove once support for `numpy<2.0` has been dropped
"array_api_strict.*",
]
# Gradually we want to add more modules to this list, ratcheting up our total
# coverage. Once a module is here, functions are checked by mypy regardless of
# whether they have type annotations. It would be especially useful to have test
# files listed here, because without them being checked, we don't have a great
# way of testing our annotations.
[[tool.mypy.overrides]]
check_untyped_defs = true
module = [
"xarray.core.accessor_dt",
"xarray.core.accessor_str",
"xarray.structure.alignment",
"xarray.computation.*",
"xarray.indexes.*",
"xarray.tests.*",
]
# This then excludes some modules from the above list. (So ideally we remove
# from here in time...)
[[tool.mypy.overrides]]
check_untyped_defs = false
module = [
"xarray.tests.test_coarsen",
"xarray.tests.test_coding_times",
"xarray.tests.test_combine",
"xarray.tests.test_computation",
"xarray.tests.test_concat",
"xarray.tests.test_coordinates",
"xarray.tests.test_dask",
"xarray.tests.test_dataarray",
"xarray.tests.test_duck_array_ops",
"xarray.tests.test_indexing",
"xarray.tests.test_merge",
"xarray.tests.test_missing",
"xarray.tests.test_parallelcompat",
"xarray.tests.test_sparse",
"xarray.tests.test_ufuncs",
"xarray.tests.test_units",
"xarray.tests.test_utils",
"xarray.tests.test_variable",
"xarray.tests.test_weighted",
]
# Use strict = true whenever namedarray has become standalone. In the meantime
# don't forget to add all new files related to namedarray here:
# ref: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
[[tool.mypy.overrides]]
# Start off with these
warn_unused_ignores = true
# Getting these passing should be easy
strict_concatenate = true
strict_equality = true
# Strongly recommend enabling this one as soon as you can
check_untyped_defs = true
# These shouldn't be too much additional work, but may be tricky to
# get passing if you use a lot of untyped libraries
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_decorators = true
# These next few are various gradations of forcing use of type annotations
disallow_incomplete_defs = true
disallow_untyped_calls = true
disallow_untyped_defs = true
# This one isn't too hard to get passing, but return on investment is lower
no_implicit_reexport = true
# This one can be tricky to get passing if you use a lot of untyped libraries
warn_return_any = true
module = ["xarray.namedarray.*", "xarray.tests.test_namedarray"]
# We disable pyright here for now, since including it means that all errors show
# up in devs' VS Code, which then makes it more difficult to work with actual
# errors. It overrides local VS Code settings so isn't escapable.
# [tool.pyright]
# defineConstant = {DEBUG = true}
# # Enabling this means that developers who have disabled the warning locally —
# # because not all dependencies are installable — are overridden
# # reportMissingImports = true
# reportMissingTypeStubs = false
[tool.ruff]
extend-exclude = ["doc", "_typed_ops.pyi"]
[tool.ruff.lint]
extend-select = [
"YTT", # flake8-2020
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"PIE", # flake8-pie
"TID", # flake8-tidy-imports (absolute imports)
"PYI", # flake8-pyi
"SIM", # flake8-simplify
"FLY", # flynt
"I", # isort
"PERF", # Perflint
"W", # pycodestyle warnings
"PGH", # pygrep-hooks
"PLC", # Pylint Convention
"PLE", # Pylint Errors
"PLR", # Pylint Refactor
"PLW", # Pylint Warnings
"UP", # pyupgrade
"FURB", # refurb
"RUF",
]
extend-safe-fixes = [
"TID252", # absolute imports
]
ignore = [
"C40", # unnecessary generator, comprehension, or literal
"PIE790", # unnecessary pass statement
"PYI019", # use `Self` instead of custom TypeVar
"PYI041", # use `float` instead of `int | float`
"SIM102", # use a single `if` statement instead of nested `if` statements
"SIM108", # use ternary operator instead of `if`-`else`-block
"SIM117", # use a single `with` statement instead of nested `with` statements
"SIM118", # use `key in dict` instead of `key in dict.keys()`
"SIM300", # yoda condition detected
"PERF203", # try-except within a loop incurs performance overhead
"E402", # module level import not at top of file
"E731", # do not assign a lambda expression, use a def
"PLC0415", # `import` should be at the top-level of a file
"PLC0206", # extracting value from dictionary without calling `.items()`
"PLR091", # too many arguments / branches / statements
"PLR2004", # magic value used in comparison
"PLW0603", # using the global statement to update is discouraged
"PLW0642", # reassigned `self` variable in instance method
"PLW1641", # object does not implement `__hash__` method
"PLW2901", # `for` loop variable overwritten by assignment target
"UP007", # use X | Y for type annotations
"FURB105", # unnecessary empty string passed to `print`
"RUF001", # string contains ambiguous unicode character
"RUF002", # docstring contains ambiguous acute accent unicode character
"RUF003", # comment contains ambiguous no-break space unicode character
"RUF005", # consider unpacking operator instead of concatenation
"RUF012", # mutable class attributes
]
[tool.ruff.lint.per-file-ignores]
# don't enforce absolute imports
"asv_bench/**" = ["TID252"]
# comparison with itself in tests
"xarray/tests/**" = ["PLR0124"]
# looks like ruff bugs
"xarray/core/_typed_ops.py" = ["PYI034"]
"xarray/namedarray/_typing.py" = ["PYI018", "PYI046"]
[tool.ruff.lint.isort]
known-first-party = ["xarray"]
[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"pandas.api.types.is_extension_array_dtype".msg = "Use xarray.core.utils.is_allowed_extension_array{_dtype} instead. Only use the banend API if the incoming data has already been sanitized by xarray"
[tool.pytest.ini_options]
addopts = [
"--strict-config",
"--strict-markers",
"--mypy-only-local-stub",
"--mypy-pyproject-toml-file=pyproject.toml",
]
# We want to forbid warnings from within xarray in our tests — instead we should
# fix our own code, or mark the test itself as expecting a warning. So this:
# - Converts any warning from xarray into an error
# - Allows some warnings ("default") which the test suite currently raises,
# since it wasn't practical to fix them all before merging this config. The
# warnings are reported in CI (since it uses `default`, not `ignore`).
#
# Over time, we can remove these rules allowing warnings. A valued contribution
# is removing a line, seeing what breaks, and then fixing the library code or
# tests so that it doesn't raise warnings.
#
# There are some instance where we'll want to add to these rules:
# - While we only raise errors on warnings from within xarray, a dependency can
# raise a warning with a stacklevel such that it's interpreted to be raised
# from xarray and this will mistakenly convert it to an error. If that
# happens, please feel free to add a rule switching it to `default` here, and
# disabling the error.
# - If these settings get in the way of making progress, it's also acceptable to
# temporarily add additional `default` rules.
# - But we should only add `ignore` rules if we're confident that we'll never
# need to address a warning.
filterwarnings = [
"error:::xarray.*",
"default:No index created:UserWarning:xarray.core.dataset",
"default::UserWarning:xarray.tests.test_coding_times",
"default::UserWarning:xarray.tests.test_computation",
"default::UserWarning:xarray.tests.test_dataset",
"default:`ancestors` has been deprecated:DeprecationWarning:xarray.core.treenode",
"default:`iter_lineage` has been deprecated:DeprecationWarning:xarray.core.treenode",
"default:`lineage` has been deprecated:DeprecationWarning:xarray.core.treenode",
"default:coords should be an ndarray:DeprecationWarning:xarray.tests.test_variable",
"default:deallocating CachingFileManager:RuntimeWarning:xarray.backends.*",
"default:deallocating CachingFileManager:RuntimeWarning:xarray.backends.netCDF4_",
"default:deallocating CachingFileManager:RuntimeWarning:xarray.core.indexing",
"default:Failed to decode variable.*NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays:DeprecationWarning",
"default:The `interpolation` argument to quantile was renamed to `method`:FutureWarning:xarray.*",
"default:invalid value encountered in cast:RuntimeWarning:xarray.core.duck_array_ops",
"default:invalid value encountered in cast:RuntimeWarning:xarray.conventions",
"default:invalid value encountered in cast:RuntimeWarning:xarray.tests.test_units",
"default:invalid value encountered in cast:RuntimeWarning:xarray.tests.test_array_api",
"default:NumPy will stop allowing conversion of:DeprecationWarning",
"default:shape should be provided:DeprecationWarning:xarray.tests.test_variable",
"default:the `pandas.MultiIndex` object:FutureWarning:xarray.tests.test_variable",
"default:Using a non-tuple sequence for multidimensional indexing is deprecated:FutureWarning",
"default:Duplicate dimension names present:UserWarning:xarray.namedarray.core",
# Zarr 2 V3 implementation
"ignore:Zarr-Python is not in alignment with the final V3 specification",
# TODO: this is raised for vlen-utf8, consolidated metadata, U1 dtype
"ignore:is currently not part .* the Zarr version 3 specification.",
# TODO: remove once we know how to deal with a changed signature in protocols
"default:::xarray.tests.test_strategies",
]
log_cli_level = "INFO"
markers = [
"flaky: flaky tests",
"mypy: type annotation tests",
"network: tests requiring a network connection",
"slow: slow tests",
"slow_hypothesis: slow hypothesis tests",
]
minversion = "7"
python_files = ["test_*.py"]
testpaths = ["xarray/tests", "properties"]
[tool.aliases]
test = "pytest"
[tool.repo-review]
ignore = [
"PP308", # This option creates a large amount of log lines.
]
[tool.typos]
[tool.typos.default]
extend-ignore-identifiers-re = [
# Variable names
"nd_.*",
".*_nd",
"ba_.*",
".*_ba",
"ser_.*",
".*_ser",
# Function/class names
"NDArray.*",
".*NDArray.*",
]
[tool.typos.default.extend-words]
# NumPy function names
arange = "arange"
ond = "ond"
aso = "aso"
# Technical terms
nd = "nd"
nin = "nin"
# Variable names
ba = "ba"
ser = "ser"
fo = "fo"
iy = "iy"
vart = "vart"
ede = "ede"
# Organization/Institution names
Stichting = "Stichting"
Mathematisch = "Mathematisch"
# People's names
Soler = "Soler"
Bruning = "Bruning"
Tung = "Tung"
Claus = "Claus"
Celles = "Celles"
slowy = "slowy"
Commun = "Commun"
# Tests
Ome = "Ome"
SUR = "SUR"
Tio = "Tio"
Ono = "Ono"
abl = "abl"
# Technical terms
splitted = "splitted"
childs = "childs"
cutted = "cutted"
LOCA = "LOCA"
[tool.typos.type.jupyter]
extend-ignore-re = ["\"id\": \".*\""]
|