Skip to content

Commit

Permalink
FIX: Correct the out of index error in interpolation
Browse files Browse the repository at this point in the history
Resolves: #31
  • Loading branch information
prokolyvakis committed Dec 2, 2023
1 parent edb8e3f commit b4f7a7a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion diptest/consts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import numpy as np


Expand Down Expand Up @@ -77,7 +79,12 @@ def compute_pval_interpolation(cls, n, dip):
# critical values for the nearest tabulated n (i.e. treat them as
# 'asymptotic')
i0 = max(0, i0)
i1 = min(cls._CRIT_VALS.shape[0], i1)
if i1 > cls._CRIT_VALS.shape[0] - 1:
i1 = cls._CRIT_VALS.shape[0] - 1
warnings.warn(
f"Sample size exceeds the maximum limit of {cls._MAX_SAMPLE_SIZE}. "
"Results may not be accurate with precomputed statistical values."
)

# Interpolate on sqrt(n)
n0, n1 = cls._SAMPLE_SIZE[[i0, i1]]
Expand Down

0 comments on commit b4f7a7a

Please sign in to comment.