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

Convert ramp fitting Cython .pyx files into annotated .py files #232

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5f1c5ec
Refactor metadata computation for OLS CAS22 ramp
WilliamJamieson Nov 15, 2023
8151490
Refactor jump detection pre-compute arrays
WilliamJamieson Nov 15, 2023
0e7c51b
Update ramp fitting code to use .py file instead
WilliamJamieson Nov 15, 2023
52e7e35
Update jump detection code to use .py file instead of .pyx
WilliamJamieson Nov 15, 2023
d9857af
Update setup.py to use .py file instead of .pyx
WilliamJamieson Nov 15, 2023
b582f22
Switch to all vectors
WilliamJamieson Nov 15, 2023
32a8ee8
Resolve cython compiler warnings
WilliamJamieson Nov 15, 2023
9d6a520
Simplify the ramp initializer
WilliamJamieson Nov 15, 2023
9aa3d29
Fix annoying inline declarations
WilliamJamieson Nov 15, 2023
515afa5
Refactor enum definitions and extract output fit's
WilliamJamieson Nov 15, 2023
27437bc
Move parameter/variance allocation outside of cython
WilliamJamieson Nov 15, 2023
01ba76e
Pre-allocate output and working memory arrays for
WilliamJamieson Nov 15, 2023
37a310b
Move consistency checking outside of cython
WilliamJamieson Nov 15, 2023
df94f43
Remove kwarg from cython function
WilliamJamieson Nov 15, 2023
dc75dd8
Move code out of ramp and into other modules
WilliamJamieson Nov 15, 2023
11891ba
Reorder jump so that most important methods are first
WilliamJamieson Nov 15, 2023
5cb9689
Merge all cas22 modules together.
WilliamJamieson Nov 15, 2023
02f8544
Reduce calls back to python
WilliamJamieson Nov 15, 2023
fbf662f
Clean up tests slightly
WilliamJamieson Nov 15, 2023
6293bc2
bugfix for ramp tests.
WilliamJamieson Nov 16, 2023
2281b7f
Partial revert of converting _fill_metadata to vectors
WilliamJamieson Nov 16, 2023
d62faa9
Move metadata creation out of cython completely
WilliamJamieson Nov 16, 2023
59d4ed9
Update docs
WilliamJamieson Nov 16, 2023
4aef566
Refactor jump detection into its own function
WilliamJamieson Nov 17, 2023
618fa98
Remove dead files
WilliamJamieson Nov 17, 2023
587fed7
Hide the cython module by making it private.
WilliamJamieson Nov 17, 2023
2fc6832
Simplify the name of the wrapping module
WilliamJamieson Nov 17, 2023
47693ed
Clean up imports
WilliamJamieson Nov 17, 2023
e09983a
Fix interface to match previous one
WilliamJamieson Nov 17, 2023
9b29624
Bump cython version
WilliamJamieson Nov 17, 2023
34e59dc
Update changes
WilliamJamieson Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ dmypy.json

# Cython debug symbols
cython_debug/
src/stcal/ramp_fitting/ols_cas22/*.c
src/stcal/ramp_fitting/ols_cas22/*.cpp
src/stcal/ramp_fitting/ols_cas22/*.html
src/stcal/ramp_fitting/_ols_cas22/*.c
src/stcal/ramp_fitting/_ols_cas22/*.cpp
src/stcal/ramp_fitting/_ols_cas22/*.html

# setuptools-scm generated module
src/stcal/_version.py
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ jump
----
- Fix the code to at least always flag the group with the shower and the requested
groups after the primary shower. [#237]

ramp
----
- Convert Cython code to using annotated .py files. [#232]

1.5.2 (2023-12-13)
==================
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test = [
requires = [
'setuptools >=61',
'setuptools_scm[toml] >=3.4',
'Cython >=0.29.21',
'Cython >=3.0.0',
'numpy >=1.18',
]
build-backend = 'setuptools.build_meta'
Expand Down Expand Up @@ -81,6 +81,7 @@ testpaths = [
"docs",
]
norecursedirs = [
'src/stcal/ramp_fitting/_ols_cas22',
'benchmarks',
'.asv',
'.eggs',
Expand Down Expand Up @@ -146,7 +147,6 @@ extend-select = [
'FLY', # flynt (f-string conversion where possible)
'NPY', # NumPy-specific checks (recommendations from NumPy)
'PERF', # Perflint (performance linting)
'LOG',
'RUF', # ruff specific checks
]
ignore = [
Expand Down
16 changes: 2 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@

extensions = [
Extension(
"stcal.ramp_fitting.ols_cas22._ramp",
["src/stcal/ramp_fitting/ols_cas22/_ramp.pyx"],
include_dirs=[np.get_include()],
language="c++",
),
Extension(
"stcal.ramp_fitting.ols_cas22._jump",
["src/stcal/ramp_fitting/ols_cas22/_jump.pyx"],
include_dirs=[np.get_include()],
language="c++",
),
Extension(
"stcal.ramp_fitting.ols_cas22._fit",
["src/stcal/ramp_fitting/ols_cas22/_fit.pyx"],
"stcal.ramp_fitting._ols_cas22._fit",
["src/stcal/ramp_fitting/_ols_cas22/_fit.py"],
include_dirs=[np.get_include()],
language="c++",
),
Expand Down
14 changes: 14 additions & 0 deletions src/stcal/ramp_fitting/_ols_cas22/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
This subpackage exists to hold the Cython implementation of the OLS cas22 algorithm
This subpackage is private, and should not be imported directly by users. Instead,
import from stcal.ramp_fitting.ols_cas22.
"""
from ._fit import FixedOffsets, Parameter, PixelOffsets, Variance, fit_ramps

__all__ = [
"fit_ramps",
"Parameter",
"Variance",
"PixelOffsets",
"FixedOffsets",
]
32 changes: 32 additions & 0 deletions src/stcal/ramp_fitting/_ols_cas22/_fit.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# cython: language_level=3str
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I was unable to eliminate this file because Cython's enum structures do not have a Python syntax equivalent at this time.



cpdef enum Parameter:
intercept
slope
n_param


cpdef enum Variance:
read_var
poisson_var
total_var
n_var


cpdef enum:
JUMP_DET = 4


cpdef enum FixedOffsets:
t_bar_diff
t_bar_diff_sqr
read_recip
var_slope_val
n_fixed_offsets


cpdef enum PixelOffsets:
local_slope
var_read_noise
n_pixel_offsets
Loading
Loading