Skip to content

Commit ecc6b75

Browse files
committed
Code tweak to '== None'
1 parent 488aebb commit ecc6b75

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

csp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def nconflicts(self, var, val, assignment):
7070
"Return the number of conflicts var=val has with other variables."
7171
# Subclasses may implement this more efficiently
7272
def conflict(var2):
73-
val2 = assignment.get(var2, None)
74-
return val2 != None and not self.constraints(var, val, var2, val2)
73+
return (var2 in assignment
74+
and not self.constraints(var, val, var2, assignment[var2]))
7575
return count_if(conflict, self.neighbors[var])
7676

7777
def display(self, assignment):

mdp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, grid, terminals, init=(0, 0), gamma=.9):
5959
self.states.add((x, y))
6060

6161
def T(self, state, action):
62-
if action == None:
62+
if action is None:
6363
return [(0.0, state)]
6464
else:
6565
return [(0.8, self.go(state, action)),

search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def recursive_dls(node, problem, limit):
193193
result = recursive_dls(successor, problem, limit)
194194
if result == 'cutoff':
195195
cutoff_occurred = True
196-
elif result != None:
196+
elif result is not None:
197197
return result
198198
return if_(cutoff_occurred, 'cutoff', None)
199199

utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def mean(values):
481481
def stddev(values, meanval=None):
482482
"""The standard deviation of a set of values.
483483
Pass in the mean if you already know it."""
484-
if meanval == None: meanval = mean(values)
484+
if meanval is None: meanval = mean(values)
485485
return math.sqrt(sum([(x - meanval)**2 for x in values]) / (len(values)-1))
486486

487487
def dotproduct(X, Y):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy