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

debugging/make_color_iter() returns the same index when the number of colors is 2 and do not use all the possible colors #25695

Open
jeromemassot opened this issue Dec 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jeromemassot
Copy link

Description

Hi JAX team,

I have noticed the following behaviors:

  • make_color_iter() returns the same color index when the number of colors is 2.
  • make_color_iter() does not use all possible colors (for example with num_rows=2 and num_cols=3, the function returns
    [0, 4, 2, 0, 4, 2] as color indexes, so 3 colors among 6 possible.

I am not sure if there is a logic behind the selection of the color index besides not selecting the color twice in a row and ensuring that the adjacent colors are not too similar, but this is a proposed quick fix that I think solves the issue:

def make_color_iter(color_map, num_rows, num_cols):
    num_colors = num_rows * num_cols
    color_values = np.linspace(0, 1, num_colors)
    idx = 0
    step = 1 if num_colors % 2 == 0 else 2  # Determine step size
    for _ in range(num_colors):
        yield color_map(color_values[idx])
        idx = (idx + step) % num_colors 

I have tested several cases, and cannot see anything wrong in this possible fix.

Please, let me know :)

Best regards
Jerome

System info (python version, jaxlib version, accelerator, etc.)

jaxlib version = 0.4.33

@jeromemassot jeromemassot added the bug Something isn't working label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant