Skip to content

Commit

Permalink
add easier and non-repetitive implementation to fix the random_sample…
Browse files Browse the repository at this point in the history
…_size
  • Loading branch information
serareif committed Jun 2, 2024
1 parent 90fd2d4 commit e12d56d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/sliders.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,13 @@ def random_sample():
adata = _adata_qc.get()
if adata is None:
return

obs_number = adata.n_obs
sample_size = input['random_sample_size']()

if int(sample_size) > int(obs_number):
sample_size = obs_number
ui.update_slider('random_sample_size', value=sample_size, max=obs_number)



sample_size = input['random_sample_size'].get()

if adata is None:
return

adata_sample = adata[np.random.choice(adata.obs.index, sample_size, replace=False)]
adata_sample = adata[np.random.choice(adata.obs.index, min(sample_size, len(adata.obs)), replace=False)]
_adata_sample.set(adata_sample)

@output
Expand Down

0 comments on commit e12d56d

Please sign in to comment.