Skip to content

Commit 425aeb9

Browse files
Update examples to use non-u variants. (#55)
1 parent 9e2f184 commit 425aeb9

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

lang/en/typeshed/stdlib/random.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from typing import TypeVar, Sequence, Union, overload
55
def getrandbits(n: int) -> int:
66
"""Generate an integer with ``n`` random bits.
77
8-
Example: ``urandom.getrandbits(1)``
8+
Example: ``random.getrandbits(1)``
99
1010
:param n: A value between 1-30 (inclusive).
1111
"""
@@ -14,7 +14,7 @@ def getrandbits(n: int) -> int:
1414
def seed(n: int) -> None:
1515
"""Initialize the random number generator.
1616
17-
Example: ``urandom.seed(0)``
17+
Example: ``random.seed(0)``
1818
1919
:param n: The integer seed
2020
@@ -26,7 +26,7 @@ def seed(n: int) -> None:
2626
def randint(a: int, b: int) -> int:
2727
"""Choose a random integer between ``a`` and ``b`` inclusive.
2828
29-
Example: ``urandom.randint(0, 9)``
29+
Example: ``random.randint(0, 9)``
3030
3131
:param a: Start value for the range (inclusive)
3232
:param b: End value for the range (inclusive)
@@ -40,7 +40,7 @@ def randrange(stop: int) -> int:
4040
"""Choose a randomly selected integer between zero and up to (but not
4141
including) ``stop``.
4242
43-
Example: ``urandom.randrange(10)``
43+
Example: ``random.randrange(10)``
4444
4545
:param stop: End value for the range (exclusive)
4646
"""
@@ -51,7 +51,7 @@ def randrange(start: int, stop: int, step: int = 1) -> int:
5151
"""
5252
Choose a randomly selected element from ``range(start, stop, step)``.
5353
54-
Example: ``urandom.randrange(0, 10)``
54+
Example: ``random.randrange(0, 10)``
5555
5656
:param start: The start of the range (inclusive)
5757
:param stop: The end of the range (exclusive)
@@ -64,7 +64,7 @@ _T = TypeVar("_T")
6464
def choice(seq: Sequence[_T]) -> _T:
6565
"""Choose a random element from the non-empty sequence ``seq``.
6666
67-
Example: ``urandom.choice([Image.HAPPY, Image.SAD])``
67+
Example: ``random.choice([Image.HAPPY, Image.SAD])``
6868
6969
:param seq: A sequence.
7070
@@ -75,7 +75,7 @@ def choice(seq: Sequence[_T]) -> _T:
7575
def random() -> float:
7676
"""Generate a random floating point number in the range [0.0, 1.0).
7777
78-
Example: ``urandom.random()``
78+
Example: ``random.random()``
7979
8080
:return: The random floating point number
8181
"""
@@ -85,7 +85,7 @@ def uniform(a: float, b: float) -> float:
8585
"""
8686
Return a random floating point number between ``a`` and ``b`` inclusive.
8787
88-
Example: ``urandom.uniform(0, 9)``
88+
Example: ``random.uniform(0, 9)``
8989
9090
:param a: Start value for the range (inclusive)
9191
:param b: End value for the range (inclusive)

lang/en/typeshed/stdlib/struct.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from typing import Any, Tuple, Union
77
def calcsize(fmt: str) -> int:
88
"""Get the number of bytes needed to store the given ``fmt``.
99
10-
Example: ``ustruct.calcsize('hf')``
10+
Example: ``struct.calcsize('hf')``
1111
1212
:param fmt: A format string.
1313
:return The number of bytes needed to store such a value.
@@ -17,7 +17,7 @@ def calcsize(fmt: str) -> int:
1717
def pack(fmt: str, v1: Any, *vn: Any) -> bytes:
1818
"""Pack values according to a format string.
1919
20-
Example: ``ustruct.pack('hf', 1, 3.1415)``
20+
Example: ``struct.pack('hf', 1, 3.1415)``
2121
2222
:param fmt: The format string.
2323
:param v1: The first value.
@@ -31,7 +31,7 @@ def pack_into(
3131
) -> None:
3232
"""Pack values according to a format string.
3333
34-
Example: ``ustruct.pack_info('hf', buffer, 1, 3.1415)``
34+
Example: ``struct.pack_info('hf', buffer, 1, 3.1415)``
3535
3636
:param fmt: The format string.
3737
:param buffer: The target buffer to write into.
@@ -44,7 +44,7 @@ def pack_into(
4444
def unpack(fmt: str, data: ReadableBuffer) -> Tuple[Any, ...]:
4545
"""Unpack data according to a format string.
4646
47-
Example: ``v1, v2 = ustruct.unpack('hf', buffer)``
47+
Example: ``v1, v2 = struct.unpack('hf', buffer)``
4848
4949
:param fmt: The format string.
5050
:param data: The data.
@@ -55,7 +55,7 @@ def unpack(fmt: str, data: ReadableBuffer) -> Tuple[Any, ...]:
5555
def unpack_from(fmt: str, buffer: ReadableBuffer, offset: int = 0) -> Tuple:
5656
"""Unpack data from a buffer according to a format string.
5757
58-
Example: ``v1, v2 = ustruct.unpack_from('hf', buffer)``
58+
Example: ``v1, v2 = struct.unpack_from('hf', buffer)``
5959
6060
:param fmt: The format string.
6161
:param buffer: The source buffer to read from.

lang/en/typeshed/stdlib/time.pyi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def sleep(seconds: Union[int, float]) -> None:
77
"""
88
Delay a number of seconds.
99
10-
Example: ``utime.sleep(1)``
10+
Example: ``time.sleep(1)``
1111
1212
:param seconds: The number of seconds to sleep for.
1313
Use a floating-point number to sleep for a fractional number of seconds.
@@ -18,7 +18,7 @@ def sleep_ms(ms: int) -> None:
1818
"""
1919
Delay for given number of milliseconds.
2020
21-
Example: ``utime.sleep_ms(1_000_000)``
21+
Example: ``time.sleep_ms(1_000_000)``
2222
2323
:param ms: The number of milliseconds delay (>= 0).
2424
"""
@@ -28,7 +28,7 @@ def sleep_us(us: int) -> None:
2828
"""
2929
Delay for given number of microseconds.
3030
31-
Example: ``utime.sleep_us(1000)``
31+
Example: ``time.sleep_us(1000)``
3232
3333
:param us: The number of microseconds delay (>= 0).
3434
"""
@@ -39,7 +39,7 @@ def ticks_ms() -> int:
3939
Get an increasing, millisecond counter with an arbitrary reference point,
4040
that wraps around after some value.
4141
42-
Example: ``utime.ticks_ms()``
42+
Example: ``time.ticks_ms()``
4343
4444
:return: The counter value in milliseconds.
4545
"""
@@ -50,7 +50,7 @@ def ticks_us() -> int:
5050
Get an increasing, microsecond counter with an arbitrary reference point,
5151
that wraps around after some value.
5252
53-
Example: ``utime.ticks_us()``
53+
Example: ``time.ticks_us()``
5454
5555
:return: The counter value in microseconds.
5656
"""
@@ -61,7 +61,7 @@ def ticks_add(ticks: int, delta: int) -> int:
6161
Offset ticks value by a given number, which can be either positive or
6262
negative.
6363
64-
Example: ``utime.ticks_add(utime.ticks_ms(), 200)``
64+
Example: ``time.ticks_add(time.ticks_ms(), 200)``
6565
6666
Given a ticks value, this function allows to calculate ticks
6767
value delta ticks before or after it, following modular-arithmetic
@@ -88,10 +88,10 @@ def ticks_add(ticks: int, delta: int) -> int:
8888
def ticks_diff(ticks1: int, ticks2: int) -> int:
8989
"""
9090
Measure ticks difference between values returned from
91-
``utime.ticks_ms()`` or ``ticks_us()``, as a signed value
91+
``time.ticks_ms()`` or ``ticks_us()``, as a signed value
9292
which may wrap around.
9393
94-
Example: ``utime.ticks_diff(scheduled_time, now)``
94+
Example: ``time.ticks_diff(scheduled_time, now)``
9595
9696
:param ticks1: The value to subtract from
9797
:param ticks2: The value to subtract
@@ -103,7 +103,7 @@ def ticks_diff(ticks1: int, ticks2: int) -> int:
103103
patterns, among them:
104104
105105
Polling with timeout. In this case, the order of events is known, and you
106-
will deal only with positive results of :func:`utime.ticks_diff()`::
106+
will deal only with positive results of :func:`time.ticks_diff()`::
107107
108108
# Wait for GPIO pin to be asserted, but at most 500us
109109
start = time.ticks_us()
@@ -112,7 +112,7 @@ def ticks_diff(ticks1: int, ticks2: int) -> int:
112112
raise TimeoutError
113113
114114
115-
Scheduling events. In this case, :func:`utime.ticks_diff()` result may be
115+
Scheduling events. In this case, :func:`time.ticks_diff()` result may be
116116
negative if an event is overdue::
117117
118118
# This code snippet is not optimized

0 commit comments

Comments
 (0)