Skip to content

fix: resolve deprecation warnings and invalid escape sequences - #434

Merged
olemke merged 5 commits into
atmtools:masterfrom
olemke:some-fixes
Aug 11, 2026
Merged

fix: resolve deprecation warnings and invalid escape sequences#434
olemke merged 5 commits into
atmtools:masterfrom
olemke:some-fixes

Conversation

@olemke

@olemke olemke commented Aug 11, 2026

Copy link
Copy Markdown
Member

This PR addresses warnings raised by modern dependency and Python versions across several typhon modules. It tackles two related categories: API deprecations in xarray/numpy that will eventually turn into hard errors (the deprecated Dataset.dims index access and in-place .shape assignment), and SyntaxWarnings for invalid escape sequences in docstrings and string literals. Together these keep the codebase healthy on current Python and dependency versions without changing behavior.

Changes

  • typhon/collocations/collocator.py: Replaced the deprecated data.dims[dim] index access with data.sizes[dim] to use the supported xarray API.
  • typhon/physics/atmosphere.py: Replaced the deprecated in-place es.shape = (dim) assignment with an explicit es = es.reshape(dim) call in column_relative_humidity.
  • typhon/constants.py, typhon/geodesy.py, typhon/math/common.py: Converted affected docstrings to raw strings (r""" ... """) to silence invalid escape sequence SyntaxWarnings.
  • typhon/physics/em.py: Marked the snell, zeeman_splitting, and zeeman_strength docstrings as raw strings and adjusted the LaTeX backslashes accordingly so the rendered math stays correct while silencing the escape sequence warnings.
  • typhon/retrieval/spareice/common.py: Prefixed the SPAREICE IWP plot ylabel with r to silence the invalid escape sequence warning ($\Delta$ IWP ...).

Breaking Changes

None — these are internal compatibility fixes and runtime behavior is unchanged.

olemke added 5 commits August 11, 2026 08:32
…docstring

Make the cantor_pairing docstring a raw string so LaTeX backslashes
(\pi, \frac) are treated literally instead of triggering Python 3.12's
SyntaxWarning: invalid escape sequence '\p'.
Convert docstrings containing LaTeX math with backslashes to raw
strings. For zeeman_splitting and zeeman_strength, reduce double
backslashes to single backslashes to preserve rendered output.
The $\Delta$ LaTeX sequence in the ylabel contained an invalid
\D escape sequence. Use a raw string literal so the backslash is
passed through to matplotlib unchanged.
Replace `data.dims[dim]` with `data.sizes[dim]` to silence the
FutureWarning about the upcoming change in return type of
`Dataset.dims`.
Replace `es.shape = (dim)` with `es.reshape(dim)` in
column_relative_humidity. Setting shape directly on an array is
deprecated in NumPy 2.5.
@olemke
olemke merged commit 2604974 into atmtools:master Aug 11, 2026
9 checks passed
@olemke
olemke deleted the some-fixes branch August 11, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant