Skip to content

Commit

Permalink
Merge pull request #264 from mwcraig/pydantic-2-upgrade
Browse files Browse the repository at this point in the history
Pydantic 2 upgrade
  • Loading branch information
mwcraig authored Feb 4, 2024
2 parents f6b40fa + aee5d1e commit 7b4b3da
Show file tree
Hide file tree
Showing 9 changed files with 830 additions and 255 deletions.
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ dependencies = [
"bottleneck",
"ccdproc",
"ginga",
"ipyautoui >=0.5.9",
"ipyautoui >=0.7",
"ipyfilechooser",
"ipywidgets",
"matplotlib",
"pandas",
"photutils >=1.9",
"pydantic<2",
"pydantic >=2",
"pyyaml",
]

Expand Down Expand Up @@ -155,4 +155,6 @@ filterwarnings = [
'ignore:Passing unrecognized arguments to super:DeprecationWarning',
# pandas will require pyarrow at some point, which is good to know, I guess...
'ignore:[.\n]*Pyarrow will become a required dependency of pandas[.\n]*:DeprecationWarning',
# ipyautoui is generating this on import because they still have some pydantic changes to make
'ignore:Using extra keyword arguments on `Field` is deprecated:'
]
6 changes: 2 additions & 4 deletions stellarphot/gui_tools/tests/test_seeing_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_seeing_profile_properties(tmp_path):

# Check that the photometry apertures have defaulted to the
# default values in the model.
assert profile_widget.aperture_settings.value == PhotometryApertures().dict()
assert profile_widget.aperture_settings.value == PhotometryApertures().model_dump()

# Get the event handler that updates plots
handler = profile_widget._make_show_event()
Expand All @@ -102,9 +102,7 @@ def test_seeing_profile_properties(tmp_path):
new_radius = phot_aps["radius"] - 2
# Change the radius by directly setting the value of the widget that holds
# the value. That ends up being nested fairly deeply...
profile_widget.aperture_settings.autowidget.children[0].children[
0
].value = new_radius
profile_widget.aperture_settings.di_widgets["radius"].value = new_radius

# Make sure the settings are updated
phot_aps["radius"] = new_radius
Expand Down
12 changes: 6 additions & 6 deletions stellarphot/photometry/tests/test_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_calc_noise_source_only(gain, aperture_area):
expected = np.sqrt(gain * counts)

# Create camera instance
camera = ZERO_CAMERA.copy()
camera = ZERO_CAMERA.model_copy()
camera.gain = gain * camera.gain.unit

np.testing.assert_allclose(
Expand All @@ -104,7 +104,7 @@ def test_calc_noise_dark_only(gain, aperture_area):
exposure = 20

# Create camera instance
camera = ZERO_CAMERA.copy()
camera = ZERO_CAMERA.model_copy()
# Set gain and dark current to values for test
camera.dark_current = dark_current * camera.dark_current.unit
camera.gain = gain * camera.gain.unit
Expand All @@ -126,7 +126,7 @@ def test_calc_read_noise_only(gain, aperture_area):
expected = np.sqrt(aperture_area * read_noise**2)

# Create camera instance
camera = ZERO_CAMERA.copy()
camera = ZERO_CAMERA.model_copy()
camera.read_noise = read_noise * camera.read_noise.unit
camera.gain = gain * camera.gain.unit

Expand All @@ -143,7 +143,7 @@ def test_calc_sky_only(gain, aperture_area):
expected = np.sqrt(gain * aperture_area * sky)

# Create camera instance
camera = ZERO_CAMERA.copy()
camera = ZERO_CAMERA.model_copy()
camera.gain = gain * camera.gain.unit

np.testing.assert_allclose(
Expand All @@ -162,7 +162,7 @@ def test_annulus_area_term():
expected = np.sqrt(gain * aperture_area * (1 + aperture_area / annulus_area) * sky)

# Create camera instance
camera = ZERO_CAMERA.copy()
camera = ZERO_CAMERA.model_copy()
camera.gain = gain * camera.gain.unit

np.testing.assert_allclose(
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_calc_noise_messy_case(digit, expected):
read_noise = 12

# Create camera instance
camera = ZERO_CAMERA.copy()
camera = ZERO_CAMERA.model_copy()
camera.gain = gain * camera.gain.unit
camera.dark_current = dark_current * camera.dark_current.unit
camera.read_noise = read_noise * camera.read_noise.unit
Expand Down
1 change: 0 additions & 1 deletion stellarphot/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .autowidgets import *
from .models import *
from .views import *
Loading

0 comments on commit 7b4b3da

Please sign in to comment.