I'm writing some code and trying to break it into classes as I go. I'm pretty new to OOP and am having some trouble getting what I've written to work. I'm having to write it in Python 2.7 as some of the packages I'm using later don't have Python 3 compatibility.
Am I going overboard on the inheritance? I basically want the Timeseries class to be able to use all variables and parameters attached to the Reanalysis object, but only get the node_coordinates back.
class Reanalysis():
"""Initiates a reanalysis object"""
def __init__(self, latitude, longitude, resolution):
self.datetime_format = '%Y-%B-%d %H:%M'
self.lat = latitude
self.lon = longitude
self.res = resolution
self.node_coordinates = Timeseries().node_coordinates
class Timeseries(Reanalysis):
def __init__(self):
super(Timeseries, self).__init__()
self.get_node_coordinates()
def get_node_coordinates(self):
"""Determines node coordinates
"""
latres = self.res
lonres = self.res
self.node_coordinates = set([(latres * np.floor(self.lat / latres),
lonres * np.floor(self.lon / lonres)),
(latres * np.ceil(self.lat / latres),
lonres * np.floor(self.lon / lonres)),
(latres * np.floor(self.lat / latres),
lonres * np.ceil(self.lon / lonres)),
(latres * np.ceil(self.lat / latres),
lonres * np.ceil(self.lon / lonres))])
When I try to compile I get the error:
super(Timeseries, self).__init__()
TypeError: must be type, not classobj
Thanks