Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GetValidName() throughout Python bindings #3302

Merged
merged 3 commits into from Nov 7, 2022

Conversation

rcurtin
Copy link
Member

@rcurtin rcurtin commented Nov 1, 2022

@NippunSharma added a function called GetValidName(), which maps binding parameters from their given name to a name suitable for Python:

inline std::string GetValidName(const std::string& paramName)
{
std::string correctParamName = paramName;
if(paramName == "lambda") correctParamName = "lambda_";
else if(paramName == "input") correctParamName = "input_";
else correctParamName = paramName;
return correctParamName;
}

Specifically, this maps lambda to lambda_, since lambda is a reserved keyword in Python, and it also maps input to input_, since input() is a builtin function in Python.

This PR changes all of our documentation functions in Python to use GetValidName(), instead of manually making the same change for lambda to lambda_ everywhere. After this PR is merged, the documentation will correctly reflect the input_ name instead of input; that is, the documentation is currently being printed incorrectly. It confused me for a few minutes while I was debugging the Python bindings. :)

Copy link

@mlpack-bot mlpack-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second approval provided automatically after 24 hours. 👍

@rcurtin rcurtin merged commit 817a83b into mlpack:master Nov 7, 2022
@rcurtin rcurtin deleted the fix-input-python-param branch November 7, 2022 14:26
@rcurtin rcurtin mentioned this pull request Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants