Skip to content

Commit 3f2f99e

Browse files
committed
Changed NotImplemented to something that actually complains. Lack of this bit me.
1 parent 60a20a4 commit 3f2f99e

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

learning.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ def decision_list_learning(examples):
339339
def find_examples(examples):
340340
"""Find a set of examples that all have the same outcome under
341341
some test. Return a tuple of the test, outcome, and examples."""
342-
NotImplemented
342+
unimplemented()
343343

344344
def passes(example, test):
345345
"Does the example pass the test?"
346-
NotImplemented
346+
unimplemented()
347347

348348
def predict(example):
349349
"Predict the outcome for the first passing test."
@@ -363,24 +363,24 @@ def NeuralNetLearner(dataset, sizes):
363363
weights = []
364364

365365
def predict(example):
366-
NotImplemented
366+
unimplemented()
367367

368368
return predict
369369

370370
class NNUnit:
371371
"""Unit of a neural net."""
372372
def __init__(self):
373-
NotImplemented
373+
unimplemented()
374374

375375
def PerceptronLearner(dataset, sizes):
376376
def predict(example):
377377
return sum([])
378-
NotImplemented
378+
unimplemented()
379379
#______________________________________________________________________________
380380

381381
def Linearlearner(dataset):
382382
"""Fit a linear model to the data."""
383-
NotImplemented
383+
unimplemented()
384384
#______________________________________________________________________________
385385

386386
def EnsembleLearner(learners):
@@ -418,7 +418,7 @@ def train(dataset):
418418
return train
419419

420420
def WeightedMajority(h, z):
421-
raise NotImplementedError
421+
unimplemented()
422422

423423
#_____________________________________________________________________________
424424
# Functions for testing learners on examples

probability.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ def is_hidden(var, X, e):
303303
return var != X and var not in e
304304

305305
def Factor(var, e):
306-
NotImplemented
306+
unimplemented()
307307

308308
def pointwise_product(factors):
309-
NotImplemented
309+
unimplemented()
310310

311311
def sum_out(var, factors):
312-
NotImplemented
312+
unimplemented()
313313

314314
#______________________________________________________________________________
315315

rl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
class PassiveADPAgent(agents.Agent):
88
"""Passive (non-learning) agent that uses adaptive dynamic programming
99
on a given MDP and policy. [Fig. 21.2]"""
10-
NotImplementedError
10+
NotImplemented
1111

1212
class PassiveTDAgent(agents.Agent):
1313
"""Passive (non-learning) agent that uses temporal differences to learn
1414
utility estimates. [Fig. 21.4]"""
15-
NotImplementedError
15+
NotImplemented

search.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ def depth_first_graph_search(problem):
174174

175175
def breadth_first_search(problem):
176176
"Fig. 3.11"
177-
NotImplemented
177+
unimplemented()
178178

179179
def uniform_cost_search(problem):
180180
"Fig. 3.14"
181-
NotImplemented
181+
unimplemented()
182182

183183
def depth_limited_search(problem, limit=50):
184184
"[Fig. 3.17]"
@@ -302,15 +302,15 @@ def simulated_annealing(problem, schedule=exp_schedule()):
302302

303303
def and_or_graph_search(problem):
304304
"[Fig. 4.11]"
305-
NotImplemented
305+
unimplemented()
306306

307307
def online_dfs_agent(s1):
308308
"[Fig. 4.21]"
309-
NotImplemented
309+
unimplemented()
310310

311311
def lrta_star_agent(s1):
312312
"[Fig. 4.24]"
313-
NotImplemented
313+
unimplemented()
314314

315315
#______________________________________________________________________________
316316
# Genetic Algorithm

utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ def isin(elt, seq):
366366
# so there are three versions of argmin/argmax, depending on what you want to
367367
# do with ties: return the first one, return them all, or pick at random.
368368

369-
370369
def argmin(seq, fn):
371370
"""Return an element with lowest fn(seq[i]) score; tie goes to first one.
372371
>>> argmin(['one', 'to', 'three'], len)
@@ -526,6 +525,7 @@ def normalize(numbers):
526525
total = float(sum(numbers))
527526
return [n / total for n in numbers]
528527

528+
#______________________________________________________________________________
529529
## OK, the following are not as widely useful utilities as some of the other
530530
## functions here, but they do show up wherever we have 2D grids: Wumpus and
531531
## Vacuum worlds, TicTacToe and Checkers, and markov decision Processes.
@@ -655,6 +655,9 @@ def DataFile(name, mode='r'):
655655
"Return a file in the AIMA /data directory."
656656
return AIMAFile(['..', 'data', name], mode)
657657

658+
def unimplemented():
659+
"Use this as a stub for not-yet-implemented functions."
660+
raise NotImplementedError
658661

659662
#______________________________________________________________________________
660663
# Queues: Stack, FIFOQueue, PriorityQueue

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