Error with given arguments and numpy - Python
<p>I have the following father class and method:</p>

<pre><code>import SubImage
import numpy as np
from scipy import misc
import random

class Image():

    # Class constructor
    def __init__(self):
        self.__image = np.empty(0)
        self.__rows = 0
        self.__cols = 0
        self.__rows_pixels = 0
        self.__cols_pixels = 0
        self.__rows_quotient = 0.0
        self.__cols_quotient = 0.0
        self.__create_image()
        self.__subimages = np.empty((self.__rows, self.__cols))

    def __create_subimages(self):
        i = 0
        j = 0

        while i != self.__rows_quotient * self.__rows:
            print (i+j)
            sub_image = SubImage(self.__image[i:i + self.__rows_quotient, j:j + self.__cols_quotient], i + j)
            if j == self.__cols_quotient * (self.__cols - 1):
                j = 0
                i += self.__rows_quotient
            else:
                j += self.__cols_quotient
</code></pre>

<p>And the following subclass which is supposed to be a child from the class above:</p>

<pre><code>import Image

class SubImage(Image):

    def __init__(self, image, position):
        self.__position = position
        self.__image = image
</code></pre>

<p>My problem is that when creating a SubImage instance in the __create_subimages method I get the following error:</p>

<pre><code>File "/home/mitolete/PycharmProjects/myprojectSubImage.py", line 3, in &lt;module&gt;
    class SubImage(Image):
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)
</code></pre>

<p>I don't get why it says I'm giving 3 arguments, I'm giving 2 which is the subimage (a numpy array) and an integer.</p>

<p>WHy is this?</p>

<p>Regards and thanks.</p>

<p>If you're importing <code>SubImage</code> from another file, i.e. a module, you will have to reference that in the import. In this case, assuming <code>SubImage</code> is in a file called <code>SubImage.py</code>, the import should be</p>

<pre><code>from SubImage import SubImage
</code></pre>

<p>so that <code>SubImage</code> now refers to the class <code>SubImage</code> in <code>SubImage.py</code>. This is also the case for <code>Image</code> in <code>Image.py</code>.</p>

<p>However, I don't think there's a need to do this given how closely related the two classes are. I'd put them in the same file and avoid the circular import.</p>

python numpy arguments