Skip to content

Commit 10d874f

Browse files
authored
Add periods to docstrings (#43)
1 parent d0e7d55 commit 10d874f

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

codetiming/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""A flexible, customizable timer for your Python code
1+
"""A flexible, customizable timer for your Python code.
22
33
You can use `codetiming.Timer` in several different ways:
44

codetiming/_timer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Definition of Timer
1+
"""Definition of Timer.
22
33
See help(codetiming) for quick instructions, and
44
https://pypi.org/project/codetiming/ for more details.
@@ -16,12 +16,12 @@
1616

1717

1818
class TimerError(Exception):
19-
"""A custom exception used to report errors in use of Timer class"""
19+
"""A custom exception used to report errors in use of Timer class."""
2020

2121

2222
@dataclass
2323
class Timer(ContextDecorator):
24-
"""Time your code using a class, context manager, or decorator"""
24+
"""Time your code using a class, context manager, or decorator."""
2525

2626
timers: ClassVar[Timers] = Timers()
2727
_start_time: Optional[float] = field(default=None, init=False, repr=False)
@@ -31,14 +31,14 @@ class Timer(ContextDecorator):
3131
last: float = field(default=math.nan, init=False, repr=False)
3232

3333
def start(self) -> None:
34-
"""Start a new timer"""
34+
"""Start a new timer."""
3535
if self._start_time is not None:
3636
raise TimerError("Timer is running. Use .stop() to stop it")
3737

3838
self._start_time = time.perf_counter()
3939

4040
def stop(self) -> float:
41-
"""Stop the timer, and report the elapsed time"""
41+
"""Stop the timer, and report the elapsed time."""
4242
if self._start_time is None:
4343
raise TimerError("Timer is not running. Use .start() to start it")
4444

@@ -65,10 +65,10 @@ def stop(self) -> float:
6565
return self.last
6666

6767
def __enter__(self) -> "Timer":
68-
"""Start a new timer as a context manager"""
68+
"""Start a new timer as a context manager."""
6969
self.start()
7070
return self
7171

7272
def __exit__(self, *exc_info: Any) -> None:
73-
"""Stop the context manager timer"""
73+
"""Stop the context manager timer."""
7474
self.stop()

codetiming/_timers.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Dictionary-like structure with information about timers"""
1+
"""Dictionary-like structure with information about timers."""
22

33
# Standard library imports
44
import collections
@@ -14,63 +14,63 @@
1414

1515

1616
class Timers(UserDict):
17-
"""Custom dictionary that stores information about timers"""
17+
"""Custom dictionary that stores information about timers."""
1818

1919
def __init__(self, *args: Any, **kwargs: Any) -> None:
2020
"""Add a private dictionary keeping track of all timings"""
2121
super().__init__(*args, **kwargs)
2222
self._timings: Dict[str, List[float]] = collections.defaultdict(list)
2323

2424
def add(self, name: str, value: float) -> None:
25-
"""Add a timing value to the given timer"""
25+
"""Add a timing value to the given timer."""
2626
self._timings[name].append(value)
2727
self.data.setdefault(name, 0)
2828
self.data[name] += value
2929

3030
def clear(self) -> None:
31-
"""Clear timers"""
31+
"""Clear timers."""
3232
self.data.clear()
3333
self._timings.clear()
3434

3535
def __setitem__(self, name: str, value: float) -> None:
36-
"""Disallow setting of timer values"""
36+
"""Disallow setting of timer values."""
3737
raise TypeError(
3838
f"{self.__class__.__name__!r} does not support item assignment. "
3939
"Use '.add()' to update values."
4040
)
4141

4242
def apply(self, func: Callable[[List[float]], float], name: str) -> float:
43-
"""Apply a function to the results of one named timer"""
43+
"""Apply a function to the results of one named timer."""
4444
if name in self._timings:
4545
return func(self._timings[name])
4646
raise KeyError(name)
4747

4848
def count(self, name: str) -> float:
49-
"""Number of timings"""
49+
"""Number of timings."""
5050
return self.apply(len, name=name)
5151

5252
def total(self, name: str) -> float:
53-
"""Total time for timers"""
53+
"""Total time for timers."""
5454
return self.apply(sum, name=name)
5555

5656
def min(self, name: str) -> float:
57-
"""Minimal value of timings"""
57+
"""Minimal value of timings."""
5858
return self.apply(lambda values: min(values or [0]), name=name)
5959

6060
def max(self, name: str) -> float:
61-
"""Maximal value of timings"""
61+
"""Maximal value of timings."""
6262
return self.apply(lambda values: max(values or [0]), name=name)
6363

6464
def mean(self, name: str) -> float:
65-
"""Mean value of timings"""
65+
"""Mean value of timings."""
6666
return self.apply(lambda values: statistics.mean(values or [0]), name=name)
6767

6868
def median(self, name: str) -> float:
69-
"""Median value of timings"""
69+
"""Median value of timings."""
7070
return self.apply(lambda values: statistics.median(values or [0]), name=name)
7171

7272
def stdev(self, name: str) -> float:
73-
"""Standard deviation of timings"""
73+
"""Standard deviation of timings."""
7474
if name in self._timings:
7575
value = self._timings[name]
7676
return statistics.stdev(value) if len(value) >= 2 else math.nan

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy