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, groups and measure_maps by ID, and every group’s members by code point;

  • in every timeline, children by offset, then ID; conversion_maps by ID; regions by start, then end, then ID; flow_control by coordinate, then ID, and the targets of every jump by place: the destination without a place first, then those with by, by value, then those with to, by ID;

  • resources, flow_maps and virtual_timelines by ID; a FlowMap’s chunks keep their order, which is the order they are played in;

  • graphical.timestamps by timeline, then coordinate, then ID, and every timestamp’s display in the order of TIMESTAMP_DISPLAY, other strings after them by code point and other values last in their given order;

  • graphical.matchstamps by ID, the alignment_anchors of each by ID, and every anchor’s display in the order of ANCHOR_DISPLAY, as a timestamp’s;

  • graphical.elisions by timeline, then start, then ID, and every elision’s display in the order of ELISION_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 admits int only, a continuous unit float or fraction, and number all three.

class timetoshare.manifest.UnitEntry(domain, modality, number_type, number_types)[source]#

Bases: NamedTuple

One row of the unit table: a unit’s domain, modality and number types.

number_type is the default number type of an axis declaring none, and number_types the number types the unit admits, in the order int, 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 timelines member 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 members holds a value that is not a string.