Fix pandas 3.x compatibility and notebook environment detection#830
Merged
Conversation
… class introspection JPY_PARENT_PID is not set in all notebook environments (VS Code, some JupyterLab configurations), causing NonGuiException in plotting functions.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates PmagPy’s I/O and environment detection logic to stay compatible with pandas 3.x and to correctly treat modern notebook runtimes (VS Code/JupyterLab) as “notebook” for plotting behavior.
Changes:
- Replaced deprecated
delim_whitespace=Trueusages withsep=r"\s+"in several CSV reads. - Fixed pandas 3.x dtype-assignment issues in
aarm_magic/atrm_magicby initializing missing specimen columns withnp.nanand coercing toobject. - Reworked notebook detection in
pmag_env/set_env.pyto use IPython shell introspection instead ofJPY_PARENT_PID.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| pmagpy/tsunashawfuncs.py | Updates whitespace-delimited parsing for pandas 3.x compatibility. |
| pmagpy/ipmag.py | Updates zeq parsing and fixes dtype initialization/casting in aarm_magic and atrm_magic. |
| pmagpy/convert_2_magic.py | Updates whitespace-delimited parsing in multiple converters for pandas 3.x compatibility. |
| pmag_env/set_env.py | Improves notebook detection to prevent GUI-show calls under inline backends. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
delim_whitespacewithsep=r"\s+"inipmag.py,convert_2_magic.py,tsunashawfuncs.py, andPmagPy_calculations.ipynbfor pandas 3.x compatibilityaarm_magicandatrm_magicby initializing missing specimen columns withnp.nanand casting toobjectdtype, preventingTypeErrorwhen assigning mixed-type values into strict-dtype columns in pandas 3.xJPY_PARENT_PIDnotebook detection with IPython kernel class introspection inset_env.py, fixingNonGuiExceptionin plotting functions when running in VS Code or JupyterLab environments that do not set that environment variableCloses #827
Closes #828
Closes #829