Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 5 additions & 6 deletions .github/workflows/test_treegp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +26,7 @@ jobs:

- name: Setup environment
run: |
sudo apt-get install -y libffi-dev
sudo apt-get install -y libffi-dev libbz2-dev

- name: Install dependencies
run: |
Expand All @@ -50,9 +50,8 @@ jobs:
pytest --cov=treegp --cov-report=xml --cov-fail-under=80

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v5
with:
file: ./tests/coverage.xml
files: ./tests/coverage.xml
fail_ci_if_error: true # Optional: specify if CI should fail when Codecov upload fails
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ setuptools>=65.5.1
numpy>=1.16.5
scipy
matplotlib
iminuit>1.3,<1.4; python_version < '3.0' # iminuit 1.4 fails on python 2.7.
iminuit>2; python_version >= '3.0' # iminuit changed API in v2.0. We use the 2.x API.

iminuit>2 # iminuit changed API in v2.0. We use the 2.x API.
treecorr>=4.2
fitsio>=0.9.12
scikit-learn>=0.18
15 changes: 13 additions & 2 deletions treegp/two_pcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class two_pcf(object):
fiting part of the GP. (Boolean)
:param robust_fit: Used minuit to fit hyperparameter. Works only
anisotropic is True. (Boolean)
:param seed: Seed to use for random number generator.
"""

def __init__(
Expand All @@ -233,6 +234,7 @@ def __init__(
anisotropic=False,
robust_fit=False,
p0=[3000.0, 0.0, 0.0],
seed=610639139,
):
self.ndim = np.shape(X)[1]
if self.ndim not in [1, 2]:
Expand All @@ -252,14 +254,22 @@ def __init__(
self.anisotropic = anisotropic
self.robust_fit = robust_fit
self.p0_robust_fit = p0
self.seed = seed
self._rng = None

@property
def rng(self):
if self._rng is None:
self._rng = np.random.default_rng(self.seed)
return self._rng

def resample_bootstrap(self):
"""
Make a single bootstrap resampling on data.
"""
npsfs = len(self.y)

ind_object = np.random.randint(0, npsfs - 1, size=npsfs)
ind_object = self.rng.integers(0, npsfs - 1, size=npsfs)
u_ressample = self.X[:, 0][ind_object]
v_ressample = self.X[:, 1][ind_object]
y_ressample = self.y[ind_object]
Expand Down Expand Up @@ -332,7 +342,8 @@ def comp_xi_covariance(self, n_bootstrap=1000, mask=None, seed=610639139):

:param seed: seed of the random generator.
"""
np.random.seed(seed)
self.seed = seed
self._rng = None
xi_bootstrap = []
for i in range(n_bootstrap):
u, v, y, y_err = self.resample_bootstrap()
Expand Down