-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #327 from dyson-ai/feature/video_grid
Feature/video grid
- Loading branch information
Showing
15 changed files
with
422 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
58 changes: 58 additions & 0 deletions
58
bencher/results/composable_container/composable_container_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from enum import Enum, auto | ||
from typing import Any | ||
from bencher.results.float_formatter import FormatFloat | ||
|
||
|
||
# TODO enable these options | ||
class ComposeType(Enum): | ||
right = auto() # append the container to the right (creates a row) | ||
down = auto() # append the container below (creates a column) | ||
overlay = auto() # overlay on top of the current container (alpha blending) | ||
sequence = auto() # display the container after (in time) | ||
|
||
|
||
class ComposableContainerBase: | ||
"""A base class for renderer backends. A composable renderr""" | ||
|
||
@staticmethod | ||
def label_formatter(var_name: str, var_value: int | float | str) -> str: | ||
"""Take a variable name and values and return a pretty version with approximate fixed width | ||
Args: | ||
var_name (str): The name of the variable, usually a dimension | ||
var_value (int | float | str): The value of the dimension | ||
Returns: | ||
str: Pretty string representation with fixed width | ||
""" | ||
|
||
if isinstance(var_value, (int, float)): | ||
var_value = FormatFloat()(var_value) | ||
if var_name is not None and var_value is not None: | ||
return f"{var_name}={var_value}" | ||
if var_name is not None: | ||
return f"{var_name}" | ||
if var_value is not None: | ||
return f"{var_value}" | ||
return None | ||
|
||
def __init__(self, horizontal: bool = True) -> None: | ||
self.horizontal: bool = horizontal | ||
self.compose_method = ComposeType.right | ||
self.container = [] | ||
|
||
def append(self, obj: Any) -> None: | ||
"""Add an object to the container. The relationship between the objects is defined by the ComposeType | ||
Args: | ||
obj (Any): Object to add to the container | ||
""" | ||
self.container.append(obj) | ||
|
||
def render(self): | ||
"""Return a representation of the container that can be composed with other render() results. This function can also be used to defer layout and rending options until all the information about the container content is known. You may need to ovverride this method depending on the container. See composable_container_video as an example. | ||
Returns: | ||
Any: Visual representation of the container that can be combined with other containers | ||
""" | ||
return self.container |
Oops, something went wrong.