Skip to content

Fix #844 Fix bug in module motifs#856

Merged
seanlaw merged 20 commits into
stumpy-dev:mainfrom
NimaSarajpoor:fix_motif_max_matches
May 10, 2023
Merged

Fix #844 Fix bug in module motifs#856
seanlaw merged 20 commits into
stumpy-dev:mainfrom
NimaSarajpoor:fix_motif_max_matches

Conversation

@NimaSarajpoor

Copy link
Copy Markdown
Collaborator

@seanlaw
Sorry for the noise! I am not getting revenge btw 😆 I am just newbie. So, the nature of our noises are different :)

@codecov-commenter

codecov-commenter commented May 5, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (82ce308) 99.28% compared to head (7e549bd) 99.28%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #856   +/-   ##
=======================================
  Coverage   99.28%   99.28%           
=======================================
  Files          83       83           
  Lines       13699    13753   +54     
=======================================
+ Hits        13601    13655   +54     
  Misses         98       98           
Impacted Files Coverage Δ
stumpy/motifs.py 100.00% <ø> (ø)
tests/test_motifs.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@NimaSarajpoor

Copy link
Copy Markdown
Collaborator Author

For future reference:
Fixing the bug resolves the exposed error and exposes an issue in one of the existing test functions. We are going to fix it in the next commit.

@NimaSarajpoor NimaSarajpoor force-pushed the fix_motif_max_matches branch from c41ed32 to e9bdaf2 Compare May 6, 2023 04:54
Comment thread tests/test_motifs.py Outdated
Comment thread tests/test_motifs.py Outdated

@NimaSarajpoor NimaSarajpoor left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@seanlaw
I just left two comments. Please add your comments as well if you have any.

Comment thread tests/test_motifs.py Outdated
Comment thread tests/test_motifs.py Outdated
@seanlaw

seanlaw commented May 9, 2023

Copy link
Copy Markdown
Contributor

I never noticed the decimal=4 in some of the npt.assert_almost_equal and I wonder if we even need to specify it? There are multiple instances throughout this file.

Also, maybe we should move the naive portion out into its own def naive_motifs function above def naive_match function

@NimaSarajpoor

Copy link
Copy Markdown
Collaborator Author

I never noticed the decimal=4 in some of the npt.assert_almost_equal and I wonder if we even need to specify it? There are multiple instances throughout this file.

I will remove it. If I notice an error raised by a specific test(s) as a result of such change, I will create an issue so that we can handle that specifc test(s) in another PR.

Also, maybe we should move the naive portion out into its own def naive_motifs function above def naive_match function

Correct. Later, we can re-use it for testing T_subseq_isconstant.

Note that the max_distance and cutoff parameters are hard-coded and they are both set to np.inf. We can add them to naive function as arguments (so that they can match the signature of performant func more closely) at the cost of making the naive func more complicated.

@seanlaw

seanlaw commented May 10, 2023

Copy link
Copy Markdown
Contributor

@NimaSarajpoor Is this ready to be merged?

@NimaSarajpoor

NimaSarajpoor commented May 10, 2023

Copy link
Copy Markdown
Collaborator Author

@seanlaw
I think it is ready to be merged.


FYI: In the function naive_motifs, we can add the following if-check to make sure that T is long enough for our test.

k = len(T) - m + 1
if k < m * max_matches * max_motifs:
      raise ValueError(...)

I think m * max_matches * max_motifs is a good, weak lower bound for k. However, since it is a naive function, I decided to avoid raising error, and instead, I just added a comment regarding this matter.

@seanlaw seanlaw merged commit f789386 into stumpy-dev:main May 10, 2023
@seanlaw

seanlaw commented May 10, 2023

Copy link
Copy Markdown
Contributor

Thanks @NimaSarajpoor

@NimaSarajpoor NimaSarajpoor deleted the fix_motif_max_matches branch September 4, 2023 03:24
seanlaw pushed a commit that referenced this pull request Jul 10, 2026
…1152)

core._find_matches seeds candidate_idx = query_idx and then breaks when
D[candidate_idx] > atol + max_distance, so it relies on D[query_idx] == 0.
core.mass_absolute establishes that, but aamp_match never passed query_idx to
it, unlike motifs.match which passes it to core.mass.

query_idx was added to core.mass and core.mass_absolute in #860; #856 wired it
into core.mass from motifs.match the next day, but aamp_motifs.py was not
updated. core.mass_absolute's query_idx branches have been unreachable since,
which is why they carry `# pragma: no cover`. They are now covered, so the
pragmas are removed.

For a correct self-join the fix is a no-op: cdist returns exactly 0.0 for the
identical row, so D[query_idx] was already the minimum. What it restores is the
"self-match is returned first" guarantee and the "Subsequences `Q` and
`T[query_idx:query_idx+m]` are different" warning when query_idx does not
describe Q -- neither of which could happen on the non-normalized path.
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

Successfully merging this pull request may close these issues.

3 participants