Skip to content

shine.validation.bias_config

Pydantic configuration models for bias testing.

Defines bias levels, convergence thresholds, shear grids, acceptance criteria, and per-run/campaign configuration.

bias_config

Pydantic configuration models for bias testing.

BiasLevel

Bases: str, Enum

Bias testing levels, from noiseless sanity check to survey-realistic.

ConvergenceThresholds

Bases: BaseModel

Thresholds for MCMC convergence diagnostics.

Attributes:

Name Type Description
rhat_max float

Maximum acceptable R-hat statistic.

ess_min int

Minimum acceptable effective sample size.

divergence_frac_max float

Maximum acceptable fraction of divergent transitions.

bfmi_min float

Minimum acceptable Bayesian Fraction of Missing Information.

validate_rhat(v) classmethod

Validate that R-hat threshold is >= 1.

Source code in shine/validation/bias_config.py
@field_validator("rhat_max")
@classmethod
def validate_rhat(cls, v: float) -> float:
    """Validate that R-hat threshold is >= 1."""
    if v < 1.0:
        raise ValueError(f"rhat_max must be >= 1.0, got {v}")
    return v

validate_ess(v) classmethod

Validate that ESS threshold is positive.

Source code in shine/validation/bias_config.py
@field_validator("ess_min")
@classmethod
def validate_ess(cls, v: int) -> int:
    """Validate that ESS threshold is positive."""
    if v <= 0:
        raise ValueError(f"ess_min must be positive, got {v}")
    return v

ShearGrid

Bases: BaseModel

Grid of true shear values for bias regression.

Attributes:

Name Type Description
values List[float]

List of g_true values to test.

validate_values(v) classmethod

Validate that shear grid values are within physical bounds.

Source code in shine/validation/bias_config.py
@field_validator("values")
@classmethod
def validate_values(cls, v: List[float]) -> List[float]:
    """Validate that shear grid values are within physical bounds."""
    for val in v:
        if abs(val) >= 1.0:
            raise ValueError(
                f"Shear values must have |g| < 1, got {val}"
            )
    return v

AcceptanceCriteria

Bases: BaseModel

Level-specific acceptance criteria for bias tests.

Attributes:

Name Type Description
max_offset_sigma float

Maximum offset from truth in units of posterior sigma.

max_posterior_width Optional[float]

Maximum posterior standard deviation.

max_abs_m Optional[float]

Maximum acceptable |m| (multiplicative bias).

max_abs_c Optional[float]

Maximum acceptable |c| (additive bias).

coverage_levels List[float]

Expected coverage levels to check (e.g., 68%, 95%).

BiasRunConfig

Bases: BaseModel

Configuration for a single bias measurement realization.

This is the per-GPU-job unit. The campaign orchestrator creates one BiasRunConfig per realization.

Attributes:

Name Type Description
shine_config_path str

Path to the base SHINE YAML config.

g1_true float

True g1 shear value for this realization.

g2_true float

True g2 shear value for this realization.

seed int

Random seed for noise generation.

paired bool

Whether this is a paired-shear realization.

output_dir str

Directory for output files.

run_id str

Unique identifier for this realization.

validate_seed(v) classmethod

Validate that seed is non-negative.

Source code in shine/validation/bias_config.py
@field_validator("seed")
@classmethod
def validate_seed(cls, v: int) -> int:
    """Validate that seed is non-negative."""
    if v < 0:
        raise ValueError(f"seed must be non-negative, got {v}")
    return v

validate_shear(v) classmethod

Validate that shear components are within physical bounds.

Source code in shine/validation/bias_config.py
@field_validator("g1_true", "g2_true")
@classmethod
def validate_shear(cls, v: float) -> float:
    """Validate that shear components are within physical bounds."""
    if abs(v) >= 1.0:
        raise ValueError(f"Shear must have |g| < 1, got {v}")
    return v

BiasTestConfig

Bases: BaseModel

Full campaign configuration for bias testing.

Attributes:

Name Type Description
level BiasLevel

Bias testing level.

shine_config_path str

Path to the base SHINE YAML config.

shear_grid ShearGrid

Grid of true shear values.

n_realizations int

Number of realizations per shear grid point.

paired bool

Whether to use paired-shear method.

convergence ConvergenceThresholds

Convergence diagnostic thresholds.

acceptance AcceptanceCriteria

Acceptance criteria for bias results.

output_dir str

Top-level output directory.

validate_n_realizations(v) classmethod

Validate that number of realizations is positive.

Source code in shine/validation/bias_config.py
@field_validator("n_realizations")
@classmethod
def validate_n_realizations(cls, v: int) -> int:
    """Validate that number of realizations is positive."""
    if v <= 0:
        raise ValueError(f"n_realizations must be positive, got {v}")
    return v