I’m facing a challenge in developing a pack that creates the cartesian product of lists.
Basically, I’m working on a tool that needs data to be disaggregated along a few dimensions, each dimension comprising a few categories. Example: dimension gender (with categories [“woman”, “man”, “non-binary”], and dimension age_group, with categories [““18-35”, “36+”]. Other dimensions could be “Level of confidence” (with 5 levels as categories: [conf-1, …, conf-5]. The categories are separate lists.
I want to create the cartesian product of all the categories in each list, as follows: [conf-1, woman, 18-25], [conf-1, woman, 36+], [conf-1, man, 18-25],…
The challenge I’m facing is defining nested arrays as parameters. Is that even possible with the ParameterTyp.Array ? See my code snippet of a pack that tries to recreate the Python function “itertools.product()”
——————–
parameters: [
coda.makeParameter({
type: coda.ParameterType.Array,
name: "lists",
description: `A single list containing multiple lists, e.g., [["F","M"],["Urban","Rural"]].`,
items: {
type: coda.ValueType.Array, // Defines each item as a list.
items: {type: coda.ValueType.String}, // Defines the contents of that inner list as strings.
},
}),
],
resultType: coda.ValueType.Array,
items: coda.makeSchema({
type: coda.ValueType.Array,
items: { type: coda.ValueType.String },
}),
—————
I keep receiving this error message when trying to build the pack:
”We found some errors: Pack metadata failed validation.
- formulas[0].parameters[0].type: Required”
Any help would be greatly appreciated. Thanks in advance.
