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

find_within bug with distance_measure='spherical_radians' #523

Closed
jinnsjj opened this issue Dec 12, 2023 · 1 comment · Fixed by #524
Closed

find_within bug with distance_measure='spherical_radians' #523

jinnsjj opened this issue Dec 12, 2023 · 1 comment · Fixed by #524
Assignees
Labels
coordinates hot For bugs on the master branch

Comments

@jinnsjj
Copy link

jinnsjj commented Dec 12, 2023

General

  • pyfar version: 0.6.1
  • Python version: 3.9.1
  • Operating System: MacOS
  • Did you install pyfar via pip: yes

Description

find_within bug with distance_measure='spherical_radians'

What I Did

I want to use pf to find all point on the northern hemisphere, I used scripts below. It returns a crash.

find = pf.Coordinates(0, 0, 1)
spatial_mask = coords.find_within(
    find,
    distance=np.pi/2,
    distance_measure='spherical_radians',
    atol=0.1)
coords.show(spatial_mask[0])

I located bug here, change == to in help me solve the problem.

        if distance_measure == ['spherical_radians', 'spherical_meter']:
            # determine validate radius
            radius = self.radius
            delta_radius = np.max(radius) - np.min(radius)
            if delta_radius > 1e-15:
                raise ValueError(
                    "find_nearest_sph only works if all points have the same \
                    radius. Differences are larger than 1e-15")
            radius = np.max(radius)

furthermore, I'm interseted in the delta_radius, 1e-15 is very small so that float value is hard to satify this threshold. Could we consider lowering the threshold?

@ahms5
Copy link
Member

ahms5 commented Dec 12, 2023

Thanks for reporting the bug, this should be fixed with pr #524. For the radius, I proposed an optional parameter to override the default.

@ahms5 ahms5 self-assigned this Dec 12, 2023
@ahms5 ahms5 added hot For bugs on the master branch coordinates labels Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coordinates hot For bugs on the master branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants