Skip to content

Commit

Permalink
Merge branch 'master' into dev-hm-fe
Browse files Browse the repository at this point in the history
  • Loading branch information
itrharrison authored Sep 17, 2024
2 parents 4862526 + 96ed26e commit 130a926
Show file tree
Hide file tree
Showing 32 changed files with 468 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Dependencies
shell: bash -el {0}
run: |
pip install tox-conda flake8
pip install tox flake8
- name: Check Code Style
shell: bash -el {0}
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: false
activate-environment: soliket-tests
environment-file: soliket-tests.yml
python-version: ${{ matrix.python-version }}
channels: conda-forge
- name: Install Dependencies
shell: bash -el {0}
run: |
pip install tox-conda
pip install tox
- name: Run Tests
shell: bash -el {0}
run: |
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Upload to PyPI

on:
release:
types: [published]

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

testpypi-publish:
name: Upload release to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/soliket
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/[email protected]
with:
name: python-package-distributions
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# repository-url: https://test.pypi.org/legacy/
# print-hash: true
# password: ${{ secrets.TEST_PYPI_TOKEN }}
12 changes: 11 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,29 @@ jobs:
python-version: '3.11'
toxenv: py311-test-latest

- name: Windows latest
os: windows-latest
python-version: '3.11'
toxenv: py311-test-latest
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: 1

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Conda w/ Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: false
activate-environment: soliket-tests
environment-file: soliket-tests.yml
python-version: ${{ matrix.python-version }}
channels: conda-forge
- name: Install Dependencies
shell: bash -el {0}
run: |
pip install tox-conda
pip install tox
- name: Run Tests
shell: bash -el {0}
run: |
Expand Down
23 changes: 21 additions & 2 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ We have provided a conda environment defined in `soliket-tests.yml <https://gith

$ conda env create --file soliket-tests.yml

You can then install the `latest released version of SOLikeT from PyPI <https://pypi.org/project/soliket/>`_ into this environment:

::

$ conda activate soliket-tests
$ pip install soliket

Installing in editable mode for development
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you wish to actively develop the code you can instead install the in-development version of SOLikeT from the github repository in editable mode:

::

$ git clone https://github.com/simonsobs/soliket
$ cd soliket
$ pip install -e .


Optional: Install CosmoPower
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In order to use the CosmoPower Theories within SOLikeT you will need to additionally install CosmoPower (and with it tensorflow, which is rather heavy and hence left out of the default installation).
Expand All @@ -22,8 +41,8 @@ Unless using an M1 Mac this should be easily achievable with::

If you wish to install it using your own system tools (including new M1 Mac) some useful information is provided below.

Harder Way: Preparing your own conda environment
----------------------------------
Harder Way: Preparing your own environment
------------------------------------------

**CREATE VIRTUAL CONDA ENV TO RUN COBAYA**
Based on `cobaya documentation <https://cobaya.readthedocs.io/en/latest/cluster_amazon.html>`_.
Expand Down
13 changes: 8 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ Installation

For a set of detailed requirements and installation instructions for different machines (e.g. NERSC, M1 Mac), please see `the installation page <INSTALL.rst>`_.

A preferred and convenient way to install SOLikeT and its dependents is through using the conda environment defined in `soliket-tests.yml <soliket-tests.yml>`_. After installing an anaconda distribution (e.g. as described `here <https://docs.anaconda.com/free/anaconda/install/index.html>`_), you can create the environment and install a locally cloned version of SOLikeT using pip::
A preferred and convenient way to install SOLikeT and its dependents is through using the conda environment defined in `soliket-tests.yml <soliket-tests.yml>`_. After installing an anaconda distribution (e.g. as described `here <https://docs.anaconda.com/free/anaconda/install/index.html>`_), you can create the environment and install a the latest released version of SOLikeT using pip::

git clone https://github.com/simonsobs/soliket
cd soliket
conda env create -f soliket-tests.yml
conda activate soliket-tests
pip install -e .
pip install soliket

You can alternatively clone a local version of the in-development code and install it in editable mode::

git clone https://github.com/simonsobs/soliket
cd soliket
pip install -e .

Running an Example
==================
Expand All @@ -43,7 +46,7 @@ SOLikeT is a collection of modules for use within the Cobaya cosmological infere

SOLikeT examples and explanatory notebooks are under construction, but will be run using standard [yaml](https://en.wikipedia.org/wiki/YAML) format (which can in turn be read in as Python dictionaries). The examples will be run using something similar to::

cobaya-run soliket-example.yml
cobaya-run examples/example_1.yaml


Developing SOLikeT Theories and Likelihoods
Expand Down
126 changes: 126 additions & 0 deletions examples/example_1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
debug: False

# Choose a sampler.
# Running the evaluate sampler will compute the likelihood
# only at a single value of parameters
sampler:
evaluate: null

# Specify the output location and file prefix
output: output/example_1

# Specify which Likelihoods we would like to use
# Any options for the Likelihood will use their default values unless specified here
# In this case the options and defaults are specified in soliket/mflike/MFLike.yaml
# Note that MFLike is a Cobaya `installable likelihood`.
# When running this yaml file, or calling `cobaya-install example_1.yaml` the required
# installable components will automatically be downloaded and installed.
# Note that for the soliket MFLike likelihood we are required to calculate:
# - CMB theory power spectra (from CAMB theory below)
# - Multi-frequency bandpass calibrations (from soliket.BandPass theory below)
# - Multi-frequency foregrounds (from soliket.Foreground theory below)
# - The combination of the above components (from soliket.TheoryForge_MFLike theory below)
likelihood:
soliket.MFLike:
data_folder: MFLike/v0.8
input_file: LAT_simu_sacc_00000.fits
cov_Bbl_file: data_sacc_w_covar_and_Bbl.fits
defaults:
polarizations: ['TT', 'TE', 'ET', 'EE']
scales:
TT: [30, 9000]
TE: [30, 9000]
ET: [30, 9000]
EE: [30, 9000]
symmetrize: False

# Specify the Theory codes which will compute observables to be compared with the data
# in the Likelihood.
# Here we specify the CAMB Einstein-Boltzmann code, with a number of choices made on
# precision and neutrino model.
theory:
camb:
extra_args:
lens_potential_accuracy: 1
WantTransfer: True
Transfer.high_precision: True
Transfer.kmax: 1.2
num_nu_massless: 1.044
num_nu_massive: 2
nu_mass_eigenstates: 2
# We use the minimal normal ordering case: massless lightest state, m2 and m3
# computed according to oscilation measurements.
nu_mass_fractions: [0.14763410387308012,0.8523658961269198]
nu_mass_numbers: [1,1]
share_delta_neff: True
stop_at_error: True

soliket.BandPass:
stop_at_error: True

soliket.Foreground:
stop_at_error: True

soliket.TheoryForge_MFLike:
spectra:
polarizations: ['tt', 'te', 'ee']
lmin: 2
lmax: 9050
stop_at_error: True

# Specify the parameter values at which to compute the likelihood
params:
H0:
latex: H_0
value: 67.7
logA:
# Dropped parameters are sampled but not passed to Likelihood/Theory codes
# Here it is As (specified below) which is passed to the Likelihood/Theory code.
drop: true
latex: \log(10^{10} A_\mathrm{s})
value: 3.05
As:
value: 'lambda logA: 1e-10*np.exp(logA)'
ombh2:
latex: \Omega_\mathrm{b} h^2
value: 0.0224
omega_de:
latex: \Omega_\Lambda
# Derived parameters are not sampled but have output values which can be constrained
# and plotted. These values can be computed internally by Theory codes (as for omega_de
# here which is calculated within camb) or given a lambda function (as fo omegamh2
# below).
derived: true
omegam:
latex: \Omega_\mathrm{m}
derived: true
omegamh2:
derived: 'lambda omegam, H0: omegam*(H0/100)**2'
latex: \Omega_\mathrm{m} h^2
omch2:
latex: \Omega_c h^2
value: 0.1202
sigma8:
latex: \sigma_8
derived: true
ns:
latex: n_s
value: 0.9649
Alens:
latex: A_lens
value: 1.0
tau:
latex: \tau_\mathrm{reio}
value: 0.0554
mnu1:
value: 0.0
drop: True
mnu2:
value: 'lambda: np.sqrt(7.5e-5)'
drop: True
mnu3:
value: 'lambda: np.sqrt(2.5e-3)'
drop: True
mnu:
value: 'lambda mnu1, mnu2 ,mnu3: mnu1 + mnu2 + mnu3'
latex: \sum m_\nu
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[project]
name = "soliket"
# version = "0.1.dev1"
dynamic = ['version']
authors = [
{name = "Simons Observatory"}
Expand All @@ -11,10 +10,10 @@ requires-python = ">=3.8, <3.12"
license = {text = "MIT"}
dependencies = [
"requests",
'importlib-metadata; python_version<"3.8"',
"numpy",
"scipy>=1.6",
"pandas", # to remove
"pytest-cov",
"astropy",
"cobaya",
"sacc",
Expand Down Expand Up @@ -62,12 +61,11 @@ include = [
"*" = ['*.yaml', '*.fits', '*.txt', '*.pkl', '*.gz']

[tool.setuptools_scm]
version_file = "soliket/version.py"
version_file = "soliket/_version.py"

[project.optional-dependencies]
all = [
"cosmopower",
"pyccl",
"tensorflow_probability<0.22",
]
docs = [
Expand Down Expand Up @@ -105,3 +103,8 @@ exclude_lines = [
# Don't complain about IPython completion helper
"def _ipython_key_completions_",
]

[tool.pytest.ini_options]
markers = [
"require_ccl",
]
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
numpy
scipy>=1.6
pandas
pytest-cov
scikit-learn
pyyaml
py-bobyqa
Expand All @@ -13,8 +14,8 @@ fuzzywuzzy
astropy
getdist
cobaya
pyccl
pyccl >= 3.0; platform_system!='Windows'
sacc
fgspectra>=1.1.0
syslibrary
pyhalomodel
pyhalomodel
3 changes: 2 additions & 1 deletion soliket-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:
dependencies:
- python>=3.8,<3.12
- pip
- pytest
- pytest-cov
- compilers
- make
Expand All @@ -16,4 +17,4 @@ dependencies:
- mpi4py
- camb
- pip:
- -r requirements.txt
- -r requirements.txt
8 changes: 8 additions & 0 deletions soliket/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("soliket")
except PackageNotFoundError:
# package is not installed
pass

from .bandpass import BandPass
from .bias import Bias, Linear_bias
from .ccl import CCL
Expand Down
Loading

0 comments on commit 130a926

Please sign in to comment.