cheatsheets icon indicating copy to clipboard operation
cheatsheets copied to clipboard

Variable names should generally be lowercase

Open timhoffm opened this issue 4 years ago • 3 comments

In many places we have uppercase variables, e.g.

X = np.linspace(0, 2 * np.pi, 100)
Y = np.sin(X)

and likewise then in the plot functions.

This is against PEP-8 naming conventions and IMHO sets a bad example. At least 1D arrays should be lowercase. One may debate on 2D arrays, which have a history of using uppercase letters in the Matplotlib docs.

timhoffm avatar Jul 25 '21 15:07 timhoffm

I use capital letters to indicate the variable is an array and I find this to be quite convenient. Since PEP-8 is a generic semantic-blind recommendation and I would prefer not to enforce it too strictly.

rougier avatar Jul 26 '21 09:07 rougier

I use capital letters to indicate the variable is an array

Numpy and matplotlib docs generally don't do this. Changing naming conventions (whether better or not) may be confusing.

timhoffm avatar Jul 26 '21 15:07 timhoffm

I think PEP-8 is confusing in that specific case. But ok to change names if really necessary.

rougier avatar Jul 26 '21 16:07 rougier