🔍 Code Extractor

function dimensionless_contents

Maturity: 36

Filters stream parameters to return only those that are not associated with any of the provided key dimensions.

File:
/tf/active/vicechatdev/patches/util.py
Lines:
1748 - 1754
Complexity:
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

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function unbound_dimensions 78.8% similar

    Filters a list of dimensions (kdims) to return only those that have not been associated with any of the provided streams.

    From: /tf/active/vicechatdev/patches/util.py
  • function drop_streams 75.3% similar

    Filters out dimensioned stream parameters from key dimensions (kdims) and their corresponding keys, returning cleaned dimensions and keys.

    From: /tf/active/vicechatdev/patches/util.py
  • function dimensioned_streams 69.7% similar

    Filters and returns streams from a DynamicMap that have parameters matching the DynamicMap's key dimensions.

    From: /tf/active/vicechatdev/patches/util.py
  • function stream_parameters 56.0% similar

    Extracts and flattens parameter names from a list of stream objects, with optional duplicate detection and parameter exclusion.

    From: /tf/active/vicechatdev/patches/util.py
  • function get_param_values 50.6% similar

    Extracts parameter values from a data object, including key dimensions (kdims), value dimensions (vdims), label, and optionally the group if it differs from the default.

    From: /tf/active/vicechatdev/patches/util.py
← Back to Browse