slac207 / cs207project

MIT License
0 stars 4 forks source link

Create a lazy property method in your TimeSeries class #9

Closed sanoke closed 7 years ago

sanoke commented 7 years ago

Task (from Project Spec 3) We'd like you to create a lazy property method in your TimeSeries class. All this method does is return a new LazyOperation instance using an identity function (a function with one argument that just returns the argument) and self as the only argument. This wraps up the TimeSeries instance and a function which does nothing and saves them both for later.

This example should give identical results:

x = TimeSeries([1,2,3,4],[1,4,9,16])
print(x)
print(x.lazy.eval())

(Recall that properties don't need to be called, so x.lazy returns the result of calling the TimeSeries.lazy(self) function, which was decorated with @property.)

This adds a single extra layer of laziness indirection.

You should probably check that running your lazy-fied TimeSeries object works with the check_length example above.

brennan-ae commented 7 years ago

Added in pull request (#10)