Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes pointed out by Eclipse PyDev static code analysis #2942

Closed
wants to merge 9 commits into from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
.deps
.libs
.tox
.project
.pydevproject
.settings
cythonize.dat
_configtest.c
build.log
Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorial/csgraph.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Compressed Sparse Graph Routines `scipy.sparse.csgraph`
=======================================================
Compressed Sparse Graph Routines (`scipy.sparse.csgraph`)
=========================================================

.. sectionauthor:: Jake Vanderplas <vanderplas@astro.washington.edu>

Expand Down
2 changes: 1 addition & 1 deletion scipy/interpolate/fitpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ def dblint(xa,xb,ya,yb,tck):
The value of the resulting integral.
"""
tx,ty,c,kx,ky = tck
return dfitpack.dblint(tx,ty,c,kx,ky,xb,xe,yb,ye)
return dfitpack.dblint(tx,ty,c,kx,ky,xa,xb,ya,yb)


def insert(x,tck,m=1,per=0):
Expand Down
10 changes: 5 additions & 5 deletions scipy/spatial/kdtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,19 @@ def __init__(self, data, leafsize=10):
class node(object):
if sys.version_info[0] >= 3:
def __lt__(self, other):
id(self) < id(other)
return id(self) < id(other)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a unit test for this change would be in order.


def __gt__(self, other):
id(self) > id(other)
return id(self) > id(other)

def __le__(self, other):
id(self) <= id(other)
return id(self) <= id(other)

def __ge__(self, other):
id(self) >= id(other)
return id(self) >= id(other)

def __eq__(self, other):
id(self) == id(other)
return id(self) == id(other)

class leafnode(node):
def __init__(self, idx):
Expand Down
7 changes: 7 additions & 0 deletions scipy/spatial/tests/test_kdtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,13 @@ def test_ball_point_ints():
assert_equal(sorted([4, 8, 9, 12]),
sorted(tree.query_ball_point((2, 0), 1)))


def test_kdtree_comparisons():
"""Regression test: node comparisons were done wrong in 0.12 w/Py3."""
nodes = [KDTree.node() for _ in range(3)]
assert_equal(sorted(nodes), sorted(nodes[::-1]))


# cKDTree is specialized to type double points, so no need to make
# a unit test corresponding to test_ball_point_ints()

Expand Down
1 change: 0 additions & 1 deletion scipy/stats/mstats_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,6 @@ def ttest_ind(a, b, axis=0):
(n1, n2) = (a.count(axis), b.count(axis))
df = n1+n2-2
svar = ((n1-1)*v1+(n2-1)*v2) / float(df)
svar == 0
t = (x1-x2)/ma.sqrt(svar*(1.0/n1 + 1.0/n2)) # N-D COMPUTATION HERE!!!!!!
t = ma.filled(t, 1) # replace NaN t-values with 1.0
probs = betai(0.5*df,0.5,float(df)/(df+t*t)).reshape(t.shape)
Expand Down
3 changes: 0 additions & 3 deletions scipy/weave/base_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ def sources(self):
def define_macros(self):
return self.get_unique_values('define_macros')

def sources(self):
return self.get_unique_values('sources')

def warnings(self):
return self.get_unique_values('warnings')

Expand Down
2 changes: 1 addition & 1 deletion scipy/weave/cpp_namespace_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self,class_name=None):
def type_match(self,value):
try:
cpp_ident = value.split('_')[2]
if self.namespace in cpp.ident:
if self.namespace in cpp_ident:
return 1
except:
pass
Expand Down