<commit_before>"""
Functions for mapping from one 2D Cartesian coordinate system to another.

These are useful for defining projections with nonlinear magnifications,
reductions, or other transformations of the input coordinate system.

Generally, these function objects should work for an arbitrary (x,y) pair,
returning new, remapped (x,y), although some classes of mappers may
define their range and domain, with undesirable or undefined behavior
outside those regions.  It is best if such objects raise a suitable
exception in those circumstances.

$Id$
"""
__version__='$Revision$'

from math import atan,pi,atan2

from numpy import exp,log,sqrt,sin,cos,zeros,ones,dot,array
from numpy.matlib import matrix, zeros as mzeros

import param

from topo.base.functionfamily import CoordinateMapperFn, IdentityMF
from topo.misc.util import signabs
from topo.misc.numbergenerator import UniformRandom, NormalRandom


##########################################################################
# coordinate mapper functions


class ConstantMapper(CoordinateMapperFn):
    """
    Coordinate Mapper that uses constant mapping values.

    Outputs constant coordinate (x_cons, y_cons).
    """
    x_cons = param.Number(default=0.0,bounds=(0,None),doc="""
       The maximum range of the mapping input.""")
    y_cons = param.Number(default=0.0,bounds=(0,None), doc="""
       The y coordinate of the mapping output.""")

    def __call__(self, x, y):
        """
        Arguments x and y are used to follow the abstraction class
        CoordinateMapperFn only.
        """
        return self.x_cons, self.y_cons


class Pipeline(CoordinateMapperFn):
    """
    Applies a sequence of coordmappers, left to right.
    """
    
    mappers=param.List(default=[],
        doc="The sequence of mappers to apply.")<commit_msg>Fixed ConstantMapper parameter bounds and documentation<commit_after>"""
Functions for mapping from one 2D Cartesian coordinate system to another.

These are useful for defining projections with nonlinear magnifications,
reductions, or other transformations of the input coordinate system.

Generally, these function objects should work for an arbitrary (x,y) pair,
returning new, remapped (x,y), although some classes of mappers may
define their range and domain, with undesirable or undefined behavior
outside those regions.  It is best if such objects raise a suitable
exception in those circumstances.

$Id$
"""
__version__='$Revision$'

from math import atan,pi,atan2

from numpy import exp,log,sqrt,sin,cos,zeros,ones,dot,array
from numpy.matlib import matrix, zeros as mzeros

import param

from topo.base.functionfamily import CoordinateMapperFn, IdentityMF
from topo.misc.util import signabs
from topo.misc.numbergenerator import UniformRandom, NormalRandom




class ConstantMapper(CoordinateMapperFn):
    """
    Map all values to the same constant, pre-specified coordinates.
    """
    
    x_cons = param.Number(default=0.0,doc="""
       Constant x value returned by the mapping.""")
    
    y_cons = param.Number(default=0.0, doc="""
       Constant y value returned by the mapping.""")

    def __call__(self, x, y):
        # Ignores all (x,y), always returning (x_cons,y_cons)
        return self.x_cons, self.y_cons


class Pipeline(CoordinateMapperFn):
    """
    Applies a sequence of coordmappers, left to right.
    """
    
    mappers=param.List(default=[],
        doc="The sequence of mappers to apply.")
{'fraction_non_alphanumeric': 0.1024602026049204, 'fraction_numerical': 0.004052098408104197, 'mean_word_length': 4.236363636363636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6406429', 'n_tokens_mistral': 964, 'n_tokens_neox': 923, 'n_words': 357}