Skip to main content

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)

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.2.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cosmology_api-0.2.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file cosmology_api-0.2.0.tar.gz.

File metadata

  • Download URL: cosmology_api-0.2.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for cosmology_api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2f3c30bae241c6d92412fd72b78f359b1e0ec6030e2d98a3dbd07d197a01fe96
MD5 5cef6de1cc2ba9dc2e07f8b20409de0b
BLAKE2b-256 30557922d7512d238d0a47f453c214a054e2ce3bdd6d9114ba9c051d5e2abcaa

See more details on using hashes here.

File details

Details for the file cosmology_api-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cosmology_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for cosmology_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f48d07642f08ea1df37fa3360dd837f61630bac26242f001b95b2c60894f17f
MD5 33fd12dc31c1bf6f46294eface5f6451
BLAKE2b-256 f98bdb32c10ee9eb194c4bac3be82866b88c15a76df53db5dfede532f2fe8e0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page