Question for issue like "'bool_' object cannot be converted to 'PyBool'"? #2078
-
·I am doing reinforcement learning with openAI gym from rust. When extracting information from rust after let py_array2 = array![action2].to_pyarray(self.py);
let py_array3 = array![action3].to_pyarray(self.py);
let py_array4 = array![action4].to_pyarray(self.py);
let final_action: &Py<PyAny> = &[
action1.to_object(self.py),
vec![py_array2, py_array3, py_array4].to_object(self.py),
]
.to_object(self.py).
self.env
.call_method1("step", (final_action,)) //not ok
.expect("call step method failed")
...
let raw_obs = step_result
.get_item(0)
.expect("got observation failed from STEP");
let obs_vec = self.get_obs_vec_from_python(raw_obs);
let reward = step_result
.get_item(1)
.expect("get REWARD from step1 failed")
.extract()
.expect("get REWARD from step2 failed");
let is_done = step_result
.get_item(2)
.expect("get IS_DONE from step1 failed")
.extract()
.expect("get IS_DONE from step2 failed");// FAILED for a specific environment But for just a specific environment, it failed when code extracs
Here Do I miss something? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I'm afraid that I don't have knowledge of your code, so don't know why a specific environment is producing PyO3's rejection of this type is unsuprising, as >>> numpy.bool_.__mro__
(<class 'numpy.bool_'>, <class 'numpy.generic'>, <class 'object'>)
>>> bool.__mro__
(<class 'bool'>, <class 'int'>, <class 'object'>)
>>> issubclass(bool, int)
True
>>> issubclass(numpy.bool_, bool)
False |
Beta Was this translation helpful? Give feedback.
-
@davidhewitt, thanks for your answer. I give it a deep try, and I found that the pure python version also output type of if done: # the numpy.bool__
print(f"done in step {_step},with score:{episode_score}")
# print("Episode finished after {} timesteps".format(t+1))
break |
Beta Was this translation helpful? Give feedback.
I'm afraid that I don't have knowledge of your code, so don't know why a specific environment is producing
numpy.bool_
values.PyO3's rejection of this type is unsuprising, as
numpy.bool_
does not inherit frombool
: