Issue 3123 in sympy: Naming conventions in sympy/stats/

3 views
Skip to first unread message

sy...@googlecode.com

unread,
Mar 1, 2012, 3:32:36 PM3/1/12
to sympy-...@googlegroups.com
Status: Accepted
Owner: ----
Labels: Type-Defect Priority-High Milestone-Release0.7.2 Statistics

New issue 3123 by Ronan.L...@gmail.com: Naming conventions in sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

There are a number of PEP8-violating names in sympy.stats:

* Density, Where, Given, Sample, CDF, Skewness: these are functions, so
their name should be lowercase.
* Covar: the conventional notation is Cov, not Covar.
* P, E: these names are too short. It's debatable whether P and E are
appropriate shortcuts, but they are clearly unsuitable as primary names
shown in documentation and tracebacks.

sy...@googlecode.com

unread,
Mar 1, 2012, 10:16:26 PM3/1/12
to sympy-...@googlegroups.com
Updates:
Cc: MRock...@gmail.com

Comment #1 on issue 3123 by asme...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

(No comment was entered for this change.)

sy...@googlecode.com

unread,
Mar 4, 2012, 11:04:46 AM3/4/12
to sympy-...@googlegroups.com

Comment #2 on issue 3123 by MRock...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

* Density, Where, Given, Sample, CDF, Skewness: these are functions, so

their name should be lowercase

These were originally intended to be classnames like Add, Mul. I'm not sure
that that's the plan any longer. I agree that these should be changed

* Covar: the conventional notation is Cov, not Covar.

agreed


* P, E: these names are too short. It's debatable whether P and E are
appropriate shortcuts, but they are clearly unsuitable as primary names
shown in documentation and tracebacks.

I strongly believe that at least the user interface should include these
function names. P(X>1) looks good enough to warrant the deviation from
style. These functions are also not in the general sympy namespace so its a
bit less important. Making them aliases to other more verbosely named
functions seems like a good compromise.

I'll get to this in a week or two if no one else does beforehand.

sy...@googlecode.com

unread,
Mar 7, 2012, 1:48:35 AM3/7/12
to sympy-...@googlegroups.com

Comment #3 on issue 3123 by nathan.f...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

But E is euler's constant. If we don't want one letter names for P, I think
I've seen Pr used to denote probability. If not, Prob maybe? Exp would
cause confusion with exp. What about Ex?

E->Ex->Exp->Expectation
P->Pr->Prob->Probability

I like the two letter names--unambiguous but still short.

sy...@googlecode.com

unread,
Mar 12, 2012, 7:09:22 PM3/12/12
to sympy-...@googlegroups.com

Comment #4 on issue 3123 by MRock...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

For me making code look like math is a high priority. E and P are the
standard ways to represent expectation and probability and so I'll back
them to the extent that they don't cause big upsets.

I think it's ok if we collide with other SymPy names because we're in a
module, not the core. If sympy.stats were to be part of the core or
imported by default then it would be very different.

sy...@googlecode.com

unread,
Mar 14, 2012, 1:32:44 PM3/14/12
to sympy-...@googlegroups.com
Updates:
Status: Started
Owner: MRock...@gmail.com

Comment #5 on issue 3123 by MRock...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

https://github.com/sympy/sympy/pull/1122

sy...@googlecode.com

unread,
Mar 17, 2012, 12:57:55 PM3/17/12
to sympy-...@googlegroups.com

Comment #6 on issue 3123 by MRock...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

Questions:

What should we do with var?
Var violates PEP8
var conflicts with sympy.var

I think the options are to go ahead and conflict with var or to just use
the full name, variance.

Depending on this choice we'll probably change Covar/covar/cov/covariance
to match

There is a pull request linked above. If no one comments in the couple days
I'll probably use variance/covariance and merge.

sy...@googlecode.com

unread,
Mar 18, 2012, 10:25:01 PM3/18/12
to sympy-...@googlegroups.com

Comment #7 on issue 3123 by asme...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

Var() seems fine to me, especially if you're going to keep using short
names for everything else.

There's no reason why you can't have both long and short names, too. Just
define it as the long name in the file and do shortname = longname.

sy...@googlecode.com

unread,
Mar 18, 2012, 10:29:06 PM3/18/12
to sympy-...@googlegroups.com

Comment #8 on issue 3123 by MRock...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

The issue with Var is that it violates PEP8. If we decide to go ahead with
capitalized Var then should we also do capitalized Cov, Std, Skewness,
Density, Sample, Given etc...?

It seems to me that using plain variance is simpler. This is also the
solution that makes the fewest choices. We can add aliases in the future
but can't take them away. In any event this isn't that big of a deal. I
just want to make things reasonable for the .72 release.

sy...@googlecode.com

unread,
Jun 25, 2012, 10:45:49 AM6/25/12
to sympy-...@googlegroups.com

Comment #9 on issue 3123 by MRock...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

PR 1122 was merged a while ago. The current names are
density, where, sample, given, variance, covariance
probability aliased to P
expectation aliased to E

I'd like to close this issue if everyone accepts these names

sy...@googlecode.com

unread,
Aug 8, 2012, 10:27:33 AM8/8/12
to sympy-...@googlegroups.com
Updates:
Status: Fixed

Comment #10 on issue 3123 by MRock...@gmail.com: Naming conventions in
sympy/stats/
http://code.google.com/p/sympy/issues/detail?id=3123

Marking this as fixed.

Reply all
Reply to author
Forward
0 new messages