[issue33573] statistics.median does not work with ordinal scale
W deW added the comment: Changing the documentation in tis way seems to me an excellent and easy way to solve the issue. -- ___ Python tracker <https://bugs.python.org/issue33573> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33573] statistics.median does not work with ordinal scale
New submission from W deW : The 0.5-quantile or median is defined for ordinal, interval, and ratio scales. An Enumerator as derived from Enum and extended with rich comparison methods implements an ordinal scale. Therefore calculating the median over a list of such enum-elements ought to be possible. The current implementation tries to interpolate the median value by averaging the two middle observations. This is allowed for interval and ratio scales, but since this interpolation involves an addition, not so for ordinal scales. Although computationally it is possible to do this for numeric ordinal variables, logically it is non-sense for the distance between ordinal values is - by definition - unknown. On non-numeric ordinal values it is even computationally impossible. The correct return value would be: the first value in an ordered set where al least half the number of observations is smaller or equal than it. This is observation[len(observation)//2] for odd and even length ordered lists of values. Whether the same applies to interval and ratio scales is a matter of opinion. The currently implemented algorith definitely is more popular these days. -- components: Library (Lib) files: testMedian.py messages: 317048 nosy: W deW priority: normal severity: normal status: open title: statistics.median does not work with ordinal scale type: crash versions: Python 3.4 Added file: https://bugs.python.org/file47601/testMedian.py ___ Python tracker <https://bugs.python.org/issue33573> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25205] setattr accepts invalid identifiers
W deW added the comment: Thanks for the ref to issue14029. I think I see how it works. As long as the object's __dict__ accepts the attributeName as a key, it needs not be a valid string nor a string at all. Though the latter *is* checked for, and that in turn can be circumvented by adding the attribute to the __dict__ directly. An object can be made attribute to itself. However, the documentation falls short here. So far, I haven't found where it defines "attribute". Is there any point in defining an attribute that cannot be addressed as an attribute if the parser doesn't allow it? It seems to me that in order to catch programing errors early, the default behaviour should include checking the valid syntax of the attribute's name. -- components: -Documentation versions: +Python 2.7 ___ Python tracker <http://bugs.python.org/issue25205> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25205] setattr accepts invalid identifiers
New submission from W deW: An identifier is defined by identifier ::= (letter|"_") (letter | digit | "_")* setattr accepts identifiers that do not meet this criterion: Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class C(object): pass ... >>> o=C() >>> setattr(o, "$$$", True) >>> dir(o) ['$$$', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__in module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__su __', '__weakref__'] >>> o.$$$ File "", line 1 o.$$$ ^ SyntaxError: invalid syntax >>> -- components: Interpreter Core messages: 251248 nosy: W deW priority: normal severity: normal status: open title: setattr accepts invalid identifiers type: behavior versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue25205> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com