Skip to content

Commit

Permalink
Updating tests as quicksort (default) is not stable for columns with …
Browse files Browse the repository at this point in the history
…same values
  • Loading branch information
shachafl committed Oct 11, 2024
1 parent 49557b7 commit 60af531
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions starfish/test/full_pipelines/api/test_dartfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,16 @@ def test_dartfish_pipeline_cropped_data(tmpdir):
cnts_starfish.rename(columns={'target': 'gene', 'area': 'cnt_starfish'}, inplace=True)

# get top 5 genes and verify they are correct
high_expression_genes = cnts_starfish.sort_values('cnt_starfish', ascending=False).head(5)
high_expression_genes = cnts_starfish.sort_values('cnt_starfish', ascending=False,
kind='stable').head(5)

assert np.array_equal(
high_expression_genes['cnt_starfish'].values,
[7, 3, 2, 2, 2]
)
assert np.array_equal(
high_expression_genes['gene'].values,
['MBP', 'MOBP', 'ADCY8', 'TRIM66', 'SYT6']
['MBP', 'MOBP', 'ADCY8', 'SYT6', 'TRIM66']
)

# verify correlation is accurate for this subset of the image
Expand Down
4 changes: 2 additions & 2 deletions starfish/test/full_pipelines/api/test_merfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ def test_merfish_pipeline_cropped_data():
spot_intensities[Features.PASSES_THRESHOLDS], drop=True
)
genes, counts = np.unique(spot_intensities_passing_filters[Features.TARGET], return_counts=True)
result_counts = pd.Series(counts, index=genes).sort_values(ascending=False)[:5]
result_counts = pd.Series(counts, index=genes).sort_values(ascending=False, kind='stable')[:5]

# assert that number of high-expression detected genes are correct
expected_counts = pd.Series(
[107, 59, 46, 32, 32],
index=('MALAT1', 'SRRM2', 'FASN', 'IGF2R', 'TLN1')
index=('MALAT1', 'SRRM2', 'FASN', 'TLN1', 'IGF2R')
)
assert np.array_equal(
expected_counts.values,
Expand Down

0 comments on commit 60af531

Please sign in to comment.