Fix support for enum/bool auxiliary signals in NX Line visualization#1738
Merged
Fix support for enum/bool auxiliary signals in NX Line visualization#1738
Conversation
0c5adc7 to
2ae498c
Compare
axelboc
commented
Jan 21, 2025
loichuder
approved these changes
Jan 22, 2025
| errors?: NumArray; | ||
| auxLabels?: string[]; | ||
| auxValues?: NumArray[]; | ||
| auxValues?: Value<Props['dataset']>[]; |
Member
There was a problem hiding this comment.
I wonder if it might not be clearer to introduce a new type alias here to not reference dataset explicitely.
It seems weird since auxValues are not stored in dataset. It just so happens that auxiliary dataset values have the same type as the dataset values.
Contributor
Author
There was a problem hiding this comment.
Yeah, wasn't sure that it was clearer. Two goals here:
- The types of
valueand of each item inauxValuesshould match (if anNXdatagroup has a boolean signal, then it should be allowed to have boolean auxiliaries). This requires changingauxValues?: NumArray[]at least toArrayValue<NumericLikeType>to match thevalueprop. - The dtype passed to
Dataset<ArrayShape, DType>should match the dtype passed toArrayValue<Dtype>. In other words, I'd like to avoid the risk of the two becoming out of sync — e.g.Dataset<ArrayShape, NumericLikeType>andArrayValue<NumericType>. This is why I refer to the type of thedatasetprop withValue<Prop['dataset'].
Perhaps the second goal is not critical, since TypeScript would show an error in the container if the dtype of dataset and value/auxValues did not match. So should I stick with ArrayValue<NumericLikeType>?
Contributor
Author
There was a problem hiding this comment.
Opening a PR to propose a normalisation of the mapped components' props.
2ae498c to
3eba27e
Compare
This was referenced Jan 23, 2025
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.
assertNumericLikeNxDatawas asserting forNxData<NumericType>instead ofNxData<NumericLikeType>... but was correctly callingassertNumericLikeTypeinternally! SoMappedLineVisthought it could only receive numeric (nd)arrays (number[] | TypedArray) when in fact, at runtime, it could receiveboolean[].No errors were thrown at runtime because JS automatically coerces booleans to numbers in all mathematical operations (e.g.
Math.min(false, 2) => 0). This typing bug would have been more problematic withbigint[], though.I say "Fix support", because the fix still has invisible runtime implications: I now convert boolean auxiliary arrays to number arrays in
MappedLineViswith a new hook calleduseToNumArrays, which avoids type coercion further down the line (e.g. inuseDomains).