Public
Edited
Apr 29, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
input_domains_projection = { // think RE blanket using all here ! filter for inputs? See t_interval
var o = {}
Object.entries(/*viz_spec.cursor*/ui).filter(([k,v]) => inputs.includes(k)).forEach(([k,v]) => {
o[k] = [v]
})
Object.entries(input_domains).forEach(([k,v]) => {
o[k] = v
})
return o
}
Insert cell
input_combos_projection = cartesianProduct(Object.entries(input_domains_projection).map(([k,v]) => ({[k == 'formulae' ? 'formula' : k]: v})))
Insert cell
Insert cell
projection = {
if (mapped.includes('formulae'))
return input_combos_projection.map(combos => {
if (!mapped.includes('interaction')) return combos
if (combos.interaction == inputs_history.length-1) return combos
else
return ({...combos, ...inputs_history[combos.interaction]/*adding too much here e.g. t_interval, restrict to inputs?*/}) // cant set to input histories here !
}).map(combos => ({...combos, value: +model[combos.formula](combos)/*.toFixed(2)*/}))
else {
// do all mapped formulae at once
var o = [];
//mapped.filter(d => formulae.includes(d)).for
input_combos_projection.forEach(combo => {
var oo = {...combo}
mapped.filter(d => formulae.includes(d)).forEach(formula => {
oo[formula] = +model[formula](combo);
})
o.push(oo);
})

return o
//combos => ({...combos, [formula]}))
//mapped.filter(formula => formulae.includes(formula)).map(formula => input_combos_projection.map(combos => ({...combos, [formula]}))
// here look for mapped functions and loop/flatten
// what will be in c-p for functions? nothing?
}
}
Insert cell
Insert cell
uis =({ // if not mapped
dampener_in: Inputs.range([-1,2], {value: 0.90, step:0.01, label: "dampener factor"}),
dx_in: Inputs.range([-5,5], {value: 3, step:0.5, label: "dx"}),
t_interval: interval([0,100], {step:1, label: 't', color: 'skyblue', value:[0,50]}),
// fut. interval for t domain : but won't be shown if t mapped! so name it something else
default: (input) => {
let config = input_domains_config.find(e => e.input == input); // put a not found thing here
return Inputs.range([config.min, config.max], {label:config.label, step:config.step});
}
})
Insert cell
domains = ({
t_in: _.range(ui.t_interval[0],ui.t_interval[1]),
formulae: formulae, // read introspection info
interaction: inputs_history.map((d,i) => i) // is this unnecessary spec recalc?
})
Insert cell
spec = ({
//// simpler to just put domains alongside channels?
// Surely I must include a group of vizes here? - sharing UI logic
// I think this justifys the structure?
//REC APPROPRIATENESS THE LAST OPEN Q I HAVE
mark: 'text',
height: 100,
channels: {
x: 't_in',
y: 'formulae',
row: 'interaction'
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
owner = "declann"
Insert cell
repo = "calculang-miscellaneous-models"
Insert cell
model_path = "/models/bounce/bounce"
Insert cell
Insert cell
inputs = Object.values(introspection.cul_functions).filter(d => d.reason == 'input definition').map(d => d.name)
Insert cell
formulae = Object.values(introspection.cul_functions).filter(d => d.reason == 'definition' && inputs.indexOf(d.name+'_in') == -1).map(d => d.name)
Insert cell
input_domains = {
// if formula mapped => not something to include
var o = {}
mapped.filter(d => !formulae.includes(d)).forEach(i => { // only use mapped
o[i] = domains[i]
})
return o
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more