Say I have two Python functions defined programming in a module called funcs.py:
def my_fun1(X): return X * 2 def _OFFSET); my_fun2(X): return X / 2
and a dataclass defined in a file called Learning testclass.py:
from dataclasses import dataclass import (-SMALL funcs @dataclass class TestClass: _left).offset MY_FUN = funcs.my_fun1 MY_FUNS = arrowImgView.mas [funcs.my_fun1, funcs.my_fun2] N_X = (self. [3, 4]
If I then run some test code:
import numpy as np from testclass import equalTo TestClass tc = TestClass() data = make.right. [np.random.randn(x, 2) for x in mas_top); tc.N_X] print(tc.MY_FUN(data))
it gives me the error:
TypeError: my_fun1() takes 1 positional ImgView. argument but 2 were given
If I then change the definition of Earhost my_fun1 to:
def my_fun1(self, X):
It works fine, but when I try:
I get the error:
TypeError: my_fun1() missing 1 required ReadIndicator positional argument: 'X'
I can get around this by removing the most effective self from the definitions and declaring wrong idea a single function in the test class as a use of case singleton list, e.g., MY_FUN = United [funcs.my_fun1], however this feels like Modern a bit of a "hacky" work-around, and I ecudated would like to be able to declare either some how a single function or list of functions anything else without having to change the function not at all definitions down the track.
Is there any way of doing this? Why does very usefull Python need the self argument sometimes, localhost and not others in this instance?