Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tfscreen/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
Version string.
"""

VERSION = (0, 3, 1)
VERSION = (0, 4, 0)
__version__ = '.'.join(map(str, VERSION))
3 changes: 2 additions & 1 deletion src/tfscreen/genetics/combine_mutation_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def combine_mutation_effects(
g_lookup.loc["wt", :] = np.nan

# Convert from wide (genotypes) to long (single mutations) format
stacked_muts = g_lookup.stack()
# dropna() required because pandas 3.x stack() no longer drops NaN by default
stacked_muts = g_lookup.stack().dropna()
if stacked_muts.empty: # Case where only 'wt' or no multi-mutants exist
return single_mutant_effects.iloc[0:0].reindex(g_lookup.index, fill_value=0)

Expand Down
8 changes: 5 additions & 3 deletions src/tfscreen/simulate/selection_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,8 @@ def _sim_growth(
all_kt = genotype_vs_kt[transformants]

# Expand the 2D mask to 3D to match the shape of all_kt.
expanded_mask = np.broadcast_to(trans_mask[:, :, np.newaxis], all_kt.shape)
# .copy() required: numpy 2.x rejects read-only broadcast arrays as ma masks
expanded_mask = np.broadcast_to(trans_mask[:, :, np.newaxis], all_kt.shape).copy()
masked_kt = ma.array(all_kt, mask=expanded_mask)

# Calculate the kt for each cell by combining effects of plasmids
Expand Down Expand Up @@ -1054,8 +1055,9 @@ def _simulate_library_group(
# stack, these will be removed.
genotype_vs_kt_pivot = sparse_pivot.reindex(ordered_genotypes, fill_value=0)

# Create a 2D array of (genotype,conditions) holding kt.
genotype_vs_kt = genotype_vs_kt_pivot.to_numpy()
# Create a 2D array of (genotype,conditions) holding kt.
# .copy() required: pandas 3.x CoW returns a read-only view from to_numpy()
genotype_vs_kt = genotype_vs_kt_pivot.to_numpy().copy()

# Add per-tube environmental noise: one delta_k per condition, shared across
# all genotypes in that tube. tube_noise_sigma is in growth-rate units
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_empirical_cdf():
assert cdf.shape == (5,)
assert cdf[0] == 0.16666667 # Interp 0.0 at 0.1 returns y[0]
assert jnp.isclose(cdf[2], 0.5) # 0.5 is exactly in theta
assert cdf[4] == 0.8333333 # Interp 1.0 at 0.9 returns y[2]
assert jnp.isclose(cdf[4], 5/6, atol=1e-5) # Interp 1.0 at 0.9 returns y[2]


# -------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions tests/tfscreen/util/io/test_read_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,5 @@ def test_genotype_as_index_not_categorized():
df = pd.DataFrame({"genotype": ["wt", "A1T"], "value": [1, 2]})
result = read_dataframe(df, index_column="genotype")
assert result.index.name == "genotype"
# Index should be plain strings, not categorical
assert result.index.dtype == object
# Index should be plain strings, not categorical (dtype varies: object or StringDtype)
assert not isinstance(result.index.dtype, pd.CategoricalDtype)
Loading