Skip to content

Commit

Permalink
solving the max samples bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Baptiste-Camps committed Feb 16, 2024
1 parent dad42a3 commit e56198a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions superstyl/preproc/tuyau.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ def docs_to_samples(paths, size, step=None, units="verses", feature="tokens", fo
else:
autsCounts[text['aut']] += 1

for autCount in autsCounts.items():
if autCount[1] > max_samples:
# get random selection
toBeSelected = [text for text in myTexts if text['aut'] is autCount[0]]
toBeSelected = random.sample(toBeSelected, k=max_samples)
# Great, now remove all texts from this author from our samples
myTexts = [text for text in myTexts if text['aut'] is not autCount[0]]
# and now concat
myTexts = myTexts + toBeSelected
for autCount in autsCounts.items():
if autCount[1] > max_samples:

Check warning on line 258 in superstyl/preproc/tuyau.py

View check run for this annotation

Codecov / codecov/patch

superstyl/preproc/tuyau.py#L257-L258

Added lines #L257 - L258 were not covered by tests
# get random selection
toBeSelected = [text for text in myTexts if text['aut'] == autCount[0]]
toBeSelected = random.sample(toBeSelected, k=max_samples)

Check warning on line 261 in superstyl/preproc/tuyau.py

View check run for this annotation

Codecov / codecov/patch

superstyl/preproc/tuyau.py#L260-L261

Added lines #L260 - L261 were not covered by tests
# Great, now remove all texts from this author from our samples
myTexts = [text for text in myTexts if text['aut'] != autCount[0]]

Check warning on line 263 in superstyl/preproc/tuyau.py

View check run for this annotation

Codecov / codecov/patch

superstyl/preproc/tuyau.py#L263

Added line #L263 was not covered by tests
# and now concat
myTexts = myTexts + toBeSelected

Check warning on line 265 in superstyl/preproc/tuyau.py

View check run for this annotation

Codecov / codecov/patch

superstyl/preproc/tuyau.py#L265

Added line #L265 was not covered by tests

return myTexts

0 comments on commit e56198a

Please sign in to comment.