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

Expose curve component functions as public state variables #1970

Merged
merged 1 commit into from
Mar 7, 2023
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
16 changes: 8 additions & 8 deletions cypress/e2e/DoenetML/dynamicalsystem/odesystem.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,8 @@ describe('ODEsystem Tag Tests', function () {
let ode = stateVariables['/ode'];
let solutionFx = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[0]);
let solutionFy = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[1]);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinition);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinition);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinitions[0]);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinitions[0]);
let solutionsFromCoreX = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[0].componentName].stateValues.value);
let solutionsFromCoreY = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[1].componentName].stateValues.value);
let expectedFx = t => 8 * Math.exp(0.1 * t) - 7 * Math.exp(0.2 * t);
Expand Down Expand Up @@ -834,8 +834,8 @@ describe('ODEsystem Tag Tests', function () {
let ode = stateVariables['/ode'];
let solutionFx = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[0]);
let solutionFy = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[1]);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinition);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinition);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinitions[0]);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinitions[0]);
let solutionsFromCoreX = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[0].componentName].stateValues.value);
let solutionsFromCoreY = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[1].componentName].stateValues.value);
let expectedFx = t => 4 * Math.exp(0.1 * t) - 1 * Math.exp(0.2 * t);
Expand Down Expand Up @@ -865,8 +865,8 @@ describe('ODEsystem Tag Tests', function () {
let ode = stateVariables['/ode'];
let solutionFx = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[0]);
let solutionFy = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[1]);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinition);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinition);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinitions[0]);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinitions[0]);
let solutionsFromCoreX = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[0].componentName].stateValues.value);
let solutionsFromCoreY = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[1].componentName].stateValues.value);
let expectedFx = t => -6 * Math.exp(0.1 * t) + 1 * Math.exp(0.2 * t);
Expand Down Expand Up @@ -902,8 +902,8 @@ describe('ODEsystem Tag Tests', function () {
let ode = stateVariables['/ode'];
let solutionFx = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[0]);
let solutionFy = createFunctionFromDefinition(ode.stateValues.numericalSolutionFDefinitions[1]);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinition);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinition);
let solutionFx2 = createFunctionFromDefinition(stateVariables["/f1"].stateValues.fDefinitions[0]);
let solutionFy2 = createFunctionFromDefinition(stateVariables["/f2"].stateValues.fDefinitions[0]);
let solutionsFromCoreX = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[0].componentName].stateValues.value);
let solutionsFromCoreY = stateVariables["/_map1"].replacements.map(x => stateVariables[stateVariables[x.componentName].replacements[1].componentName].stateValues.value);
for (let t = 0; t <= 10; t += 1) {
Expand Down
110 changes: 60 additions & 50 deletions cypress/e2e/DoenetML/tagSpecific/curve.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("centripetal");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.8);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(-2);
expect(fs[0](2)).eq(-4);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(-2);
expect(f1(2)).eq(-4);
expect(f2(2)).eq(-4);
})

cy.get("#\\/_mathinput1 textarea").type("{end}{backspace}{backspace}4{enter}", { force: true });
Expand All @@ -45,11 +46,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("centripetal");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.8);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(4);
expect(fs[0](2)).eq(8);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(4);
expect(f1(2)).eq(8);
expect(f2(2)).eq(-4);
})

});
Expand Down Expand Up @@ -79,11 +81,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("centripetal");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.8);
expect(stateVariables['/_curve1'].stateValues.label).eq("Hi \\((-1,2), (2, -2), (2(-2), -4), (5,6)\\)");
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(-2);
expect(fs[0](2)).eq(-4);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(-2);
expect(f1(2)).eq(-4);
expect(f2(2)).eq(-4);
})

cy.get("#\\/_mathinput1 textarea").type("{end}{backspace}{backspace}4{enter}", { force: true });
Expand All @@ -95,11 +98,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("centripetal");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.8);
expect(stateVariables['/_curve1'].stateValues.label).eq("Hi \\((-1,2), (2, 4), (2(4), -4), (5,6)\\)");
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(4);
expect(fs[0](2)).eq(8);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(4);
expect(f1(2)).eq(8);
expect(f2(2)).eq(-4);
})

});
Expand Down Expand Up @@ -130,11 +134,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("centripetal");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.8);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(-2);
expect(fs[0](2)).eq(-4);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(-2);
expect(f1(2)).eq(-4);
expect(f2(2)).eq(-4);
})

cy.get("#\\/_mathinput1 textarea").type("{end}{backspace}{backspace}4{enter}", { force: true });
Expand All @@ -145,11 +150,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("centripetal");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.8);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(4);
expect(fs[0](2)).eq(8);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(4);
expect(f1(2)).eq(8);
expect(f2(2)).eq(-4);
})

cy.window().then(async (win) => {
Expand All @@ -163,11 +169,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("centripetal");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.8);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(5);
expect(fs[1](1)).eq(7);
expect(fs[0](2)).eq(14);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(5);
expect(f2(1)).eq(7);
expect(f1(2)).eq(14);
expect(f2(2)).eq(-4);
})

});
Expand Down Expand Up @@ -198,11 +205,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("uniform");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.4);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(-2);
expect(fs[0](2)).eq(-4);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(-2);
expect(f1(2)).eq(-4);
expect(f2(2)).eq(-4);
})

cy.get("#\\/_mathinput1 textarea").type("{end}{backspace}{backspace}4{enter}", { force: true });
Expand All @@ -213,11 +221,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("uniform");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.4);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(2);
expect(fs[1](1)).eq(4);
expect(fs[0](2)).eq(8);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(2);
expect(f2(1)).eq(4);
expect(f1(2)).eq(8);
expect(f2(2)).eq(-4);
})

cy.window().then(async (win) => {
Expand All @@ -231,11 +240,12 @@ describe('Curve Tag Tests', function () {
expect(stateVariables['/_curve1'].stateValues.nThroughPoints).eq(4);
expect(stateVariables['/_curve1'].stateValues.splineForm).eq("uniform");
expect(stateVariables['/_curve1'].stateValues.splineTension).eq(0.4);
let fs = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
expect(fs[0](1)).eq(5);
expect(fs[1](1)).eq(7);
expect(fs[0](2)).eq(14);
expect(fs[1](2)).eq(-4);
let f1 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[0])
let f2 = createFunctionFromDefinition(stateVariables['/_curve1'].stateValues.fDefinitions[1])
expect(f1(1)).eq(5);
expect(f2(1)).eq(7);
expect(f1(2)).eq(14);
expect(f2(2)).eq(-4);
})

});
Expand Down
Loading