From 1f1b6e12e9e012efab0c41ad4a1e5e351657d922 Mon Sep 17 00:00:00 2001 From: Pol Alvarez Date: Fri, 29 Sep 2023 14:09:46 +0200 Subject: [PATCH 1/2] fix: reenabled cap/uncapped feature in continuous embeddings Signed-off-by: Pol Alvarez --- src/components/Loader.jsx | 1 - src/components/plots/ContinuousEmbeddingPlot.jsx | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/Loader.jsx b/src/components/Loader.jsx index 95846db4da..8ca1d642f7 100644 --- a/src/components/Loader.jsx +++ b/src/components/Loader.jsx @@ -60,7 +60,6 @@ const Loader = ({ experimentId }) => { () => (experimentId ? `/v2/experiments/${experimentId}/backendStatus` : null), fetchAPI, ); - console.log('workerStatus', workerStatus); if (!workerStatus) { return ( diff --git a/src/components/plots/ContinuousEmbeddingPlot.jsx b/src/components/plots/ContinuousEmbeddingPlot.jsx index bdc2992efc..634ba1dc76 100644 --- a/src/components/plots/ContinuousEmbeddingPlot.jsx +++ b/src/components/plots/ContinuousEmbeddingPlot.jsx @@ -16,7 +16,7 @@ import changeEmbeddingAxesIfNecessary from './helpers/changeEmbeddingAxesIfNeces const ContinuousEmbeddingPlot = (props) => { const { experimentId, config, - plotData, + plotData, truncatedPlotData, actions, loading, error, reloadPlotData, onUpdate, } = props; @@ -67,7 +67,7 @@ const ContinuousEmbeddingPlot = (props) => { generateData( cellSets, config.selectedSample, - plotData, + config.truncatedValues ? truncatedPlotData : plotData, embeddingData, ), ), @@ -130,7 +130,10 @@ const ContinuousEmbeddingPlot = (props) => { }; ContinuousEmbeddingPlot.defaultProps = { + reloadPlotData: () => { }, + config: null, plotData: null, + truncatedPlotData: null, actions: true, }; @@ -138,6 +141,7 @@ ContinuousEmbeddingPlot.propTypes = { experimentId: PropTypes.string.isRequired, config: PropTypes.object, plotData: PropTypes.array, + truncatedPlotData: PropTypes.array, actions: PropTypes.oneOfType([ PropTypes.bool, PropTypes.object, @@ -148,10 +152,4 @@ ContinuousEmbeddingPlot.propTypes = { onUpdate: PropTypes.func.isRequired, }; -ContinuousEmbeddingPlot.defaultProps = { - reloadPlotData: () => { }, - config: null, - truncatedPlotData: null, -}; - export default ContinuousEmbeddingPlot; From e9d68f34ef181bf7c1632a567cf3131bd8c5464d Mon Sep 17 00:00:00 2001 From: Pol Alvarez Date: Fri, 29 Sep 2023 14:39:05 +0200 Subject: [PATCH 2/2] test: for continuous embedding cap / uncap Signed-off-by: Pol Alvarez --- .../plots/ContinuousEmbeddingPlot.test.jsx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/__test__/components/plots/ContinuousEmbeddingPlot.test.jsx b/src/__test__/components/plots/ContinuousEmbeddingPlot.test.jsx index e166b5dfed..760670cb99 100644 --- a/src/__test__/components/plots/ContinuousEmbeddingPlot.test.jsx +++ b/src/__test__/components/plots/ContinuousEmbeddingPlot.test.jsx @@ -4,6 +4,7 @@ import { screen, render } from '@testing-library/react'; import { Provider } from 'react-redux'; import { makeStore } from 'redux/store'; import fetchMock, { enableFetchMocks } from 'jest-fetch-mock'; +import * as PlotSpecGenerators from 'utils/plotSpecs/generateEmbeddingContinuousSpec'; import { dispatchWorkRequest } from 'utils/work/seekWorkResponse'; import { loadBackendStatus } from 'redux/actions/backendStatus'; @@ -101,6 +102,29 @@ describe('Continuous embedding plot', () => { expect(screen.getByRole('graphics-document', { name: 'Continuous embedding plot' })).toBeInTheDocument(); }); + it('Calls generateData with truncatedPlotData when config.truncatedValues is true', async () => { + // Spy on the function + const generateDataSpy = jest.spyOn(PlotSpecGenerators, 'generateData'); + + await renderContinuousEmbeddingPlot(storeState, { + config: { + ...initialPlotConfigStates.embeddingContinuous, + truncatedValues: true, + }, + }); + + // Check if generateData was called with truncatedPlotData + expect(generateDataSpy).toHaveBeenCalledWith( + expect.anything(), // cellSets + expect.anything(), // selectedSample + truncatedPlotData, // truncatedPlotData + expect.anything(), // embeddingData + ); + + // Cleanup + generateDataSpy.mockRestore(); + }); + it('Shows a loader if there is no config', async () => { await act(async () => { render(