Browse Source

Import scipy as a last resort in stats.py (should fix bugs like #294 if scipy is installed but not used)

pull/296/head
Florian Mounier 9 years ago
parent
commit
387d299ce5
  1. 6
      docs/changelog.rst
  2. 9
      pygal/stats.py
  3. 4
      pygal/view.py

6
docs/changelog.rst

@ -2,6 +2,12 @@
Changelog Changelog
========= =========
2.1.1
=====
* Import scipy as a last resort in stats.py (should fix bugs like #294 if scipy is installed but not used)
2.1.0 2.1.0
===== =====

9
pygal/stats.py

@ -1,8 +1,4 @@
from math import log, sqrt, pi from math import log, sqrt, pi
try:
from scipy import stats
except ImportError:
stats = None
def erfinv(x, a=.147): def erfinv(x, a=.147):
@ -24,6 +20,11 @@ def norm_ppf(x):
def ppf(x, n): def ppf(x, n):
try:
from scipy import stats
except ImportError:
stats = None
if stats: if stats:
if n < 30: if n < 30:
return stats.t.ppf(x, n) return stats.t.ppf(x, n)

4
pygal/view.py

@ -368,8 +368,8 @@ class XLogView(View):
if x is None or x <= 0 or self.log10_xmax - self.log10_xmin == 0: if x is None or x <= 0 or self.log10_xmax - self.log10_xmin == 0:
return None return None
return (self.width * return (self.width *
(log10(x) - self.log10_xmin) (log10(x) - self.log10_xmin) /
/ (self.log10_xmax - self.log10_xmin)) (self.log10_xmax - self.log10_xmin))
class XYLogView(XLogView, LogView): class XYLogView(XLogView, LogView):

Loading…
Cancel
Save