autowisp.tests.test_diagnostics_views module

Class Inheritance Diagram

Inheritance diagram of DiagnosticType, DiagnosticsViewTestCase, Image, ImageDiagnostics, ImageType, ObservingSession, PipelineError, SeriesKey, TestAvailableQuantities, TestExpressionAxis, TestImageTypeSplit, TestQuantileSeriesExpansion, TestRowId, TestSeriesGrouping, TestSharedTimeOffset, datetime

Characterization tests for the BUI diagnostics view modules.

These pin the behaviours that must survive merging image_diagnostics_views and diag_vs_diag_views into a single x-versus-y path: how the pixel_quantiles pseudo-name expands into series, and how the time-series figure offsets and groups its series. They are written against the current code, so they must pass before the merge starts.

Uses a throwaway project database, following test_error_render.

class autowisp.tests.test_diagnostics_views.DiagnosticsViewTestCase(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.DiagnosticsViewTestCase

Base creating one throwaway project database holding two nights.

classmethod _fill_database()[source]

Create two observing sessions, the second holding two image types.

Every frame records bg_center in channel R; only object frames record the quantiles, which is the ordinary case of a diagnostic that is not defined for every type. Provenance foreign keys are left dangling, as SQLite does not enforce them and the diagnostics queries only ever join back to observing_session and image_type.

static bind(row, *channels)[source]

Return the row as the client posts it with its dropdowns set.

images_of = {}

{(night, image_type): [image_id, ...]}, in JD order, so a test can say which images a series is supposed to be built from.

rows_for(x_diagnostic, y_diagnostic, expressions=None)[source]

Return {(session, type, quantile): row} for an axis pair.

Keyed by the group rather than by the whole series, a row having no channels until something binds them.

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

class autowisp.tests.test_diagnostics_views.TestAvailableQuantities(methodName='runTest')[source]

Bases: DiagnosticsViewTestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.TestAvailableQuantities

What the two axis selectors offer, given what this project holds.

Availability rather than validity: every stored expression is valid in every project, so the only question a selector can usefully ask is whether the diagnostics an expression reaches have actually been recorded here.

_recorded()[source]

Return the raw in-use diagnostic names.

test_a_broken_expression_is_hidden_rather_than_raised()[source]

A stored cycle must not stop the plot page rendering.

Saying what is wrong with it belongs to the management page; here the only sane answer is not to offer it.

test_a_concrete_quantile_is_judged_against_the_raw_names()[source]

Which is why the family collapse happens after this check.

Against the collapsed list pixel_q999 would look unrecorded and a perfectly drawable expression would go missing from the selector.

test_a_dependency_makes_its_dependents_unavailable()[source]

Availability follows the whole subtree, not the direct names.

test_a_jd_only_expression_is_always_available()[source]

jd exists for every image of the canonical list.

test_an_unknown_name_is_hidden_too()[source]

A typo no version of AutoWISP defines, rather than a cycle.

test_expression_hidden_where_an_input_is_not_recorded()[source]

Not an error – astrom_residual is real, merely unrecorded.

The distinction the whole design rests on: this expression is valid here and would be offered in a project that had run plate solving.

test_expression_offered_where_its_inputs_are_recorded()[source]

The ordinary case, and the composed one behind it.

test_expressions_join_the_same_flat_list()[source]

Not a second list beside it.

An axis reads one name, and a recorded diagnostic is an expression of itself as far as everything downstream is concerned – which is the same flat name space that stops an expression taking a diagnostic’s name.

test_recorded_names_are_raw()[source]

The individual quantiles, not the family that replaces them.

This is the set an expression is judged against, and one may reference a concrete pixel_q999, so the collapse must happen after rather than before.

test_selector_offers_the_family_not_its_members()[source]

One entry expanding to a series per quantile, and jd first.

class autowisp.tests.test_diagnostics_views.TestExpressionAxis(methodName='runTest')[source]

Bases: DiagnosticsViewTestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.TestExpressionAxis

An expression selected for an axis, as a diagnostic would be.

The library is passed in rather than stored, which is the arrangement that lets these run against a project database alone: what the view does with an expression does not depend on where it was kept.

library = {'q_ratio': 'pixel_q999[1] / pixel_q99[1]', 'rel_bg': 'bg_center[1] - nanmedian(bg_center[1])', 'scaled_bg': 'rel_bg[1] * 10'}

Referenced by every test here; bg_center is recorded for both image types, so the availability answer is interesting.

test_a_composed_expression_reaches_through()[source]

scaled_bg needs what rel_bg needs, transitively.

test_an_expression_against_a_diagnostic()[source]

Both axes at once, one of each kind, sharing a query.

test_an_unknown_name_is_refused()[source]

Neither a diagnostic nor an expression, so nothing to plot.

test_offered_wherever_its_diagnostics_are()[source]

Availability follows what the expression reaches, not its name.

Nothing records a diagnostic called rel_bg; the series it can be drawn for are those recording the bg_center it is built from.

test_restricted_to_the_types_recording_its_inputs()[source]

Only object frames record the quantiles, so only they are offered.

test_the_values_are_the_expression_evaluated()[source]

End to end: an expression axis produces its own numbers.

class autowisp.tests.test_diagnostics_views.TestImageTypeSplit(methodName='runTest')[source]

Bases: DiagnosticsViewTestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.TestImageTypeSplit

A session holding several image types yields a series per type.

test_a_type_without_the_diagnostic_is_absent()[source]

Only object frames record the quantiles, so only they appear.

test_canonical_list_holds_only_its_own_type()[source]

The alignment the whole design rests on is per type.

Every array is padded onto this list, so if it mixed types then so would every quantity built against it.

test_each_type_gets_its_own_series()[source]

The mixed night offers object and flat separately.

test_the_type_is_shown_in_the_table()[source]

Otherwise two rows of the mixed night would look identical.

test_values_are_not_taken_across_types()[source]

The point of the split: an aggregate sees one population.

A series covering the whole night would hand nanmedian all five frames and return the object median, since the objects outnumber the flats – silently, and wrongly.

class autowisp.tests.test_diagnostics_views.TestQuantileSeriesExpansion(methodName='runTest')[source]

Bases: DiagnosticsViewTestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.TestQuantileSeriesExpansion

pixel_quantiles expands to one series per pixel_q*.

On either axis, since the expansion happens where the series are built rather than per axis.

_series_ids(x_diagnostic, y_diagnostic)[source]

Return the series ids offered for the given axis pair.

test_quantile_column_present()[source]

A quantile pairing gains the extra Quantile table column.

test_quantiles_on_x_axis()[source]

One row per quantile per night, the name carried in the id.

test_quantiles_on_y_axis()[source]

Reversing the axes yields the same expansion.

class autowisp.tests.test_diagnostics_views.TestRowId(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.TestRowId

The row id, a round trip through the client and back.

It becomes an HTML element id, four more element ids are built from it, and it keys the datasets object the client posts back – so it has to survive all of that as an opaque string. What it deliberately does not carry is the channels: those are chosen in the row, and an id that changed as they were would take every element id with it.

round_trip(session_id, image_type, quantile_name, ordinal=0)[source]

Return the group recovered from the id built from these.

test_an_ambiguous_field_is_refused()[source]

Failing loudly beats an id that silently pairs wrong data.

test_plain_row()[source]

No quantile: the field is empty rather than missing.

test_quantile_row()[source]

The quantile survives despite containing underscores.

This is what the previous encoding could not do without guessing which underscores separated fields and which belonged to the name.

test_siblings_differ_by_their_ordinal()[source]

A group holds a row per binding, and they share everything else.

test_the_image_type_is_part_of_the_identity()[source]

Two types in one session must not collide on one id.

test_the_key_takes_its_channels_from_the_client()[source]

The half of a series that the table edits, and only that half.

test_underscores_anywhere_are_harmless()[source]

Neither the image type nor the quantile has to avoid them.

class autowisp.tests.test_diagnostics_views.TestSeriesGrouping(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.TestSeriesGrouping

group_series_by_x_overlap splits only non-overlapping ranges.

static _entry(jd_values)[source]

Build the tuple shape the grouping helper consumes.

test_disjoint_ranges_split()[source]

Two nights a day apart occupy separate subplots.

test_overlapping_ranges_merge()[source]

Overlapping ranges share one subplot.

This is the case a non-time x axis reduces to once the grouping is generalized from JD to arbitrary x, so it must keep holding.

class autowisp.tests.test_diagnostics_views.TestSharedTimeOffset(methodName='runTest')[source]

Bases: DiagnosticsViewTestCase

Inheritance diagram of autowisp.tests.test_diagnostics_views.TestSharedTimeOffset

The x-offset is one value for the whole figure, not per series.

_plotted_x_values()[source]

Return the x arrays that reach the per-series plotting call.

plot_image_diagnostic_series is mocked out, which both captures the offset values and avoids reverse() needing Django settings.

_series_starts()[source]

Return where each plotted series begins on the shared x axis.

test_offset_is_not_per_series()[source]

Guard the exact regression the merge could introduce.

Zeroing each series on its own would start every one of them at 0, collapsing the day between the two nights. The second night’s series keep that day, wherever in the night each one begins.

test_only_the_earliest_series_starts_at_zero()[source]

One offset for the figure, so exactly one series lands on 0.

autowisp.tests.test_diagnostics_views._diagnostic_names = ('bg_center', 'pixel_q99', 'pixel_q999')

the lazy database initialization behind set_project_home creates the schema but seeds no diagnostic_type rows, and depending on that would couple these tests to project-creation behaviour they are not about.

Type:

Every diagnostic the fixture records. All are created explicitly

autowisp.tests.test_diagnostics_views._first_bg_center = {'flat': 500.0, 'object': 100.0}

bg_center of the first frame of each type. Far enough apart that a median over one type cannot be confused with a median over the mixture.

autowisp.tests.test_diagnostics_views._first_jd = 2460000.5

JD of the first image of the first night.

autowisp.tests.test_diagnostics_views._frames_per_night = ({'object': 3}, {'flat': 2, 'object': 3})

Frames of each type per night. Only the second night is mixed, which is what lets these tests tell a per-type series from one that lumps a whole session together; leaving the first night single-type keeps the plain one-series-per-night cases readable.

autowisp.tests.test_diagnostics_views._night_separation = 1.0

Nights are one day apart, so their JD ranges cannot overlap.

autowisp.tests.test_diagnostics_views._quantile_names = ('pixel_q99', 'pixel_q999')

The quantile diagnostics, which expand to one series each.