Skip to content

Commit 191e2d8

Browse files
committed
pymc switch, theano removed
1 parent f8b6a50 commit 191e2d8

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ The GUI is optional functionality, and its dependencies can be included when ins
4949
If there are issues launching the gui, pip may not have properly installed all Pyside6 dependencies. In that case try
5050
installing Pyside6 separately with e.g. conda.
5151

52-
**Star Shine has only been tested in Python 3.11**. Using older versions could result in unexpected errors,
53-
although any Python version >=3.8 is expected to work. An upper limit of 3.12 is set specifically for the GUI
54-
dependency pyside6, later versions of this package support higher Python versions.
52+
**Star Shine has only been tested in Python 3.11 and 3.12**.
53+
Using older versions could result in unexpected errors, although any Python version >=3.8 is expected to work.
54+
An upper limit of 3.12 is set specifically for the GUI dependency pyside6, later versions of this package support
55+
higher Python versions.
5556

5657
**Package dependencies:** The following package versions have been used in the development of this code,
5758
meaning older versions can in principle work, but this is not guaranteed. NumPy 1.20.3, SciPy 1.7.3, Numba 0.55.1,

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ dependencies = [
2828

2929
[project.optional-dependencies]
3030
mcmc = [
31-
"pymc3>=3.11.4,<4.0.0",
32-
"theano-pymc>=1.1.2,<2.0.0",
31+
"pymc>=5.0.0,<6.0.0",
3332
"arviz>=0.11.4,<1.0.0",
3433
"fastprogress>=1.0.0,<2.0.0"
3534
]

star_shine/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@
4141
4242
If there are issues launching the GUI, pip may not have properly installed all Pyside6 dependencies.
4343
In that case try installing Pyside6 separately with e.g. conda.
44-
Installing via the `pyproject.toml` via Poetry should also forego this dependency issue.
4544
4645
### Notes on library versions
4746
4847
The GUI uses the PySide6 library, which is tightly bound to specific Python versions.
4948
Each PySide6 version only supports a small range of Python versions, as may be found in their documentation.
5049
The standard Star Shine dependencies do not have this limitation.
5150
52-
**Star Shine has only been tested in Python 3.11**.
51+
**Star Shine has only been tested in Python 3.11 and 3.12**.
5352
Using older versions could result in unexpected errors, however, any Python version >=3.6 is expected to work,
5453
and Python versions >=3.8 are expected to work with the GUI.
5554
An upper limit of Python 3.12 is set specifically for the GUI dependency pyside6, although later versions of this

star_shine/core/mcmc.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
try:
1515
# optional functionality
16-
import pymc3 as pm
17-
import theano.tensor as tt
16+
import pymc as pm
17+
import pytensor.tensor as pt
1818
import arviz as az
1919
from fastprogress import fastprogress
2020
except (ImportError, AttributeError) as e:
@@ -77,8 +77,8 @@ def sample_sinusoid(time, flux, const, slope, f_n, a_n, ph_n, c_err, sl_err, f_n
7777
"""
7878
# setup
7979
time_t = time.reshape(-1, 1) # transposed time
80-
t_mean = tt.as_tensor_variable(np.mean(time))
81-
t_mean_s = tt.as_tensor_variable(np.array([np.mean(time[s[0]:s[1]]) for s in i_chunks]))
80+
t_mean = pt.as_tensor_variable(np.mean(time))
81+
t_mean_s = pt.as_tensor_variable(np.array([np.mean(time[s[0]:s[1]]) for s in i_chunks]))
8282
lin_shape = (len(const),)
8383
sin_shape = (len(f_n),)
8484
# progress bar
@@ -97,7 +97,7 @@ def sample_sinusoid(time, flux, const, slope, f_n, a_n, ph_n, c_err, sl_err, f_n
9797
slope_pm = pm.Normal('slope', mu=slope, sigma=sl_err, shape=lin_shape, testval=slope)
9898
# piece-wise linear curve
9999
linear_curves = [const_pm[k] + slope_pm[k] * (time[s[0]:s[1]] - t_mean_s[k]) for k, s in enumerate(i_chunks)]
100-
model_linear = tt.concatenate(linear_curves)
100+
model_linear = pt.concatenate(linear_curves)
101101
# sinusoid parameter models
102102
f_n_pm = pm.TruncatedNormal('f_n', mu=f_n, sigma=f_n_err, lower=0, shape=sin_shape, testval=f_n)
103103
a_n_pm = pm.TruncatedNormal('a_n', mu=a_n, sigma=a_n_err, lower=0, shape=sin_shape, testval=a_n)
@@ -111,8 +111,7 @@ def sample_sinusoid(time, flux, const, slope, f_n, a_n, ph_n, c_err, sl_err, f_n
111111

112112
# do the sampling
113113
with lc_model:
114-
inf_data = pm.sample(draws=1000, tune=1000, init='adapt_diag', cores=1, progressbar=(logger is not None),
115-
return_inferencedata=True)
114+
inf_data = pm.sample(draws=1000, tune=1000, init='adapt_diag', cores=1, progressbar=(logger is not None))
116115

117116
if logger is not None:
118117
az.summary(inf_data, round_to=2, circ_var_names=['ph_n'])
@@ -201,8 +200,8 @@ def sample_sinusoid_h(time, flux, p_orb, const, slope, f_n, a_n, ph_n, p_err, c_
201200
"""
202201
# setup
203202
time_t = time.reshape(-1, 1) # transposed time
204-
t_mean = tt.as_tensor_variable(np.mean(time))
205-
t_mean_s = tt.as_tensor_variable(np.array([np.mean(time[s[0]:s[1]]) for s in i_chunks]))
203+
t_mean = pt.as_tensor_variable(np.mean(time))
204+
t_mean_s = pt.as_tensor_variable(np.array([np.mean(time[s[0]:s[1]]) for s in i_chunks]))
206205
harmonics, harmonic_n = star_shine.core.frequency_sets.find_harmonics_from_pattern(f_n, 1/p_orb, f_tol=1e-9)
207206
non_harm = np.delete(np.arange(len(f_n)), harmonics)
208207
lin_shape = (len(const),)
@@ -224,7 +223,7 @@ def sample_sinusoid_h(time, flux, p_orb, const, slope, f_n, a_n, ph_n, p_err, c_
224223
slope_pm = pm.Normal('slope', mu=slope, sigma=sl_err, shape=lin_shape, testval=slope)
225224
# piece-wise linear curve
226225
linear_curves = [const_pm[k] + slope_pm[k] * (time[s[0]:s[1]] - t_mean_s[k]) for k, s in enumerate(i_chunks)]
227-
model_linear = tt.concatenate(linear_curves)
226+
model_linear = pt.concatenate(linear_curves)
228227
# sinusoid parameter models
229228
f_n_pm = pm.TruncatedNormal('f_n', mu=f_n[non_harm], sigma=f_n_err[non_harm], lower=0, shape=sin_shape,
230229
testval=f_n[non_harm])
@@ -250,8 +249,7 @@ def sample_sinusoid_h(time, flux, p_orb, const, slope, f_n, a_n, ph_n, p_err, c_
250249

251250
# do the sampling
252251
with lc_model:
253-
inf_data = pm.sample(draws=1000, tune=1000, init='adapt_diag', cores=1, progressbar=(logger is not None),
254-
return_inferencedata=True)
252+
inf_data = pm.sample(draws=1000, tune=1000, init='adapt_diag', cores=1, progressbar=(logger is not None))
255253

256254
if logger is not None:
257255
az.summary(inf_data, round_to=2, circ_var_names=['ph_n'])

star_shine/core/visualisation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
az = None
1717
pass
1818

19-
from star_shine.core import time_series as tms, model as mdl, frequency_sets as frs
19+
from star_shine.core import model as mdl, frequency_sets as frs
2020
from star_shine.core import periodogram as pdg, utility as ut, io
2121
from star_shine.config.helpers import get_mpl_stylesheet_path
2222

0 commit comments

Comments
 (0)