cassiopeia/__init__.py file:
High-level description
This file serves as the top-level initialization for the Cassiopeia package. It imports and exposes key submodules, sets up version information, and configures the package namespace.Code Structure
The file imports various submodules of Cassiopeia and makes them available at the top level of the package. It also sets up version information using importlib.metadata and configures the package namespace.Symbols
Imported submodules
Description
The following submodules are imported and made available at the top level of the Cassiopeia package:preprocess(aliased aspp)solverplotting(aliased aspl)datacritiquesimulator(aliased assim)tools(aliased astl)
__version__
Description
Stores the version number of the Cassiopeia package.Internal Logic
The version is retrieved usingimportlib.metadata.version() with the package name “cassiopeia-lineage”. This allows for dynamic version retrieval based on the installed package metadata.
Package namespace configuration
Description
Configures the package namespace to allow direct access to certain submodules.Internal Logic
Thesys.modules dictionary is updated to allow direct access to the tl, pp, pl, and sim submodules from the Cassiopeia package namespace. This means users can access these submodules directly, e.g., cassiopeia.tl instead of cassiopeia.tools.
Dependencies
| Dependency | Purpose |
|---|---|
| importlib.metadata | Used for retrieving the package version |
| importlib_metadata | Fallback for Python versions that don’t have importlib.metadata |
Error Handling
The code includes a try-except block to handle potentialModuleNotFoundError when importing importlib.metadata. If this import fails, it falls back to using importlib_metadata.
Your response should not exceed 3000 words or 4000 tokens. Focus on providing clear, concise information that can be directly inferred from the code. Include optional sections only when they provide significant value for understanding the code.