Skip to main content

Cosmology API standard

Project description

There are a lot of (Python) cosmology libraries out there, from big projects – including Astropy, CLASS, and CAMB – down to small personal scripts. These libraries perform many of the same tasks, but they all have different interfaces, and different ways of doing things. This makes it hard to switch between libraries, and nearly impossible to write code that works with multiple libraries.

The Cosmology API for Python solves this problem, providing detailed interfaces for cosmology codes, from individual methods and functions up to fully-featured cosmology objects, even whole libraries. Best of all, using the Cosmology API does not require any run-time dependencies, even this library!

With the Cosmology API you can write code that works with anything that implements the API, i.e many different cosmology libraries. We provide the easy-to-use, well-defined descriptions, you can build functions that work with any supporting library. For example

# No implementation, just a description of the interface!
from cosmology.api import StandardCosmology


def flat_angular_diameter_distance(
    cosmo: StandardCosmology[Array, Array], z: Array
) -> Array:
    # Do some cosmology with any object that implements the API
    if cosmo.Omega_k != 0:
        raise ValueError("This function only works for flat cosmologies")
    return cosmo.comoving_distance(z) / (1 + z)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cosmology.api-0.1.0.tar.gz (49.3 kB view details)

Uploaded Source

Built Distribution

cosmology.api-0.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file cosmology.api-0.1.0.tar.gz.

File metadata

  • Download URL: cosmology.api-0.1.0.tar.gz
  • Upload date:
  • Size: 49.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for cosmology.api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a2ca2e3d765d694c7ebaff9fa734c2c4d9c364f73402e4588eb07a2bc2f1773f
MD5 0b11ecb6fa9cb3fccf8dde6c64691a4f
BLAKE2b-256 2b5894ce26c3adfe91a4c33f95bfa2a66abed3f16f30c94d78db0a97f6ea970a

See more details on using hashes here.

File details

Details for the file cosmology.api-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cosmology.api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ec21546990dea1ab1a8e799763fa378e3bb366f6c14f466f836d99d77077167
MD5 de0e144b6a2f99e26b76cc9f61ecc518
BLAKE2b-256 ff947b9a1e3e88d9538de07d67be95d93978119310e2bcd203337eaa456a0de4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page