Skip to content

laser.measles.wrapper

laser.measles.wrapper

This module provides wrapper classes for LaserFrame objects with enhanced printing capabilities.

Classes:

Name Description
LaserFrameWrapper

A wrapper around LaserFrame that provides clean and snazzy printing.

laser.measles.wrapper.PrettyComponentsList

Bases: list

A list wrapper that provides enhanced printing for model components.

This class maintains full list functionality while adding a formatted display similar to the LaserFrame wrapper style.

laser.measles.wrapper.PrettyComponentsList.__repr__()

Return a detailed representation.

laser.measles.wrapper.PrettyComponentsList.__str__()

Return a formatted string representation of the components list.

laser.measles.wrapper.PrettyLaserFrameWrapper(laserframe)

A wrapper around LaserFrame that provides enhanced printing capabilities.

This wrapper maintains full compatibility with the underlying LaserFrame while adding a clean and snazzy print method that displays all properties.

Example:

1
2
3
4
5
>>> lf = LaserFrame(capacity=1000)
>>> lf.add_scalar_property("age", dtype=np.uint8)
>>> lf.add_vector_property("states", 4)  # S, E, I, R
>>> wrapped_lf = LaserFrameWrapper(lf)
>>> print(wrapped_lf)  # Clean and snazzy output

Initialize the wrapper with a LaserFrame.

Parameters:

Name Type Description Default
laserframe LaserFrame

The LaserFrame object to wrap

required

laser.measles.wrapper.PrettyLaserFrameWrapper.__getattr__(name)

Delegate attribute access to the wrapped LaserFrame.

laser.measles.wrapper.PrettyLaserFrameWrapper.__len__()

Return the length of the wrapped LaserFrame.

laser.measles.wrapper.PrettyLaserFrameWrapper.__repr__()

Return a detailed representation of the wrapper.

laser.measles.wrapper.PrettyLaserFrameWrapper.__setattr__(name, value)

Delegate attribute setting to the wrapped LaserFrame.

laser.measles.wrapper.PrettyLaserFrameWrapper.__str__()

Return a clean and snazzy string representation of the LaserFrame.

laser.measles.wrapper.PrettyLaserFrameWrapper.print_laserframe(max_items=None)

Print the LaserFrame with optional data preview.

Parameters:

Name Type Description Default
max_items int | None

Maximum number of items to show in data preview (None for all)

None

laser.measles.wrapper.pretty_laserframe(cls)

Class decorator that wraps LaserFrame subclasses with enhanced printing.

This decorator can be applied to LaserFrame subclasses to automatically provide enhanced printing capabilities to all instances.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
>>> @wrapper_class
... class PeopleLaserFrame(LaserFrame):
...     patch_id: np.ndarray
...     state: np.ndarray
...
...     def __init__(self, capacity: int, initial_count: int = 0):
...         super().__init__(capacity=capacity, initial_count=initial_count)
...
>>> people = PeopleLaserFrame(capacity=1000)
>>> print(people)  # Clean and snazzy output

laser.measles.wrapper.return_pretty_laserframe(func)

Decorator that wraps the return value of a function with LaserFrameWrapper.

This decorator can be used to automatically wrap LaserFrame objects returned by functions with enhanced printing capabilities.

Example:

1
2
3
4
5
6
7
8
>>> @wrapper
... def create_patches():
...     lf = LaserFrame(capacity=1000)
...     lf.add_scalar_property("age", dtype=np.uint32)
...     return lf  # This will be automatically wrapped
...
>>> patches = create_patches()
>>> print(patches)  # Clean and snazzy output

laser.measles.wrapper.wrap_laserframe(laserframe)

Convenience function to wrap a LaserFrame with enhanced printing.

Parameters:

Name Type Description Default
laserframe LaserFrame

The LaserFrame to wrap

required

Returns:

Type Description
PrettyLaserFrameWrapper

A LaserFrameWrapper instance