我将断点设置为第10行-使用以下代码:
ipdb> b 10
然后我运行以下内容以继续
ipdb> c
我认为这样做会在我设置的第10行的断点处停止
return self # line 10
但是,它将一直运行到最后。为什么?它不应该停在我设置的断点第10行吗?
代码(来自书本):
from sklearn.base import BaseEstimator, TransformerMixin
rooms_ix, bedrooms_ix, population_ix, household_ix = 3, 4, 5, 6
class CombinedAttributesAdder(BaseEstimator, TransformerMixin):
def __init__(self, add_bedrooms_per_room = True): # no *args or **kargs
import pdb; pdb.set_trace()
self.add_bedrooms_per_room = add_bedrooms_per_room
def fit(self, X, y=None):
return self # line 10
def transform(self, X, y=None):
rooms_per_household = X[:, rooms_ix] / X[:, household_ix]
population_per_household = X[:, population_ix] / X[:, household_ix]
if self.add_bedrooms_per_room:
bedrooms_per_room = X[:, bedrooms_ix] / X[:, rooms_ix]
return np.c_[X, rooms_per_household, population_per_household, bedrooms_per_room]
else:
return np.c_[X, rooms_per_household, population_per_household]
attr_adder = CombinedAttributesAdder(add_bedrooms_per_room=False)
谢谢