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

CI with python 3.11 and removal of some deprecation warnings #577

Merged
merged 30 commits into from Jan 30, 2024

Conversation

sibirrer
Copy link
Collaborator

this PR updates the CI to python version 3.11, replaces scipy interp2d with a non-deprecated version, and updates all the setup(self) to setup_method(self) for testing

Copy link

codecov bot commented Jan 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8600471) 96.21% compared to head (79617f9) 96.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #577      +/-   ##
==========================================
- Coverage   96.21%   96.20%   -0.02%     
==========================================
  Files         261      261              
  Lines       22118    22134      +16     
==========================================
+ Hits        21281    21293      +12     
- Misses        837      841       +4     
Files Coverage Δ
lenstronomy/Cosmo/cosmo_solver.py 100.00% <100.00%> (ø)
lenstronomy/ImSim/image_linear_solve.py 99.20% <100.00%> (ø)
lenstronomy/ImSim/multiplane_organizer.py 100.00% <ø> (ø)
lenstronomy/LensModel/Profiles/gnfw.py 100.00% <ø> (ø)
lenstronomy/Plots/plot_quasar_images.py 100.00% <100.00%> (ø)
lenstronomy/Util/image_util.py 100.00% <ø> (ø)

... and 14 files with indirect coverage changes

@sibirrer
Copy link
Collaborator Author

@ajshajib can you review this PR such that I can merge it and make sure the build is not failing in newer PRs?
Also, is there a way to have in the setup() removed if inherited a unittest class?

@@ -11,7 +11,7 @@


class TestKinBin(object):
def setup(self):
def setup_method(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to here, setup_method() should be for setting up for testing a specific method and not for everything in the class, and it should take an argument method. I think, in most cases of test classes in lenstronomy, setup() can be replaced with __init__(). The other option setup_class() is a class method, and it would not then be usable to create instance-level variables as in __init__(), I think.

@ajshajib
Copy link
Collaborator

@sibirrer, looks good to me overall. I have changed all the setup_method() to __init__(). Now, one test is failing in an unchanged test module, so I think that needs to be looked at if there is a pre-existing issue.

@sibirrer
Copy link
Collaborator Author

@ajshajib it seems that init() does not work for test, as there are warnings like these appearing: ```
test/test_Sampling/test_Likelihoods/test_kinematic_2D_likelihood.py:13
/home/runner/work/lenstronomy/lenstronomy/test/test_Sampling/test_Likelihoods/test_kinematic_2D_likelihood.py:13: PytestCollectionWarning: cannot collect test class 'TestKinLikelihood' because it has a init constructor (from: test/test_Sampling/test_Likelihoods/test_kinematic_2D_likelihood.py)

@ajshajib
Copy link
Collaborator

@sibirrer, ok, thanks for the clarification! I have changed back all the def __init__(self) to def setup_method(self, method). Reading the documentation, this method will be called before calling each test method. The method argument is optional for pytest-v3.0, but I left it there in case it's not optional in the future, and this is the default way provided, it's fine not to use the method variable inside the function.

@ajshajib
Copy link
Collaborator

@sibirrer, looks good to me, and I approved the PR! Please proceed with merging.

@sibirrer sibirrer merged commit 4255f17 into lenstronomy:main Jan 30, 2024
3 of 4 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
Development

Successfully merging this pull request may close these issues.

None yet

2 participants