Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
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
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
df34b3d0
Commit
df34b3d0
authored
2 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug where (1/2) is literally passed to C++, which results in 0 due to integever division
parent
f1022a6c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/hemisphere-joint-demo/hemisphere_joint_demo/sympy_to_code.py
+4
-3
4 additions, 3 deletions
...isphere-joint-demo/hemisphere_joint_demo/sympy_to_code.py
with
4 additions
and
3 deletions
python/hemisphere-joint-demo/hemisphere_joint_demo/sympy_to_code.py
+
4
−
3
View file @
df34b3d0
...
...
@@ -253,16 +253,17 @@ def expr_to_cpp(
if
isinstance
(
expr
,
sp
.
Symbol
):
# Must be part of local variables.
assert
expr
in
cpp
.
function_args
return
str
(
expr
)
elif
isinstance
(
expr
,
sp
.
Number
):
# Will be turned into a literal.
pass
# The number can also be something like (1/2), where "1 / 2" would be 0 in C++.
# So we pre-evaluate these constants in Python, and pass the result literal to C++.
return
str
(
eval
(
str
(
expr
)))
else
:
raise
TypeError
(
f
"
Got expr
{
expr
}
of type
{
type
(
expr
)
}
"
)
return
str
(
expr
)
else
:
# Non-leaf
print
(
f
"
{
indent
}
Node:
{
expr
}
"
)
...
...
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