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

@rsubset Float64 values without using tolerance #403

Open
Jigyasu4indp opened this issue Oct 24, 2024 · 1 comment
Open

@rsubset Float64 values without using tolerance #403

Jigyasu4indp opened this issue Oct 24, 2024 · 1 comment

Comments

@Jigyasu4indp
Copy link

This code is working:

tolerance = 1e-4

zvalue = @chain dtd_new_5g begin
    @rsubset(abs(:latitude - 26.0846) < tolerance, abs(:longitude - 86.1236) < tolerance)
end

But how can I make it work without using tolerance and absolute values?"

@pdeffebach
Copy link
Collaborator

You probably want isapprox (a built-in Julia function)

  isapprox(x, y; atol::Real=0, rtol::Real=atol>0 ? 0 : √eps, nans::Bool=false[, norm::Function])

  Inexact equality comparison. Two numbers compare equal if their
  relative distance or their absolute distance is within tolerance
  bounds: isapprox returns true if norm(x-y) <= max(atol,
  rtol*max(norm(x), norm(y))). The default atol (absolute tolerance) is
  zero and the default rtol (relative tolerance) depends on the types of
  x and y. The keyword argument nans determines whether or not NaN values
  are considered equal (defaults to false).

  For real or complex floating-point values, if an atol > 0 is not
  specified, rtol defaults to the square root of eps of the type of x or
  y, whichever is bigger (least precise). This corresponds to requiring
  equality of about half of the significant digits. Otherwise, e.g. for
  integer arguments or if an atol > 0 is supplied, rtol defaults to zero.

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

2 participants