Skip to content

Commit

Permalink
Finish nitclk unit tests (#1041)
Browse files Browse the repository at this point in the history
* Add initial metadata

* Create nitclk.mak

* Remove numpy restriction

Bug fixed

* Upgrade pip

* Remove specific version of flake8

'\' in comments now need to be escaped

* Add basepython section

* Try using pypy3.5

* Go back to pypy3 and remove basepython block

* Don't need to run build_test for all builds - only 3.6

* Remove warning from coverage

* Undo previous change

* Try disabling faulthandler

* Remove --no-faulthandler

* pypy needs an older version of pytest

See pytest-dev/pytest#5807

* Use platform_python_implementation since implementation_name is not defined on Python2

* Try to get back to the initial coverage

* Do the same thing for build_test

* Remove redundant pip

* Add codecov file to try to control limits for passing

* Enable nitclk build

* There are some files we will need to skip for now

* Add generated nitclk files

* Update generated files

* Can't skip README.rst

* Update templates

* Add new cases for buffers with a converter

* Need to handle ' []' to normalize everything

* Get the session handle name from config instead of hardcoding 'vi'

* Temp commit

* Fix syntax error

* Test new cases

* Force change

* Update generated files

* Update generated files

* Add different target for pr (project) and commit (patch)

* threshold should be number

* Renumber scaler cases to be in order used in the code

* Update generated files

* Renumber buffer cases to match order used in code

* Move and rename test to match case (C020)

* Update generated files

* Add nitclk specific session template

* No longer need to skip generating session.py

* Add new session.py

* Add placeholder nitclk example

* Enable example documentation build

* Add generated examples.rst

* Add VIUInt32 matcher

* Add ViSession buffer matcher

* We want to look at all of nitclk since there are differences in some of the generarted files

* Run unit tests on nitclk

* Add initial test and setup

* Update generated files

* Correct wrong exception

* Rename test

* Add return (helps editor auto formatting)

* Update generated files

* Few more tests

* Add new filter type

Needed for API functions in nitclk

* Don't try to use a singleton any more - didn't work

* Use new filter type

* All API functions tested

This covers both the api function and the helper class

* Update generated files

* Fix metadata for GetAttributeViString

* More tests!

* Correct type is ViSession

* Need to say it isn't the session handle

* Test class for testing session number converter

* Additional tests

* Update generated files

* We don't need to measure anything from nitclk or nimodinst other than session.py

* Fix class names to work with pytest

* Use correct name

* Don't codegen ViBoolean functions since they aren't actually used

* Update generated files

* Use the session name from config - doesn't always match the parameter name

* Update converter name

* Need a reperated capabilities for get/set attribute

* Function is now private

* Update generated files

* Update coverage target based on new tests

* Remove unused parameters

* Update docstring per review

* Update docstring per review

* Update comment per review

* Change class name

* Need to say not the session handle

* Update gnereated files

* Changed enum value per review

* Update docstring per review

* Make nidigital get/set ViSession attribute functions private

* Rename test class per review

* Update docstring per review

* Rename class used for testing

* Missing test

* Update generated files
  • Loading branch information
texasaggie97-zz authored and marcoskirsch committed Sep 24, 2019
1 parent d9f8327 commit 1d22f55
Show file tree
Hide file tree
Showing 16 changed files with 534 additions and 246 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ coverage:
threshhold: 5
patch:
default:
target: 20%
target: 85%
threshhold: 5


10 changes: 7 additions & 3 deletions build/helper/codegen_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
'skip_self': False,
'name_to_use': 'python_name_with_default',
},
ParameterUsageOptions.SESSION_METHOD_PASSTHROUGH_CALL: {
'skip_self': True,
'name_to_use': 'python_name',
},
ParameterUsageOptions.SESSION_INIT_DECLARATION: {
'skip_self': False,
'name_to_use': 'python_name_with_default',
Expand Down Expand Up @@ -191,7 +195,7 @@ def get_ctype_variable_declaration_snippet(parameter, parameters, ivi_dance_step
elif parameter['is_buffer'] is True:
definitions = _get_ctype_variable_definition_snippet_for_buffers(parameter, parameters, ivi_dance_step, use_numpy_array, custom_type, module_name)
else:
definitions = _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi_dance_step, module_name)
definitions = _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi_dance_step, module_name, config)

return definitions

Expand Down Expand Up @@ -253,7 +257,7 @@ def _get_ctype_variable_definition_snippet_for_string(parameter, parameters, ivi
return definitions


def _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi_dance_step, module_name):
def _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi_dance_step, module_name, config):
'''These are the different cases for initializing the ctype variable for scalars:
S110. Input session handle: visatype.ViSession(self._vi)
Expand Down Expand Up @@ -281,7 +285,7 @@ def _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi

if parameter['direction'] == 'in':
if parameter['is_session_handle'] is True:
definition = '{0}.{1}(self._{2}) # case S110'.format(module_name, parameter['ctypes_type'], parameter['python_name'])
definition = '{0}.{1}(self._{2}) # case S110'.format(module_name, parameter['ctypes_type'], config['session_handle_parameter_name'])
elif parameter['size']['mechanism'] == 'python-code':
definition = '{0}.{1}({2}) # case S120'.format(module_name, parameter['ctypes_type'], parameter['size']['value'])
elif parameter['enum'] is not None:
Expand Down
13 changes: 13 additions & 0 deletions build/helper/metadata_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
'mechanism': 'fixed, passed-in, len',
'python_api_list': True,
},
ParameterUsageOptions.SESSION_METHOD_PASSTHROUGH_CALL: {
'skip_session_handle': True,
'skip_input_parameters': False,
'skip_output_parameters': True,
'but_keep_output_numpy_array_parameters': False,
'skip_size_parameter': True,
'reordered_for_default_values': True,
'skip_repeated_capability_parameter': True,
'skip_non_enum_parameter': False,
'skip_all_except_numpy_parameters': False,
'mechanism': 'fixed, passed-in, len',
'python_api_list': True,
},
ParameterUsageOptions.SESSION_NUMPY_INTO_METHOD_DECLARATION: {
'skip_session_handle': True,
'skip_input_parameters': False,
Expand Down
2 changes: 2 additions & 0 deletions build/helper/parameter_usage_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ParameterUsageOptions(AutoNumber):

SESSION_METHOD_DECLARATION = ()
'''For declaring a regular method in Session'''
SESSION_METHOD_PASSTHROUGH_CALL = ()
'''Same as SESSION_METHOD_DECLARATION but without default values - For calling into Session using parameters of the same name and order that are simply passed through'''
SESSION_INIT_DECLARATION = ()
'''For declaring an init method in Session'''
SESSION_NUMPY_INTO_METHOD_DECLARATION = ()
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = '1.1.3.dev0'
release = '0.1.0.dev0'
# The short X.Y version.
version = release[:3]

Expand Down
68 changes: 0 additions & 68 deletions docs/nidigital/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1933,44 +1933,6 @@ get_attribute_vi_real64
get_attribute_vi_session
------------------------

.. py:currentmodule:: nidigital.Session
.. py:method:: get_attribute_vi_session(attribute)
TBD
.. tip:: This method requires repeated capabilities (channels). If called directly on the
nidigital.Session object, then the method will use all repeated capabilities in the session.
You can specify a subset of repeated capabilities using the Python index notation on an
nidigital.Session repeated capabilities container, and calling this method on the result.:
.. code:: python
session.channels[0,1].get_attribute_vi_session(property)
:param attribute:
:type attribute: int
:rtype: int
:return:
get_attribute_vi_string
-----------------------

Expand Down Expand Up @@ -3478,36 +3440,6 @@ set_attribute_vi_real64
:type value: float
set_attribute_vi_session
------------------------

.. py:currentmodule:: nidigital.Session
.. py:method:: set_attribute_vi_session(attribute)
TBD
.. tip:: This method requires repeated capabilities (channels). If called directly on the
nidigital.Session object, then the method will use all repeated capabilities in the session.
You can specify a subset of repeated capabilities using the Python index notation on an
nidigital.Session repeated capabilities container, and calling this method on the result.:
.. code:: python
session.channels[0,1].set_attribute_vi_session(property)
:param attribute:
:type attribute: int
set_attribute_vi_string
-----------------------

Expand Down
16 changes: 9 additions & 7 deletions generated/nidigital/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,8 @@ def get_attribute_vi_real64(self, attribute):
return float(value_ctype.value)

@ivi_synchronized
def get_attribute_vi_session(self, attribute):
r'''get_attribute_vi_session
def _get_attribute_vi_session(self, attribute):
r'''_get_attribute_vi_session
TBD
Expand All @@ -1030,7 +1030,7 @@ def get_attribute_vi_session(self, attribute):
You can specify a subset of repeated capabilities using the Python index notation on an
nidigital.Session repeated capabilities container, and calling this method on the result.:
session.channels[0,1].get_attribute_vi_session(property)
session.channels[0,1]._get_attribute_vi_session(property)
Args:
attribute (int):
Expand Down Expand Up @@ -1716,8 +1716,8 @@ def set_attribute_vi_real64(self, attribute, value):
return

@ivi_synchronized
def set_attribute_vi_session(self, attribute):
r'''set_attribute_vi_session
def _set_attribute_vi_session(self, attribute, value):
r'''_set_attribute_vi_session
TBD
Expand All @@ -1727,16 +1727,18 @@ def set_attribute_vi_session(self, attribute):
You can specify a subset of repeated capabilities using the Python index notation on an
nidigital.Session repeated capabilities container, and calling this method on the result.:
session.channels[0,1].set_attribute_vi_session(property)
session.channels[0,1]._set_attribute_vi_session(property, value)
Args:
attribute (int):
value (int):
'''
vi_ctype = _visatype.ViSession(self._vi) # case S110
channel_name_ctype = ctypes.create_string_buffer(self._repeated_capability.encode(self._encoding)) # case C010
attribute_ctype = _visatype.ViAttr(attribute) # case S150
value_ctype = _visatype.ViSession(self._value) # case S110
value_ctype = _visatype.ViSession(value) # case S150
error_code = self._library.niDigital_SetAttributeViSession(vi_ctype, channel_name_ctype, attribute_ctype, value_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return
Expand Down
18 changes: 0 additions & 18 deletions generated/nitclk/_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ def __init__(self, ctypes_library):
# We cache the cfunc object from the ctypes.CDLL object
self.niTClk_ConfigureForHomogeneousTriggers_cfunc = None
self.niTClk_FinishSyncPulseSenderSynchronize_cfunc = None
self.niTClk_GetAttributeViBoolean_cfunc = None
self.niTClk_GetAttributeViReal64_cfunc = None
self.niTClk_GetAttributeViSession_cfunc = None
self.niTClk_GetAttributeViString_cfunc = None
self.niTClk_GetExtendedErrorInfo_cfunc = None
self.niTClk_Initiate_cfunc = None
self.niTClk_IsDone_cfunc = None
self.niTClk_SetAttributeViBoolean_cfunc = None
self.niTClk_SetAttributeViReal64_cfunc = None
self.niTClk_SetAttributeViSession_cfunc = None
self.niTClk_SetAttributeViString_cfunc = None
Expand All @@ -52,14 +50,6 @@ def niTClk_FinishSyncPulseSenderSynchronize(self, session_count, sessions, min_t
self.niTClk_FinishSyncPulseSenderSynchronize_cfunc.restype = ViStatus # noqa: F405
return self.niTClk_FinishSyncPulseSenderSynchronize_cfunc(session_count, sessions, min_time)

def niTClk_GetAttributeViBoolean(self, session, channel_name, attribute_id, value): # noqa: N802
with self._func_lock:
if self.niTClk_GetAttributeViBoolean_cfunc is None:
self.niTClk_GetAttributeViBoolean_cfunc = self._library.niTClk_GetAttributeViBoolean
self.niTClk_GetAttributeViBoolean_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar), ViAttr, ctypes.POINTER(ViBoolean)] # noqa: F405
self.niTClk_GetAttributeViBoolean_cfunc.restype = ViStatus # noqa: F405
return self.niTClk_GetAttributeViBoolean_cfunc(session, channel_name, attribute_id, value)

def niTClk_GetAttributeViReal64(self, session, channel_name, attribute_id, value): # noqa: N802
with self._func_lock:
if self.niTClk_GetAttributeViReal64_cfunc is None:
Expand Down Expand Up @@ -108,14 +98,6 @@ def niTClk_IsDone(self, session_count, sessions, done): # noqa: N802
self.niTClk_IsDone_cfunc.restype = ViStatus # noqa: F405
return self.niTClk_IsDone_cfunc(session_count, sessions, done)

def niTClk_SetAttributeViBoolean(self, session, channel_name, attribute_id, value): # noqa: N802
with self._func_lock:
if self.niTClk_SetAttributeViBoolean_cfunc is None:
self.niTClk_SetAttributeViBoolean_cfunc = self._library.niTClk_SetAttributeViBoolean
self.niTClk_SetAttributeViBoolean_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar), ViAttr, ViBoolean] # noqa: F405
self.niTClk_SetAttributeViBoolean_cfunc.restype = ViStatus # noqa: F405
return self.niTClk_SetAttributeViBoolean_cfunc(session, channel_name, attribute_id, value)

def niTClk_SetAttributeViReal64(self, session, channel_name, attribute_id, value): # noqa: N802
with self._func_lock:
if self.niTClk_SetAttributeViReal64_cfunc is None:
Expand Down

0 comments on commit 1d22f55

Please sign in to comment.