'''

'''
from __future__ import absolute_import

from ..core.enums import StepMode, JitterRandomDistribution
from ..core.properties import abstract
from ..core.properties import Either, Enum, Float, Instance, Seq, String, Tuple
from ..model import Model
from .sources import ColumnDataSource

@abstract
class Transform(Model):
    ''' Base class for ``Transform`` models that represent a computation
    to be carried out on the client-side.

    JavaScript implementations should implement the following methods:

    .. code-block: coffeescript

        compute: (x) ->
            # compute the transform of a single value

        v_compute: (xs) ->
            # compute the transform of an array of values

    '''
    pass


class Jitter(Transform):
    ''' Apply either a uniform or normally sampled random jitter to data.

    '''


    mean = Float(default=0, help="""
    The central value for the random sample
    """)

    width = Float(default=1, help="""
    The width (absolute for uniform distribution and sigma for the normal distribution) of the random sample.
    """)

    distribution = Enum(JitterRandomDistribution, default='uniform', help="""
    The random distribution upon which to pull the random scatter
    """)

@abstract
class Interpolator(Transform):
    ''' Base class for interpolator transforms.

    Interpolators are configured with ``values`` which can either be:

    * A literal sequence of values:

    .. code-block: python

        interp = Interpolator(x=[1, 2, 3, 4, 5], y=[2, 5, 10, 12, 16])

    * or a pair of columns defined in a `ColumnDataSource` object:

    .. code-block: python

        interp = Interpolator(x="year", y="earnings", data=jewlery_prices))

    '''
    x = Either(String, Seq(Float), help="""
    Independant coordiante denoting the location of a point.
    """)

    y = Either(String, Seq(Float), help="""
    Dependant coordinate denoting the value of a point at a location.
    """)

    data = Instance(ColumnDataSource, help="""
    Data which defines the source for the named columns if a string is passed to either the `x` or `y` parameters.
    """)

    # Define an initialization routine to do some cross checking of input values
    def __init__(self, palette=None, **kwargs):
        super(Interpolator, self).__init__(**kwargs)


class LinearInterpolator(Interpolator):
    ''' Compute a linear interpolation between the points given by ``values``.

    '''
    pass


class StepInterpolator(Interpolator):
    ''' Compute a step-wise interpolation between the points given
    by ``values``.

    '''

    mode = Enum(StepMode, default="after", help="""

    """)

@@ -1350,59 +1350,412 @@
 ors 
-a
 re
- configured with %60%60values%60%60 which can either be:
+turn the value of a function which has been evalauted between pre-sepcified (x, y) pairs of data.  As an example, if two control point pairs were provided to the interpolator, a linear interpolaction at a specific value of 'x' would result in the value of 'y' which existed on the line conneting the two control points.%0A%0A    The control point pairs for the interpolators can be specified through either
 %0A%0A  
@@ -2060,16 +2060,247 @@
 ices))%0A%0A
+%0A    This is the base class and is not intended to end use.  Please see the documentation for the final derived classes (Jitter, LineraInterpolator, StepInterpolator) for mor information on their specific methods of interpolation.%0A
     '''%0A
@@ -2682,16 +2682,20 @@
 he %60
-x
+%60x%60
 %60 or %60
-y
+%60y%60
 %60 pa
@@ -2993,34 +2993,82 @@
 the 
-points given by %60%60values%60%60
+control points provided throught the %60%60x%60%60, %60%60y%60%60, and %60%60data%60%60 parameters
 .%0A%0A 
@@ -3188,31 +3188,67 @@
 nts 
-given%0A    by %60%60values%60%60
+provided throught the %60%60x%60%60, %60%60y%60%60, and %60%60data%60%60 parameters
 .%0A%0A 
@@ -3307,16 +3307,500 @@
 elp=%22%22%22%0A
+    Adjust the behavior of the returned value in relation to the control points.  The parameter can assume one of three values:%0A%0A    * %60%60after%60%60 (default): Assume the y-value associated with the nearest x-value which is less than or equal to the point to transform.%0A    * %60%60before%60%60: Assume the y-value associated with the nearest x-value which is greater than the point to transform.%0A    * %60%60center%60%60: Assume the y-value associated with the nearest x-value to the point to transform.
 %0A    %22%22%22

Add and alter some of the documentation.