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

Feature/cele 90 improvement #44

Merged
merged 8 commits into from
Oct 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ const CustomListItem = ({
<DeleteOutlinedIcon fontSize="small" />
</IconButton>
</Tooltip>
<Tooltip title="Add to group">
<IconButton>
<AddIcon fontSize="small" />
</IconButton>
</Tooltip>
{isNeurons && (
<Tooltip title="Add to group">
<IconButton>
<AddIcon fontSize="small" />
</IconButton>
</Tooltip>
)}
</Box>
)}
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import CustomEntitiesDropdown from "./CustomEntitiesDropdown.tsx";
import CustomListItem from "./CustomListItem.tsx";

const { gray900, gray500 } = vars;
const mapNeuronsToListItem = (neuron: string, visibility: ViewerData) => ({
const mapToListItem = (neuron: string, visibility: ViewerData) => ({
id: neuron,
label: neuron,
checked: Object.values(visibility).every((e) => e === undefined || e.visibility === Visibility.Visible),
});
const mapNeuronsAvailableNeuronsToOptions = (neuron: Neuron) => ({

const neuronToOption = (neuron: Neuron) => ({
id: neuron.name,
label: neuron.name,
content: [],
Expand Down Expand Up @@ -60,7 +61,7 @@ const Neurons = ({ children }) => {
};

const autoCompleteOptions = Object.values(neurons)
.map((neuron: Neuron) => mapNeuronsAvailableNeuronsToOptions(neuron))
.map((neuron: Neuron) => neuronToOption(neuron))
.sort((a, b) => a.label.localeCompare(b.label));

return (
Expand Down Expand Up @@ -115,7 +116,7 @@ const Neurons = ({ children }) => {
{Array.from(activeNeurons).map((neuronId) => (
<CustomListItem
key={neuronId}
data={mapNeuronsToListItem(neuronId, currentWorkspace.visibilities[neuronId])}
data={mapToListItem(neuronId, currentWorkspace.visibilities[neuronId])}
showTooltip={false}
showExtraActions={true}
listType="neurons"
Expand All @@ -142,11 +143,11 @@ const Neurons = ({ children }) => {
{Array.from(Object.keys(groups)).map((groupId) => (
<CustomListItem
key={groupId}
data={mapNeuronsToListItem(groupId, currentWorkspace.visibilities[groupId])}
data={mapToListItem(groupId, currentWorkspace.visibilities[groupId])}
showTooltip={false}
showExtraActions={true}
listType="groups"
onSwitchChange={() => console.log("switch")}
onSwitchChange={handleSwitchChange}
onDelete={() => console.log("delete")}
deleteTooltipTitle="Remove group from the workspace"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ const TwoDViewer = () => {
const hiddenNeurons = useMemo(() => {
return getHiddenNeuronsIn2D(workspace);
}, [
Object.keys(workspace.availableNeurons)
.map((neuronId) => workspace.visibilities[neuronId]?.[ViewerType.Graph]?.visibility || "")
Object.entries(workspace.visibilities)
.map(([name, data]) => `${name}-${data[ViewerType.Graph].visibility}`)
.join(","),
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const groupNeurons = (selectedNeurons: Set<string>, workspace: Workspace)
name: originalGroupName || newGroupId,
color: originalGroupColor,
neurons: newGroupNeurons,
visible: true,
};

return { newGroupId, newGroup, groupsToDelete };
Expand Down
13 changes: 4 additions & 9 deletions applications/visualizer/frontend/src/helpers/twoD/twoDHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,12 @@ export const updateWorkspaceNeurons2DViewerData = (workspace: Workspace, cy: Cor
};

export function getVisibleActiveNeuronsIn2D(workspace: Workspace): Set<string> {
const activeVisibleNeurons = Array.from(workspace.activeNeurons).filter((neuronId) => {
return workspace.visibilities[neuronId]?.[ViewerType.Graph]?.visibility === Visibility.Visible;
});
const activeVisibleNeurons = Array.from(workspace.activeNeurons).filter(
(neuronId) => workspace.visibilities[neuronId]?.[ViewerType.Graph]?.visibility === Visibility.Visible,
);

// Create a set to store the class neurons that are active and visible
const activeVisibleClasses = new Set(
activeVisibleNeurons.filter((neuronId) => {
const neuron = workspace.availableNeurons[neuronId];
return neuron && isNeuronClass(neuronId, workspace);
}),
);
const activeVisibleClasses = new Set(activeVisibleNeurons.filter((neuronId) => workspace.availableNeurons[neuronId] && isNeuronClass(neuronId, workspace)));

// Filter out individual cells if their class neuron is active and visible
return new Set(
Expand Down
1 change: 1 addition & 0 deletions applications/visualizer/frontend/src/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface NeuronGroup {
name: string;
color: string;
neurons: Set<string>;
visible: boolean;
}

export interface GraphViewerData {
Expand Down
1 change: 0 additions & 1 deletion applications/visualizer/frontend/src/models/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class Workspace {
});
this.updateContext(updated);
}

hideNeuron(neuronId: string): void {
const updated = produce(this, (draft: Workspace) => {
if (!(neuronId in draft.visibilities)) {
Expand Down