autowisp.tests.test_tfa_num_templates module

Class Inheritance Diagram

Inheritance diagram of HashableArray, LightCurveFile, TFACorrection, TestTemplateSelectionDiagnostics, TestTemplateSourceIdsVlen, _TemplateSelectionHarness

Unit tests for variable TFA template counts and selection diagnostics.

These are deliberately self-contained (no downloaded test-data bundle): the bundle cannot exercise a varying template count because every test channel happens to select the same number, so the ragged-storage regression and the short-count warning are covered here instead.

class autowisp.tests.test_tfa_num_templates.TestTemplateSelectionDiagnostics(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_tfa_num_templates.TestTemplateSelectionDiagnostics

The short-count warning emitted by _select_template_stars.

static _configuration(sqrt_num_templates)[source]

Config with cuts loose enough that every synthetic star passes.

static _make_epd_statistics(num_stars)[source]

A single-photometry structured array that survives every cut.

All stars are unsaturated, bright, long-LC, and follow a clean magnitude-RMS relation (small scatter so the typical-RMS fit keeps them), spread over a 2-D field.

test_full_count_no_warning()[source]

Enough distinct templates for the grid must not warn.

test_shortfall_emits_warning()[source]

Fewer selected than sqrt_num_templates**2 logs a warning.

Ten eligible stars against a 4x4 (=16) grid: the grid-nearest-neighbor collapse yields fewer than 16 distinct templates, which must warn and report the per-stage funnel.

class autowisp.tests.test_tfa_num_templates.TestTemplateSourceIdsVlen(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_tfa_num_templates.TestTemplateSourceIdsVlen

Ragged storage of the TFA TemplateStarIDs config datasets.

classmethod setUpClass()[source]

Point the DB/project home at a throwaway directory.

classmethod tearDownClass()[source]

Drop the throwaway project home.

test_dtype_override_is_vlen()[source]

get_dtype reports a vlen dtype (of the DB base) for the keys.

test_varying_template_counts_round_trip()[source]

Appending configs of different template counts must not broadcast.

Reproduces the production crash (Can't broadcast (1, 12) -> (1, 10)): one TFA run stores a width-10 row, a later run for the same source appends a width-12 row. With fixed-2D storage the append failed; as ragged rows it succeeds and round-trips.

autowisp.tests.test_tfa_num_templates._TEMPLATE_KEYS = ('shapefit.tfa.cfg.template_source_ids', 'apphot.tfa.cfg.template_source_ids')

The two config datasets whose per-config value is a variable-length array of template star IDs.

class autowisp.tests.test_tfa_num_templates._TemplateSelectionHarness(configuration)[source]

Bases: TFACorrection

A TFACorrection exposing just the template-selection step.

The full TFACorrection.__init__ reads per-light-curve template measurements and observation IDs (_prepare_template_data), which needs real data. _select_template_stars only consults the configuration and the (passed-in) EPD statistics, so this harness sets the configuration and skips the data-reading construction.