Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arraycontext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
arraycontext
Commits
427d25c7
Commit
427d25c7
authored
3 years ago
by
Andreas Klöckner
Committed by
Andreas Klöckner
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Tighten type info on {rec_,}keyed_map_array_container
parent
9eda169a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#252591
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arraycontext/container/traversal.py
+9
-5
9 additions, 5 deletions
arraycontext/container/traversal.py
with
9 additions
and
5 deletions
arraycontext/container/traversal.py
+
9
−
5
View file @
427d25c7
...
...
@@ -70,7 +70,7 @@ import numpy as np
from
arraycontext.context
import
ArrayContext
,
DeviceArray
from
arraycontext.container
import
(
ContainerT
,
ArrayOrContainerT
,
NotAnArrayContainerError
,
ArrayT
,
ContainerT
,
ArrayOrContainerT
,
NotAnArrayContainerError
,
serialize_container
,
deserialize_container
)
...
...
@@ -327,8 +327,11 @@ def multimapped_over_array_containers(
# {{{ keyed array container traversal
def
keyed_map_array_container
(
f
:
Callable
[[
Any
,
Any
],
Any
],
ary
:
ArrayOrContainerT
)
->
ArrayOrContainerT
:
def
keyed_map_array_container
(
f
:
Callable
[
[
Any
,
ArrayOrContainerT
],
ArrayOrContainerT
],
ary
:
ArrayOrContainerT
)
->
ArrayOrContainerT
:
r
"""
Applies *f* to all components of an :class:`ArrayContainer`.
Works similarly to :func:`map_array_container`, but *f* also takes an
...
...
@@ -350,8 +353,9 @@ def keyed_map_array_container(f: Callable[[Any, Any], Any],
])
def
rec_keyed_map_array_container
(
f
:
Callable
[[
Tuple
[
Any
,
...],
Any
],
Any
],
ary
:
ArrayOrContainerT
)
->
ArrayOrContainerT
:
def
rec_keyed_map_array_container
(
f
:
Callable
[[
Tuple
[
Any
,
...],
ArrayT
],
ArrayT
],
ary
:
ArrayOrContainerT
)
->
ArrayOrContainerT
:
"""
Works similarly to :func:`rec_map_array_container`, except that *f* also
takes in a traversal path to the leaf array. The traversal path argument is
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment