climate_ref.baseline_report.analyse
#
Turn a collected report into everything the templates need.
Text blobs are fetched from the native store and diffed here.
AnalysedCase
#
One test case, with its files analysed and tallied.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
back_link
instance-attribute
#
Relative link from this case's page back to the index, one .. per label segment.
change
instance-attribute
#
The underlying change.
committed
instance-attribute
#
The committed artefacts that moved, in name order.
counts
instance-attribute
#
One entry per kind, in report column order.
files
instance-attribute
#
Every analysed file, in the order collection produced them.
images
instance-attribute
#
The image files, which render as a two-up comparison.
netcdfs
instance-attribute
#
The NetCDF files, which render as a header diff and a table of variable statistics.
others
instance-attribute
#
Every remaining file, which renders as a table row.
texts
instance-attribute
#
The text files, which render as a diff.
tree
instance-attribute
#
The captured baseline's native files, as a flattened folder listing.
AnalysedCommitted
#
One committed regression artefact, with its diff.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
AnalysedFile
#
One native file, with its blob URLs and whatever its kind is analysed into.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
change
instance-attribute
#
The underlying change.
netcdf
instance-attribute
#
The header and stats diff, set only for
:attr:~climate_ref.baseline_report.collect.FileKind.NETCDF files.
new_url
instance-attribute
#
Store URL of the head blob, or None when the file was removed.
old_url
instance-attribute
#
Store URL of the base blob, or None when the file is new.
size_delta
instance-attribute
#
Signed byte change, or None when the file exists on only one side.
text
instance-attribute
#
The diff, set only for :attr:~climate_ref.baseline_report.collect.FileKind.TEXT files.
AnalysedReport
#
A whole report, ready to render.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
cases
instance-attribute
#
The analysed cases, in the order collection produced them.
kinds
instance-attribute
#
The count column headers, matching the order of every case's counts.
report
instance-attribute
#
The underlying report.
store_url
instance-attribute
#
Base location blobs are served from, matching what :func:blob_url builds.
DiffLine
#
One line of a unified diff, tagged so a template can style it.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
KindCounts
#
How many files of one kind were added, changed and removed.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
NetcdfDiff
#
What changed inside one NetCDF file, or the reason nothing could be read.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
header
instance-attribute
#
The two ncdump-style headers merged into one tagged listing.
Every line is kept rather than only the changed hunks, because the header is what tells a reader what the file holds.
header_changed
property
#
Whether the headers differ.
Returns:
| Type | Description |
|---|---|
bool
|
|
header_new
instance-attribute
#
HEAD's header, for reading one side on its own.
header_old
instance-attribute
#
The base ref's header, for reading one side on its own.
note
instance-attribute
#
Why the file could not be analysed, or None when it was.
rows
instance-attribute
#
One row per data variable, in name order.
Pair
#
One statistic on each side of the change.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
atol = 0.0
class-attribute
instance-attribute
#
How far a numeric pair may move before it reads as changed. Zero compares exactly.
changed
property
#
Whether the two sides differ by more than :attr:atol.
Returns:
| Type | Description |
|---|---|
bool
|
|
new
instance-attribute
#
The value on HEAD, or None when it could not be computed.
old
instance-attribute
#
The value on the base ref, or None when it could not be computed.
StatRow
#
Whole-array statistics for one data variable, on each side of the change.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
atol
instance-attribute
#
How far a value may move before it counts as changed.
:data:NOISE_RTOL scaled by the base ref's own magnitude, so one number governs
both the row's verdict and which of its statistics are emphasised.
cells_differ
instance-attribute
#
Cells that changed, counting NaN as equal to NaN.
differs
property
#
Whether the cell by cell comparison found a change worth reading.
Returns:
| Type | Description |
|---|---|
bool
|
|
max_abs_diff
instance-attribute
#
Largest absolute change, or None when the shapes differ or a side is absent.
max_rel_diff
instance-attribute
#
:attr:max_abs_diff over the largest magnitude on the base ref.
maximum
instance-attribute
#
Maximum on each side, ignoring NaN.
mean
instance-attribute
#
Mean on each side, ignoring NaN.
minimum
instance-attribute
#
Minimum on each side, ignoring NaN.
moved
instance-attribute
#
Whether anything about this variable changed, however small the change.
name
instance-attribute
#
The variable's name.
nan
instance-attribute
#
NaN cells on each side, None when the variable is absent or not numeric.
severity
property
#
How much weight the row deserves.
A run reproduced on different hardware moves the last bits of nearly every cell, so a row that only moved that far is called out as noise rather than as a change.
Returns:
| Type | Description |
|---|---|
Literal['same', 'noise', 'changed']
|
|
shape
instance-attribute
#
Dimensions on each side, as 180x360, or scalar.
TextDiff
#
The unified diff of one text output, or the reason there is not one.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
TreeNode
#
One row of the captured baseline's folder listing.
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
depth
instance-attribute
#
How deep the entry sits, so a template can indent it.
is_dir
instance-attribute
#
Whether the row is a directory rather than a file.
name
instance-attribute
#
The directory or file name at this level.
size
instance-attribute
#
The file's size on HEAD, or on the base ref when it was removed.
None for a directory and for a committed artefact, whose manifest entry has no size.
status
instance-attribute
#
added, changed or removed, or None when the file did not move.
analyse(report, store, *, fetch, workdir)
#
Build everything the templates need from a collected report.
A blob that cannot be fetched becomes a note on its file rather than an exception, because one unreachable object should not cost the whole report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
Report
|
The collected report. |
required |
store
|
NativeStore
|
The store to read blobs from. |
required |
fetch
|
bool
|
Whether blobs may be downloaded. With |
required |
workdir
|
Path
|
Directory fetched blobs are written into. |
required |
Returns:
| Type | Description |
|---|---|
AnalysedReport
|
The analysed report. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
baseline_tree(case)
#
Flatten the captured baseline's files into an indented folder listing.
Every captured file is listed, not only the ones that moved, because the listing is what tells a reviewer what the baseline actually holds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
case
|
CaseChange
|
The collected case. |
required |
Returns:
| Type | Description |
|---|---|
tuple[TreeNode, ...]
|
One row per directory and file, in path order. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
blob_url(store, digest)
#
Build the URL a blob is served from.
A local store fans its blobs out by the first two digest characters, so a flat URL under its root would point at nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
NativeStore
|
The store the blob lives in. |
required |
digest
|
str
|
The blob's sha256 hex digest. |
required |
Returns:
| Type | Description |
|---|---|
str
|
An absolute URL a browser can open. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
committed_diff(change)
#
Build the unified diff of one committed regression artefact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
change
|
CommittedChange
|
The artefact that moved, carrying both sides' content. |
required |
Returns:
| Type | Description |
|---|---|
TextDiff
|
The diff, or a note explaining why there is not one. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
netcdf_diff(old, new)
#
Diff the headers and whole-array statistics of two NetCDF blobs.
Decoding is turned off so a non-standard calendar or unit cannot fail the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
Path | None
|
The base blob, or |
required |
new
|
Path | None
|
The head blob, or |
required |
Returns:
| Type | Description |
|---|---|
NetcdfDiff
|
The header diff and one row per data variable, or a note when a file could not be opened. |
Source code in packages/climate-ref/src/climate_ref/baseline_report/analyse.py
text_diff(old, new, name)
#
Build the unified diff between two fetched blobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
Path | None
|
The base blob, or |
required |
new
|
Path | None
|
The head blob, or |
required |
name
|
str
|
The file's name, used in the diff header and to detect JSON. |
required |
Returns:
| Type | Description |
|---|---|
TextDiff
|
The diff, or a note explaining why there is not one. |