MCPcopy Create free account
hub / github.com/dabeaz-course/practical-python / interpolate

Method interpolate

Work/Data/stocksim.py:90–99  ·  view source on GitHub ↗
(self,field)

Source from the content-addressed store, hash-verified

88 # Calculate interpolated value of a given field based on
89 # current time
90 def interpolate(self,field):
91 first = self.history[self.index][field]
92 next = self.history[self.index+1][field]
93 first_t = self.history[self.index][3]
94 next_t = self.history[self.index+1][3]
95 try:
96 slope = (next - first)/(next_t-first_t)
97 return first + slope*(self.time - first_t)
98 except ZeroDivisionError:
99 return first
100
101 # Update all computed values
102 def update(self):

Callers 1

updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected