1

class FileIO:
    file_name = "F:\CalgaryWeather.csv"
    data = np.loadtxt(file_name, delimiter=',' , skiprows = 1, dtype = np.float)

class Date:
    year = FileIO.data[:,0]
    month = FileIO.data[:,1]

class TemperautureData:
    maxTemp = FileIO.data[:,2]
    minTemp = FileIO.data[:,3]
    snowFall = FileIO.data[:,4]

class WeatherAnalyzer:
    def getmintemp():
        array1 = [TemperautureData.minTemp]
        mini = np.amin(array1)
        return mini

def main():
    print(WeatherAnalyzer.getmintemp())

if __name__ == "__main__":
    main()

The program runs but it says there is a problem with def getmintemp(): saying Method had no argument pylint(no-method-argument)[17,5]

Gabe Ngu
  • 21
  • 1
  • 1
    Does this answer your question? [What is the purpose of the word 'self'?](https://stackoverflow.com/questions/2709821/what-is-the-purpose-of-the-word-self) – MyNameIsCaleb Nov 24 '20 at 23:18
  • As an aside the use of classes here seems a bit odd, I would take another look at it if I were you. – AMC Nov 24 '20 at 23:26

2 Answers2

2

In Python, inside a class, methods are defined like that, with the 'self' argument: https://docs.python.org/3/tutorial/classes.html

class WeatherAnalyzer:
    def getmintemp(self):
        array1 = [TemperautureData.minTemp]
        mini = np.amin(array1)
        return mini
Malo
  • 1,233
  • 1
  • 8
  • 25
1

What you want is a static method:

class WeatherAnalyzer:

    @staticmethod
    def getmintemp():
        array1 = [TemperautureData.minTemp]
        mini = np.amin(array1)
        return mini
André Ginklings
  • 353
  • 1
  • 11