Skip to content

Commit

Permalink
used Sized for Progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Oct 16, 2024
1 parent 08bc488 commit 9b84cdb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spinn_utilities/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
# limitations under the License.

from collections import defaultdict
from collections.abc import Sized
from datetime import date
import logging
import math
import os
import sys
from typing import Dict, Iterable, List, TypeVar
from typing import Dict, Iterable, List, TypeVar, Union
from spinn_utilities.config_holder import get_config_bool
from spinn_utilities.log import FormatAdapter
from spinn_utilities.overrides import overrides
Expand Down Expand Up @@ -46,15 +47,14 @@ class ProgressBar(object):
"_step_character", "_end_character", "_in_bad_terminal",
)

def __init__(self, total_number_of_things_to_do,
def __init__(self, total_number_of_things_to_do: Union[int, Sized],
string_describing_what_being_progressed,
step_character="=", end_character="|"):
try:
self._number_of_things = int(total_number_of_things_to_do)
except TypeError:

# Might be dealing with general iterable; better not be infinite
self._number_of_things = len(list(total_number_of_things_to_do))
self._number_of_things = len(total_number_of_things_to_do)

self._currently_completed = 0
self._chars_per_thing = None
Expand Down

0 comments on commit 9b84cdb

Please sign in to comment.