Skip to content

Commit f6f4c53

Browse files
authored
Merge pull request #46 from harp-tech/fix-parser
Make `data` input to `_compose_parser` optional
2 parents 9d05b58 + 3ee94ae commit f6f4c53

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

harp/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import numpy.typing as npt
88
import pandas as pd
9-
from pandas._typing import Axes
9+
from pandas._typing import Axes # pyright: ignore[reportPrivateImportUsage]
1010

1111
from harp.typing import _BufferLike, _FileLike
1212

harp/reader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from numpy import dtype
1212
from pandas import DataFrame, Series
13-
from pandas._typing import Axes
13+
from pandas._typing import Axes # pyright: ignore[reportPrivateImportUsage]
1414

1515
from harp.io import MessageType, read
1616
from harp.model import BitMask, GroupMask, Model, PayloadMember, Register
@@ -82,7 +82,7 @@ def _compose_parser(
8282
params: _ReaderParams,
8383
) -> Callable[..., DataFrame]:
8484
def parser(
85-
data,
85+
data: Optional[Union[_FileLike, _BufferLike]] = None,
8686
columns: Optional[Axes] = None,
8787
epoch: Optional[datetime] = params.epoch,
8888
keep_type: bool = params.keep_type,

tests/data/device.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ registers:
2424
length: 3
2525
access: Event
2626
description: Reports the current values of the analog input lines.
27+
AnalogDataPayloadSpec:
28+
address: 44
29+
type: S16
30+
length: 3
31+
access: Event
32+
description: Reports the current values of the analog input lines.
33+
payloadSpec:
34+
AnalogInput0:
35+
offset: 0
36+
description: The voltage at the output of the ADC channel 0.
37+
Encoder:
38+
offset: 1
39+
description: The quadrature counter value on Port 2
40+
AnalogInput1:
41+
offset: 2
42+
description: The voltage at the output of the ADC channel 1.
2743
bitMasks:
2844
DigitalInputs:
2945
description: Specifies the state of the digital input lines.

tests/test_reader.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
expected_whoAmI=0,
1717
expected_registers=["AnalogData"],
1818
),
19+
DeviceSchemaParam(
20+
path="data/device.yml",
21+
expected_whoAmI=0,
22+
expected_registers=["AnalogDataPayloadSpec"],
23+
),
1924
]
2025

2126

0 commit comments

Comments
 (0)