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
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8cfe3be
change Python github workflow to Python version 3.11
sibirrer Jan 25, 2024
1a267c8
Merge remote-tracking branch 'origin/main'
sibirrer Jan 25, 2024
eee5309
fix deprecation warnings for interp2d
sibirrer Jan 26, 2024
9f0365b
changed setup(self) -> setup_method(self) for testing due to deprecat…
sibirrer Jan 26, 2024
0dd976d
stability improvement and also deprecation warning avoidance
sibirrer Jan 26, 2024
78d1c84
revert setup_method when combined with unit testing
sibirrer Jan 26, 2024
743f30b
slightly modified test tolerance for passing tests in python 3.11
sibirrer Jan 28, 2024
398bcc9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 28, 2024
78acfa5
Update lenstronomy/LensModel/Profiles/gnfw.py
ajshajib Jan 30, 2024
8501312
Update test/test_Data/test_kinematic_data_2D.py
ajshajib Jan 30, 2024
d2f33ca
Update test/test_ImSim/test_multi_plane_organizer.py
ajshajib Jan 30, 2024
a511de9
Update test/test_LightModel/test_Profiles/test_shapelets_ellipse.py
ajshajib Jan 30, 2024
696b1a0
Update test/test_Sampling/test_Likelihoods/test_kinematic_2D_likeliho…
ajshajib Jan 30, 2024
614097c
Update test/test_Sampling/test_Likelihoods/test_kinematic_NN_call.py
ajshajib Jan 30, 2024
0dee463
Update test/test_Util/test_kin_sampling_util.py
ajshajib Jan 30, 2024
9068697
Update test/test_Workflow/test_alignment_matching.py
ajshajib Jan 30, 2024
98a0a1f
Update test/test_Workflow/test_flux_calibration.py
ajshajib Jan 30, 2024
e9c26cf
Update test/test_Workflow/test_flux_calibration.py
ajshajib Jan 30, 2024
0bd032a
Update test/test_Workflow/test_flux_calibration.py
ajshajib Jan 30, 2024
76f244d
Update test/test_Workflow/test_flux_calibration.py
ajshajib Jan 30, 2024
7b33032
Update test/test_Workflow/test_flux_calibration.py
ajshajib Jan 30, 2024
3d9a6ca
Update test/test_Workflow/test_flux_calibration.py
ajshajib Jan 30, 2024
eef3677
Update test/test_Workflow/test_alignment_matching.py
ajshajib Jan 30, 2024
54b927e
Update test/test_Util/test_kin_sampling_util.py
ajshajib Jan 30, 2024
7caf6a1
Update test/test_Sampling/test_Likelihoods/test_kinematic_NN_call.py
ajshajib Jan 30, 2024
f9bed88
Update test/test_Sampling/test_Likelihoods/test_kinematic_2D_likeliho…
ajshajib Jan 30, 2024
526eda7
Update test/test_LightModel/test_Profiles/test_shapelets_ellipse.py
ajshajib Jan 30, 2024
0ec2d46
Update test/test_ImSim/test_multi_plane_organizer.py
ajshajib Jan 30, 2024
3887147
Update test/test_Data/test_kinematic_data_2D.py
ajshajib Jan 30, 2024
79617f9
remove deprecation warning in plot
sibirrer Jan 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
- uses: actions/checkout@v4
Expand Down
20 changes: 6 additions & 14 deletions lenstronomy/Cosmo/cosmo_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,15 @@ def _make_interpolation(self):
)
Dd_grid[i] = Dd
Ds_Dds_grid[i] = Ds_Dds
self._f_H0 = interpolate.interp2d(
Dd_grid,
Ds_Dds_grid,
self._f_H0 = interpolate.LinearNDInterpolator(
(Dd_grid, Ds_Dds_grid),
H0_grid,
kind="linear",
copy=False,
bounds_error=False,
fill_value=-1,
)
print("H0 interpolation done")
self._f_omega_m = interpolate.interp2d(
Dd_grid,
Ds_Dds_grid,
self._f_omega_m = interpolate.LinearNDInterpolator(
(Dd_grid, Ds_Dds_grid),
omega_m_grid,
kind="linear",
copy=False,
bounds_error=False,
fill_value=0,
)
print("omega_m interpolation done")
Expand All @@ -153,9 +145,9 @@ def get_cosmo(self, Dd, Ds_Dds):
print(H0, "H0")
omega_m = self._f_omega_m(Dd, Ds_Dds)
Dd_new, Ds_Dds_new = cosmo2angular_diameter_distances(
H0[0], omega_m[0], self.z_d, self.z_s
H0, omega_m, self.z_d, self.z_s
)
if abs(Dd - Dd_new) / Dd > 0.01 or abs(Ds_Dds - Ds_Dds_new) / Ds_Dds > 0.01:
return -1, -1
else:
return H0[0], omega_m[0]
return H0, omega_m
2 changes: 1 addition & 1 deletion lenstronomy/ImSim/image_linear_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ def _image_linear_solve_interferometry_natwt_solving(self, A, d):
for i in range(num_of_light):
b[i] = np.sum(A[i] * (d))

param_amps = np.linalg.lstsq(M, b)[0]
param_amps = np.linalg.lstsq(M, b, rcond=None)[0]

clean_temp = np.zeros((num_of_image_pixel))
dirty_temp = np.zeros((num_of_image_pixel))
Expand Down
6 changes: 3 additions & 3 deletions lenstronomy/ImSim/multiplane_organizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class MultiPlaneOrganizer(object):
being the $P+1$-th plane), the effective Fermat potential is defined as (eq. 9 of Shajib et al. 2020):

.. math::
\phi^{\rm eff} (\theta) \equiv \sum_{i=1}^{P} \frac{1+z_i}{1+z_{\rm d}} \frac{D_i D_{i+1} D_{\rm ds}}{D_{\rm d} D_{\rm s}D_{i\ i+1} } \left[ \frac{(\theta_{i} - \theta_{ i+1})^2}{2} - \zeta_{i,i+1} \psi_{i}(\theta_{i}) \right].
\\phi^{\\rm eff} (\\theta) \\equiv \\sum_{i=1}^{P} \\frac{1+z_i}{1+z_{\\rm d}} \\frac{D_i D_{i+1} D_{\\rm ds}}{D_{\\rm d} D_{\\rm s}D_{i\\ i+1} } \\left[ \\frac{(\\theta_{i} - \\theta_{ i+1})^2}{2} - \\zeta_{i,i+1} \\psi_{i}(\\theta_{i}) \\right].

Then, the $a_i$ and $b_i$ distance ratios are defined as:

.. math::
a_i \equiv \frac{D_i D_{i+1} D_{1\ P+1}}{D_{\rm 1} D_{P+1}D_{i\ i+1} } = \frac{D_i D_{i+1}}{D_{i\ i+1} D_{\Delta t}^{\rm eff}}
b_i \equiv \frac{D_i D_{1\ P+1}}{D_1 D_{i\ P+1}} = \frac{D_i D_{P+1}}{D_{i\ P+1} D_{\Delta t}^{\rm eff}}.
a_i \\equiv \\frac{D_i D_{i+1} D_{1\\ P+1}}{D_{\\rm 1} D_{P+1}D_{i\\ i+1} } = \\frac{D_i D_{i+1}}{D_{i\\ i+1} D_{\\Delta t}^{\\rm eff}}
b_i \\equiv \\frac{D_i D_{1\\ P+1}}{D_1 D_{i\\ P+1}} = \\frac{D_i D_{P+1}}{D_{i\\ P+1} D_{\\Delta t}^{\\rm eff}}.

This class converts the $a_i$ and $b_i$ ratios to the relevant cosmological
distances needed for ray-tracing. However, instead of using $a_i$ and $b_i$,
Expand Down
4 changes: 2 additions & 2 deletions lenstronomy/LensModel/Profiles/gnfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ def rho02kappa_s(rho0, Rs, gamma_in):
@staticmethod
def kappa_s2rho0(kappa_s, Rs, gamma_in):
"""Convenience function to compute rho0 from kappa_s. The returned rho_0 is
normalized with $\Sigma_crit$.
normalized with $\\Sigma_{\\rm crit}$.

:param kappa_s: convergence correspoding to rho0
:param kappa_s: convergence corresponding to rho0
:type kappa_s: float
:param Rs: scale radius
:type Rs: float
Expand Down
4 changes: 0 additions & 4 deletions lenstronomy/Util/image_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ def re_size_array(x_in, y_in, input_values, x_out, y_out):
:param y_out:
:return:
"""
# from skimage.transform import resize
# resize(input_values)
# interp_2d = interpolate.interp2d(x_in, y_in, input_values, kind="linear")
# out_values = interp_2d.__call__(x_out, y_out)
from scipy.interpolate import RectBivariateSpline

func = RectBivariateSpline(x_in, y_in, z=input_values, kx=1, ky=1, s=0)
Expand Down
2 changes: 1 addition & 1 deletion test/test_Analysis/test_kinematics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ def test_velocity_dispersion_map_direct_convolved_against_jampy(self):
]
)

assert np.max(np.abs(jampy_vel_dis / vel_dis[14:28, 14:28] - 1)) < 0.008
assert np.max(np.abs(jampy_vel_dis / vel_dis[14:28, 14:28] - 1)) < 0.009

def test_velocity_dispersion_map(self):
np.random.seed(42)
Expand Down
2 changes: 1 addition & 1 deletion test/test_Cosmo/test_cosmo_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_get_cosmo(self):
Dd, Ds_Dds = cosmo2angular_diameter_distances(H0, omega_m, self.z_d, self.z_s)
H0_new, omega_m_new = self.invertCosmo.get_cosmo(Dd, Ds_Dds)
npt.assert_almost_equal(H0_new, H0, decimal=1)
npt.assert_almost_equal(omega_m_new, omega_m, decimal=3)
npt.assert_almost_equal(omega_m_new, omega_m, decimal=2)

H0_new, omega_m_new = self.invertCosmo_default.get_cosmo(Dd, Ds_Dds)
npt.assert_almost_equal(H0_new, H0, decimal=1)
Expand Down
2 changes: 1 addition & 1 deletion test/test_Data/test_kinematic_data_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TestKinBin(object):
def setup(self):
def __init__(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
self.numPix = 10
self.num_bin = 4
kwargs_kin = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_image_linear_solve_with_primary_beam_and_interferometry_psf():
b[0] = np.sum(A0 * sim_data)
b[1] = np.sum(A1 * sim_data)

amps0 = np.linalg.lstsq(M, b)[0]
amps0 = np.linalg.lstsq(M, b, rcond=None)[0]
clean_model = amps0[0] * A0 + amps0[1] * A1
dirty_model = amps0[0] * A0c + amps0[1] * A1c

Expand Down
2 changes: 1 addition & 1 deletion test/test_ImSim/test_multi_plane_organizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class TestMultiPlaneOrganizer(object):
""""""

def setup(self):
def __init__(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
""""""
self.lens_redshift_list = [0.2, 0.4, 0.6, 1.0]
self.source_redshift_list = [0.6, 1.0, 1.0, 1.2]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class TestShapeletSetEllipse(object):
def setup(self):
def __init__(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
self.ellipse = ShapeletSetEllipse()
self.spherical = ShapeletSet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TestKinLikelihood(object):
def setup(self):
def __init__(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
self.kinematic_NN = kinematic_NN_call.KinematicNN().SKiNN_installed
# initialize KinLikelihood class and calculate example vrms for testing
major_axis_pa = 30 * np.pi / 180
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class TestKinNNCall(object):
def setup(self):
def __init__(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
self.example_input = np.array(
[
8.56306356e-01,
Expand Down
2 changes: 1 addition & 1 deletion test/test_Util/test_kin_sampling_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class TestKinSamplingUtil(object):
def setup(self):
def __init__(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
self.image = np.array(
[
[0, 1, 0, 0, 0],
Expand Down
2 changes: 1 addition & 1 deletion test/test_Workflow/test_alignment_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class TestAlignmentMatching(object):
def setup(self):
def __init__(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
np.random.seed(41)
# data specifics
sigma_bkg = 0.01 # background noise per pixel
Expand Down
2 changes: 1 addition & 1 deletion test/test_Workflow/test_flux_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class TestImageCalibration(object):
def setup(self):
def setup_method(self):
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
np.random.seed(41)
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
# data specifics
ajshajib marked this conversation as resolved.
Show resolved Hide resolved
sigma_bkg = 0.01 # background noise per pixel
Expand Down