Skip to content

Fix pandas 3.x compatibility and notebook environment detection#830

Merged
Swanson-Hysell merged 5 commits into
masterfrom
test_exploration
Mar 7, 2026
Merged

Fix pandas 3.x compatibility and notebook environment detection#830
Swanson-Hysell merged 5 commits into
masterfrom
test_exploration

Conversation

@Swanson-Hysell

Copy link
Copy Markdown
Member
  • Replace deprecated delim_whitespace with sep=r"\s+" in ipmag.py, convert_2_magic.py, tsunashawfuncs.py, and PmagPy_calculations.ipynb for pandas 3.x compatibility
  • Fix dtype conflicts in aarm_magic and atrm_magic by initializing missing specimen columns with np.nan and casting to object dtype, preventing TypeError when assigning mixed-type values into strict-dtype columns in pandas 3.x
  • Replace fragile JPY_PARENT_PID notebook detection with IPython kernel class introspection in set_env.py, fixing NonGuiException in plotting functions when running in VS Code or JupyterLab environments that do not set that environment variable

Closes #827
Closes #828
Closes #829

… class introspection

JPY_PARENT_PID is not set in all notebook environments (VS Code, some
JupyterLab configurations), causing NonGuiException in plotting functions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=True usages with sep=r"\s+" in several CSV reads.
  • Fixed pandas 3.x dtype-assignment issues in aarm_magic / atrm_magic by initializing missing specimen columns with np.nan and coercing to object.
  • Reworked notebook detection in pmag_env/set_env.py to use IPython shell introspection instead of JPY_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.

Comment thread pmagpy/ipmag.py Outdated
Comment thread pmagpy/tsunashawfuncs.py
Comment thread pmagpy/ipmag.py
Comment thread pmagpy/convert_2_magic.py
Comment thread pmagpy/convert_2_magic.py
Comment thread pmagpy/ipmag.py Outdated
@Swanson-Hysell Swanson-Hysell merged commit ef44c9e into master Mar 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants