Skip to content

Commit

Permalink
Removing float switch for uint32_t type. Switching to doubles in the …
Browse files Browse the repository at this point in the history
…C code from floats fixed a test case.
  • Loading branch information
kmacdonald-stsci committed Jan 16, 2024
1 parent b7963b7 commit ae84fc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
10 changes: 0 additions & 10 deletions src/stcal/ramp_fitting/src/slope_fitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2852,12 +2852,7 @@ save_ramp_fit(
#endif

ptr = PyArray_GETPTR2(rate_prod->dq, pr->row, pr->col);
#if REAL_IS_DOUBLE
float_tmp = (float) pr->rate.dq;
memcpy(ptr, &(float_tmp), sizeof(float_tmp));
#else
memcpy(ptr, &(pr->rate.dq), sizeof(pr->rate.dq));
#endif

ptr = PyArray_GETPTR2(rate_prod->var_poisson, pr->row, pr->col);
#if REAL_IS_DOUBLE
Expand Down Expand Up @@ -2894,12 +2889,7 @@ save_ramp_fit(
#endif

ptr = PyArray_GETPTR3(rateint_prod->dq, integ, pr->row, pr->col);
#if REAL_IS_DOUBLE
float_tmp = (float) pr->rateints[integ].dq;
memcpy(ptr, &(float_tmp), sizeof(float_tmp));
#else
memcpy(ptr, &(pr->rateints[integ].dq), sizeof(pr->rateints[integ].dq));
#endif

ptr = PyArray_GETPTR3(rateint_prod->var_poisson, integ, pr->row, pr->col);
#if REAL_IS_DOUBLE
Expand Down
11 changes: 3 additions & 8 deletions tests/test_ramp_fitting_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def test_pix_4():
NOTE:
There are small differences in the slope computation due to architectural
differences of C and python.
Switching to doubles from floats in the C code fixed this problem.
--------------------------------------------------------------------------------
*** [2627] Segment 2, Integration 0 ***
Expand Down Expand Up @@ -282,7 +283,6 @@ def test_pix_4():
"""


@pytest.mark.skip(reason="C architecture gives small differences for slope.")
def test_pix_5():
"""
CASE B: segment has >2 groups, not at end of ramp.
Expand All @@ -308,17 +308,12 @@ def test_pix_5():
ramp_data, bufsize, save_opt, rnoise, gain, algo, "optimal", ncores, dqflags
)

# XXX see the note above for the differences in C and python testing values.
# Set truth values for PRIMARY results:
p_true_p = [1.076075, JUMP, 0.16134359, 0.00227273, 0.02375903]
# p_true_c = [1.076122522354126, JUMP, 0.16134359, 0.00227273, 0.02375903] # To be used with C
p_true = p_true_p
p_true = [1.076075, JUMP, 0.16134359, 0.00227273, 0.02375903]

# Set truth values for OPTIONAL results:
oslope_p = [1.2799551, 1.0144024]
# oslope_c = [1.2799551, 1.0144479] # To be used with C
o_true = [
oslope_p,
[1.2799551, 1.0144024],
[18.312422, 9.920552],
[0.00606061, 0.00363636],
[0.10691562, 0.03054732],
Expand Down

0 comments on commit ae84fc8

Please sign in to comment.