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

Clearer stratify #2767

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
<div class="strata-group" :style="`border-left: 9px solid ${props.config.borderColour}`">
<div class="input-row">
<div class="sub-header">
<label>Directed</label>
<InputSwitch @change="emit('update-self', updatedConfig)" v-model="directed" />
<label class="multi-line-label">Create new transitions between stratum</label>
<InputSwitch @change="emit('update-self', updatedConfig)" v-model="useStructure" />
</div>
<div class="sub-header">
<label>Cartesian product</label>
<label class="multi-line-label"
>Allow existing interactions to invole multiple stratum</label
>
<InputSwitch @change="emit('update-self', updatedConfig)" v-model="cartesianProduct" />
</div>
</div>
Expand Down Expand Up @@ -64,8 +66,9 @@ const strataName = ref(props.config.name);
const selectedVariables = ref<string[]>(props.config.selectedVariables);
const labels = ref(props.config.groupLabels);
const cartesianProduct = ref<boolean>(props.config.cartesianProduct);
const directed = ref<boolean>(props.config.directed);
const structure = ref<any>(props.config.structure); // currently not used
const directed = ref<boolean>(props.config.directed); // Currently not used, assume to be true
const structure = ref<any>(props.config.structure); // Proxied by "useStructure"
const useStructure = ref<any>(props.config.useStructure);

const updatedConfig = computed<StratifyGroup>(() => ({
borderColour: props.config.borderColour,
Expand All @@ -74,7 +77,8 @@ const updatedConfig = computed<StratifyGroup>(() => ({
groupLabels: labels.value,
cartesianProduct: cartesianProduct.value,
directed: directed.value,
structure: structure.value
structure: structure.value,
YohannParis marked this conversation as resolved.
Show resolved Hide resolved
useStructure: useStructure.value
}));

watch(
Expand All @@ -84,6 +88,8 @@ watch(
selectedVariables.value = props.config.selectedVariables;
labels.value = props.config.groupLabels;
cartesianProduct.value = props.config.cartesianProduct;
structure.value = props.config.structure;
useStructure.value = props.config.useStructure;
}
);
</script>
Expand Down Expand Up @@ -118,6 +124,10 @@ watch(
color: var(--text-color-subdued);
}

.multi-line-label {
max-width: 12rem;
}

.input-row {
width: 100%;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface StratifyGroup {

directed: boolean;
structure: null | any[];

useStructure: boolean;
}

export interface StratifyCode {
Expand All @@ -27,9 +29,23 @@ export const blankStratifyGroup: StratifyGroup = {
name: '',
selectedVariables: [],
groupLabels: '',

// Allow existing transitions to involve multiple strata
cartesianProduct: true,
directed: false,
structure: null

// Create new transitions between strata, this act as a proxy to MIRA "structure", which is
// null = everything
// [] = nothing
// [[a, b], [c, d]] = somewhere in between
//
// Here we use a simpler proxy useStructure, where
// true => structure = null
// false => structuer = []
structure: null,
useStructure: true,

// Always true for now - Feb 2024
directed: true
};

export const StratifyMiraOperation: Operation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ const stratifyRequest = () => {
key: strataOption.name,
strata: strataOption.groupLabels.split(',').map((d) => d.trim()),
concepts_to_stratify: strataOption.selectedVariables,
cartesian_control: strataOption.cartesianProduct
cartesian_control: strataOption.cartesianProduct,
structure: strataOption.useStructure === true ? null : []
}
};

Expand Down
Loading