Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 081f6fa

Browse files
committed
Don't compare strings with 'is not'. (Broke things in pypy.) Also show Struct members in sorted order so doctests work in pypy.
1 parent 45d87a4 commit 081f6fa

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

learning.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def setproblem(self, target, inputs=None, exclude=()):
8383
self.inputs = removeall(self.target, inputs)
8484
else:
8585
self.inputs = [a for a in self.attrs
86-
if a is not self.target and a not in exclude]
86+
if a != self.target and a not in exclude]
8787
if not self.values:
8888
self.values = map(unique, zip(*self.examples))
8989
self.check_me()
@@ -137,7 +137,7 @@ def parse_csv(input, delim=','):
137137
>>> parse_csv('1, 2, 3 \n 0, 2, na')
138138
[[1, 2, 3], [0, 2, 'na']]
139139
"""
140-
lines = [line for line in input.splitlines() if line.strip() is not '']
140+
lines = [line for line in input.splitlines() if line.strip()]
141141
return [map(num_or_str, line.split(delim)) for line in lines]
142142

143143
#______________________________________________________________________________

search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def iterative_deepening_search(problem):
204204
"[Fig. 3.18]"
205205
for depth in xrange(sys.maxint):
206206
result = depth_limited_search(problem, depth)
207-
if result is not 'cutoff':
207+
if result != 'cutoff':
208208
return result
209209

210210
#______________________________________________________________________________

utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def __cmp__(self, other):
260260

261261
def __repr__(self):
262262
args = ['%s=%s' % (k, repr(v)) for (k, v) in vars(self).items()]
263-
return 'Struct(%s)' % ', '.join(args)
263+
return 'Struct(%s)' % ', '.join(sorted(args))
264264

265265
def update(x, **entries):
266266
"""Update a dict; or an object with slots; according to entries.

0 commit comments

Comments
 (0)