-
Couldn't load subscription status.
- Fork 17
Pyo3 and numpy update #958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| let dtype: &PyArrayDescr = dtype_obj.cast_as(py).unwrap(); | ||
| let np_dtype = dtype.get_datatype().unwrap(); | ||
| match np_dtype { | ||
| numpy::DataType::Float32 => Ok(Value::from(pyobj_tensor_to_host_tensor::<f32>(py, obj))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enum was removed as a result of this comment: PyO3/rust-numpy#256 (comment)
Not much of a conversation and/or migration guide. I think I followed the suggested path though, judging by the comments and the changes in that PR.
| numpy::DataType::Uint64 => Ok(Value::from(pyobj_tensor_to_host_tensor::<u64>(py, obj))), | ||
| numpy::DataType::Bool => Ok(Value::from(pyobj_tensor_to_host_bit_tensor(py, obj))), | ||
| match dtype { | ||
| dt if dt.is_equiv_to(numpy::dtype::<f32>(py)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we can use obj.is_instance_of::<PyArrayDyn<f32>> syntax, but I think this one is a bit better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw I also thought is_equiv_to was the right approach, so happy to go with this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
| numpy::DataType::Uint64 => Ok(Value::from(pyobj_tensor_to_host_tensor::<u64>(py, obj))), | ||
| numpy::DataType::Bool => Ok(Value::from(pyobj_tensor_to_host_bit_tensor(py, obj))), | ||
| match dtype { | ||
| dt if dt.is_equiv_to(numpy::dtype::<f32>(py)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw I also thought is_equiv_to was the right approach, so happy to go with this 👍
No description provided.