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

slmsuite.holography.toolbox.smallest_distance unexpected behavior #49

Open
tpr0p opened this issue Jul 9, 2023 · 1 comment
Open

slmsuite.holography.toolbox.smallest_distance unexpected behavior #49

tpr0p opened this issue Jul 9, 2023 · 1 comment
Assignees
Labels
bug Something isn't working r0.0.2 Planned part of the 0.0.2 release

Comments

@tpr0p
Copy link
Member

tpr0p commented Jul 9, 2023

smallest_distance returns different value depending on ordering of vectors argument.

MWE:

import numpy as np
import matplotlib.pyplot as plt
import slmsuite.holography.toolbox as toolbox

# generate points
shape = (2, 2)
p0 = (0, 0)
p1 = (10, 0)
p2 = (0, 10)
p3 = (10, 10)
points_top_right = np.around(toolbox.fit_3pt(
    p3,
    p1,
    p2,
    N=shape,
    x0=(1, 1),
    x1=(1, 0),
    x2=(0, 1)
)).astype(np.uint64)
points_bottom_left = np.around(toolbox.fit_3pt(
    p3,
    p1,
    p2,
    N=shape,
    x0=(0, 0),
    x1=(1, 0),
    x2=(0, 1)
)).astype(np.uint64)
# plot
plt.scatter(points_bottom_left[0, :], points_bottom_left[1, :], alpha=0.5, color="red", s=100)
plt.scatter(points_top_right[0, :], points_top_right[1, :], alpha=0.5, color="blue", s=10)
xoff, yoff = 0.5, 0.5
for idx in range(np.prod(shape)):
    name_str = "{}".format(idx)
    xtr, ytr = points_top_right[:, idx]
    plt.text(xtr + xoff, ytr + yoff, name_str, color="blue")
    xbl, ybl = points_bottom_left[:, idx]
    plt.text(xbl - xoff, ybl - yoff, name_str, color="red")
ll = -1
lh = 11
plt.xlim(ll, lh)
plt.ylim(ll, lh)
plt.show()
# smallest distance
dtr = toolbox.smallest_distance(points_top_right)
dbl = toolbox.smallest_distance(points_bottom_left)
print("distance_top_right: {}, distance_bottom_left: {}".format(dtr, dbl))
@tpr0p tpr0p added bug Something isn't working good first issue Good for newcomers labels Jul 9, 2023
@tpr0p
Copy link
Member Author

tpr0p commented Jul 9, 2023

The problem is that the points are np.uint64 so the subtraction in the chebyshev metric causes overflow, or similar issue. Not sure if we want to do anything about this.

@tpr0p tpr0p removed the good first issue Good for newcomers label Jul 9, 2023
@ichristen ichristen added the r0.0.2 Planned part of the 0.0.2 release label Mar 10, 2024
@ichristen ichristen self-assigned this Mar 10, 2024
@ichristen ichristen mentioned this issue May 1, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working r0.0.2 Planned part of the 0.0.2 release
Projects
None yet
Development

No branches or pull requests

2 participants