Skip to content

Fix optional matplotlib#32

Open
sanchalitorpe-source wants to merge 4 commits intoINCF:masterfrom
sanchalitorpe-source:fix-optional-matplotlib
Open

Fix optional matplotlib#32
sanchalitorpe-source wants to merge 4 commits intoINCF:masterfrom
sanchalitorpe-source:fix-optional-matplotlib

Conversation

@sanchalitorpe-source
Copy link

This PR makes plotting optional by deferring matplotlib imports and raising a clear error only when plot functions are used.

This allows installing and using CSA in environments without matplotlib (e.g. CI, minimal installs), addressing issue #11.

Copy link

@rowleya rowleya left a comment

Choose a reason for hiding this comment

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

This looks helpful, but it would also be useful if setup.py had an optional dependency on matplotlib, as otherwise it will be force-required. Some information on this here: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies

@sanchalitorpe-source
Copy link
Author

I’ve now added matplotlib as an optional dependency via extras_require in setup.py.
Plotting support can be installed with:
pip install csa[plot]
This aligns the packaging metadata with the lazy matplotlib imports.

@rowleya
Copy link

rowleya commented Jan 21, 2026

This sounds good... do you need to push this still?

@sanchalitorpe-source
Copy link
Author

Yes, I just need to push the branch so the PR includes the changes. Once pushed, plotting support will be installable via pip install csa[plot].

Copy link
Contributor

@mdjurfeldt mdjurfeldt left a comment

Choose a reason for hiding this comment

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

Hi @sanchalitorpe-source, before making a decision on whether the form of this change is a good idea, you need to commit the changes to setup.py. Also, please use the same formatting style as in the rest of the code, i.e. for example foo (a1, ...). However, you are correct that there shouldn't be a space between an array and its subscript, so g[i] is the correct formatting.

@sanchalitorpe-source
Copy link
Author

Hi @mdjurfeldt,
I’ve now committed and pushed the setup.py changes, moving matplotlib from install_requires to an optional dependency via extras_require.
I’ve also aligned formatting with the existing code style.

Please let me know if this looks good now.

Copy link

@rowleya rowleya left a comment

Choose a reason for hiding this comment

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

I can approve from my side given the changes to setup.py

@sanchalitorpe-source
Copy link
Author

All requested changes have been implemented: setup.py now marks matplotlib as optional via extras_require, code formatting is aligned, and plotting functions raise a clear error only when used. This PR is ready to merge.

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.

3 participants