Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fluiddyn
transonic
Commits
fd41debad5f7
Commit
65975169
authored
Nov 28, 2018
by
Pierre Augier
Browse files
[][] -> [:, :] and ndim=0
parent
029e50eccef1
Changes
3
Hide whitespace changes
Inline
Side-by-side
data_tests/type_hint_notemplate.py
View file @
fd41deba
...
...
@@ -8,6 +8,7 @@ N = NDim(1, 3)
A
=
Array
[
T
,
N
]
A1
=
Array
[
np
.
float32
,
N
+
1
]
A3d
=
Array
[
np
.
float32
,
"3d"
]
N1
=
NDim
(
4
,
5
)
N1
=
NDim
(
4
,
5
)
...
...
fluidpythran/annotation.py
View file @
fd41deba
...
...
@@ -271,10 +271,10 @@ class ArrayMeta(type):
if
dtype
is
None
or
ndim
is
None
:
raise
ValueError
base
=
f
"
{
dtype
.
__name__
}
"
if
ndim
==
0
:
raise
NotImplementedError
return
f
"
{
dtype
.
__name__
}
[
{
', '
.
join
([
':'
]
*
ndim
)
}
]"
return
base
return
base
+
f
"[
{
', '
.
join
([
':'
]
*
ndim
)
}
]"
class
Array
(
metaclass
=
ArrayMeta
):
...
...
@@ -295,6 +295,20 @@ def compute_pythran_types_from_types(types, **kwargs):
pythran_type
=
type_
.
__name__
else
:
pythran_type
=
str
(
type_
)
types
=
pythran_type
.
split
(
" or "
)
new_types
=
[]
for
_type
in
types
:
if
"]["
in
_type
:
# C style: we try to rewrite it in Cython style
base
,
dims
=
_type
.
split
(
"["
,
1
)
dims
=
", "
.
join
(
[
_
or
":"
for
_
in
dims
[:
-
1
].
split
(
"]["
)]
)
_type
=
base
+
"["
+
dims
+
"]"
elif
_type
.
endswith
(
"[]"
):
_type
=
_type
[:
-
2
]
+
"[:]"
new_types
.
append
(
_type
)
pythran_type
=
" or "
.
join
(
new_types
)
pythran_types
.
append
(
pythran_type
)
...
...
fluidpythran/for_test_justintime.py
View file @
fd41deba
...
...
@@ -18,7 +18,7 @@ def func():
@
cachedjit
def
func1
(
a
,
l
):
def
func1
(
a
:
"int[][] or float[]"
,
l
:
list
):
tmp
=
np
.
exp
(
sum
(
l
))
result
=
tmp
*
a
*
func0
(
a
)
+
func
()
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment