nustack

mapping

Mapping family: a key-value collection in a shape fabric.

Module nu.domains.shape.mapping.

Mapping family: a key-value collection in a shape fabric.

Forms weave the Python mapping surface with the shape collection ops, tier by tier, and type every result by what the slot declared: a value reads as the declared value's form, and keys, values, items and whole-mapping results carry the declared types on.

Refs add descent. ref[key] is the child ref at that key, built by the fabric from the declared value, because only the fabric knows which of its refs holds that value.

NameSortCallMeaning
MappingRefrefMappingRef(address, parent_ref=None, owner_shape=None)Key-value container Ref; ref[key] navigates to the value's child Ref.
MutableMappingRefrefMutableMappingRef(address, parent_ref=None, owner_shape=None)Mutable key-value container Ref.
ReactiveMappingRefrefReactiveMappingRef(address, parent_ref=None, owner_shape=None)Reactive key-value container Ref.

MappingRef

Key-value container Ref; ref[key] navigates to the value's child Ref.

MappingRef(address, parent_ref=None, owner_shape=None)

Path nu.domains.shape.MappingRef. Kind Ref, sort ref, cardinality scalar.

Navigation is defined once here and routes through _wrap_item_ref, the one hook that returns a ref rather than a form. It is a substrate plug-point on StructuredRef: the child is always a fabric's own ref, so the fabric's substrate base supplies it, and a fabric that leaves it out fails loudly.

Methods

a[key]

Navigate to the child Ref at key, with self as parent.

Builds StructuredRef.

Arguments

NameTypeDefaultMeaning
keyobject

Undocumented: example.

Inherited methods

From nu.domains.shape.mapping.MappingForm:

CallBuildsMeaning
.iter()IteratorA lazy stream over its keys, typed by the declared key.

From nu.forms.collections.abc.mapping.MappingForm:

CallBuildsMeaning
.keys()CollectionResultTAll keys of the mapping: mapping.keys().
.values()CollectionResultTAll values of the mapping: mapping.values().
.items()CollectionResultTAll (key, value) pairs of the mapping: mapping.items().
.get_item(key, default=None)ValueResultTValue at key, falling back to default: mapping.get_item(key, default).
.copy()CollectionResultTShallow copy of self: mapping.copy().
.reversed_keys()CollectionResultTKeys in reverse insertion order: reversed(mapping).
.reversed_values()CollectionResultTValues in reverse insertion order: reversed(mapping.values()).
.reversed_items()CollectionResultT(key, value) pairs in reverse insertion order: reversed(mapping.items()).
.merge(other)CollectionResultTSelf and other merged into a new mapping, like Python's dict |.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.domains.shape.collection.CollectionForm:

CallBuildsMeaning
.exists()BoolWhether this collection slot holds a value, as a Bool.
.missing()BoolWhether this slot holds no value, as a Bool: the negation of exists().

From nu.lang.forms.Form:

CallBuildsMeaning
a == bBoolSelf equal to other by value: an Eq term, never a Python bool.
a != bBoolSelf not equal to other by value: a Ne term, never a Python bool.
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.not_empty()BoolTrue if this Form does not yield EMPTY.
.fallback(*alternatives)SelfThe first of this value and alternatives that is not EMPTY.

Undocumented: example.

MutableMappingRef

Mutable key-value container Ref.

MutableMappingRef(address, parent_ref=None, owner_shape=None)

Path nu.domains.shape.MutableMappingRef. Kind Ref, sort ref, cardinality scalar.

Adds: set(k,v), delete(k), update(), store(v), erase() on top of MappingRef.

Inherited methods

From nu.forms.collections.abc.mapping.MutableMappingForm:

CallBuildsMeaning
.set_item(key, value)AnySet the value at key, inserting the key if it's missing: mapping[key] = value.
.del_item(key)AnyDelete the entry at key: del mapping[key].
.update(other)AnyWrite other's entries into self, in place: mapping.update(other).
.pop(key, default=None)ValueResultTRemove key and yield its value, or default if key is missing.
.popitem()ValueResultTRemove and yield an arbitrary (key, value) pair: mapping.popitem().
.setdefault(key, default=None)ValueResultTValue at key, inserting default there first if key is missing.
.merge_update(other)CollectionResultTMerge other into self in place, and yield self, like Python's dict |=.
.clear()AnyRemove all entries: mapping.clear().

From nu.domains.shape.mapping.MappingRef:

CallBuildsMeaning
a[key]StructuredRefNavigate to the child Ref at key, with self as parent.

From nu.domains.shape.mapping.MappingForm:

CallBuildsMeaning
.iter()IteratorA lazy stream over its keys, typed by the declared key.

From nu.forms.collections.abc.mapping.MappingForm:

CallBuildsMeaning
.keys()CollectionResultTAll keys of the mapping: mapping.keys().
.values()CollectionResultTAll values of the mapping: mapping.values().
.items()CollectionResultTAll (key, value) pairs of the mapping: mapping.items().
.get_item(key, default=None)ValueResultTValue at key, falling back to default: mapping.get_item(key, default).
.copy()CollectionResultTShallow copy of self: mapping.copy().
.reversed_keys()CollectionResultTKeys in reverse insertion order: reversed(mapping).
.reversed_values()CollectionResultTValues in reverse insertion order: reversed(mapping.values()).
.reversed_items()CollectionResultT(key, value) pairs in reverse insertion order: reversed(mapping.items()).
.merge(other)CollectionResultTSelf and other merged into a new mapping, like Python's dict |.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.domains.shape.collection.MutableCollectionForm:

CallBuildsMeaning
.set(value)SetCmdBuild a SetCmd.
.erase()EraseBuild an Erase.
.init(value)IfDoSet value iff the collection is currently missing.

From nu.domains.shape.collection.CollectionForm:

CallBuildsMeaning
.exists()BoolWhether this collection slot holds a value, as a Bool.
.missing()BoolWhether this slot holds no value, as a Bool: the negation of exists().

From nu.lang.forms.Form:

CallBuildsMeaning
a == bBoolSelf equal to other by value: an Eq term, never a Python bool.
a != bBoolSelf not equal to other by value: a Ne term, never a Python bool.
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.not_empty()BoolTrue if this Form does not yield EMPTY.
.fallback(*alternatives)SelfThe first of this value and alternatives that is not EMPTY.

Undocumented: example.

ReactiveMappingRef

Reactive key-value container Ref.

ReactiveMappingRef(address, parent_ref=None, owner_shape=None)

Path nu.domains.shape.ReactiveMappingRef. Kind Ref, sort ref, cardinality scalar.

Adds: on_change() (generic), on_child_change(), on_children_change(), on_descendants_change() (shape-domain) on top of MutableMappingRef.

Inherited methods

From nu.forms.collections.abc.mapping.ReactiveMappingForm:

CallBuildsMeaning
.on_change()objectSubscribe to any change on this mapping slot.

From nu.forms.collections.abc.mapping.MutableMappingForm:

CallBuildsMeaning
.set_item(key, value)AnySet the value at key, inserting the key if it's missing: mapping[key] = value.
.del_item(key)AnyDelete the entry at key: del mapping[key].
.update(other)AnyWrite other's entries into self, in place: mapping.update(other).
.pop(key, default=None)ValueResultTRemove key and yield its value, or default if key is missing.
.popitem()ValueResultTRemove and yield an arbitrary (key, value) pair: mapping.popitem().
.setdefault(key, default=None)ValueResultTValue at key, inserting default there first if key is missing.
.merge_update(other)CollectionResultTMerge other into self in place, and yield self, like Python's dict |=.
.clear()AnyRemove all entries: mapping.clear().

From nu.domains.shape.mapping.MappingRef:

CallBuildsMeaning
a[key]StructuredRefNavigate to the child Ref at key, with self as parent.

From nu.domains.shape.mapping.MappingForm:

CallBuildsMeaning
.iter()IteratorA lazy stream over its keys, typed by the declared key.

From nu.forms.collections.abc.mapping.MappingForm:

CallBuildsMeaning
.keys()CollectionResultTAll keys of the mapping: mapping.keys().
.values()CollectionResultTAll values of the mapping: mapping.values().
.items()CollectionResultTAll (key, value) pairs of the mapping: mapping.items().
.get_item(key, default=None)ValueResultTValue at key, falling back to default: mapping.get_item(key, default).
.copy()CollectionResultTShallow copy of self: mapping.copy().
.reversed_keys()CollectionResultTKeys in reverse insertion order: reversed(mapping).
.reversed_values()CollectionResultTValues in reverse insertion order: reversed(mapping.values()).
.reversed_items()CollectionResultT(key, value) pairs in reverse insertion order: reversed(mapping.items()).
.merge(other)CollectionResultTSelf and other merged into a new mapping, like Python's dict |.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.domains.shape.collection.ReactiveCollectionForm:

CallBuildsMeaning
.on_child_change(address)OnChildChangeObserve writes at one child's own address; for its subtree use on_descendants_change.
.on_children_change()OnChildrenChangeObserve writes at the direct children only; for subtrees use on_descendants_change.
.on_descendants_change()OnDescendantsChangeObserve changes across descendants matching pattern.

From nu.domains.shape.collection.MutableCollectionForm:

CallBuildsMeaning
.set(value)SetCmdBuild a SetCmd.
.erase()EraseBuild an Erase.
.init(value)IfDoSet value iff the collection is currently missing.

From nu.domains.shape.collection.CollectionForm:

CallBuildsMeaning
.exists()BoolWhether this collection slot holds a value, as a Bool.
.missing()BoolWhether this slot holds no value, as a Bool: the negation of exists().

From nu.lang.forms.Form:

CallBuildsMeaning
a == bBoolSelf equal to other by value: an Eq term, never a Python bool.
a != bBoolSelf not equal to other by value: a Ne term, never a Python bool.
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.not_empty()BoolTrue if this Form does not yield EMPTY.
.fallback(*alternatives)SelfThe first of this value and alternatives that is not EMPTY.

Undocumented: example.

On this page