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
583b3062bfbe
Commit
8198f6c6
authored
Feb 15, 2021
by
Pierre Augier
Browse files
Fix signature split (for cases like float[:,:])
parent
f4209faea823
Pipeline
#18023
passed with stage
in 10 minutes and 9 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
transonic/analyses/__init__.py
View file @
583b3062
...
...
@@ -14,6 +14,7 @@
"""
import
re
from
pprint
import
pformat
import
gast
as
ast
...
...
@@ -384,6 +385,9 @@ def analyse_aot(code, pathfile, backend_name):
annotations
[
"__locals__"
]
=
{}
annotations
[
"__returns__"
]
=
{}
# match a comma except if inside backets (for `float[:,:]`)
pattern
=
re
.
compile
(
r
",\s*(?![^[]*\])"
)
for
functions_backend
in
boosted_dicts
[
"functions"
].
values
():
for
name_func
,
fdef
in
functions_backend
.
items
():
try
:
...
...
@@ -395,7 +399,7 @@ def analyse_aot(code, pathfile, backend_name):
for
sig
in
signatures
:
types
=
[
type_
.
strip
()
for
type_
in
sig
[
len
(
fdef
.
name
)
+
1
:
-
1
]
.
split
(
","
)
for
type_
in
re
.
split
(
pattern
,
sig
[
len
(
fdef
.
name
)
+
1
:
-
1
])
]
annotations_sign
.
append
(
dict
(
zip
(
arg_names
,
types
)))
if
annotations_sign
:
...
...
transonic/typing.py
View file @
583b3062
...
...
@@ -877,7 +877,6 @@ def str2type(str_type):
>>> str2type("(int, float[:, :])")
Tuple[int, Array[float, "2d"]]
"""
str_type
=
str_type
.
strip
()
if
" or "
in
str_type
:
...
...
Write
Preview
Supports
Markdown
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