Skip to content

[BUG] make_multi_bowl #469

@djps

Description

@djps

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions