Giter Site home page Giter Site logo

Incompatible with python 2.6 about py-statistics HOT 1 OPEN

mrname avatar mrname commented on September 17, 2024
Incompatible with python 2.6

from py-statistics.

Comments (1)

stefanocrosta avatar stefanocrosta commented on September 17, 2024

Ok, I see two things there:

  • with python >= 2.7 numbers come out (nicely?) rounded, but with py 2.6 they come out as floats and thus fail equality comparison
  • collections.Counter was introduced in python 2.7, so of course it's missing
    There's a backport of that: https://pypi.python.org/pypi/backport_collections/0.1

The second issue is thus easy to solve (I can add the backported package to the dependencies if the python version is <2.7).

The first issue seem related to the way that repr works in python 2.6 vs. 2.7

[https://docs.python.org/dev/whatsnew/2.7.html#python-3-1-features]: The repr() of a float x is shorter in many cases: it’s now based on the shortest decimal string that’s guaranteed to round back to x. As in previous versions of Python, it’s guaranteed that float(repr(x)) recovers x.

Simply try:

Python 2.6.9 (unknown, Sep  9 2014, 15:05:12)
[...]
>>> 2.6
2.6000000000000001

and

 Python 2.7.10 (default, Jul 13 2015, 12:05:58)
 [...]
 >>> 2.6
 2.6

(or see: http://stackoverflow.com/questions/20643386/floating-point-behavior-in-python-2-6-vs-2-7 )

To pass those tests, they should be written to print the same precision for py 2.6: '%.12g' % value

I'm not sure I care too much about that myself...
Though I understand that not everybody has the luxury to move to python 2.7

from py-statistics.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.