Skip to content
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

Replace fixed-point with exact notation in Matrix and Compound vis #1753

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

axelboc
Copy link
Contributor

@axelboc axelboc commented Feb 4, 2025

As discussed in #1646 (comment). Keeping the issue open until I address the formatting of numbers in the visualizations' tooltips.

This should also address the user need of #1742 in a more usable way than the solution proposed of adding a control to the toolbar to increase the fixed point precision.

While I'm at it, I bring the formatting of complex numbers in line with the formatting of other numbers. We were so far using formatters with less precision to save space in the Matrix vis, but I think consistency should prime.

Here is a more precise list of user-facing changes:

  1. < Scalar > Display complex numbers with exact precision
  2. < Scalar > Always show both real and imaginary parts of complex numbers to avoid confusing complex numbers without imaginary parts with real numbers — this applies also when inspecting values of complex attributes in the metadata viewer
  3. < Matrix > Replace Fixed-point notation with Exact notation to allow inspecting and copying exact values
  4. < Matrix > Inherit integer and/or float formatting for complex numbers in Auto and Scientific notations (depending on dtype of real and imaginary parts) — concretely, complex numbers are now displayed with more precision regardless of the notation.
# Before After
1 image image
2 image image
3 image image image image
4 image image image image

Comment on lines +75 to +76
getFormatter(type.realType, notation),
getFormatter(type.imagType, notation),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recurse to inherit the formatting of integers/floats.

@@ -216,7 +216,7 @@ export interface UnknownType {
export type ScalarValue<T extends DType = DType> = T extends NumericLikeType
?
| number
| (T extends NumericType ? bigint : never) // let providers return bigints
| (T extends IntegerType ? bigint : never) // let providers return bigints
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated. This is more precise but has no impact on the codebase since we don't have visualizations that accept only integers or only floats.

Comment on lines -75 to -81
if (imag === 0 && !full) {
return formatVal(real);
}

if (real === 0 && !full) {
return `${formatVal(imag)} i`;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing the feature of showing only the real part or only the imaginary part if the other part is equal to 0.

@axelboc
Copy link
Contributor Author

axelboc commented Feb 4, 2025

/approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant