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

Add support for nD datasets in CompoundMatrix #1169

Merged
merged 3 commits into from
Jul 13, 2022
Merged

Conversation

loichuder
Copy link
Member

Follow-up of #1130

I also refactored a few things: I will underline them in the comments. Tell me if you agree.

packages/app/src/providers/mock/mock-api.ts Show resolved Hide resolved

const [slicedDims, slicedMapping] = useSlicedDimsAndMapping(dims, dimMapping);
const [mappedArray] = useMappedArray(
value.flat(1),
Copy link
Member Author

Choose a reason for hiding this comment

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

Given our dimMapping, value will always be a 1D array of tuples. So value.flat(1) is still valid to flatten the tuples.

value: ArrayValue<PrintableType>;
dims: number[];
dimMapping: DimensionMapping;
toolbarContainer: HTMLDivElement | undefined;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at what is needed to add support for nD, I realized that there were a few props in MappedMatrixVis that were derived from other props:

  • selection can be derived from dimMapping through getSliceSelection
  • dims is simply dataset.shape

Therefore, I think removing these props simplifies the component and reduces the risk of misuse.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm true, true, I was going to argue against calling getSliceSelection in MappedCompoundMatrixVis, but you're making an excellent point. getSliceSelection is cheap, so why not 🤷

Do you want to do this in the other containers/mapped vis, then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha, didn't realize it was the case for other containers. I will revert it for MatrixVis and do another PR to do it for all containers at once.

@loichuder loichuder force-pushed the nD-compound-matrix branch from d1fae05 to 9576550 Compare July 13, 2022 08:38
@loichuder loichuder requested a review from axelboc July 13, 2022 08:38
value: ArrayValue<PrintableType>;
dims: number[];
dimMapping: DimensionMapping;
toolbarContainer: HTMLDivElement | undefined;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm true, true, I was going to argue against calling getSliceSelection in MappedCompoundMatrixVis, but you're making an excellent point. getSliceSelection is cheap, so why not 🤷

Do you want to do this in the other containers/mapped vis, then?

@loichuder loichuder force-pushed the nD-compound-matrix branch from 9576550 to 6b7e627 Compare July 13, 2022 13:23
@loichuder
Copy link
Member Author

/approve

@loichuder loichuder merged commit 8d34a54 into main Jul 13, 2022
@loichuder loichuder deleted the nD-compound-matrix branch July 13, 2022 14:06
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.

2 participants