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

DM-43332: Improve match_probabilistic performance #188

Merged
merged 8 commits into from May 16, 2024
Merged

Conversation

taranu
Copy link
Contributor

@taranu taranu commented Mar 14, 2024

No description provided.

Copy link

@enourbakhsh enourbakhsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably not on the agenda for this ticket, but it would make sense to change single quotes to double quotes for strings later. Below are my other comments.

k=config.match_n_max,
)
# Call scipy for non-spherical case
# The spherical case won't trigger, but the implementation is left for comparison, if needed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "The non-spherical case won't trigger"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you anticipate such comparisons becoming necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean that the spherical case won't use scipy but will use smatch instead. So the _radec_to_xyz if coords_spherical else np.vstack on line 542 will never actually call _radec_to_xyz.

I anticipate most users will match on spherical coordinates and so the else block won't get called much.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you're getting at now. Sorry, that comment is quite confusing in the current version of the code. I mistakenly thought you actually wanted to say "The non-spherical case won't trigger in general" to point out that "The non-spherical case (the else block) won't get called much, and not at all by default."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So within this else block intended for non-spherical coordinates where coords_spherical is False, there's an if coords_spherical condition that obviously won't be met but might be useful for comparison. I suggest adding a more explicit comment to convey this and clear up any confusion.

try:
chisq_sum = np.zeros(n_found, dtype=float)
chisq_sum[chisq_good] = np.nansum(chi[chisq_good, :] ** 2, axis=1)
idx_chisq_min = np.nanargmin(chisq_sum / n_finite)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we always safeguarded against division by zero here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as n_finite_min > 0, yes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's why I suggested you add a check in match_n_finite_min = pexConfig.Field(...).

)
match_n_finite_min = pexConfig.Field(
dtype=int,
default=3,
default=2,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a check here to specify the valid domain?

@taranu taranu merged commit 4be5004 into main May 16, 2024
2 checks passed
@taranu taranu deleted the tickets/DM-43332 branch May 16, 2024 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants