oryx.core.nest
Stay organized with collections
Save and categorize content based on your preferences.
Wraps a function to create a new scope for harvested values.
oryx.core.nest(
f, *, scope: str
)
Used in the notebooks
Harvested values live in one dynamic name scope (for a particular tag),
and in strict mode, values with the same name cannot be collected or injected
more than once. nest(f, scope=[name])
will take all tagged values in f
and
put them into a nested dictionary with key [name]
. This enables having
duplicate names in one namespace provided they are in different scopes. This
is different from using a separate tag to namespace, as it enables creating
nested/hierarchical structure within a single tag's namespace.
Example:
def foo(x):
return sow(x, tag='test', name='x')
harvest(foo, tag='test')({}, 1.) # (1., {'x': 1.})
harvest(nest(foo, scope='a'), tag='test')({}, 1.) # (1., {'a': {'x': 1.} })
Args |
f
|
a function to be transformed
|
scope
|
a string that will act as the parent scope of all values tagged in
f .
|
Returns |
A semantically identical function to f , but when harvested, uses nested
values according to the input scope.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-24 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-24 UTC."],[],[]]