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
Alexandru Fikl
arraycontext
Commits
82a84595
Unverified
Commit
82a84595
authored
3 years ago
by
Alexandru Fikl
Browse files
Options
Downloads
Patches
Plain Diff
make failed reshape message less opaque
parent
8fb7d285
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arraycontext/container/traversal.py
+15
-6
15 additions, 6 deletions
arraycontext/container/traversal.py
with
15 additions
and
6 deletions
arraycontext/container/traversal.py
+
15
−
6
View file @
82a84595
...
...
@@ -530,9 +530,16 @@ def flatten(ary: ArrayOrContainerT, actx: ArrayContext) -> Any:
except
ValueError
as
exc
:
# NOTE: we can't do much if the array context fails to ravel,
# since it is the one responsible for the actual memory layout
raise
NotImplementedError
(
"'
flatten
'
requires advanced reshaping
"
"
functionality that is not implemented in the array
"
f
"
context
'
{
type
(
actx
).
__name__
}
'"
)
from
exc
if
hasattr
(
subary
,
"
strides
"
):
strides_msg
=
f
"
and strides
{
subary
.
strides
}
"
else
:
strides_msg
=
""
raise
NotImplementedError
(
f
"'
{
type
(
actx
).
__name__
}
.np.ravel
'
failed to reshape
"
f
"
an array with shape
{
subary
.
shape
}{
strides_msg
}
.
"
"
This functionality needs to be implemented by the
"
"
array context.
"
)
from
exc
result
.
append
(
flat_subary
)
else
:
...
...
@@ -577,9 +584,11 @@ def unflatten(
except
ValueError
as
exc
:
# NOTE: we can't do much if the array context fails to reshape,
# since it is the one responsible for the actual memory layout
raise
NotImplementedError
(
"'
unflatten
'
requires advanced reshaping
"
"
functionality that is not implemented in the array
"
f
"
context
'
{
type
(
actx
).
__name__
}
'"
)
from
exc
raise
NotImplementedError
(
f
"'
{
type
(
actx
).
__name__
}
.np.reshape
'
failed to reshape
"
f
"
the flat array into shape
{
template_subary
.
shape
}
.
"
"
This functionality needs to be implemented by the
"
"
array context.
"
)
from
exc
if
hasattr
(
template_subary
,
"
strides
"
):
if
template_subary
.
strides
!=
subary
.
strides
:
...
...
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