Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mujoco Py
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Jakob Hollenstein
Mujoco Py
Commits
9ca102f0
Unverified
Commit
9ca102f0
authored
5 years ago
by
Million Integrals
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reraising mujoco error exceptions (#435)
* Reraising mujoco error exceptions
parent
f66788ac
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mujoco_py/cymj.pyx
+14
-1
14 additions, 1 deletion
mujoco_py/cymj.pyx
mujoco_py/tests/test_cymj.py
+18
-0
18 additions, 0 deletions
mujoco_py/tests/test_cymj.py
mujoco_py/version.py
+1
-1
1 addition, 1 deletion
mujoco_py/version.py
with
33 additions
and
2 deletions
mujoco_py/cymj.pyx
+
14
−
1
View file @
9ca102f0
...
...
@@ -61,6 +61,7 @@ cdef object py_error_callback
# with wrap_mujoco_warning():
# mj_somefunc()
cdef
object
py_warning_exception
=
None
cdef
object
py_error_exception
=
None
cdef
void
c_warning_callback
(
const
char
*
msg
)
with
gil
:
...
...
@@ -106,7 +107,12 @@ cdef void c_error_callback(const char *msg) with gil:
MuJoCo error handlers are expected to terminate the program and never return.
'''
global
py_error_callback
(
<
object
>
py_error_callback
)(
msg
)
try
:
(
<
object
>
py_error_callback
)(
msg
)
except
Exception
as
e
:
global
py_error_exception
py_error_exception
=
e
def
set_error_callback
(
err_callback
):
...
...
@@ -140,11 +146,18 @@ class wrap_mujoco_warning(object):
def
__enter__
(
self
):
global
py_warning_exception
py_warning_exception
=
None
global
py_error_exception
py_error_exception
=
None
def
__exit__
(
self
,
type
,
value
,
traceback
):
global
py_warning_exception
global
py_error_exception
if
py_warning_exception
is
not
None
:
raise
py_warning_exception
if
py_error_exception
is
not
None
:
raise
py_error_exception
def
load_model_from_path
(
str
path
):
"""
Loads model from path.
"""
...
...
This diff is collapsed.
Click to expand it.
mujoco_py/tests/test_cymj.py
+
18
−
0
View file @
9ca102f0
...
...
@@ -348,6 +348,24 @@ def test_mj_error_called():
assert
error_message
==
"
error
"
def
test_mj_error_raises
():
def
error_callback
(
msg
):
raise
RuntimeError
(
msg
.
decode
())
cymj
.
set_error_callback
(
error_callback
)
called
=
False
try
:
with
cymj
.
wrap_mujoco_warning
():
functions
.
mju_error
(
"
error
"
)
except
RuntimeError
as
e
:
assert
e
.
args
[
0
]
==
"
error
"
called
=
True
assert
called
def
test_ignore_mujoco_warnings
():
# Two boxes on a plane need more than 1 contact (nconmax)
xml
=
'''
...
...
This diff is collapsed.
Click to expand it.
mujoco_py/version.py
+
1
−
1
View file @
9ca102f0
__all__
=
[
'
__version__
'
,
'
get_version
'
]
version_info
=
(
2
,
0
,
2
,
3
)
version_info
=
(
2
,
0
,
2
,
4
)
# format:
# ('mujoco_major', 'mujoco_minor', 'mujoco_py_major', 'mujoco_py_minor')
...
...
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