generated from thousandbrainsproject/tbp.python_package
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: interactive plot for pointcloud hypothesis space #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ramyamounir
wants to merge
15
commits into
thousandbrainsproject:main
Choose a base branch
from
ramyamounir:hyp_space_pointcloud
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ba6c91b
feat: interactive plot for pointcloud hypothesis space
ramyamounir 9a91325
refactor!: alpha to mesh transparency
ramyamounir d5427f1
refactor!: rename sensor to agent
ramyamounir c85b16c
refactor!: rename buttons to "Name: [on|off]"
ramyamounir 97faf91
chore: reposition some buttons
ramyamounir 784d6fb
feat: add tbp color palette
ramyamounir b9aa913
refactor: change colors to use tbp palette
ramyamounir 7a96a50
fix: minor typing fix
ramyamounir 8495f5d
feat: increase figure dpi to 200
ramyamounir ec627f7
refactor: extract FONT constant
ramyamounir 39ba30d
refactor: change scalarbar font and font sizes extraction
ramyamounir f71204a
feat: add rectangles and plotting mods
ramyamounir 2daeb65
refactor!: label renames for lineplot
ramyamounir 5451703
docs: change docstrings and fix typos
ramyamounir de62bdd
refactor: change current_episode default from -1 to None
ramyamounir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,75 @@ | ||
| # Copyright 2025 Thousand Brains Project | ||
| # | ||
| # Copyright may exist in Contributors' modifications | ||
| # and/or contributions to the work. | ||
| # | ||
| # Use of this source code is governed by the MIT | ||
| # license that can be found in the LICENSE file or at | ||
| # https://opensource.org/licenses/MIT. | ||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
| Color = str | tuple[float, float, float] | tuple[float, float, float, float] | ||
|
|
||
|
|
||
| def hex_to_rgb(hex_str: str, alpha: float | None = None) -> Color: | ||
| hex_clean = hex_str.lstrip("#") | ||
| if len(hex_clean) != 6: | ||
| raise ValueError(f"Expected 6 hex digits, got: {hex_str!r}") | ||
|
|
||
| r = int(hex_clean[0:2], 16) / 255.0 | ||
| g = int(hex_clean[2:4], 16) / 255.0 | ||
| b = int(hex_clean[4:6], 16) / 255.0 | ||
|
|
||
| if alpha is None: | ||
| return (r, g, b) | ||
| return (r, g, b, alpha) | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class Palette: | ||
| """The TBP color palette. | ||
|
|
||
| If you request a color that doesn't exist, a KeyError is raised with a list of | ||
| available names. | ||
| """ | ||
|
|
||
| # Primary Colors | ||
| indigo: str = "#2f2b5c" | ||
| numenta_blue: str = "#00a0df" | ||
|
|
||
| # Secondary Colors | ||
| bossanova: str = "#5c315f" | ||
| vivid_violet: str = "#86308b" | ||
| blue_violet: str = "#655eb2" | ||
| amethyst: str = "#915acc" | ||
|
|
||
| # Accent Colors/Shades | ||
| rich_black: str = "#000000" | ||
| charcoal: str = "#3f3f3f" | ||
| link_water: str = "#dfe6f5" | ||
|
|
||
| # ---------- Internal helper ---------- | ||
| @classmethod | ||
| def _validate(cls, name: str) -> str: | ||
| if not hasattr(cls, name): | ||
| available = [k for k in cls.__dict__.keys() if not k.startswith("_")] | ||
| msg = ( | ||
| f"Color '{name}' is not defined in Palette.\n" | ||
| f"Available colors: {', '.join(available)}" | ||
| ) | ||
| raise KeyError(msg) | ||
| return getattr(cls, name) | ||
|
|
||
| # ---------- Public API ---------- | ||
| @classmethod | ||
| def as_hex(cls, name: str) -> Color: | ||
| """Return the raw hex string for a color name.""" | ||
| return cls._validate(name) | ||
|
|
||
| @classmethod | ||
| def as_rgb(cls, name: str, alpha: float | None = None) -> Color: | ||
| """Return the color as an RGB(A) tuple in [0,1] range.""" | ||
| hex_str = cls._validate(name) | ||
| return hex_to_rgb(hex_str, alpha=alpha) |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason tbp.monty wouldn't be installed if using these plotting tools? Was this something you came across?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,
tbp.plotuses a different uv environment that does not containtbp.montyin it. One reason is the mismatch in python versions,tbp.plotuses python 3.13 (not 3.8). But also, ideally, we wouldn't want to depend on thetbp.montycodebase since everything we need is the log files and pretrained models.In the future, I imagine it would be really cool to have visualizations that actually run a Monty episode step by step from Vedo. This would allow us to change parameters, swap/manipulate objects, move sensors, etc., between steps. At this point, we would have to install
tbp.monty.