Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build/helper/metadata_add_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def _add_complex_type(parameter):
parameter['complex_type'] = None


def _add_array_dimension(parameter):
'''Adds a array_dimension parameter to the metadata for multi dimensional arrays'''
if 'array_dimension' not in parameter:
parameter['array_dimension'] = 1
def _add_array_dimensions(parameter):
'''Adds a array_dimensions parameter to the metadata for multi dimensional arrays'''
if 'array_dimensions' not in parameter:
parameter['array_dimensions'] = 1


def _add_numpy_info(parameter, parameters, config):
Expand Down Expand Up @@ -463,7 +463,7 @@ def add_all_function_metadata(functions, config):
_add_ctypes_variable_name(p)
_add_ctypes_type(p, config)
_add_complex_type(p)
_add_array_dimension(p)
_add_array_dimensions(p)
_add_numpy_info(p, functions[f]['parameters'], config)
_add_default_value_name(p)
_add_default_value_name_for_docs(p, config['module_name'])
Expand Down
4 changes: 2 additions & 2 deletions build/templates/session.py/numpy_write_method.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
raise TypeError('${parameter['python_name']} must be in C-order')
if ${parameter['python_name']}.dtype is not numpy.dtype('${parameter['numpy_type']}'):
raise TypeError('${parameter['python_name']} must be numpy.ndarray of dtype=${parameter['numpy_type']}, is ' + str(${parameter['python_name']}.dtype))
if ${parameter['python_name']}.ndim != ${parameter['array_dimension']}:
raise TypeError('${parameter['python_name']} must be numpy.ndarray of dimension=${parameter['array_dimension']}, is ' + str(${parameter['python_name']}.ndim))
if ${parameter['python_name']}.ndim != ${parameter['array_dimensions']}:
raise TypeError('${parameter['python_name']} must be numpy.ndarray of dimension=${parameter['array_dimensions']}, is ' + str(${parameter['python_name']}.ndim))
% endfor
% for p in helper.filter_parameters(parameters, helper.ParameterUsageOptions.INTERPRETER_METHOD_CALL):
% if 'python_api_converter_name' in p:
Expand Down
28 changes: 14 additions & 14 deletions build/unit_tests/test_metadata_add_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'vi',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'name_ctype',
Expand Down Expand Up @@ -295,7 +295,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'name',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'pin_data_buffer_size_ctype',
Expand Down Expand Up @@ -333,7 +333,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': False,
'python_name_or_default_for_init': 'pin_data_buffer_size',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'python_code_input_ctype',
Expand Down Expand Up @@ -371,7 +371,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'python_code_input',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'None if actual_num_pin_data_ctype is None else (ctypes.pointer(actual_num_pin_data_ctype))',
Expand Down Expand Up @@ -409,7 +409,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': False,
'python_name_or_default_for_init': 'actual_num_pin_data',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'expected_pin_states_ctype',
Expand Down Expand Up @@ -449,7 +449,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'expected_pin_states',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'custom_type_input_ctype',
Expand Down Expand Up @@ -487,7 +487,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'custom_type_input',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'None if custom_type_output_ctype is None else (ctypes.pointer(custom_type_output_ctype))',
Expand Down Expand Up @@ -525,7 +525,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'custom_type_output',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'custom_type_without_struct_prefix_input_ctype',
Expand Down Expand Up @@ -563,7 +563,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'custom_type_without_struct_prefix_input',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'None if custom_type_without_struct_prefix_output_ctype is None else (ctypes.pointer(custom_type_without_struct_prefix_output_ctype))',
Expand Down Expand Up @@ -601,7 +601,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'custom_type_without_struct_prefix_output',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
],
'python_name': 'make_a_foo',
Expand Down Expand Up @@ -650,7 +650,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'vi',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'status_ctype',
Expand Down Expand Up @@ -688,7 +688,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'status',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'data_buffer_size_ctype',
Expand Down Expand Up @@ -726,7 +726,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': False,
'python_name_or_default_for_init': 'data_buffer_size',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
{
'ctypes_method_call_snippet': 'data_ctype',
Expand Down Expand Up @@ -765,7 +765,7 @@ def _compare_dicts(actual, expected):
'use_in_python_api': True,
'python_name_or_default_for_init': 'data',
'complex_type': None,
'array_dimension': 1,
'array_dimensions': 1,
},
],
'documentation': {
Expand Down
2 changes: 1 addition & 1 deletion src/nifake/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3027,7 +3027,7 @@
'numpy': True,
'use_numpy_array': True,
'use_in_python_api': True,
'array_dimension': 3
'array_dimensions': 3
},
],
'python_name': 'function_with_3d_numpy_array_of_numpy_complex128_input_parameter',
Expand Down
8 changes: 4 additions & 4 deletions src/nirfsg/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@
'use_array': False
},
{
'array_dimension': 3,
'array_dimensions': 3,
'complex_type': 'numpy',
'direction': 'in',
'documentation': {
Expand Down Expand Up @@ -2005,7 +2005,7 @@
'use_in_python_api': True
},
{
'array_dimension': 3,
'array_dimensions': 3,
'complex_type': 'numpy',
'direction': 'in',
'documentation': {
Expand Down Expand Up @@ -2079,7 +2079,7 @@
'use_in_python_api': True
},
{
'array_dimension': 2,
'array_dimensions': 2,
'complex_type': 'numpy',
'direction': 'out',
'documentation': {
Expand Down Expand Up @@ -2673,7 +2673,7 @@
'use_in_python_api': True
},
{
'array_dimension': 2,
'array_dimensions': 2,
'complex_type': 'numpy',
'direction': 'out',
'documentation': {
Expand Down
Loading