fix: resolve deprecation warnings and invalid escape sequences - #434
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.dimsindex access and in-place.shapeassignment), andSyntaxWarningsfor 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 deprecateddata.dims[dim]index access withdata.sizes[dim]to use the supported xarray API.typhon/physics/atmosphere.py: Replaced the deprecated in-placees.shape = (dim)assignment with an explicites = es.reshape(dim)call incolumn_relative_humidity.typhon/constants.py,typhon/geodesy.py,typhon/math/common.py: Converted affected docstrings to raw strings (r""" ... """) to silence invalid escape sequenceSyntaxWarnings.typhon/physics/em.py: Marked thesnell,zeeman_splitting, andzeeman_strengthdocstrings 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 withrto silence the invalid escape sequence warning ($\Delta$ IWP ...).Breaking Changes
None — these are internal compatibility fixes and runtime behavior is unchanged.