-
Notifications
You must be signed in to change notification settings - Fork 3
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
ENH: Prefer using NumPy's random number generator #83
base: main
Are you sure you want to change the base?
Conversation
3f59eb8
to
728079c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #83 +/- ##
=======================================
Coverage 69.15% 69.15%
=======================================
Files 20 20
Lines 963 963
Branches 119 119
=======================================
Hits 666 666
Misses 254 254
Partials 43 43 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
vs 1.14.1 in the latest successful build: Honestly, I cannot see how to workaround the issue without adding an exception to the checks on the affected lines. |
8cc572e
to
3c25992
Compare
Re #83 (comment) @effigies I'd be grateful if you could review commit 3c25992. I have not been able to fix the issue without preventing |
e54973b
to
f9adbcb
Compare
Prefer using NumPy's random number generator and the relevant random number sampling functions introduced in NumPy 1.17.0 over the legacy versions. Add a fixture for tests to set the random number generator consistently across tests. Documentation: https://numpy.org/doc/2.2/reference/random/new-or-different.html#what-s-new-or-different
Use the `dipy.core.gradientsGradientTable` class for type hinting instead of `dipy.core.gradients.gradient_table`: the latter is a function name and hence does not provide type information. Fixes: ``` src/nifreeze/testing/simulations.py:151: error: Function "dipy.core.gradients.gradient_table" is not valid as a type [valid-type] src/nifreeze/testing/simulations.py:151: note: Perhaps you need "Callable[...]" or a callback protocol? src/nifreeze/testing/simulations.py:185: error: Function "dipy.core.gradients.gradient_table" is not valid as a type [valid-type] src/nifreeze/testing/simulations.py:185: note: Perhaps you need "Callable[...]" or a callback protocol? src/nifreeze/testing/simulations.py:207: error: gradient_table? has no attribute "b0s_mask" [attr-defined] src/nifreeze/testing/simulations.py:208: error: gradient_table? has no attribute "bvecs" [attr-defined] ```
Remove `ClassVar[dict]` type hinting from GPR parameter constraints variable and define it as a normal dictionary. Fixes: ``` Cannot override instance variable '_parameter_constraints' (previously declared on base class 'GaussianProcessRegressor') with class variable ``` As `_param_constraints` is an instance variable in `scikit-learn`: https://github.com/scikit-learn/scikit-learn/blob/1.6.X/sklearn/gaussian_process/_gpr.py#L189
Ignore `scikit-learn` `Interval` and `StrOptions` type checking errors to prevent `mypy` erroring with the argument that they are abstract classes with the `__str__` abstract attribute. Fixes: ``` src/nifreeze/model/gpr.py:161: error: Cannot instantiate abstract class "Interval" with abstract attribute "__str__" [abstract] src/nifreeze/model/gpr.py:162: error: Cannot instantiate abstract class "StrOptions" with abstract attribute "__str__" [abstract] src/nifreeze/model/gpr.py:163: error: Cannot instantiate abstract class "Interval" with abstract attribute "__str__" [abstract] src/nifreeze/model/gpr.py:166: error: Cannot instantiate abstract class "Interval" with abstract attribute "__str__" [abstract] ```
Require `nitransforms` 22.x. Fixes: ``` .tox/py310/lib/python3.10/site-packages/nitransforms/io/base.py:4: in <module> from scipy.io.matlab.miobase import get_matfile_version E ImportError: cannot import name 'get_matfile_version' from 'scipy.io.matlab.miobase' (/home/runner/work/nifreeze/nifreeze/.tox/py310/lib/python3.10/site-packages/scipy/io/matlab/miobase.py) ``` raised for example in: https://github.com/nipreps/nifreeze/actions/runs/14013636690/job/39236852012?pr=83#step:11:58 Importing `scipy.io.matlabt.miobase.get_matfile_version` was removed in: https://github.com/nipy/nitransforms/pull/151/files included in release 22.0.0: https://github.com/nipy/nitransforms/releases/tag/22.0.0
f9adbcb
to
9263143
Compare
@oesteban I'd dare to say that any new PR will fail in absence of the 4 relevant commits in this PR. After having checked #83 (comment), I'd say that the changes in this PR should be uncontroversial so as to merge it and have the CIs passing. |
GradientTable
class for type hintingClassVar[dict]
type hinting from GPR param constraintsscikit-learn
Interval
andStrOptions
type checkingnitransforms
22.x