Skip to content

test: Make start-point plotting tests deterministic #1719

Closed

Description

@Jammy2211

Overview

Make start-point plotting tests deterministic. Selected as one of four PyAutoFit model-inspection and test-reliability tasks authorized on 2026-10-25.

Plan

  • Reproduce the reported defect against current main.
  • Set an explicit seed in the shared Emcee test factory using the current search seed interface. Repeat all three tests 200 times; leave production initializer tolerance unchanged.
  • Run focused regressions and the full library suite; record any environmental or pre-existing failures honestly.

Tier: glance (notify for test-only task) — merge mode: human /prm; no merge requested.

Detailed implementation plan

Set an explicit seed in the shared Emcee test factory using the current search seed interface. Repeat all three tests 200 times; leave production initializer tolerance unchanged.

Repository: PyAutoFit; main clean at discovery; no existing active PyAutoFit claim or open PR found. Branch: feature/seed-start-point-tests. Each task retains a separate branch and PR. The four branches are coordinated within this user-authorized group, with no overlapping source edits committed together. Existing identifiers/output-directory identity must remain stable.

Original Prompt

test_start_points.py draws unseeded start points and flakes on IDENTICAL_FIGURES_OF_MERIT (nojax leg, PyAutoFit#1714)

Type: bug
Target: PyAutoFit
Repos:

  • PyAutoFit
    Themes:
  • ci
  • samplers
    Difficulty: small
    Autonomy: safe
    Priority: normal
    Status: formalised
    Consequence: notify
    Witness: pytest test_autofit/non_linear/search/test_start_points.py -q -p no:randomly --count 200 (or a 200-iteration shell loop) passes every time; the three tests draw their points from a seeded generator (or a fitness whose figures of merit cannot coincide), and no InitializerException can arise from the draw.
    Review-minutes: 2
    Unattended: ready
    Filed: 2026-10-23

Why

On PyAutoFit PR #1714 (run 39976190947, unittest-nojax leg) test_plot_false_skips_the_plot
failed with autofit.exc.InitializerException: The initial samples all have the same figure of merit while the 3.12 and 3.13 legs of the same sha passed and main's nojax leg was green an hour
earlier (run 39970496109). The PR touches only the EP evidence readout; the test does not reach it.

_search_and_fitness builds af.Emcee() with af.Model(af.ex.Gaussian) on data = np.ones(10)
and calls search.start_points(model, fitness, n=2). InitializerBall.samples_from_model draws
from np.random.default_rng() when no rng is passed (autofit/non_linear/initializer.py:104) and
raises when np.allclose(fom[0], fom[1:]) (:214). With n=2 on flat data two random draws land
on near-identical log likelihoods often enough to flake. Locally the test passed 3/3 under a nojax
emulation on the PR head.

Ask

  • Seed the draws in these tests (pass rng=np.random.default_rng(0) through start_points, or set
    the search's seed) so the tests are deterministic, or use a fitness whose figures of merit cannot
    coincide for distinct points.
  • Check the sibling tests in the file (test_plots_the_first_point_once,
    test_initializer_gets_the_effective_core_count) for the same unseeded draw.
  • Consider whether IDENTICAL_FIGURES_OF_MERIT at n == 2 should use a tolerance tighter than
    np.allclose defaults, or require n >= 3, in the library itself — report, do not change, unless
    trivially safe.

Lineage

Activity

  1. Jammy2211 commented on Oct 25, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged in #1723 at 9994c44, unchanged from the reviewed head, following the user's /prm command. All workflow jobs at that head passed. Combined validation: 3913 passed, 1 skipped, 1 xfailed; identifier parity checked. Downstream workspace smoke was not run and remains an explicit validation limitation. Pending PyAutoFit release; no release performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions