#-----------------------------------------------------------------------------# Copyright (c) Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------''''''#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Bokeh importsfrom..core.has_propsimportabstractfrom..core.propertiesimportInstance,Requiredfrom.transformsimportTransform#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=('CategoricalScale','CompositeScale','LinearScale','LogScale','Scale',)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------
[docs]@abstractclassScale(Transform):''' Base class for ``Scale`` models that represent an invertible computation to be carried out on the client-side. JavaScript implementations should implement the following methods: .. code-block compute(x: number): number { # compute and return the transform of a single value } v_compute(xs: Arrayable<number>): Arrayable<number> { # compute and return the transform of an array of values } invert(sx: number): number { # compute and return the inverse transform of a single value } v_invert(sxs: Arrayable<number>): Arrayable<number> { # compute and return the inverse transform of an array of values } '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
classContinuousScale(Scale):''' Represent a scale transformation between continuous ranges. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classLinearScale(ContinuousScale):''' Represent a linear scale transformation between continuous ranges. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classLogScale(ContinuousScale):''' Represent a log scale transformation between continuous ranges. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classCategoricalScale(Scale):''' Represent a scale transformation between a categorical source range and continuous target range. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classCompositeScale(Scale):''' Represent a composition of two scales, which useful for defining sub-coordinate systems. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)source_scale=Required(Instance(Scale),help=""" The source scale. """)target_scale=Required(Instance(Scale),help=""" The target scale. """)
# TODO assert source_scale != target_scale#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Private API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Code#-----------------------------------------------------------------------------