Skip to content

Commit

Permalink
Fix name generator for width=1
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 13, 2024
1 parent a9eb0cb commit d9bf5aa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/test_complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ def make_zip_path(self, depth=1, width=1) -> zipp.Path:
@classmethod
def make_names(cls, width, letters=string.ascii_lowercase):
"""
>>> list(TestComplexity.make_names(1))
['a']
>>> list(TestComplexity.make_names(2))
['a', 'b']
>>> list(TestComplexity.make_names(30))
['aa', 'ab', ..., 'bd']
"""
# determine how many products are needed to produce width
n_products = math.ceil(math.log(width, len(letters)))
n_products = max(1, math.ceil(math.log(width, len(letters))))
inputs = (letters,) * n_products
combinations = itertools.product(*inputs)
names = map(''.join, combinations)
Expand Down

0 comments on commit d9bf5aa

Please sign in to comment.