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

[BUG] make_multi_bowl #469

Open
djps opened this issue Sep 17, 2024 · 1 comment
Open

[BUG] make_multi_bowl #469

djps opened this issue Sep 17, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@djps
Copy link
Collaborator

djps commented Sep 17, 2024

Describe the bug

Using make_multi_bowl results in an error as the wrong type of arguments are passed to make_bowl, resulting in the error

BeartypeCallHintParamViolation: Function kwave.utils.mapgen.make_bowl() parameter radius=20 violates type hint typing.Union[int, float], as <protocol "numpy.int64"> 20 not int or float.

To Reproduce

In collab:

!pip install k-wave-python

import numpy as np
from copy import deepcopy
from kwave.data import Vector
from kwave.utils.mapgen import make_multi_bowl
Nx: int = 64
Ny: int = 64
Nz: int = 64
bowl_pos = np.array([[19, 19, Nz // 2 - 1], [48, 48, Nz // 2 - 1]], dtype=int)
bowl_radius = [20, int(15)]
bowl_diameter = [int(15), int(21)]
bowl_focus = [(int(31), int(31), int(31))]
binary_mask, labelled_mask = make_multi_bowl(Vector([Nx, Ny, Nz]), bowl_pos, bowl_radius, bowl_diameter, bowl_focus)

casting to different integer types doesn't help.

not that if bowl_pos is a list (as typing suggests) it fails in a different way, i.e. with

bowl_pos = [(19, 19, Nz // 2 - 1), (48, 48, Nz // 2 - 1)] 

then

AttributeError: 'list' object has no attribute 'shape'

I am not sure the typing is enforced, as it wants a list of (x,y) coordinates, but here it states if bowl_pos.shape[-1] != 3:

@djps djps added the bug Something isn't working label Sep 17, 2024
@waltsims
Copy link
Owner

This issue is a case of poor documentation and type-checking. I'm updating the label to enhancement since there are running configurations as tested in this file.

@waltsims waltsims added documentation Improvements or additions to documentation enhancement New feature or request and removed bug Something isn't working labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants