Skip to content

Fix warning due to string comparison with `is` in Stats

Vicentini Filippo requested to merge github/fork/femtobit/fix-warnings into v3.0

Created by: femtobit

Strings should be compared with ==. Comparing with is checks for object identity. This works accidentally here but is not guaranteed to, because equal strings are not necessarily the same object. For this reason, the code produces warnings in Python 3.8.

Further, name is "mean" or "Mean" evaluates to True if name is "mean" but to "Mean" otherwise because it is parsed as

	(name is "mean") or "Mean"

which, while not breaking the code, is also unexpected.

In contrast, checking for membership with name in (...) also checks for equality (==).

(This PR also adds "R" as alias key for "R_hat", so that now all keys are backwards compatible with the v2 names.)

Merge request reports