function dimensionless_contents
Filters stream parameters to return only those that are not associated with any of the provided key dimensions.
/tf/active/vicechatdev/patches/util.py
1748 - 1754
simple
Purpose
This function is used to identify stream parameters that are independent of key dimensions, typically in data visualization or streaming contexts. It helps separate dimensional parameters from non-dimensional ones by filtering out parameters that match key dimension names. This is useful for distinguishing between parameters that define data dimensions versus those that control other aspects of streams.
Source Code
def dimensionless_contents(streams, kdims, no_duplicates=True):
"""
Return a list of stream parameters that have not been associated
with any of the key dimensions.
"""
names = stream_parameters(streams, no_duplicates)
return [name for name in names if name not in kdims]
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
streams |
- | - | positional_or_keyword |
kdims |
- | - | positional_or_keyword |
no_duplicates |
- | True | positional_or_keyword |
Parameter Details
streams: A collection of stream objects or stream-like data structures from which parameters will be extracted. Expected to be compatible with the stream_parameters function.
kdims: Key dimensions - a list or iterable of dimension names (strings) that should be excluded from the result. These represent the dimensional parameters that should be filtered out.
no_duplicates: Boolean flag (default: True) that controls whether duplicate parameter names should be removed from the result. When True, ensures each parameter name appears only once in the output.
Return Value
Returns a list of strings representing stream parameter names that are not present in the kdims (key dimensions) list. These are the 'dimensionless' parameters - those that exist in the streams but are not associated with any key dimension. The list will contain unique values if no_duplicates is True.
Dependencies
param
Required Imports
from streams import Params
Usage Example
# Assuming stream_parameters function is available and streams are defined
# Example with hypothetical stream objects
from streams import Params
# Create some stream objects with parameters
stream1 = Params(parameters=['x', 'y', 'color', 'size'])
stream2 = Params(parameters=['x', 'z', 'alpha'])
streams = [stream1, stream2]
# Define key dimensions
key_dimensions = ['x', 'y', 'z']
# Get dimensionless parameters (those not in key dimensions)
result = dimensionless_contents(streams, key_dimensions, no_duplicates=True)
# result would be: ['color', 'size', 'alpha']
# With duplicates allowed
result_with_dupes = dimensionless_contents(streams, key_dimensions, no_duplicates=False)
# result_with_dupes might contain duplicate entries if streams have overlapping parameters
Best Practices
- Ensure the stream_parameters function is available in the same scope or properly imported
- The kdims parameter should contain valid dimension names that exist in your stream parameters
- Use no_duplicates=True (default) when you need a clean list of unique parameter names
- This function is typically used in visualization libraries like HoloViews for separating dimensional from non-dimensional stream parameters
- The function performs a simple membership test, so kdims should ideally be a set for better performance with large lists, though the function will work with any iterable
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function unbound_dimensions 78.8% similar
-
function drop_streams 75.3% similar
-
function dimensioned_streams 69.7% similar
-
function stream_parameters 56.0% similar
-
function get_param_values 50.6% similar