Improve string and HTML representations.#856
Open
pfebrer wants to merge 2 commits intometatensor:mainfrom
Open
Improve string and HTML representations.#856pfebrer wants to merge 2 commits intometatensor:mainfrom
pfebrer wants to merge 2 commits intometatensor:mainfrom
Conversation
Luthaf
reviewed
Jun 18, 2025
Member
Luthaf
left a comment
There was a problem hiding this comment.
This should also handle Labels in a similar ways. Here are a couple of tweak suggestions:
- TensorBlock str should remove the
<>and maybe be simplified like this:
metatensor.TensorBlock:
values shape: (...)
samples: [system, atom]
components: [xyz, o3_mu]
properties: [n1, n2, ...]
- TensorMap str: I would also remove
<>, and remove the4in4 keys: (names). Just havingkeys: (names)like we do for samples/components/properties would be enough
Finally, all of them needs to check what happen when you have 100+ entries in Labels (key/samples/properties). We will likely want to truncate the representation at some point and/or add scroll bars.
| @@ -0,0 +1,167 @@ | |||
| # CSS styles for the HTML representation | |||
Member
There was a problem hiding this comment.
This should not be in a separate file if we want to make it easy to use from C++ as well
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses #847 and #848 by modifying slightly the string representation of
TensorMapandTensorBlockand introducing a new HTML representation.If you agree with the way it looks I'll finish some details and then we would need to port the string representations to the C++ api as well (which I don't know exactly how to test yet 😅 )
This is how it looks with the tensormap from the tutorials:
TensorBlock html:
TensorBlock str:
TensorMap html (blocks expand by clicking):
TensorMap str: