Skip to content
Browse files

beautification

  • Loading branch information...
1 parent 6b85338 commit c79dec8174cef09401abdbcd0b3e647487be0d1c @T-002 committed
Showing with 16 additions and 27 deletions.
  1. +10 −23 pycast/errors/meanabsolutepercentageerror.py
  2. +4 −4 pycast/tests/__init__.py
  3. +2 −0 pycast/tests/errormeasuretest.py
View
33 pycast/errors/meanabsolutepercentageerror.py
@@ -70,29 +70,6 @@ def local_error(self, originalValue, calculatedValue):
MAPE = MeanAbsolutePercentageError
-class MeanSignedPercentageError(MeanAbsolutePercentageError):
- """Calculates the mean percentage error."""
-
- def local_error(self, originalValue, calculatedValue):
- """Calculates the error between the two given values.
-
- :param List originalValue: List containing the values of the original data.
- :param List calculatedValue: List containing the values of the calculated TimeSeries that
- corresponds to originalValue.
-
- :return: Returns the error measure of the two given values.
- :rtype: Numeric
- """
- originalValue = originalValue[0]
- calculatedValue = calculatedValue[0]
-
- if 0 == originalValue:
- return None
-
- return ((calculatedValue - originalValue)/float(originalValue)) * 100.0
-
-MSPE = MeanSignedPercentageError
-
class GeometricMeanAbsolutePercentageError(MeanAbsolutePercentageError):
"""Calculates the geometric MAPE."""
@@ -134,8 +111,18 @@ def _calculate(self, startingPercentage, endPercentage, startDate, endDate):
class MeanSignedPercentageError(MeanAbsolutePercentageError):
+ """An over/under estimation aware percentage error."""
def local_error(self, originalValue, calculatedValue):
+ """Calculates the error between the two given values.
+
+ :param List originalValue: List containing the values of the original data.
+ :param List calculatedValue: List containing the values of the calculated TimeSeries that
+ corresponds to originalValue.
+
+ :return: Returns the error measure of the two given values.
+ :rtype: Numeric
+ """
if calculatedValue[0] - originalValue[0] > 0:
# over estimation
return super(MeanSignedPercentageError, self).local_error(originalValue, calculatedValue)
View
8 pycast/tests/__init__.py
@@ -23,9 +23,9 @@
#WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## TimeSeries related tests
-from timeseriesdatabasetest import DatabaseConnectorTest
-from timeseriesmiscellaneoustest import TimeSeriesMiscellaneousTest
-from json_encodertest import PycastEncoderTest
+from timeseriesdatabasetest import DatabaseConnectorTest
+from timeseriesmiscellaneoustest import TimeSeriesMiscellaneousTest
+from json_encodertest import PycastEncoderTest
from multidimensionaltimeseriestest import MultiDimensionalTimeSeriesTest
## profileMe decorator related tests
@@ -40,7 +40,7 @@
## error measure tests
from errormeasuretest import BaseErrorMeasureTest, MeanSquaredErrorTest, SymmetricMeanAbsolutePercentageErrorTest, MeanAbsoluteDeviationErrorTest, MedianAbsolutePercentageErrorTest, MeanAbsoluteScaledErrorTest, MeanSignedDifferenceErrorTest
-from mapetest import MeanAbsolutePercentageErrorTest, GeometricMeanAbsolutePercentageErrorTest
+from mapetest import MeanAbsolutePercentageErrorTest, GeometricMeanAbsolutePercentageErrorTest
from weightedmapetest import WeightedMeanAbsolutePercentageErrorTest
#from meetest import MeanEconomicErrorTest
View
2 pycast/tests/errormeasuretest.py
@@ -504,6 +504,8 @@ def error_calculation_test(self):
assert False # pragma: no cover
class MeanSignedDifferenceErrorTest(unittest.TestCase):
+ """Test for the MeanSignedDifferenceError."""
+
def setUp(self):
self.ts1 = TimeSeries.from_twodim_list([[1.0, 1.0], [2.0,20.0], [3.0, 3.0]])
self.ts2 = TimeSeries.from_twodim_list([[1.0,10.0], [2.0, 2.0], [3.0,30.0]])

0 comments on commit c79dec8

Please sign in to comment.
Something went wrong with that request. Please try again.