Skip to content

Conversation

@voronaam
Copy link
Collaborator

No description provided.

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))),
Copy link
Collaborator Author

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)) => {
Copy link
Collaborator Author

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.

Copy link
Member

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 👍

Copy link
Member

@mortendahl mortendahl left a 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)) => {
Copy link
Member

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 👍

@voronaam voronaam merged commit 5430b1d into main Mar 18, 2022
@voronaam voronaam deleted the lvorona/pymoose-state branch March 18, 2022 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants