Skip to content

Commit

Permalink
fixing all the docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Relm-Arrowny committed Apr 18, 2024
1 parent a47f96b commit cac9b01
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions src/ophyd_async/core/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,27 @@ async def _verify_readings(
expectation: Mapping[str, Reading],
) -> None:
"""Take a read/read_configuration function that return a dictionary and
compare it with the expected result (expectation)
compare it with the expected result (expectation)
Parameters
----------
func:
read/read_configuration function, call at the start
and results is validate with the expectation.
read/read_configuration function.
expectation:
The expected value from the readable/Configurable.
Notes
-----
Example usage::
await assert_reading(signal, value)
await _verify_readings(readable.read, reading)
Or::
await _verify_readings(configurable.read_configuration, configuration)
Future::
func will only be Waitable in the future and the if loop can be removed:
result = func()
"""
if asyncio.iscoroutinefunction(func):
result = await func()
Expand All @@ -287,34 +294,31 @@ async def _verify_readings(


async def assert_value(signal: SignalR[T], value: T) -> None:
"""Assert a signal value
"""Assert a signal's value and compare it an expected signal.
Parameters
----------
signal:
Call signal.get_value and compare it with expected value.
signal with get_value.
value:
The expected value from the signal.
Notes
-----
Example usage::
await _verify_readings(readable.read, reading)
Or::
await _verify_readings(configurable.read_configuration, configuration)
await assert_value(signal, value)
"""
assert await signal.get_value() == value


async def assert_reading(readable: Readable, reading: Dict[str, Reading]) -> None:
"""Assert readable by calling_verify_readings
"""Assert readings from readable.
Parameters
----------
readable:
Call readable.read and compare it with expected reading.
Callable with readable.read function that generate readings.
reading:
The expected readings from the readable.
Expand All @@ -332,17 +336,15 @@ async def assert_configuration(
configurable: Configurable,
configuration: Mapping[str, Reading],
) -> None:
"""
Assert configurable generated by configurable.read_configuration by
using _verify_readings
"""Assert readings from Configurable.
Parameters
----------
configurable:
Call configurable.read_configuration and compare it with expected configuration.
Configurable with Configurable.read function that generate readings.
configuration:
The expected readings from the configurable.
The expected readings from configurable.
Notes
-----
Expand All @@ -354,7 +356,22 @@ async def assert_configuration(


def assert_emitted(docs: Mapping[str, list[DocumentType]], **numbers: int):
"""Assert emitted"""
"""Assert emitted document generated by running a Bluesky plan
Parameters
----------
Doc:
A dictionary
numbers:
expected emission in kwarg from
Notes
-----
Example usage::
assert_emitted(docs, start=1, descriptor=1,
resource=1, datum=1, event=1, stop=1)
"""
assert list(docs) == list(numbers)
assert {name: len(d) for name, d in docs.items()} == numbers

Expand Down

0 comments on commit cac9b01

Please sign in to comment.