Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing multiplying by a constant #11

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
24 changes: 20 additions & 4 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
name: CI

on: [push]
on:
push:
branches:
- master

workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]

include:
- os: macos-latest
python-version: 3.9

steps:
- uses: actions/checkout@v2
Expand All @@ -18,10 +28,16 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Setup environment
- name: Setup environment - linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y libffi-dev

- name: Setup environment - macos
if: matrix.os == 'macos-latest'
run: |
brew install libffi

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
12 changes: 6 additions & 6 deletions treegp/two_pcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def get_correlation_length_matrix(size, e1, e2):
:param size: Correlation lenght of the kernel.
:param e1, e2: Shear applied to isotropic kernel.
"""
if abs(e1)>1 or abs(e2)>1:
raise ValueError('abs value of e1 and e2 must be lower than one')
e = np.sqrt(e1**2 + e2**2)
if e>1:
raise ValueError('magnitude of e must be lower than one')
q = (1-e) / (1+e)
phi = 0.5 * np.arctan2(e2,e1)
rot = np.array([[np.cos(phi), np.sin(phi)],
Expand Down Expand Up @@ -92,15 +92,15 @@ def _model_skl(self, sigma, corr_length, g1, g2):
from sklearn kernel.

:param sigma: Standard deviation of the gaussian random field.
:param corr_length: Correlation lenght of the kernel.
:param corr_length: Correlation length of the kernel.
:param g1, g2: Shear applied to isotropic kernel.
"""
if abs(g1)>1 or abs(g2)>1:
if (g1**2 + g2**2)>1:
return None
else:
L = get_correlation_length_matrix(corr_length, g1, g2)
invLam = np.linalg.inv(L)
kernel_used = sigma**2 * self.kernel_class(invLam=invLam)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an example of this failing can be nice. I am not able to reproduce this error.

kernel_used = sklearn.gaussian_process.kernels.ConstantKernel(sigma**2,constant_value_bounds = "fixed") * self.kernel_class(invLam=invLam)
pcf = kernel_used.__call__(self.coord,Y=np.zeros_like(self.coord))[:,0]
self.kernel_fit = kernel_used
return pcf
Expand Down Expand Up @@ -190,7 +190,7 @@ def minimize_minuit(self, p0 = [3000., 0.2, 0.2]):

class two_pcf(object):
"""
Fit statistical uncertaintie on two-point correlation function using bootstraping.
Fit statistical uncertainty on two-point correlation function using bootstraping.

:param X: Coordinates of the field. (n_samples, 1 or 2)
:param y: Values of the field. (n_samples)
Expand Down