Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autogalaxy/config/notation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ label:
outer_slope: t_{\rm 2}
overdens: \Delta_{\rm vir}
pixels: N_{\rm pix}
ra: r_{\rm a}
radius_break: R_{\rm b}
redshift: z
redshift_object: z_{\rm obj}
redshift_source: z_{\rm src}
rs: r_{\rm s}
scale_radius: R_{\rm s}
scatter: \sigma
separation: s
Expand Down Expand Up @@ -128,12 +130,14 @@ label_format:
outer_slope: '{:.4f}'
overdens: '{:.4f}'
pixels: '{:.4f}'
ra: '{:.4f}'
radius: '{:.4f}'
radius_break: '{:.4f}'
redshift: '{:.4f}'
redshift_object: '{:.4f}'
redshift_source: '{:.4f}'
rho: '{:.4f}'
rs: '{:.4f}'
scale_radius: '{:.4f}'
separation: '{:.4f}'
sersic_index: '{:.4f}'
Expand Down
3 changes: 3 additions & 0 deletions autogalaxy/config/priors/mesh/delaunay.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Delaunay:
areas_factor:
type: Constant
value: 0.5
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,22 @@ def test__default_class__supports_model_composition():
assert model_sph.prior_count == 9


def test__ra_rs_have_notation_labels_not_the_first_letter_fallback():
# With no notation entry autofit labels a parameter by its first letter,
# which renders both `ra` and `rs` as "r" in corner plots and tables.
import autofit as af

labels = dict(
zip(
af.Model(ag.mp.dPIEPotential).parameter_names,
af.Model(ag.mp.dPIEPotential).parameter_labels,
)
)

assert labels["ra"] == r"r_{\rm a}"
assert labels["rs"] == r"r_{\rm s}"


def test__from_b0__returns_internal_parameterization():
# The non-standard construction path: dPIEMass.from_b0 / dPIEMassSph.from_b0
# return the internal (ra, rs, b0) classes with the inputs passed through.
Expand Down
31 changes: 19 additions & 12 deletions test_autogalaxy/profiles/test_model_figure_semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,51 +180,58 @@ def test__point_centre_is_a_free_tuple():


# ----------------------------------------------------------------------------
# the `missing` state -- unset configuration on a `Delaunay` mesh
# the `missing` state -- unset configuration on a real class
# ----------------------------------------------------------------------------


def test__delaunay_areas_factor_has_no_prior_configured_and_is_missing():
spec = af.GraphSpec.from_model(af.Model(ag.mesh.Delaunay))
def test__curvature_mask_coefficient_has_no_prior_configured_and_is_missing():
# `CurvatureMask` ships no prior for `coefficient`, so it is the real-class
# witness of the `missing` state (it was `Delaunay.areas_factor` until that
# was configured as a Constant).
spec = af.GraphSpec.from_model(af.Model(ag.reg.CurvatureMask))

row = rows_of(spec)["areas_factor"]
row = rows_of(spec)["coefficient"]

assert row.sampling == "missing"
assert row.prior_cls_name == "ConfigException"
assert spec.counts["missing"] == 1

presentation = af.ModelPlotter(af.Model(ag.mesh.Delaunay)).presentation()
presentation = af.ModelPlotter(af.Model(ag.reg.CurvatureMask)).presentation()

assert "areas_factor · missing" in pill_texts(presentation)
assert "coefficient · missing" in pill_texts(presentation)


def test__delaunay_pixels_and_zeroed_pixels_are_fixed_not_missing():
def test__delaunay_pixels_zeroed_pixels_and_areas_factor_are_fixed_not_missing():
"""
Measured, not assumed.

The epic's brief expected ``pixels``, ``zeroed_pixels`` and ``areas_factor``
to be three ``missing`` rows. They are not: ``pixels: int`` has no default,
so ``af.Model`` fills the slot with ``af.Model(int)`` -- a *fixed* row by
rule R7, never a ``ConfigException`` -- and ``zeroed_pixels: Optional[int] =
0`` simply takes its default. Only ``areas_factor`` is genuinely unset
configuration. This test pins that distinction so the figure cannot start
calling an unset int "missing" without someone noticing.
0`` simply takes its default. ``areas_factor`` is configured as a
``Constant`` (``priors/mesh/delaunay.yaml``), so it is fixed too. This test
pins that distinction so the figure cannot start calling an unset int
"missing" without someone noticing.
"""
spec = af.GraphSpec.from_model(af.Model(ag.mesh.Delaunay))

rows = rows_of(spec)

assert rows["pixels"].sampling == "fixed"
assert rows["areas_factor"].sampling == "fixed"
assert rows["areas_factor"].prior_cls_name == "Constant"
assert [row.name for row in spec.root.rows] == ["pixels", "areas_factor"]
assert spec.counts["missing"] == 0

set_spec = af.GraphSpec.from_model(
af.Model(ag.mesh.Delaunay, pixels=500, zeroed_pixels=0)
)
set_rows = set_spec.root.rows

assert [row.name for row in set_rows] == ["pixels", "zeroed_pixels", "areas_factor"]
assert [row.sampling for row in set_rows] == ["fixed", "fixed", "missing"]
assert set_spec.counts["missing"] == 1
assert [row.sampling for row in set_rows] == ["fixed", "fixed", "fixed"]
assert set_spec.counts["missing"] == 0


# ----------------------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions test_autogalaxy/test_priors_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,18 @@ def test__ellipse_multipole_scaled_model_resolves():
assert model.prior_count == 2

model.instance_from_prior_medians()


def test__delaunay_mesh_model_has_no_missing_prior():
# `areas_factor` is a float `__init__` argument, so without a configured
# prior `af.Model` reports it as "Prior Missing" (the packaged file was a
# bare `Delaunay:`); it is a fixed Constant at the class default.
model = af.Model(ag.mesh.Delaunay, pixels=100)

assert "Prior Missing" not in model.info
assert model.prior_count == 0
assert model.areas_factor == 0.5

instance = model.instance_from_prior_medians()

assert instance.areas_factor == 0.5
Loading