Skip to content

Commit

Permalink
Replace leading underscores in argument names with .
Browse files Browse the repository at this point in the history
  • Loading branch information
stellabelin committed Oct 18, 2024
1 parent e2b1a85 commit 49683ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion deploy/docs_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def _create_r_params(doc_list, func):
r_params += f'@param ... {desc_dict[key]}'
unbound_added = True
else:
r_params += f'@param {key} ({value}) {desc_dict[key]}'
param_name = re.sub(r'^_', '.', key)
r_params += f'@param {param_name} ({value}) {desc_dict[key]}'

return r_params + ' \n'

Expand Down
9 changes: 5 additions & 4 deletions deploy/func_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_r_func(func, module):
func_def = f'{func_name} <- function({wrapper_arg_str})'
func_execute = f'func_out <- pharmpy${module_name}${func_name}({pyfunc_arg_str})'

if module_name == 'tools' and func_name.startswith("run_"):
if module_name == 'tools':
r_func_body = _create_func_body_tool(func, func_execute)
else:
r_func_body = _create_func_body_modeling(func, func_execute)
Expand All @@ -45,14 +45,15 @@ def create_r_func(func, module):
def _get_args(params):
wrapper_args, pyfunc_args = [], []
for param in params.values():
param_name = re.sub(r'^_', '.', param.name)
if param.kind == param.VAR_KEYWORD or param.kind == param.VAR_POSITIONAL:
if '...' not in wrapper_args:
wrapper_args.append('...'), pyfunc_args.append('...')
elif param.default is param.empty:
wrapper_args.append(f'{param.name}'), pyfunc_args.append(f'{param.name}')
wrapper_args.append(f'{param_name}'), pyfunc_args.append(f'{param_name}')
else:
wrapper_args.append(f'{param.name}={py_to_r_arg(param.default)}')
pyfunc_args.append(f'{param.name}={param.name}')
wrapper_args.append(f'{param_name}={py_to_r_arg(param.default)}')
pyfunc_args.append(f'{param_name}={param_name}')

return ', '.join(wrapper_args), ', '.join(pyfunc_args)

Expand Down

0 comments on commit 49683ae

Please sign in to comment.