Skip to content
1 change: 0 additions & 1 deletion src/nitypes/waveform/_analog.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ def __init__(
of this array. If not specified, an ndarray is created based on the specified dtype,
start index, sample count, and capacity.
start_index: The sample index at which the analog waveform data begins.
sample_count: The number of samples in the analog waveform.
capacity: The number of samples to allocate. Pre-allocating a larger buffer optimizes
appending samples to the waveform.
extended_properties: The extended properties of the analog waveform.
Expand Down
1 change: 0 additions & 1 deletion src/nitypes/waveform/_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ def __init__(
of this array. If not specified, an ndarray is created based on the specified dtype,
start index, sample count, and capacity.
start_index: The sample index at which the waveform data begins.
sample_count: The number of samples in the waveform.
capacity: The number of samples to allocate. Pre-allocating a larger buffer optimizes
appending samples to the waveform.
extended_properties: The extended properties of the waveform.
Expand Down
15 changes: 11 additions & 4 deletions src/nitypes/waveform/_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def __init__(
of this array. If not specified, an ndarray is created based on the specified dtype,
start index, sample count, and capacity.
start_index: The sample index at which the waveform data begins.
sample_count: The number of samples in the waveform.
capacity: The number of samples to allocate. Pre-allocating a larger buffer optimizes
appending samples to the waveform.
extended_properties: The extended properties of the waveform.
Expand Down Expand Up @@ -456,6 +455,14 @@ def sample_count(self) -> int:
"""The number of samples in the waveform."""
return self._sample_count

@sample_count.setter
def sample_count(self, value: int) -> None:
"""Set the number of samples in the waveform."""
value = arg_to_uint("sample count", value)
if value <= 0:
raise ValueError("Sample count must be greater than zero.")
self._sample_count = value

@property
def capacity(self) -> int:
"""The total capacity available for waveform data.
Expand Down Expand Up @@ -506,14 +513,14 @@ def channel_name(self, value: str) -> None:
self._extended_properties[CHANNEL_NAME] = value

@property
def unit_description(self) -> str:
def units(self) -> str:
"""The unit of measurement, such as volts, of the waveform."""
value = self._extended_properties.get(UNIT_DESCRIPTION, "")
assert isinstance(value, str)
return value

@unit_description.setter
def unit_description(self, value: str) -> None:
@units.setter
def units(self, value: str) -> None:
if not isinstance(value, str):
raise invalid_arg_type("unit description", "str", value)
self._extended_properties[UNIT_DESCRIPTION] = value
Expand Down
7 changes: 3 additions & 4 deletions src/nitypes/waveform/_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ def __init__(
of this array. If not specified, an ndarray is created based on the specified dtype,
start index, sample count, and capacity.
start_index: The sample index at which the spectrum data begins.
sample_count: The number of samples in the spectrum.
capacity: The number of samples to allocate. Pre-allocating a larger buffer optimizes
appending samples to the spectrum.
start_frequency: The start frequency of the spectrum.
Expand Down Expand Up @@ -609,14 +608,14 @@ def channel_name(self, value: str) -> None:
self._extended_properties[CHANNEL_NAME] = value

@property
def unit_description(self) -> str:
def units(self) -> str:
"""The unit of measurement, such as volts, of the spectrum."""
value = self._extended_properties.get(UNIT_DESCRIPTION, "")
assert isinstance(value, str)
return value

@unit_description.setter
def unit_description(self, value: str) -> None:
@units.setter
def units(self, value: str) -> None:
if not isinstance(value, str):
raise invalid_arg_type("unit description", "str", value)
self._extended_properties[UNIT_DESCRIPTION] = value
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/waveform/test_analog_waveform.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,20 +944,20 @@ def test___invalid_type___set_channel_name___raises_type_error() -> None:
assert exc.value.args[0].startswith("The channel name must be a str.")


def test___waveform___set_unit_description___sets_extended_property() -> None:
def test___waveform___set_units___sets_extended_property() -> None:
waveform = AnalogWaveform()

waveform.unit_description = "Volts"
waveform.units = "Volts"

assert waveform.unit_description == "Volts"
assert waveform.units == "Volts"
assert waveform.extended_properties["NI_UnitDescription"] == "Volts"


def test___invalid_type___set_unit_description___raises_type_error() -> None:
def test___invalid_type___set_units___raises_type_error() -> None:
waveform = AnalogWaveform()

with pytest.raises(TypeError) as exc:
waveform.unit_description = None # type: ignore[assignment]
waveform.units = None # type: ignore[assignment]

assert exc.value.args[0].startswith("The unit description must be a str.")

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/waveform/test_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,20 +786,20 @@ def test___invalid_type___set_channel_name___raises_type_error() -> None:
assert exc.value.args[0].startswith("The channel name must be a str.")


def test___spectrum___set_unit_description___sets_extended_property() -> None:
def test___spectrum___set_units___sets_extended_property() -> None:
spectrum = Spectrum()

spectrum.unit_description = "Volts"
spectrum.units = "Volts"

assert spectrum.unit_description == "Volts"
assert spectrum.units == "Volts"
assert spectrum.extended_properties["NI_UnitDescription"] == "Volts"


def test___invalid_type___set_unit_description___raises_type_error() -> None:
def test___invalid_type___set_units___raises_type_error() -> None:
spectrum = Spectrum()

with pytest.raises(TypeError) as exc:
spectrum.unit_description = None # type: ignore[assignment]
spectrum.units = None # type: ignore[assignment]

assert exc.value.args[0].startswith("The unit description must be a str.")

Expand Down
Loading