Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lang/en/typeshed/stdlib/random.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from typing import TypeVar, Sequence, Union, overload
def getrandbits(n: int) -> int:
"""Generate an integer with ``n`` random bits.

Example: ``urandom.getrandbits(1)``
Example: ``random.getrandbits(1)``

:param n: A value between 1-30 (inclusive).
"""
Expand All @@ -14,7 +14,7 @@ def getrandbits(n: int) -> int:
def seed(n: int) -> None:
"""Initialize the random number generator.

Example: ``urandom.seed(0)``
Example: ``random.seed(0)``

:param n: The integer seed

Expand All @@ -26,7 +26,7 @@ def seed(n: int) -> None:
def randint(a: int, b: int) -> int:
"""Choose a random integer between ``a`` and ``b`` inclusive.

Example: ``urandom.randint(0, 9)``
Example: ``random.randint(0, 9)``

:param a: Start value for the range (inclusive)
:param b: End value for the range (inclusive)
Expand All @@ -40,7 +40,7 @@ def randrange(stop: int) -> int:
"""Choose a randomly selected integer between zero and up to (but not
including) ``stop``.

Example: ``urandom.randrange(10)``
Example: ``random.randrange(10)``

:param stop: End value for the range (exclusive)
"""
Expand All @@ -51,7 +51,7 @@ def randrange(start: int, stop: int, step: int = 1) -> int:
"""
Choose a randomly selected element from ``range(start, stop, step)``.

Example: ``urandom.randrange(0, 10)``
Example: ``random.randrange(0, 10)``

:param start: The start of the range (inclusive)
:param stop: The end of the range (exclusive)
Expand All @@ -64,7 +64,7 @@ _T = TypeVar("_T")
def choice(seq: Sequence[_T]) -> _T:
"""Choose a random element from the non-empty sequence ``seq``.

Example: ``urandom.choice([Image.HAPPY, Image.SAD])``
Example: ``random.choice([Image.HAPPY, Image.SAD])``

:param seq: A sequence.

Expand All @@ -75,7 +75,7 @@ def choice(seq: Sequence[_T]) -> _T:
def random() -> float:
"""Generate a random floating point number in the range [0.0, 1.0).

Example: ``urandom.random()``
Example: ``random.random()``

:return: The random floating point number
"""
Expand All @@ -85,7 +85,7 @@ def uniform(a: float, b: float) -> float:
"""
Return a random floating point number between ``a`` and ``b`` inclusive.

Example: ``urandom.uniform(0, 9)``
Example: ``random.uniform(0, 9)``

:param a: Start value for the range (inclusive)
:param b: End value for the range (inclusive)
Expand Down
10 changes: 5 additions & 5 deletions lang/en/typeshed/stdlib/struct.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from typing import Any, Tuple, Union
def calcsize(fmt: str) -> int:
"""Get the number of bytes needed to store the given ``fmt``.

Example: ``ustruct.calcsize('hf')``
Example: ``struct.calcsize('hf')``

:param fmt: A format string.
:return The number of bytes needed to store such a value.
Expand All @@ -17,7 +17,7 @@ def calcsize(fmt: str) -> int:
def pack(fmt: str, v1: Any, *vn: Any) -> bytes:
"""Pack values according to a format string.

Example: ``ustruct.pack('hf', 1, 3.1415)``
Example: ``struct.pack('hf', 1, 3.1415)``

:param fmt: The format string.
:param v1: The first value.
Expand All @@ -31,7 +31,7 @@ def pack_into(
) -> None:
"""Pack values according to a format string.

Example: ``ustruct.pack_info('hf', buffer, 1, 3.1415)``
Example: ``struct.pack_info('hf', buffer, 1, 3.1415)``

:param fmt: The format string.
:param buffer: The target buffer to write into.
Expand All @@ -44,7 +44,7 @@ def pack_into(
def unpack(fmt: str, data: ReadableBuffer) -> Tuple[Any, ...]:
"""Unpack data according to a format string.

Example: ``v1, v2 = ustruct.unpack('hf', buffer)``
Example: ``v1, v2 = struct.unpack('hf', buffer)``

:param fmt: The format string.
:param data: The data.
Expand All @@ -55,7 +55,7 @@ def unpack(fmt: str, data: ReadableBuffer) -> Tuple[Any, ...]:
def unpack_from(fmt: str, buffer: ReadableBuffer, offset: int = 0) -> Tuple:
"""Unpack data from a buffer according to a format string.

Example: ``v1, v2 = ustruct.unpack_from('hf', buffer)``
Example: ``v1, v2 = struct.unpack_from('hf', buffer)``

:param fmt: The format string.
:param buffer: The source buffer to read from.
Expand Down
20 changes: 10 additions & 10 deletions lang/en/typeshed/stdlib/time.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def sleep(seconds: Union[int, float]) -> None:
"""
Delay a number of seconds.

Example: ``utime.sleep(1)``
Example: ``time.sleep(1)``

:param seconds: The number of seconds to sleep for.
Use a floating-point number to sleep for a fractional number of seconds.
Expand All @@ -18,7 +18,7 @@ def sleep_ms(ms: int) -> None:
"""
Delay for given number of milliseconds.

Example: ``utime.sleep_ms(1_000_000)``
Example: ``time.sleep_ms(1_000_000)``

:param ms: The number of milliseconds delay (>= 0).
"""
Expand All @@ -28,7 +28,7 @@ def sleep_us(us: int) -> None:
"""
Delay for given number of microseconds.

Example: ``utime.sleep_us(1000)``
Example: ``time.sleep_us(1000)``

:param us: The number of microseconds delay (>= 0).
"""
Expand All @@ -39,7 +39,7 @@ def ticks_ms() -> int:
Get an increasing, millisecond counter with an arbitrary reference point,
that wraps around after some value.

Example: ``utime.ticks_ms()``
Example: ``time.ticks_ms()``

:return: The counter value in milliseconds.
"""
Expand All @@ -50,7 +50,7 @@ def ticks_us() -> int:
Get an increasing, microsecond counter with an arbitrary reference point,
that wraps around after some value.

Example: ``utime.ticks_us()``
Example: ``time.ticks_us()``

:return: The counter value in microseconds.
"""
Expand All @@ -61,7 +61,7 @@ def ticks_add(ticks: int, delta: int) -> int:
Offset ticks value by a given number, which can be either positive or
negative.

Example: ``utime.ticks_add(utime.ticks_ms(), 200)``
Example: ``time.ticks_add(time.ticks_ms(), 200)``

Given a ticks value, this function allows to calculate ticks
value delta ticks before or after it, following modular-arithmetic
Expand All @@ -88,10 +88,10 @@ def ticks_add(ticks: int, delta: int) -> int:
def ticks_diff(ticks1: int, ticks2: int) -> int:
"""
Measure ticks difference between values returned from
``utime.ticks_ms()`` or ``ticks_us()``, as a signed value
``time.ticks_ms()`` or ``ticks_us()``, as a signed value
which may wrap around.

Example: ``utime.ticks_diff(scheduled_time, now)``
Example: ``time.ticks_diff(scheduled_time, now)``

:param ticks1: The value to subtract from
:param ticks2: The value to subtract
Expand All @@ -103,7 +103,7 @@ def ticks_diff(ticks1: int, ticks2: int) -> int:
patterns, among them:

Polling with timeout. In this case, the order of events is known, and you
will deal only with positive results of :func:`utime.ticks_diff()`::
will deal only with positive results of :func:`time.ticks_diff()`::

# Wait for GPIO pin to be asserted, but at most 500us
start = time.ticks_us()
Expand All @@ -112,7 +112,7 @@ def ticks_diff(ticks1: int, ticks2: int) -> int:
raise TimeoutError


Scheduling events. In this case, :func:`utime.ticks_diff()` result may be
Scheduling events. In this case, :func:`time.ticks_diff()` result may be
negative if an event is overdue::

# This code snippet is not optimized
Expand Down