I have the following class and method:
class Basis(object):
def __init__(self, P = {'dimension': 1, 'generation':1}):
self.P = P
self.P['angle'] = np.pi/4
where P is a dict that does not include the 'angle', hence why I am setting it within the constructor (the angle is something fixed for now, but I might have it a user-defined funciton in the future).
Now I have a method:
def make_projection(self, dimension, angle = np.pi/4):
return (angle*3)
and I would like to set the default value of angle in this function to the self.P['angle'] defined in the constructor.
I do not want to use the self.P['angle'] within the main code of the function, as I might use the method on its own giving it a different angle.
If I just do: def make_projection(self, dimension, angle = self.P['angle']): , it underlines both self and I do not understand why.
--
Is this something I am allowed to do?