i have simple code , strange error:
from abc import abcmeta, abstractmethod class cviterator(abcmeta): def __init__(self): self.n = none # value of n obtained in fit method return class kfold_new_version(cviterator): # new version of kfold def __init__(self, k): assert k > 0, valueerror('cannot have k below 1') self.k = k return cv = kfold_new_version(10) in [4]: --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-4-ec56652b1fdc> in <module>() ----> 1 __pyfile = open('''/tmp/py13196ibs''');exec(compile(__pyfile.read(), '''/home/donbeo/desktop/prova.py''', 'exec'));__pyfile.close() /home/donbeo/desktop/prova.py in <module>() 19 20 ---> 21 cv = kfold_new_version(10) typeerror: __new__() missing 2 required positional arguments: 'bases' , 'namespace' what doing wrong? theoretical explanation appreciated.
you used abcmeta meta class incorrectly. meta class, not base class. use such.
for python 2, means assigning __metaclass__ attribute on class:
class cviterator(object): __metaclass__ = abcmeta def __init__(self): self.n = none # value of n obtained in fit method in python 3, you'd use metaclass=... syntax when defining class:
class cviterator(metaclass=abcmeta): def __init__(self): self.n = none # value of n obtained in fit method
Comments
Post a Comment