I am looking to essentially create a new method and replace the old method. All I am changing is the size of the range by 3 at the minimum and maximum.
The method in_range in the object power_spectrum in this library is
def in_range(self, frequency_min, frequency_max):
"""Returns part of the power spectrum within a given frequency range."""
ir = copy(self)
mask = (self.frequency > frequency_min) & (self.frequency <= frequency_max)
ir.frequency = self.frequency[mask]
ir.power = self.power[mask]
return irtype here
I wanted to increase the range by 3 on each side and replace the original method so I made a new method and tried to apply it to the object like below
def in_range(self, frequency_min, frequency_max):
ir = list.copy(self)
mask = (self.frequency > frequency_min - 3) & (self.frequency <= frequency_max + 3)
ir.frequency = self.frequency[mask]
ir.power = self.power[mask]
return ir
power_spectrum.in_range = in_range
I got an error: plot_power_spectrum..in_range() missing 1 required positional argument: 'frequency_max'
Then checked the method with print(inspect.getsource(power_spectrum.in_range))
and it showed this.
def in_range(self, frequency_min, frequency_max):
"""Returns part of the power spectrum within a given frequency range."""
ir = copy(self)
mask = (self.frequency > frequency_min) & (self.frequency <= frequency_max)
ir.frequency = self.frequency[mask]
ir.power = self.power[mask]
return ir
def in_range(self, frequency_min, frequency_max):
ir = list.copy(self)
mask = (self.frequency > frequency_min - 3) & (self.frequency <= frequency_max + 3)
ir.frequency = self.frequency[mask]
ir.power = self.power[mask]
return ir
So it just added it to the end of the old method instead of replacing it which is not what I wanted to do.