Skip to content

Commit 56dc935

Browse files
committed
added test for NaN or finite nature of r_crit
1 parent 9b1668f commit 56dc935

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pyleoclim/tests/test_core_Series.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,24 @@ def test_correlation_t5(self):
724724

725725
assert np.abs((corr_res.r_crit -r_crit)/r_crit) < 0.1
726726

727+
@pytest.mark.parametrize('sig_method', ['ttest','built-in','ar1sim','phaseran','CN'])
728+
def test_correlation_t6(self, sig_method, number=10, eps=0.1):
729+
''' Test the various significance methods
730+
'''
731+
nt = 100
732+
rho = 0.4 # target correlation
733+
ts1 = gen_ts(nt=nt,alpha=1,seed=333).standardize()
734+
# generate series whose correlation with ts1 should be close to rho:
735+
v = rho*ts1.value + np.sqrt(1-rho**2)*np.random.normal(loc=0, scale=1, size=nt)
736+
ts2 = pyleo.Series(time=ts1.time, value=v, verbose=False, auto_time_params=True)
737+
738+
corr_res = ts1.correlation(ts2, method= sig_method, number=number)
739+
740+
if sig_method == 'built-in':
741+
assert np.isnan(corr_res.r_crit)
742+
else:
743+
assert np.isfinite(corr_res.r_crit)
744+
727745

728746
class TestUISeriesCausality:
729747
''' Test Series.causality()

0 commit comments

Comments
 (0)