Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all JAX and machine learning related dependencies optional #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pmenczel
Copy link
Member

The JOPT and RL algorithms come with very heavy dependencies, which don't need to be installed for every user. This PR adds targets "jopt" and "rl" so that one can use pip install qutip-qoc [jopt] or pip install qutip-qoc [rl] to include these dependencies, otherwise they are omitted. The full installation (as it was previously) can be obtained with pip install qutip-qoc [full].

I updated the code to still work if these dependencies are not installed, as long as these algorithms are not invoked, and made the tests skip if the dependencies are not installed. Someone please double-check if I missed anything, but I have checked that the tests pass in all installation configurations.

This PR does not fix issue #30 but should improve things somewhat, since everything still works on Windows if the RL dependencies are not installed.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 12922178635

Details

  • 28 of 36 (77.78%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.6%) to 87.996%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/qutip_qoc/result.py 4 6 66.67%
src/qutip_qoc/_jopt.py 20 23 86.96%
src/qutip_qoc/pulse_optim.py 4 7 57.14%
Totals Coverage Status
Change from base Build 12691527707: -0.6%
Covered Lines: 821
Relevant Lines: 933

💛 - Coveralls

@@ -11,6 +10,12 @@

import qutip as qt

try:
import jaxlib
_jitfun_type = jaxlib.xla_extension.PjitFunction
Copy link
Member Author

@pmenczel pmenczel Feb 7, 2025

Choose a reason for hiding this comment

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

Just noticed that this line raises an AttributeError if JAX is installed but import jax wasn't executed yet. This is reminder to myself to fix
Edit: oh, this is also why documentation build failed

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.

2 participants