Skip to content

Commit 7c5e9e4

Browse files
committed
perf: vectorize gene_pointer construction
Made-with: Cursor
1 parent 3de4f22 commit 7c5e9e4

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

malariagen_data/anoph/genome_features.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,11 @@ def plot_genes(
446446

447447
# Put gene pointers (▲ or ▼) in a new column, depending on the strand.
448448
# Except if the gene_label is null or an empty string, which should not be shown.
449-
# Vectorized operation: use np.where for conditional logic
450-
has_label = data["gene_label"].astype(bool)
451-
pointer_symbol = np.where(data["strand"] == "+", "▼", "▲")
452-
data["gene_pointer"] = np.where(has_label, pointer_symbol, "")
449+
data["gene_pointer"] = np.where(
450+
data["gene_label"] == "",
451+
"",
452+
np.where(data["strand"] == "+", "▼", "▲"),
453+
)
453454

454455
# Put the pointer above or below the gene rectangle, depending on + or - strand.
455456
neg_strand_pointer_y = orig_mid_y_range - 1.1

0 commit comments

Comments
 (0)