class Config_v4
A configuration class that manages global HoloViews behavior settings, including deprecation warnings, default colormaps, and rendering parameters.
/tf/active/vicechatdev/patches/util.py
96 - 141
simple
Purpose
Config is a parameterized configuration class that serves as a centralized control point for HoloViews' global behavior. It allows users to toggle deprecation warnings, set default colormaps for various element types, configure image sampling tolerance, and control padding behavior. The class inherits from param.ParameterizedFunction, making it both callable and providing parameter validation. It's designed to be instantiated once and used throughout an application to maintain consistent global settings.
Source Code
class Config(param.ParameterizedFunction):
"""
Set of boolean configuration values to change HoloViews' global
behavior. Typically used to control warnings relating to
deprecations or set global parameter such as style 'themes'.
"""
future_deprecations = param.Boolean(default=False, doc="""
Whether to warn about future deprecations""")
image_rtol = param.Number(default=10e-4, doc="""
The tolerance used to enforce regular sampling for regular,
gridded data where regular sampling is expected. Expressed as the
maximal allowable sampling difference between sample
locations.""")
no_padding = param.Boolean(default=False, doc="""
Disable default padding (introduced in 1.13.0).""")
warn_options_call = param.Boolean(default=True, doc="""
Whether to warn when the deprecated __call__ options syntax is
used (the opts method should now be used instead). It is
recommended that users switch this on to update any uses of
__call__ as it will be deprecated in future.""")
default_cmap = param.String(default='kbc_r', doc="""
Global default colormap. Prior to HoloViews 1.14.0, the default
value was 'fire' which can be set for backwards compatibility.""")
default_gridded_cmap = param.String(default='kbc_r', doc="""
Global default colormap for gridded elements (i.e. Image, Raster
and QuadMesh). Can be set to 'fire' to match raster defaults
prior to HoloViews 1.14.0 while allowing the default_cmap to be
the value of 'kbc_r' used in HoloViews >= 1.14.0""")
default_heatmap_cmap = param.String(default='kbc_r', doc="""
Global default colormap for HeatMap elements. Prior to HoloViews
1.14.0, the default value was the 'RdYlBu_r' colormap.""")
raise_deprecated_tilesource_exception = param.Boolean(default=False,
doc=""" Whether deprecated tile sources should raise a
deprecation exception instead of issuing warnings.""")
def __call__(self, **params):
self.param.set_param(**params)
return self
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
param.ParameterizedFunction | - |
Parameter Details
future_deprecations: Boolean flag (default: False) that controls whether warnings about future deprecations should be displayed. Set to True to get early warnings about features that will be deprecated in upcoming versions.
image_rtol: Numerical tolerance value (default: 10e-4) used to enforce regular sampling for gridded data. Represents the maximum allowable difference between sample locations to be considered regularly sampled.
no_padding: Boolean flag (default: False) that disables the default padding introduced in HoloViews 1.13.0. Set to True to revert to pre-1.13.0 padding behavior.
warn_options_call: Boolean flag (default: True) that controls whether to warn when the deprecated __call__ options syntax is used. Users should switch to using the opts method instead.
default_cmap: String (default: 'kbc_r') specifying the global default colormap. Can be set to 'fire' for backwards compatibility with versions prior to 1.14.0.
default_gridded_cmap: String (default: 'kbc_r') specifying the default colormap for gridded elements like Image, Raster, and QuadMesh. Can be set to 'fire' to match pre-1.14.0 defaults.
default_heatmap_cmap: String (default: 'kbc_r') specifying the default colormap for HeatMap elements. Prior to 1.14.0, this was 'RdYlBu_r'.
raise_deprecated_tilesource_exception: Boolean flag (default: False) that controls whether deprecated tile sources should raise exceptions instead of issuing warnings. Set to True for stricter error handling.
Return Value
When instantiated, Config returns a Config object that can be used to manage global settings. The __call__ method returns self after setting parameters, allowing for method chaining. All parameter attributes return their respective types (bool, float, or str) when accessed.
Class Interface
Methods
__call__(self, **params) -> Config
Purpose: Sets multiple configuration parameters at once and returns self for method chaining
Parameters:
params: Keyword arguments where keys are parameter names (future_deprecations, image_rtol, no_padding, warn_options_call, default_cmap, default_gridded_cmap, default_heatmap_cmap, raise_deprecated_tilesource_exception) and values are the new settings
Returns: Returns self (the Config instance) to allow method chaining
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
future_deprecations |
param.Boolean | Parameter controlling whether to warn about future deprecations (default: False) | class |
image_rtol |
param.Number | Tolerance for enforcing regular sampling in gridded data (default: 10e-4) | class |
no_padding |
param.Boolean | Flag to disable default padding introduced in version 1.13.0 (default: False) | class |
warn_options_call |
param.Boolean | Flag to warn when deprecated __call__ options syntax is used (default: True) | class |
default_cmap |
param.String | Global default colormap for visualizations (default: 'kbc_r') | class |
default_gridded_cmap |
param.String | Default colormap for gridded elements like Image, Raster, and QuadMesh (default: 'kbc_r') | class |
default_heatmap_cmap |
param.String | Default colormap specifically for HeatMap elements (default: 'kbc_r') | class |
raise_deprecated_tilesource_exception |
param.Boolean | Flag to raise exceptions instead of warnings for deprecated tile sources (default: False) | class |
Dependencies
param
Required Imports
import param
Usage Example
import param
class Config(param.ParameterizedFunction):
future_deprecations = param.Boolean(default=False)
image_rtol = param.Number(default=10e-4)
no_padding = param.Boolean(default=False)
warn_options_call = param.Boolean(default=True)
default_cmap = param.String(default='kbc_r')
default_gridded_cmap = param.String(default='kbc_r')
default_heatmap_cmap = param.String(default='kbc_r')
raise_deprecated_tilesource_exception = param.Boolean(default=False)
def __call__(self, **params):
self.param.set_param(**params)
return self
# Instantiate the config object
config = Config()
# Set configuration values using __call__
config(future_deprecations=True, default_cmap='fire')
# Or set individual parameters
config.param.set_param(no_padding=True)
# Access configuration values
print(config.default_cmap) # 'fire'
print(config.image_rtol) # 10e-4
# Chain configuration calls
config(warn_options_call=False)(default_heatmap_cmap='RdYlBu_r')
Best Practices
- Instantiate Config once at the application level and reuse the same instance throughout to maintain consistent global settings
- Use the __call__ method with keyword arguments to set multiple parameters at once for cleaner code
- Enable future_deprecations early in development to catch upcoming breaking changes
- When migrating from older HoloViews versions, set default_cmap='fire' to maintain visual consistency
- Access parameter values directly as attributes (e.g., config.default_cmap) rather than through internal param mechanisms
- The class is designed to be used as a singleton-like configuration object, not instantiated multiple times
- Changes to configuration parameters affect global HoloViews behavior, so be cautious when modifying in shared environments
- Use warn_options_call=True during development to identify and update deprecated syntax patterns
Tags
Similar Components
AI-powered semantic similarity - components with related functionality: