Skip to content

[FIX] OWDBSCAN: handle empty X#7107

Merged
VesnaT merged 2 commits intobiolab:masterfrom
ajdapretnar:dbscan-empty-X
Jun 16, 2025
Merged

[FIX] OWDBSCAN: handle empty X#7107
VesnaT merged 2 commits intobiolab:masterfrom
ajdapretnar:dbscan-empty-X

Conversation

@ajdapretnar
Copy link
Contributor

Issue

Fixes #7105.

Description of changes

Handle empty X (often from plain Corpus).

Includes
  • Code changes
  • Tests
  • Documentation

@ajdapretnar ajdapretnar changed the title [MNT] OWDBSCAN: handle empty X [FIX] OWDBSCAN: handle empty X Jun 12, 2025
@codecov
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.73%. Comparing base (5872eb6) to head (7d6d8d2).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7107      +/-   ##
==========================================
- Coverage   88.73%   88.73%   -0.01%     
==========================================
  Files         332      332              
  Lines       73450    73455       +5     
==========================================
+ Hits        65176    65177       +1     
- Misses       8274     8278       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

return

if self.data is None:
if self.data.X is None or self.data.X.shape[1] == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think self.data.X is None could never be True.
Table.X is always a np.ndarray, but sometimes empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought as much. Thanks for checking!

self.Error.no_features()
self.data = None
self.Outputs.annotated_data.send(None)
self.plot.clear_plot()
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid the duplicated code, I'd rather the code was places right after the

        if not self.check_data_size(data):
            data = None

block, and implemented similarly (not necessarily with an additional function, but by setting the data to None before assigning it to self.data). In this case self.data_normalized would also be properly set.

@ajdapretnar
Copy link
Contributor Author

@VesnaT Fixed, you can check again.

@VesnaT VesnaT merged commit a997eb0 into biolab:master Jun 16, 2025
10 of 28 checks passed
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.

DBSCAN: crashes on empty X

2 participants