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

Examples #3

Open
3 of 5 tasks
ColmTalbot opened this issue May 15, 2024 · 6 comments
Open
3 of 5 tasks

Examples #3

ColmTalbot opened this issue May 15, 2024 · 6 comments
Assignees

Comments

@ColmTalbot
Copy link
Owner

ColmTalbot commented May 15, 2024

Add examples demonstrating

  • Comparison with approximation in Adachi & Kasai 2011
  • Comparison of pre-specified models with astropy
  • Comparison across parameter space with astropy
  • Demonstration of using jax/numpy backends
  • other things?

A decent amount of this is already being done in #1

@afarah18
Copy link
Collaborator

It might also be good to do a bare-bones example of cosmological inference with this on a GPU, since that's the main reason we developed this.

@ColmTalbot
Copy link
Owner Author

Good idea, I can probably modify my notebook from last week.

@ColmTalbot
Copy link
Owner Author

See #7

@Qazalbash
Copy link

Hi, I am struggling to select the backend. I used the set_backend function mentioned in the example, but it uses numpy while I specified jax.

import numpy as np
import wcosmo


def set_backend(backend):
    from importlib import import_module
    np_modules = dict(
        numpy="numpy",
        jax="jax.numpy",
        cupy="cupy",
    )
    linalg_modules = dict(
        numpy="scipy.linalg",
        jax="jax.scipy.linalg",
        cupy="cupyx.scipy.linalg",
    )
    setattr(wcosmo.wcosmo, "xp", import_module(np_modules[backend]))
    setattr(wcosmo.utils, "xp", import_module(np_modules[backend]))
    toeplitz = getattr(import_module(linalg_modules[backend]), "toeplitz")
    setattr(wcosmo.utils, "toeplitz", toeplitz)

@ColmTalbot
Copy link
Owner Author

ColmTalbot commented Oct 21, 2024

I suspect this example is out of date, there are now additional submodules that need to have these updated. The easiest solution if you're happy with some additional dependencies is to install gwpopulation and use gwpopulation.set_backend. As a temporary measure, the full set that need to be updated is specified in the pyproject.toml. The gwpopulation code to do this is here, we could quite easily adapt something like this, but I'm concerned about code duplication.

[project.entry-points."gwpopulation.xp"]
wcosmo = "wcosmo.wcosmo"
wcosmo-analytic = "wcosmo.analytic"
wcosmo-astropy = "wcosmo.astropy"
wcosmo-integrate = "wcosmo.integrate"
wcosmo-taylor = "wcosmo.taylor"
wcosmo-utils = "wcosmo.utils"

[project.entry-points."gwpopulation.scs"]
wcosmo-analytic = "wcosmo.analytic"

[project.entry-points."gwpopulation.other"]
wcosmo-taylor = "wcosmo.taylor:scipy.linalg.toeplitz"

@Qazalbash
Copy link

Can you also guide me on how to use units inside jit/grad/vmap transforms?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants