Skip to content

Commit

Permalink
Fix parameter rosette_meas_types type in docstrings (#511)
Browse files Browse the repository at this point in the history
* Fixed rosette_meas_types in docstrings

* added enum parameter for rosetteMeasTypes

* fixed wrong import

* reverted numpy.array to numpy.int32

* removed comments in test case

* fixed mypy error
  • Loading branch information
WayneDroid authored Mar 12, 2024
1 parent ca462ac commit 0f65354
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 60 deletions.
11 changes: 6 additions & 5 deletions generated/nidaqmx/_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4411,17 +4411,17 @@ def read_ctr_ticks(
return read_array_high_ticks, read_array_low_ticks, samps_per_chan_read.value

def read_ctr_ticks_scalar(self, task, timeout):
high_ticks = ctypes.c_uint()
low_ticks = ctypes.c_uint()
high_ticks = ctypes.c_uint32()
low_ticks = ctypes.c_uint32()

cfunc = lib_importer.windll.DAQmxReadCtrTicksScalar
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_double,
ctypes.POINTER(ctypes.c_uint),
ctypes.POINTER(ctypes.c_uint),
ctypes.POINTER(ctypes.c_uint32),
ctypes.POINTER(ctypes.c_uint32),
ctypes.POINTER(c_bool32)]

error_code = cfunc(
Expand Down Expand Up @@ -6043,7 +6043,8 @@ def write_ctr_ticks_scalar(
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, c_bool32, ctypes.c_double,
ctypes.c_uint, ctypes.c_uint, ctypes.POINTER(c_bool32)]
ctypes.c_uint32, ctypes.c_uint32,
ctypes.POINTER(c_bool32)]

error_code = cfunc(
task, auto_start, timeout, high_ticks, low_ticks, None)
Expand Down
44 changes: 23 additions & 21 deletions generated/nidaqmx/_task_modules/ai_channel_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
ForceIEPESensorSensitivityUnits, ForceUnits, FrequencyUnits,
LVDTSensitivityUnits, LengthUnits, PressureUnits, RTDType,
RVDTSensitivityUnits, ResistanceConfiguration, ResistanceUnits,
SoundPressureUnits, StrainGageBridgeType, StrainGageRosetteType,
StrainUnits, TEDSUnits, TemperatureUnits, TerminalConfiguration,
ThermocoupleType, TorqueUnits, VelocityIEPESensorSensitivityUnits,
VelocityUnits, VoltageUnits)
SoundPressureUnits, StrainGageBridgeType,
StrainGageRosetteMeasurementType, StrainGageRosetteType, StrainUnits,
TEDSUnits, TemperatureUnits, TerminalConfiguration, ThermocoupleType,
TorqueUnits, VelocityIEPESensorSensitivityUnits, VelocityUnits,
VoltageUnits)


class AIChannelCollection(ChannelCollection):
Expand All @@ -40,8 +41,8 @@ def _create_chan(self, physical_channel, name_to_assign_to_channel=''):
name_to_assign_to_channel (Optional[str]): Specifies a name to
assign to the virtual channel this method creates.
Returns:
nidaqmx._task_modules.channels.ai_channel.AIChannel:
nidaqmx._task_modules.channels.ai_channel.AIChannel:
Specifies the newly created AIChannel object.
"""
if name_to_assign_to_channel:
Expand Down Expand Up @@ -539,8 +540,8 @@ def add_ai_force_bridge_polynomial_chan(
if reverse_coeffs is None:
reverse_coeffs = [0.0, 0.02]

forward_coeffs = numpy.float64(forward_coeffs)
reverse_coeffs = numpy.float64(reverse_coeffs)
forward_coeffs = numpy.array(forward_coeffs, dtype=numpy.float64)
reverse_coeffs = numpy.array(reverse_coeffs, dtype=numpy.float64)


self._interpreter.create_ai_force_bridge_polynomial_chan(
Expand Down Expand Up @@ -629,8 +630,8 @@ def add_ai_force_bridge_table_chan(
if physical_vals is None:
physical_vals = [-100.0, 0.0, 100.0]

electrical_vals = numpy.float64(electrical_vals)
physical_vals = numpy.float64(physical_vals)
electrical_vals = numpy.array(electrical_vals, dtype=numpy.float64)
physical_vals = numpy.array(physical_vals, dtype=numpy.float64)


self._interpreter.create_ai_force_bridge_table_chan(
Expand Down Expand Up @@ -1202,8 +1203,8 @@ def add_ai_pressure_bridge_polynomial_chan(
if reverse_coeffs is None:
reverse_coeffs = [0.0, 0.02]

forward_coeffs = numpy.float64(forward_coeffs)
reverse_coeffs = numpy.float64(reverse_coeffs)
forward_coeffs = numpy.array(forward_coeffs, dtype=numpy.float64)
reverse_coeffs = numpy.array(reverse_coeffs, dtype=numpy.float64)


self._interpreter.create_ai_pressure_bridge_polynomial_chan(
Expand Down Expand Up @@ -1294,8 +1295,8 @@ def add_ai_pressure_bridge_table_chan(
if physical_vals is None:
physical_vals = [-100.0, 0.0, 100.0]

electrical_vals = numpy.float64(electrical_vals)
physical_vals = numpy.float64(physical_vals)
electrical_vals = numpy.array(electrical_vals, dtype=numpy.float64)
physical_vals = numpy.array(physical_vals, dtype=numpy.float64)


self._interpreter.create_ai_pressure_bridge_table_chan(
Expand Down Expand Up @@ -1470,8 +1471,9 @@ def add_ai_rosette_strain_gage_chan(
and measurements.
gage_orientation (float): Specifies information about the
rosette configuration and measurements.
rosette_meas_types (List[int]): Specifies information about
the rosette configuration and measurements.
rosette_meas_types (List[nidaqmx.constants.StrainGageRosetteMeasurementType]):
Specifies information about the rosette configuration
and measurements.
name_to_assign_to_channel (Optional[str]): Specifies a name
to assign to the virtual channel this function creates.
If you do not specify a value for this input, NI-DAQmx
Expand Down Expand Up @@ -1507,7 +1509,7 @@ def add_ai_rosette_strain_gage_chan(
if rosette_meas_types is None:
rosette_meas_types = []

rosette_meas_types = numpy.int32(rosette_meas_types)
rosette_meas_types = numpy.array([p.value for p in rosette_meas_types], dtype=numpy.int32)


self._interpreter.create_ai_rosette_strain_gage_chan(
Expand Down Expand Up @@ -1926,8 +1928,8 @@ def add_ai_torque_bridge_polynomial_chan(
if reverse_coeffs is None:
reverse_coeffs = [0.0, 0.02]

forward_coeffs = numpy.float64(forward_coeffs)
reverse_coeffs = numpy.float64(reverse_coeffs)
forward_coeffs = numpy.array(forward_coeffs, dtype=numpy.float64)
reverse_coeffs = numpy.array(reverse_coeffs, dtype=numpy.float64)


self._interpreter.create_ai_torque_bridge_polynomial_chan(
Expand Down Expand Up @@ -2017,8 +2019,8 @@ def add_ai_torque_bridge_table_chan(
if physical_vals is None:
physical_vals = [-100.0, 0.0, 100.0]

electrical_vals = numpy.float64(electrical_vals)
physical_vals = numpy.float64(physical_vals)
electrical_vals = numpy.array(electrical_vals, dtype=numpy.float64)
physical_vals = numpy.array(physical_vals, dtype=numpy.float64)


self._interpreter.create_ai_torque_bridge_table_chan(
Expand Down
3 changes: 2 additions & 1 deletion generated/nidaqmx/_task_modules/triggering/start_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,8 @@ def cfg_dig_pattern_start_trig(

def cfg_time_start_trig(self, when, timescale=Timescale.USE_HOST):
"""
New Start Trigger
Configures the task to start acquiring or generating samples at
a specified time.
Args:
when (datetime): Specifies when to trigger.
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/system/physical_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def write_to_teds_from_array(
if bit_stream is None:
bit_stream = []

bit_stream = numpy.uint8(bit_stream)
bit_stream = numpy.array(bit_stream, dtype=numpy.uint8)


self._interpreter.write_to_teds_from_array(
Expand Down
29 changes: 9 additions & 20 deletions src/codegen/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@
}
],
'python_class_name': 'StartTrigger',
'python_description': 'New Start Trigger',
'python_description': 'Configures the task to start acquiring or generating samples at a specified time.',
'returns': 'int32'
},
'CfgWatchdogAOExpirStates': {
Expand Down Expand Up @@ -5364,13 +5364,14 @@
{
'ctypes_data_type': 'numpy.int32',
'direction': 'in',
'enum': 'StrainGageRosetteMeasurementType',
'has_explicit_buffer_size': True,
'is_list': True,
'is_optional_in_python': False,
'name': 'rosetteMeasTypes',
'python_data_type': 'int',
'python_data_type': 'StrainGageRosetteMeasurementType',
'python_description': 'Specifies information about the rosette configuration and measurements.',
'python_type_annotation': 'List[int]',
'python_type_annotation': 'List[nidaqmx.constants.StrainGageRosetteMeasurementType]',
'size': {
'mechanism': 'len',
'value': 'numRosetteMeasTypes'
Expand Down Expand Up @@ -18753,23 +18754,17 @@
'type': 'float64'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'ctypes_data_type': 'ctypes.c_uint32',
'direction': 'out',
'is_optional_in_python': False,
'name': 'highTicks',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'ctypes_data_type': 'ctypes.c_uint32',
'direction': 'out',
'is_optional_in_python': False,
'name': 'lowTicks',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
Expand Down Expand Up @@ -23806,7 +23801,7 @@
],
'python_class_name': 'Task',
'python_codegen_method': 'CustomCode',
'python_description': 'DAQmx Wait for Valid Timestamp',
'python_description': 'Wait until the specified timestamp has a value. Use this function to ensure the timestamp has a valid value to prevent an error when querying a timestamp value.',
'returns': 'int32'
},
'WaitUntilTaskDone': {
Expand Down Expand Up @@ -24675,23 +24670,17 @@
'type': 'float64'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'ctypes_data_type': 'ctypes.c_uint32',
'direction': 'in',
'is_optional_in_python': False,
'name': 'highTicks',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'ctypes_data_type': 'ctypes.c_uint32',
'direction': 'in',
'is_optional_in_python': False,
'name': 'lowTicks',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class AIChannelCollection(ChannelCollection):
name_to_assign_to_channel (Optional[str]): Specifies a name to
assign to the virtual channel this method creates.
Returns:
nidaqmx._task_modules.channels.ai_channel.AIChannel:
nidaqmx._task_modules.channels.ai_channel.AIChannel:

Specifies the newly created AIChannel object.
"""
if name_to_assign_to_channel:
Expand Down
17 changes: 12 additions & 5 deletions src/codegen/utilities/function_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,19 @@ def get_instantiation_lines(function_parameters):
for param in function_parameters:
if param.direction == "in":
if param.is_list:
if param.is_enum:
instantiation_lines.append(
"{0} = {1}([p.value for p in {0}])".format(
param.parameter_name, param.ctypes_data_type
if param.ctypes_data_type.startswith("numpy."):
if param.is_enum:
instantiation_lines.append(
"{0} = numpy.array([p.value for p in {0}], dtype={1})".format(
param.parameter_name, param.ctypes_data_type
)
)
else:
instantiation_lines.append(
"{0} = numpy.array({0}, dtype={1})".format(
param.parameter_name, param.ctypes_data_type
)
)
)
else:
instantiation_lines.append(
"{0} = {1}({0})".format(param.parameter_name, param.ctypes_data_type)
Expand Down
3 changes: 1 addition & 2 deletions tests/component/_task_modules/channels/test_ai_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,12 +844,11 @@ def test___task___add_ai_rosette_strain_gage_chan___sets_channel_attributes(
task: Task,
sim_bridge_device: Device,
) -> None:
# #483: add_ai_rosette_strain_gage_chan parameter rosette_meas_types has the wrong type
task.ai_channels.add_ai_rosette_strain_gage_chan(
",".join(sim_bridge_device.ai_physical_chans.channel_names[0:2]),
StrainGageRosetteType.TEE,
0.0,
[StrainGageRosetteMeasurementType.PRINCIPAL_STRAIN_1.value],
[StrainGageRosetteMeasurementType.PRINCIPAL_STRAIN_1],
)
chan: AIChannel = task.ai_channels["rosette0_principalStrain1"]
assert chan.ai_meas_type == UsageTypeAI.ROSETTE_STRAIN_GAGE
Expand Down
3 changes: 0 additions & 3 deletions tests/component/test_stream_writers_co.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def test___counter_writer___write_many_sample_pulse_frequency_with_wrong_dtype__
freq_dtype: numpy.typing.DTypeLike,
duty_cycle_dtype: numpy.typing.DTypeLike,
) -> None:

writer = CounterWriter(co_freq_task.out_stream)
samples_to_write = 10
frequencies = numpy.full(samples_to_write, math.inf, dtype=freq_dtype)
Expand Down Expand Up @@ -209,7 +208,6 @@ def test___counter_writer___write_many_sample_pulse_time_with_wrong_dtype___rais
high_time_dtype: numpy.typing.DTypeLike,
low_time_dtype: numpy.typing.DTypeLike,
) -> None:

writer = CounterWriter(co_time_task.out_stream)
samples_to_write = 10
high_times = numpy.full(samples_to_write, math.inf, dtype=high_time_dtype)
Expand Down Expand Up @@ -270,7 +268,6 @@ def test___counter_writer___write_many_sample_pulse_ticks_with_wrong_dtype___rai
high_ticks_dtype: numpy.typing.DTypeLike,
low_ticks_dtype: numpy.typing.DTypeLike,
) -> None:

writer = CounterWriter(co_ticks_task.out_stream)
samples_to_write = 10
high_ticks = numpy.full(samples_to_write, 0, dtype=high_ticks_dtype)
Expand Down

0 comments on commit 0f65354

Please sign in to comment.