timetoshare.manifest#
The canonical order of a TimeToShare manifest and the respelling of its values.
Readers accept a manifest’s arrays in any order; writers emit one canonical order (the README’s “Canonical order”):
timelines,groupsandmeasure_mapsby ID, and every group’smembersby code point;in every timeline,
childrenby offset, then ID;conversion_mapsby ID;regionsby start, then end, then ID;flow_controlby coordinate, then ID, and thetargetsof every jump by place: the destination without a place first, then those withby, by value, then those withto, by ID;resources,flow_mapsandvirtual_timelinesby ID; a FlowMap’schunkskeep their order, which is the order they are played in;graphical.timestampsby timeline, then coordinate, then ID, and every timestamp’sdisplayin the order ofTIMESTAMP_DISPLAY, other strings after them by code point and other values last in their given order;graphical.matchstampsby ID, thealignment_anchorsof each by ID, and every anchor’sdisplayin the order ofANCHOR_DISPLAY, as a timestamp’s;graphical.elisionsby timeline, then start, then ID, and every elision’sdisplayin the order ofELISION_DISPLAY, as a timestamp’s.
Coordinates compare by their exact numeric value, never by their spelling; strings compare by Unicode code point; entries that tie keep their given order. Every other array keeps its order.
The declared number type decides how an own-axis value is read, never its
spelling, and writers respell every own-axis value as its axis’s number type
selects (the README’s “Values on a timeline’s own axis”): an integral float on
an int axis as the integer it equals, an integer on a float axis as the
float that equals it exactly, and a Fraction pair on a fraction axis
reduced to lowest terms, its members integers. A value its number type cannot
take, and every value on an axis whose unit or number_type is unknown,
is written as given.
- timetoshare.manifest.ANCHOR_DISPLAY = ('line', 'name')#
The words of an alignment anchor’s
display, in canonical order.
- timetoshare.manifest.ELISION_DISPLAY = ('ellipsis', 'name', 'id', 'coordinate', 'continuation')#
The words of an elision’s
display, in canonical order.
- timetoshare.manifest.TIMESTAMP_DISPLAY = ('wedge', 'name', 'id', 'coordinate', 'cross_section')#
The words of a named timestamp’s
display, in canonical order.
- timetoshare.manifest.UNITS: Mapping[str, UnitEntry] = mappingproxy({'number': UnitEntry(domain='logical', modality='continuous', number_type='float', number_types=('int', 'float', 'fraction')), 'floating_measures': UnitEntry(domain='logical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'whole_notes': UnitEntry(domain='logical', modality='continuous', number_type='fraction', number_types=('float', 'fraction')), 'quarters': UnitEntry(domain='logical', modality='continuous', number_type='fraction', number_types=('float', 'fraction')), 'ticks': UnitEntry(domain='logical', modality='discrete', number_type='int', number_types=('int',)), 'milliseconds': UnitEntry(domain='physical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'seconds': UnitEntry(domain='physical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'minutes': UnitEntry(domain='physical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'samples': UnitEntry(domain='physical', modality='discrete', number_type='int', number_types=('int',)), 'frames': UnitEntry(domain='physical', modality='discrete', number_type='int', number_types=('int',)), 'pixels': UnitEntry(domain='graphical', modality='discrete', number_type='int', number_types=('int',)), 'meters': UnitEntry(domain='graphical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'centimeters': UnitEntry(domain='graphical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'millimeters': UnitEntry(domain='graphical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'inches': UnitEntry(domain='graphical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'points': UnitEntry(domain='graphical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'css_pixels': UnitEntry(domain='graphical', modality='continuous', number_type='float', number_types=('float', 'fraction')), 'user_units': UnitEntry(domain='graphical', modality='continuous', number_type='float', number_types=('float', 'fraction'))})#
The unit table, in the schema’s order of
TimeUnit: every unit’s domain, modality, default number type and admitted number types. A discrete unit admitsintonly, a continuous unitfloatorfraction, andnumberall three.
- class timetoshare.manifest.UnitEntry(domain, modality, number_type, number_types)[source]#
Bases:
NamedTupleOne row of the unit table: a unit’s domain, modality and number types.
number_typeis the default number type of an axis declaring none, andnumber_typesthe number types the unit admits, in the orderint,float,fraction.
- timetoshare.manifest.canonical_order(value)[source]#
Return a deep copy of
value, a manifest put in canonical order and spelling.A value is a manifest when it is an object whose
timelinesmember is an array: its arrays are put in canonical order (module docstring) and its own-axis values respelled. Object keys are left as they are (the writers sort them), and every other value is copied unchanged.- Raises:
ValueError – If the manifest cannot be put in canonical order: an entry of an ordered array of objects is not an object, lacks a member it is ordered by or holds that member in a wrong type, or a group’s
membersholds a value that is not a string.