aw.cosmo¶
Cosmograph-specific validator tool.
Provides functional validation for cosmograph visualization requirements.
Functions
Basic validator that checks structural requirements only. |
|
|
Create a validator for cosmograph requirements. |
Infer suitable cosmograph parameters from DataFrame. |
|
Strict validator that actually calls cosmograph. |
|
|
Try to create a cosmograph visualization. |
- aw.cosmo.basic_cosmo_validator()[source]¶
Basic validator that checks structural requirements only.
Does not require cosmograph to be installed.
Example
>>> validator = basic_cosmo_validator() >>> success, info = validator(df)
- Return type:
- aw.cosmo.create_cosmo_validator(cosmo_function=None, required_columns=2, allow_generated_params=True)[source]¶
Create a validator for cosmograph requirements.
This validator attempts to actually call cosmograph.cosmo() with the DataFrame to see if it’s ready for visualization.
- Parameters:
- Return type:
- Returns:
Validator function following (artifact) -> (success, info) protocol
Example
>>> validator = create_cosmo_validator() >>> success, info = validator(df) >>> if success: ... print(f"Can visualize with: {info['params']}")
- aw.cosmo.infer_cosmo_params(df)[source]¶
Infer suitable cosmograph parameters from DataFrame.
- Parameters:
df – pandas DataFrame
- Return type:
- Returns:
Dict of suggested parameters for cosmograph.cosmo()
Example
>>> params = infer_cosmo_params(df) >>> from cosmograph import cosmo >>> cosmo(df, **params)
- aw.cosmo.strict_cosmo_validator()[source]¶
Strict validator that actually calls cosmograph.
Requires cosmograph to be installed.
Example
>>> validator = strict_cosmo_validator() >>> success, info = validator(df)
- Return type:
- aw.cosmo.try_cosmo_visualization(df, cosmo_function=None, **cosmo_kwargs)[source]¶
Try to create a cosmograph visualization.
This is a functional validator that actually attempts the visualization.
- Parameters:
- Return type:
- Returns:
Tuple of (success, info)
Example
>>> from cosmograph import cosmo >>> success, info = try_cosmo_visualization(df, cosmo)