From 02059bffa5c464d27883d473da7c93f81c088a5b Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Tue, 1 Apr 2025 11:12:59 -0700 Subject: [PATCH 1/3] Make `data` input to `_compose_parser` optional This allows `g` aka `_create_register_reader` to take care of the path inference logic --- harp/reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harp/reader.py b/harp/reader.py index 590164c..de130ad 100644 --- a/harp/reader.py +++ b/harp/reader.py @@ -82,7 +82,7 @@ def _compose_parser( params: _ReaderParams, ) -> Callable[..., DataFrame]: def parser( - data, + data: Optional[Union[_FileLike, _BufferLike]] = None, columns: Optional[Axes] = None, epoch: Optional[datetime] = params.epoch, keep_type: bool = params.keep_type, From 6a882c275ae9320535da6ad8cf47b276a0a81726 Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Tue, 1 Apr 2025 14:24:30 -0700 Subject: [PATCH 2/3] Add unittest for registers with payload spec --- tests/data/device.yml | 16 ++++++++++++++++ tests/test_reader.py | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/tests/data/device.yml b/tests/data/device.yml index 583f290..636a6cf 100644 --- a/tests/data/device.yml +++ b/tests/data/device.yml @@ -24,6 +24,22 @@ registers: length: 3 access: Event description: Reports the current values of the analog input lines. + AnalogDataPayloadSpec: + address: 44 + type: S16 + length: 3 + access: Event + description: Reports the current values of the analog input lines. + payloadSpec: + AnalogInput0: + offset: 0 + description: The voltage at the output of the ADC channel 0. + Encoder: + offset: 1 + description: The quadrature counter value on Port 2 + AnalogInput1: + offset: 2 + description: The voltage at the output of the ADC channel 1. bitMasks: DigitalInputs: description: Specifies the state of the digital input lines. diff --git a/tests/test_reader.py b/tests/test_reader.py index 41c2776..0dc838f 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -16,6 +16,11 @@ expected_whoAmI=0, expected_registers=["AnalogData"], ), + DeviceSchemaParam( + path="data/device.yml", + expected_whoAmI=0, + expected_registers=["AnalogDataPayloadSpec"], + ), ] From 3ee94ae1f8491b4a135dd91d601777ca35b3bfa7 Mon Sep 17 00:00:00 2001 From: bruno-f-cruz <7049351+bruno-f-cruz@users.noreply.github.com> Date: Tue, 1 Apr 2025 14:33:43 -0700 Subject: [PATCH 3/3] Suppress `pyright` error on internal method import --- harp/io.py | 2 +- harp/reader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/harp/io.py b/harp/io.py index 5b9091b..2b750c0 100644 --- a/harp/io.py +++ b/harp/io.py @@ -6,7 +6,7 @@ import numpy as np import numpy.typing as npt import pandas as pd -from pandas._typing import Axes +from pandas._typing import Axes # pyright: ignore[reportPrivateImportUsage] from harp.typing import _BufferLike, _FileLike diff --git a/harp/reader.py b/harp/reader.py index de130ad..bcc76f6 100644 --- a/harp/reader.py +++ b/harp/reader.py @@ -10,7 +10,7 @@ from numpy import dtype from pandas import DataFrame, Series -from pandas._typing import Axes +from pandas._typing import Axes # pyright: ignore[reportPrivateImportUsage] from harp.io import MessageType, read from harp.model import BitMask, GroupMask, Model, PayloadMember, Register