Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ejm714 committed Sep 27, 2022
1 parent c8b39be commit 0fdbc20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 5 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ def test_extra_column(tmp_path, labels_absolute_path):
index=False,
)
# this column is not one hot encoded
config = TrainConfig(labels=tmp_path / "extra_species_col.csv", save_dir=tmp_path / "my_model")
config = TrainConfig(
labels=tmp_path / "extra_species_col.csv",
save_dir=tmp_path / "my_model",
use_default_model_labels=False,
)
assert list(config.labels.columns) == [
"filepath",
"split",
Expand Down
16 changes: 9 additions & 7 deletions zamba/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def make_split(labels, values):
too_few = {
k.split("species_", 1)[1]: v
for k, v in num_videos_per_species.items()
if v < len(expected_splits)
if 0 < v < len(expected_splits)
}

if len(too_few) > 0:
Expand All @@ -644,12 +644,14 @@ def make_split(labels, values):
for c in labels.filter(regex="species_").columns:
species_df = labels[labels[c] > 0]

# within each species, seed splits by putting one video in each set and then allocate videos based on split proportions
labels.loc[species_df.index, "split"] = expected_splits + random.choices(
list(values["split_proportions"].keys()),
weights=list(values["split_proportions"].values()),
k=len(species_df) - len(expected_splits),
)
if len(species_df):

# within each species, seed splits by putting one video in each set and then allocate videos based on split proportions
labels.loc[species_df.index, "split"] = expected_splits + random.choices(
list(values["split_proportions"].keys()),
weights=list(values["split_proportions"].values()),
k=len(species_df) - len(expected_splits),
)

logger.info(f"{labels.split.value_counts()}")

Expand Down

0 comments on commit 0fdbc20

Please sign in to comment.