Skip to content

Commit d306b1d

Browse files
committed
- updated interface definition
1 parent 49a06bd commit d306b1d

File tree

4 files changed

+31
-32
lines changed

4 files changed

+31
-32
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ Typical usage often looks like this:
2121
ts.add_entry(4.0, 2.0)
2222

2323
ts.normalize("second")
24-
sma = SimpleMovingAverage(3)
25-
ts.smooth(sma)
24+
smootedTS = ts.apply(SimpleMovingAverage(3))
2625

2726

2827
Some usage examples of pycast in combination with other tools like gnuplot

pycast/common/timeseries.py

+11-24
Original file line numberDiff line numberDiff line change
@@ -339,31 +339,18 @@ def is_normalized(self):
339339
"""
340340
return self._normalized
341341

342-
def smooth(self, smoothingMethod):
343-
"""Applies the given SmoothingMethod from the pycast.smoothing module to the TimeSeries.
344-
345-
@param smoothingMethod SmoothingMethod that should be applied to the time series.
346-
For more information about the smoothing methods look into
347-
their corresponding documentation in the pycast.smoothing module.
348-
349-
@return Returns a new TimeSeries containing the smoothed values.
342+
def apply(self, method):
343+
"""Applies the given ForecastingAlgorithm or SmoothingMethod from the pycast.forecasting and
344+
pycast.smoothingmodule to the TimeSeries.
345+
346+
@param method Method that should be used with the TimeSeries.
347+
For more information about the methods take a look into
348+
their corresponding documentation.
350349
"""
351-
print self
352350
## sort and normalize, if necessary
353-
if smoothingMethod.has_to_be_normalized():
351+
if method.has_to_be_normalized():
354352
self.normalize()
355-
elif smoothingMethod.has_to_be_sorted():
353+
elif method.has_to_be_sorted():
356354
self.sort_timeseries()
357-
358-
print self
359-
return smoothingMethod.execute(self)
360-
361-
def apply_forecasting(self, forecastingAlgorithm):
362-
"""Applies the given ForecastingAlgorithm from the pycast.forecasting module to the TimeSeries.
363-
364-
@param forecastingAlgorithm ForecastingAlgorithm that should be used with the TimeSeries.
365-
Fore more information about the forecasting algorithms look into
366-
their corresponding documentation in the pycasst.forecasting module.
367-
"""
368-
## @todo This is not implemetned yet.
369-
## @todo Check, if this interface definition works good with GridSearch or HookeJeaves opimization.
355+
356+
return method.execute(self)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name = "pycast",
5-
version = "0.0.0-prealpha",
5+
version = "0.0.1-prealpha",
66
author = "Christian S",
77
author_email = "[email protected]",
88
packages = ["pycast"],

test.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,26 @@
3131
#result =linear_interpolation(v1,v2,4)
3232
#assert(result == [1.0, 2.0, 3.0, 4.0])
3333

34+
#from pycast.common.timeseries import TimeSeries
35+
#ts1 = TimeSeries()
36+
#ts1.add_entry(0.0, 0.0)
37+
#ts1.add_entry(1.0, 0.8)
38+
#ts1.add_entry(1.1, 0.9)
39+
#ts1.add_entry(1.2, 1.3)
40+
#ts1.add_entry(2.0, 2.0)
41+
#
42+
#ts1.normalize("second", "average", "linear")
43+
#print ts1
44+
3445
from pycast.common.timeseries import TimeSeries
3546
ts1 = TimeSeries()
3647
ts1.add_entry(0.0, 0.0)
3748
ts1.add_entry(1.0, 0.8)
38-
ts1.add_entry(1.1, 0.9)
39-
ts1.add_entry(1.2, 1.3)
40-
ts1.add_entry(2.0, 2.0)
49+
ts1.add_entry(2.1, 0.9)
50+
ts1.add_entry(3.2, 1.3)
51+
ts1.add_entry(4.0, 2.0)
4152

42-
ts1.normalize("second", "average", "linear")
43-
print ts1
53+
from pycast.smoothing.simplemovingaverage import SimpleMovingAverage
54+
sma = SimpleMovingAverage(3)
55+
ts1.normalize("second")
56+
print ts1.apply(sma)

0 commit comments

Comments
 (0)