Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pystencils_autodiff
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
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
pycodegen
pystencils_autodiff
Commits
03ee157a
Commit
03ee157a
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Extend ArrayWithIndexDimensions to ArrayWrapper
parent
4b8c0f08
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#20017
failed
5 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils_autodiff/field_tensor_conversion.py
+24
-4
24 additions, 4 deletions
src/pystencils_autodiff/field_tensor_conversion.py
with
24 additions
and
4 deletions
src/pystencils_autodiff/field_tensor_conversion.py
+
24
−
4
View file @
03ee157a
...
@@ -10,14 +10,30 @@ class _WhatEverClass:
...
@@ -10,14 +10,30 @@ class _WhatEverClass:
self
.
__dict__
.
update
(
kwargs
)
self
.
__dict__
.
update
(
kwargs
)
class
ArrayW
ithIndexDimensions
:
class
ArrayW
rapper
:
def
__init__
(
self
,
def
__init__
(
self
,
array
,
array
,
index_dimensions
,
index_dimensions
=
0
,
field_type
=
FieldType
.
GENERIC
):
field_type
=
FieldType
.
GENERIC
,
coordinate_transform
=
None
,
spacing
=
None
,
origin
=
None
,
coordinate_origin
=
None
):
self
.
array
=
array
self
.
array
=
array
self
.
index_dimensions
=
index_dimensions
self
.
index_dimensions
=
index_dimensions
self
.
field_type
=
field_type
self
.
field_type
=
field_type
if
spacing
:
coordinate_transform
=
sympy
.
diag
(
*
spacing
)
if
origin
:
origin
=
sympy
.
Matrix
(
origin
)
spacing
=
spacing
or
origin
/
origin
coordinate_transform
=
sympy
.
diag
(
*
spacing
)
coordinate_origin
=
origin
/
spacing
if
coordinate_transform
:
self
.
coordinate_transform
=
coordinate_transform
if
coordinate_origin
:
self
.
coordinate_origin
=
coordinate_origin
def
__array__
(
self
):
def
__array__
(
self
):
return
self
.
array
return
self
.
array
...
@@ -40,7 +56,7 @@ def create_field_from_array_like(field_name, maybe_array, annotations=None):
...
@@ -40,7 +56,7 @@ def create_field_from_array_like(field_name, maybe_array, annotations=None):
if
annotations
and
isinstance
(
annotations
,
dict
):
if
annotations
and
isinstance
(
annotations
,
dict
):
index_dimensions
=
annotations
.
get
(
'
index_dimensions
'
,
0
)
index_dimensions
=
annotations
.
get
(
'
index_dimensions
'
,
0
)
field_type
=
annotations
.
get
(
'
field_type
'
,
FieldType
.
GENERIC
)
field_type
=
annotations
.
get
(
'
field_type
'
,
FieldType
.
GENERIC
)
elif
isinstance
(
maybe_array
,
ArrayW
ithIndexDimensions
):
elif
isinstance
(
maybe_array
,
ArrayW
rapper
):
index_dimensions
=
maybe_array
.
index_dimensions
index_dimensions
=
maybe_array
.
index_dimensions
field_type
=
maybe_array
.
field_type
field_type
=
maybe_array
.
field_type
maybe_array
=
maybe_array
.
array
maybe_array
=
maybe_array
.
array
...
@@ -65,6 +81,10 @@ def create_field_from_array_like(field_name, maybe_array, annotations=None):
...
@@ -65,6 +81,10 @@ def create_field_from_array_like(field_name, maybe_array, annotations=None):
field
=
Field
.
create_from_numpy_array
(
field_name
,
maybe_array
,
index_dimensions
)
field
=
Field
.
create_from_numpy_array
(
field_name
,
maybe_array
,
index_dimensions
)
field
.
field_type
=
field_type
field
.
field_type
=
field_type
if
hasattr
(
maybe_array
,
'
coordinate_transform
'
):
field
.
coordinate_transform
=
maybe_array
.
coordinate_transform
if
hasattr
(
maybe_array
,
'
coordinate_origin
'
):
field
.
coordinate_origin
=
maybe_array
.
coordinate_origin
return
field
return
field
...
...
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