MCPcopy
hub / github.com/dabeaz-course/python-mastery / interpolate

Method interpolate

Data/stocksim.py:92–101  ·  view source on GitHub ↗
(self,field)

Source from the content-addressed store, hash-verified

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

Callers 1

updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected