Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
b19e36fd
Unverified
Commit
b19e36fd
authored
May 15, 2019
by
QuanluZhang
Committed by
GitHub
May 15, 2019
Browse files
fix bug that annotation cannot deal with negative numbers (#1040)
* fix bug that annotation cannot deal with negative numbers
parent
8818cb65
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
tools/nni_annotation/search_space_generator.py
tools/nni_annotation/search_space_generator.py
+4
-2
No files found.
tools/nni_annotation/search_space_generator.py
View file @
b19e36fd
...
...
@@ -21,6 +21,7 @@
import
ast
import
astor
import
numbers
# pylint: disable=unidiomatic-typecheck
...
...
@@ -87,8 +88,9 @@ class SearchSpaceGenerator(ast.NodeTransformer):
args
=
[
key
.
n
if
type
(
key
)
is
ast
.
Num
else
key
.
s
for
key
in
node
.
args
[
0
].
keys
]
else
:
# arguments of other functions must be literal number
assert
all
(
type
(
arg
)
is
ast
.
Num
for
arg
in
node
.
args
),
'Smart parameter
\'
s arguments must be number literals'
args
=
[
arg
.
n
for
arg
in
node
.
args
]
assert
all
(
isinstance
(
ast
.
literal_eval
(
astor
.
to_source
(
arg
)),
numbers
.
Real
)
for
arg
in
node
.
args
),
\
'Smart parameter
\'
s arguments must be number literals'
args
=
[
ast
.
literal_eval
(
astor
.
to_source
(
arg
))
for
arg
in
node
.
args
]
key
=
self
.
module_name
+
'/'
+
name
+
'/'
+
func
# store key in ast.Call
...
...
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