Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hysop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
particle_methods
hysop
Commits
65ae5c1d
Commit
65ae5c1d
authored
4 years ago
by
Jean-Baptiste Keck
Browse files
Options
Downloads
Patches
Plain Diff
fix numpy wrapper routines
parent
8b8922dc
No related branches found
No related tags found
2 merge requests
!24
Resolve "Add python3.x support"
,
!15
WIP: Resolve "HySoP with tasks"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hysop/tools/numpywrappers.py
+18
-15
18 additions, 15 deletions
hysop/tools/numpywrappers.py
with
18 additions
and
15 deletions
hysop/tools/numpywrappers.py
+
18
−
15
View file @
65ae5c1d
...
...
@@ -4,9 +4,6 @@ Interface to numpy arrays, with hysop predifined types for int, real ...
Those functions are useful to enforce hysop predefined types in numpy arrays.
"""
from
hysop.constants
import
HYSOP_REAL
,
HYSOP_COMPLEX
,
HYSOP_ORDER
from
hysop.constants
import
HYSOP_INTEGER
,
HYSOP_INDEX
,
HYSOP_DIM
,
HYSOP_BOOL
from
hysop.tools.types
import
check_instance
from
hysop.deps
import
np
as
npw
...
...
@@ -19,7 +16,7 @@ def __generate_hysop_type_functions():
'
as{type}array
'
:
'''
def
__
hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs):
def hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs):
"""
Convert the input to an array of dtype HYSOP_{TYPE}.
"""
...
...
@@ -28,7 +25,7 @@ def __hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs):
'''
,
'
asany{type}array
'
:
'''
def
__
hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs):
def hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs):
"""
Convert the input to an array of dtype HYSOP_{TYPE}.
"""
...
...
@@ -37,7 +34,7 @@ def __hysop_array_generated_method(a, order=HYSOP_ORDER, **kargs):
'''
,
'
{type}_prod
'
:
'''
def
__
hysop_array_generated_method(a, axis=None, out=None, **kargs):
def hysop_array_generated_method(a, axis=None, out=None, **kargs):
"""
Sum of array elements over a given axis.
"""
...
...
@@ -46,7 +43,7 @@ def __hysop_array_generated_method(a, axis=None, out=None, **kargs):
'''
,
'
{type}_sum
'
:
'''
def
__
hysop_array_generated_method(a, axis=None, out=None, **kargs):
def hysop_array_generated_method(a, axis=None, out=None, **kargs):
"""
Sum of array elements over a given axis.
"""
...
...
@@ -56,7 +53,7 @@ def __hysop_array_generated_method(a, axis=None, out=None, **kargs):
'
{type}_empty
'
:
'''
def
__
hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
def hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
"""
Return a new array of given shape and type, without initializing entries.
"""
...
...
@@ -66,7 +63,7 @@ def __hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
'
{type}_ones
'
:
'''
def
__
hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
def hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
"""
Return a new array of given shape filled with ones of type HYSOP_{TYPE}.
"""
...
...
@@ -76,7 +73,7 @@ def __hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
'
{type}_zeros
'
:
'''
def
__
hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
def hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
"""
Return a new array of given shape, filled with zeros of type HYSOP_{TYPE}.
"""
...
...
@@ -86,7 +83,7 @@ def __hysop_array_generated_method(shape, order=HYSOP_ORDER, **kargs):
'
{type}_full
'
:
'''
def
__
hysop_array_generated_method(shape, fill_value, order=HYSOP_ORDER, **kargs):
def hysop_array_generated_method(shape, fill_value, order=HYSOP_ORDER, **kargs):
"""
Return a new array of given shape, filled with fill_value of type HYSOP_{TYPE}.
"""
...
...
@@ -100,12 +97,18 @@ def __hysop_array_generated_method(shape, fill_value, order=HYSOP_ORDER, **kargs
for
ht
in
hysop_types
:
for
_fname
,
fdefinition
in
functions
.
items
():
fname
=
_fname
.
format
(
type
=
ht
,
TYPE
=
ht
.
upper
())
fdef
=
fdefinition
.
format
(
type
=
ht
,
TYPE
=
ht
.
upper
())
exec
(
fdef
)
setattr
(
npw
,
fname
,
__hysop_array_generated_method
)
fdef
=
\
'''
from hysop.constants import HYSOP_REAL, HYSOP_COMPLEX, HYSOP_ORDER
from hysop.constants import HYSOP_INTEGER, HYSOP_INDEX, HYSOP_DIM, HYSOP_BOOL
{}
'''
.
format
(
fdefinition
.
format
(
type
=
ht
,
TYPE
=
ht
.
upper
()))
namespace
=
dict
()
exec
(
fdef
,
namespace
)
setattr
(
npw
,
fname
,
namespace
[
'
hysop_array_generated_method
'
])
if
ht
==
'
integer
'
:
fname
=
_fname
.
format
(
type
=
'
int
'
)
setattr
(
npw
,
fname
,
__
hysop_array_generated_method
)
setattr
(
npw
,
fname
,
namespace
[
'
hysop_array_generated_method
'
]
)
__generate_hysop_type_functions
()
...
...
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