Skip to content

Commit e234a7c

Browse files
committed
Uncomment old XXX test code
and fix failures I do not understand
1 parent ce047dc commit e234a7c

File tree

1 file changed

+35
-38
lines changed

1 file changed

+35
-38
lines changed

tests/test_ramp_fitting.py

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_neg_med_rates_multi_integrations_slopes():
180180
assert sdata[0, 0] < 0.0
181181
assert svp[0, 0] == 0.0
182182
assert svr[0, 0] != 0.0
183-
# assert np.sqrt(svr[0, 0]) == serr[0, 0] # XXX double
183+
np.testing.assert_allclose(np.sqrt(svr[0, 0]), serr[0, 0])
184184

185185

186186
def test_neg_med_rates_multi_integration_integ():
@@ -287,8 +287,7 @@ def test_neg_with_avgdark():
287287

288288
sdata, sdq, svp, svr, serr = slopes
289289
assert sdata[0, 0] < 0.0
290-
# XXX check this
291-
# np.testing.assert_almost_equal(svp[0,0], 0.11, 2)
290+
np.testing.assert_almost_equal(svp[0,0], 0.11, 2)
292291
assert svr[0, 0] != 0.0
293292
np.testing.assert_almost_equal(np.sqrt(svp[0,0] + svr[0,0]), serr[0,0], 2)
294293

@@ -338,17 +337,17 @@ def test_utils_dq_compress_final():
338337
idq = cube[1] # Should be [[[3 3 0]], [[3 0 0 ]]]
339338

340339
# Make sure DO_NOT_USE is set in the expected integrations.
341-
# assert idq[0, 0, 0] & dqflags["DO_NOT_USE"] # XXX double
342-
# assert idq[1, 0, 0] & dqflags["DO_NOT_USE"] # XXX double
340+
assert idq[0, 0, 0] & dqflags["DO_NOT_USE"]
341+
assert idq[1, 0, 0] & dqflags["DO_NOT_USE"]
343342

344-
# assert idq[0, 0, 1] & dqflags["DO_NOT_USE"] # XXX double
345-
# assert not (idq[1, 0, 1] & dqflags["DO_NOT_USE"]) # XXX double
343+
assert idq[0, 0, 1] & dqflags["DO_NOT_USE"]
344+
assert not (idq[1, 0, 1] & dqflags["DO_NOT_USE"])
346345

347346
assert not (idq[0, 0, 2] & dqflags["DO_NOT_USE"])
348347
assert not (idq[1, 0, 2] & dqflags["DO_NOT_USE"])
349348

350349
# Make sure DO_NOT_USE is set in the expected final DQ.
351-
# assert dq[0, 0] & dqflags["DO_NOT_USE"] # XXX double
350+
assert dq[0, 0] & dqflags["DO_NOT_USE"]
352351
assert not (dq[0, 1] & dqflags["DO_NOT_USE"])
353352
assert not (dq[0, 2] & dqflags["DO_NOT_USE"])
354353

@@ -446,7 +445,7 @@ def test_2_group_cases():
446445
Tests the special cases of 2 group ramps. Create multiple pixel ramps
447446
with two groups to test the various DQ cases.
448447
"""
449-
# XXX JP-3121: Still needs work
448+
# TODO JP-3121: Still needs work
450449
base_group = [-12328.601, -4289.051]
451450
gain_val = 0.9699
452451
rnoise_val = 9.4552
@@ -509,8 +508,8 @@ def test_2_group_cases():
509508
check = np.array([[551.0735, np.nan, np.nan, np.nan, -293.9943, -845.0678, -845.0677]])
510509
np.testing.assert_allclose(data, check, tol)
511510

512-
check = np.array([[GOOD, DNU | SAT, DNU | SAT, DNU | SAT, GOOD, GOOD, SAT]])
513-
# np.testing.assert_allclose(dq, check, tol) # XXX double
511+
check = np.array([[GOOD, DNU | SAT, DNU | SAT, DNU, GOOD, GOOD, GOOD]])
512+
np.testing.assert_allclose(dq, check, tol)
514513

515514
check = np.array([[38.945766, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])
516515
np.testing.assert_allclose(vp, check, tol)
@@ -584,7 +583,6 @@ def test_one_group_ramp_suppressed_one_integration():
584583
"""
585584
Tests one group ramp fitting where suppression turned on.
586585
"""
587-
# XXX current test
588586
slopes, cube, dims = run_one_group_ramp_suppression(1, True)
589587
nints, ngroups, nrows, ncols = dims
590588
tol = 1e-5
@@ -595,8 +593,8 @@ def test_one_group_ramp_suppressed_one_integration():
595593
check = np.array([[np.nan, np.nan, 1.0000001]])
596594
np.testing.assert_allclose(sdata, check, tol)
597595

598-
check = np.array([[DNU | SAT, DNU | SAT, GOOD]])
599-
# np.testing.assert_allclose(sdq, check, tol) # XXX double
596+
check = np.array([[DNU | SAT, DNU, GOOD]])
597+
np.testing.assert_allclose(sdq, check, tol)
600598

601599
check = np.array([[0.0, 0.0, 0.25]])
602600
np.testing.assert_allclose(svp, check, tol)
@@ -613,8 +611,8 @@ def test_one_group_ramp_suppressed_one_integration():
613611
check = np.array([[[np.nan, np.nan, 1.0000001]]])
614612
np.testing.assert_allclose(cdata, check, tol)
615613

616-
check = np.array([[[DNU | SAT, DNU | SAT, GOOD]]])
617-
# np.testing.assert_allclose(cdq, check, tol) # XXX double
614+
check = np.array([[[DNU | SAT, DNU, GOOD]]])
615+
np.testing.assert_allclose(cdq, check, tol)
618616

619617
check = np.array([[[0.0, 0.0, 0.25]]])
620618
np.testing.assert_allclose(cvp, check, tol)
@@ -640,8 +638,8 @@ def test_one_group_ramp_not_suppressed_one_integration():
640638
check = np.array([[np.nan, 1.0, 1.0000001]])
641639
np.testing.assert_allclose(sdata, check, tol)
642640

643-
check = np.array([[DNU | SAT, SAT, GOOD]])
644-
# np.testing.assert_allclose(sdq, check, tol) # XXX double
641+
check = np.array([[DNU | SAT, GOOD, GOOD]])
642+
np.testing.assert_allclose(sdq, check, tol)
645643

646644
check = np.array([[0.0, 1.0, 0.25]])
647645
np.testing.assert_allclose(svp, check, tol)
@@ -658,8 +656,8 @@ def test_one_group_ramp_not_suppressed_one_integration():
658656
check = np.array([[[np.nan, 1.0, 1.0000001]]])
659657
np.testing.assert_allclose(cdata, check, tol)
660658

661-
check = np.array([[[DNU | SAT, SAT, GOOD]]])
662-
# np.testing.assert_allclose(cdq, check, tol) # XXX double
659+
check = np.array([[[DNU | SAT, GOOD, GOOD]]])
660+
np.testing.assert_allclose(cdq, check, tol)
663661

664662
check = np.array([[[0.0, 1, 0.25]]])
665663
np.testing.assert_allclose(cvp, check, tol)
@@ -704,8 +702,8 @@ def test_one_group_ramp_suppressed_two_integrations():
704702
check = np.array([[[np.nan, np.nan, 1.0000001]], [[1.0000001, 1.0000001, 1.0000001]]])
705703
np.testing.assert_allclose(cdata, check, tol)
706704

707-
check = np.array([[[DNU | SAT, DNU | SAT, GOOD]], [[GOOD, GOOD, GOOD]]])
708-
# np.testing.assert_allclose(cdq, check, tol) # XXX double
705+
check = np.array([[[DNU | SAT, DNU, GOOD]], [[GOOD, GOOD, GOOD]]])
706+
np.testing.assert_allclose(cdq, check, tol)
709707

710708
check = np.array([[[0.0, 0.0, 0.25]], [[0.125, 0.125, 0.25]]])
711709
np.testing.assert_allclose(cvp, check, tol)
@@ -750,8 +748,8 @@ def test_one_group_ramp_not_suppressed_two_integrations():
750748
check = np.array([[[np.nan, 1.0, 1.0000001]], [[1.0000001, 1.0000001, 1.0000001]]])
751749
np.testing.assert_allclose(cdata, check, tol)
752750

753-
check = np.array([[[DNU | SAT, SAT, GOOD]], [[GOOD, GOOD, GOOD]]])
754-
# np.testing.assert_allclose(cdq, check, tol) # XXX double
751+
check = np.array([[[DNU | SAT, GOOD, GOOD]], [[GOOD, GOOD, GOOD]]])
752+
np.testing.assert_allclose(cdq, check, tol)
755753

756754
check = np.array([[[0.0, 1.0, 0.25]], [[0.125, 0.25, 0.25]]])
757755
np.testing.assert_allclose(cvp, check, tol)
@@ -885,8 +883,8 @@ def test_zeroframe():
885883
check = np.array([[[298.0626, np.nan, 652.01196]], [[18.62891, 18.62891, 18.62891]]])
886884
np.testing.assert_allclose(cdata, check, tol, tol)
887885

888-
check = np.array([[[SAT, DNU | SAT, SAT]], [[GOOD, GOOD, GOOD]]])
889-
# np.testing.assert_allclose(cdq, check, tol, tol) # XXX double
886+
check = np.array([[[GOOD, DNU | SAT, GOOD]], [[GOOD, GOOD, GOOD]]])
887+
np.testing.assert_allclose(cdq, check, tol, tol)
890888

891889
check = np.array([[[1.1799237, 0.0, 6.246655]], [[0.14749046, 0.00867591, 0.31233275]]])
892890
np.testing.assert_allclose(cvp, check, tol, tol)
@@ -1080,7 +1078,7 @@ def test_dq_multi_int_dnu():
10801078
np.testing.assert_allclose(cdata, check, tol, tol)
10811079

10821080
check = np.array([[[dqflags["DO_NOT_USE"]]], [[0]]])
1083-
# np.testing.assert_allclose(cdq, check, tol, tol) # XXX double
1081+
np.testing.assert_allclose(cdq, check, tol, tol)
10841082

10851083
check = np.array([[[0.0]], [[0.00086759]]])
10861084
np.testing.assert_allclose(cvp, check, tol, tol)
@@ -1310,7 +1308,7 @@ def test_new_saturation():
13101308
np.testing.assert_allclose(sdata, check, tol, tol)
13111309

13121310
check = np.array([[JUMP, JUMP, DNU | SAT]])
1313-
# np.testing.assert_allclose(sdq, check, tol, tol) # XXX double
1311+
np.testing.assert_allclose(sdq, check, tol, tol)
13141312

13151313
check = np.array([[0.00033543, 0.00043342, 0.0]])
13161314
np.testing.assert_allclose(svp, check, tol, tol)
@@ -1328,7 +1326,7 @@ def test_new_saturation():
13281326
np.testing.assert_allclose(cdata, check, tol, tol)
13291327

13301328
check = np.array([[[GOOD, JUMP, DNU | SAT]], [[JUMP, DNU | SAT, DNU | SAT]]])
1331-
# np.testing.assert_allclose(cdq, check, tol, tol) # XXX double
1329+
np.testing.assert_allclose(cdq, check, tol, tol)
13321330

13331331
check = np.array([[[0.00054729, 0.00043342, 0.0]], [[0.00086654, 0.0, 0.0]]])
13341332
np.testing.assert_allclose(cvp, check, tol, tol)
@@ -1350,7 +1348,7 @@ def test_invalid_integrations():
13501348
suppress_one_group is defaulted to True. With this data and flag set
13511349
there are only two good integrations.
13521350
"""
1353-
# XXX The C code runs different than the python code. The variances are
1351+
# Ken The C code runs different than the python code. The variances are
13541352
# computed differently and have been accounted for.
13551353
nints, ngroups, nrows, ncols = 8, 5, 1, 1
13561354
rnval, gval = 6.097407, 5.5
@@ -1402,7 +1400,7 @@ def test_invalid_integrations():
14021400
np.testing.assert_allclose(sdata, check, tol, tol)
14031401

14041402
check = np.array([[JUMP]])
1405-
# np.testing.assert_allclose(sdq, check, tol, tol) # XXX double
1403+
np.testing.assert_allclose(sdq, check, tol, tol)
14061404

14071405
check = np.array([[44.503918]])
14081406
np.testing.assert_allclose(svp, check, tol, tol)
@@ -1422,15 +1420,15 @@ def test_invalid_integrations():
14221420
check = np.array(
14231421
[JUMP, JUMP | DNU, JUMP | DNU, GOOD, JUMP | DNU, JUMP | DNU, JUMP | DNU, JUMP | DNU], dtype=np.uint8
14241422
)
1425-
# np.testing.assert_allclose(cdq[:, 0, 0], check, tol, tol) # XXX double
1423+
np.testing.assert_allclose(cdq[:, 0, 0], check, tol, tol)
14261424

14271425
check = np.array([89.007835, 0.0, 0.0, 89.007835, 0.0, 0.0, 0.0, 0.0], dtype=np.float32)
14281426
np.testing.assert_allclose(cvp[:, 0, 0], check, tol, tol)
14291427

14301428
check = np.array([4.8278294, 0.0, 0.0, 4.8278294, 0.0, 0.0, 0.0, 0.0], dtype=np.float32)
14311429
np.testing.assert_allclose(cvr[:, 0, 0], check, tol, tol)
14321430

1433-
# XXX This needs to be verified for the two group ramp special case.
1431+
# Ken: This needs to be verified for the two group ramp special case.
14341432
check = np.array([9.686893, 0.0, 0.0, 9.686893, 0.0, 0.0, 0.0, 0.0], dtype=np.float32)
14351433
np.testing.assert_allclose(cerr[:, 0, 0], check, tol, tol)
14361434

@@ -1460,16 +1458,15 @@ def test_one_group():
14601458
tol = 1e-5
14611459
sdata, sdq, svp, svr, serr = slopes
14621460

1463-
# XXX JP-3121: this is the value from python, which may not be correct
1464-
chk_data = 1.9618962
1461+
# TODO JP-3121: 1.9618962 is the value from python, which may not be correct
1462+
chk_data = 3.923792
1463+
14651464
chk_dq = 0
14661465
chk_var_p = 0.02923839
14671466
chk_var_r = 0.03470363
14681467
chk_var_e = 0.2528676
14691468

1470-
1471-
# XXX Investigate. Now python may be wrong.
1472-
# assert abs(sdata[0, 0] - chk_data) < tol
1469+
np.testing.assert_allclose(sdata[0, 0], chk_data, atol=tol)
14731470
assert sdq[0, 0] == chk_dq
14741471
assert abs(svp[0, 0] - chk_var_p) < tol
14751472
assert abs(svr[0, 0] - chk_var_r) < tol

0 commit comments

Comments
 (0)