Skip to content
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

Confusion about TypeMustMatch and f64 #444

Open
legendre6891 opened this issue Sep 24, 2024 · 0 comments
Open

Confusion about TypeMustMatch and f64 #444

legendre6891 opened this issue Sep 24, 2024 · 0 comments

Comments

@legendre6891
Copy link

Hi! I have a question about why the following code seems to work without throwing an assert error.

On the Rust side:

#[pyfunction]
fn sum_up<'py>(py: Python<'py>, array: PyArrayLike1<'py, f64, TypeMustMatch>) -> f64 {
    array.as_array().sum()
}

On the python side

>>> A = np.array([2**63, 2**63+1], dtype=np.uint64)
>>> sum_up(A)
1.8446744073709552e+19

It seems like A is being converted to a f64, and then addition is carried out. (For reference, A.sum() = 1.) I thought that the TypeMustMatch means that the array's dtype must be f64.

Either I'm misunderstanding TypeMustMatch or perhaps there is a bug here?

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

No branches or pull requests

1 participant