Python only
Functions without an R counterpart in the reference.
Backend
dataclass
What a data argument is, and whether it is lazy.
NestedScalesError
Bases: ValueError
Raised for every user-facing error (R: .stop()).
NestedScalesWarning
Bases: UserWarning
Issued for every user-facing warning (R: .warn()).
ProductSummary
dataclass
The quantitative view of a product (R: summary() ->
summary_ScaleProduct).
axes is a table with one row per axis: axis, scale (the name of
its scale), frames (how many), leaves, key and coverage.
total is the size of the product, coverage the per-axis coverage,
joint_coverage their product, and joint_weights whether joint
weights are attached.
RESERVED_AXES
module-attribute
RESERVED_AXES = ('name', 'desc', 'keys', 'joint_weights')
ScaleDataset
dataclass
An opened store: data (a lazily read pyarrow Dataset) and scale.
Experimental: this feature may change or be removed in a later version.
ScaleSummary
dataclass
The quantitative view of a scale (R: summary() -> summary_Scale).
attributes, aliases and labels are tables of row counts: by
attribute, frame and source; by source; and by frame and
variant. nesting has one entry per adjacent pair of frames.
ScaleTree
dataclass
The parts of a scale (R: a scale_tree data frame).
table has one row per part: part, the parent field it belongs to
("" for a field of the object), its kind, shape, mark, the
verb that changes it and a note. header names the class and the
identity. str() draws the tree, with +, - and | for the branches
unless the output stream is UTF-8; lines(ascii=) chooses.
Verdict
dataclass
A yes/no answer with its evidence (R: a logical with attributes).
Truthy as ok, and equal to a bool of the same value, so
if scale_nests(...) and scale_nests(...) == True both read naturally.
offenders names the codes that broke the test; sizes carries the
per-member totals of scale_is_uniform().
scale_set_props
scale_set_props(
x: NestedScale, check: bool = False, **props: Any
) -> NestedScale
A copy of x with fields replaced, keeping the concrete class.
The counterpart of R's S7::set_props(x, ..., .check = FALSE), for the
payload hooks of a subclass: a hook receives an object whose parts are
consistent only once it has finished, so the copy is not validated
unless check=True. Any field of the object may be named, a subclass's
own included. x is left as it was.
A field replaced without check=True is stored as given: meta and
members become read-only, and the other fields are coerced, when the
copy is validated.
Examples
import nestedscales as ns s = ns.scale_example() t = ns.scale_set_props(s, check=True, meta={**s.meta, "source": "demo"}) t.meta["source"], "source" in s.meta ('demo', False)
scale_validate
scale_validate(x: NestedScale) -> NestedScale
Normalise and validate x in place and return it (R: S7::validate()).
Raises NestedScalesError listing every problem. Normalising coerces
the fields to their stored forms (tuples, read-only dicts, the member
tables' schemas); on an object that was built by a constructor or
returned by a verb it changes nothing, so the only objects it alters
are those under construction: a copy from scale_set_props() that was
not checked, or self inside a subclass constructor.