Skip to content

Commit

Permalink
Merge pull request hms-dbmi-cellenics#900 from biomage-org/fixed-cap-…
Browse files Browse the repository at this point in the history
…uncap

fix: reenabled cap/uncapped feature in continuous embeddings
  • Loading branch information
kafkasl authored Oct 2, 2023
2 parents 1f557e1 + 1897b3e commit 61070be
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
24 changes: 24 additions & 0 deletions src/__test__/components/plots/ContinuousEmbeddingPlot.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion src/components/Loader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const Loader = ({ experimentId }) => {
() => (experimentId ? `/v2/experiments/${experimentId}/backendStatus` : null),
fetchAPI,
);
console.log('workerStatus', workerStatus);

if (!workerStatus) {
return (
Expand Down
14 changes: 6 additions & 8 deletions src/components/plots/ContinuousEmbeddingPlot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import changeEmbeddingAxesIfNecessary from './helpers/changeEmbeddingAxesIfNeces
const ContinuousEmbeddingPlot = (props) => {
const {
experimentId, config,
plotData,
plotData, truncatedPlotData,
actions, loading, error,
reloadPlotData, onUpdate,
} = props;
Expand Down Expand Up @@ -67,7 +67,7 @@ const ContinuousEmbeddingPlot = (props) => {
generateData(
cellSets,
config.selectedSample,
plotData,
config.truncatedValues ? truncatedPlotData : plotData,
embeddingData,
),
),
Expand Down Expand Up @@ -130,14 +130,18 @@ const ContinuousEmbeddingPlot = (props) => {
};

ContinuousEmbeddingPlot.defaultProps = {
reloadPlotData: () => { },
config: null,
plotData: null,
truncatedPlotData: null,
actions: true,
};

ContinuousEmbeddingPlot.propTypes = {
experimentId: PropTypes.string.isRequired,
config: PropTypes.object,
plotData: PropTypes.array,
truncatedPlotData: PropTypes.array,
actions: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object,
Expand All @@ -148,10 +152,4 @@ ContinuousEmbeddingPlot.propTypes = {
onUpdate: PropTypes.func.isRequired,
};

ContinuousEmbeddingPlot.defaultProps = {
reloadPlotData: () => { },
config: null,
truncatedPlotData: null,
};

export default ContinuousEmbeddingPlot;

0 comments on commit 61070be

Please sign in to comment.