51
Inheritance Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution Lice See http://software-carpentry.org/license.html for more informati Classes and Objects

Inheritance Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See

Tags:

Embed Size (px)

Citation preview

  • Slide 1

Inheritance Copyright Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information. Classes and Objects Slide 2 Inheritance Interpolating time series signals time strength Slide 3 Classes and ObjectsInheritance Interpolating time series signals time strength step function linear interpolation Slide 4 Classes and ObjectsInheritance Interpolating time series signals time strength step function linear interpolation A lot of the implementation is the same Slide 5 Classes and ObjectsInheritance Interpolating time series signals time strength step function linear interpolation A lot of the implementation is the same How can we eliminate the reduncancy? Slide 6 Classes and ObjectsInheritance First implementation class StepSignal(object):... def get(self, where): if where < self.values[0][0]: raise IndexError, '%f too low' % where for i in range(len(self.values)-1): x0, y0 = self.values[i] x1, y1 = self.values[i+1] if x0