diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 659f370..586dbb5 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -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 @@ -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 diff --git a/treegp/two_pcf.py b/treegp/two_pcf.py index d75587d..6a52b53 100644 --- a/treegp/two_pcf.py +++ b/treegp/two_pcf.py @@ -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)], @@ -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) + 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 @@ -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)