Skip to content

Commit 256572d

Browse files
committed
chore: avoid using deprecated methods
1 parent cddd913 commit 256572d

File tree

77 files changed

+1698
-1698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1698
-1698
lines changed

test/compute-engine/arithmetic.test.ts

Lines changed: 134 additions & 134 deletions
Large diffs are not rendered by default.

test/compute-engine/ascii-math.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ce = engine;
55

66
function check(s: string | Expression): string {
77
if (typeof s === 'string') return ce.parse(s).toString();
8-
return ce.box(s).toString();
8+
return ce.expr(s).toString();
99
}
1010

1111
// Check serialization of ASCII math using toString()

test/compute-engine/assumptions.test.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,122 +4,122 @@ import '../utils'; // For snapshot serializers
44

55
export const ce = new ComputeEngine();
66

7-
ce.assume(ce.box(['Equal', 'one', 1]));
8-
ce.assume(ce.box(['Greater', 'x', 4]));
7+
ce.assume(ce.expr(['Equal', 'one', 1]));
8+
ce.assume(ce.expr(['Greater', 'x', 4]));
99
// ce.assume(['Element', 'm', ['Range', -Infinity, Infinity]]); @fixme
1010
// ce.assume(['Element', 'n', ['Range', 0, Infinity]]); @fixme
11-
ce.assume(ce.box(['Equal', 'o', 1]));
12-
ce.assume(ce.box(['Equal', 'p', 11]));
11+
ce.assume(ce.expr(['Equal', 'o', 1]));
12+
ce.assume(ce.expr(['Equal', 'p', 11]));
1313
// ce.assume(['Element', 'q', ['Range', -Infinity, 0]]); @fixme
1414
// ce.assume(['Element', 'r', ['Interval', ['Open', 0], +Infinity]]); @fixme
1515

16-
ce.assume(ce.box(['Greater', 's', 5]));
17-
ce.assume(ce.box(['Greater', 't', 0]));
16+
ce.assume(ce.expr(['Greater', 's', 5]));
17+
ce.assume(ce.expr(['Greater', 't', 0]));
1818

1919
// console.info([...ce.context!.dictionary!.symbols.keys()]);
2020

2121
// #18: Value Resolution from Equality Assumptions
22-
// When `ce.assume(['Equal', 'one', 1])` is made, `ce.box('one').evaluate()` should return `1`
22+
// When `ce.assume(['Equal', 'one', 1])` is made, `ce.expr('one').evaluate()` should return `1`
2323
describe('VALUE RESOLUTION FROM EQUALITY ASSUMPTIONS', () => {
2424
test(`one.value should be 1`, () => {
25-
expect(ce.box('one').evaluate().json).toEqual(1);
25+
expect(ce.expr('one').evaluate().json).toEqual(1);
2626
});
2727

2828
test(`one.domain should be integer`, () => {
2929
// The type might be 'finite_integer' (subtype of integer)
30-
expect(ce.box('one').type.matches('integer')).toBe(true);
30+
expect(ce.expr('one').type.matches('integer')).toBe(true);
3131
});
3232

3333
test(`Equal(one, 1) should evaluate to True`, () => {
34-
expect(ce.box(['Equal', 'one', 1]).evaluate().json).toEqual('True');
34+
expect(ce.expr(['Equal', 'one', 1]).evaluate().json).toEqual('True');
3535
});
3636

3737
test(`Equal(o, 1) should evaluate to True`, () => {
38-
expect(ce.box(['Equal', 'o', 1]).evaluate().json).toEqual('True');
38+
expect(ce.expr(['Equal', 'o', 1]).evaluate().json).toEqual('True');
3939
});
4040

4141
test(`NotEqual(one, 1) should evaluate to False`, () => {
42-
expect(ce.box(['NotEqual', 'one', 1]).evaluate().json).toEqual('False');
42+
expect(ce.expr(['NotEqual', 'one', 1]).evaluate().json).toEqual('False');
4343
});
4444

4545
test(`Equal(one, 0) should evaluate to False`, () => {
46-
expect(ce.box(['Equal', 'one', 0]).evaluate().json).toEqual('False');
46+
expect(ce.expr(['Equal', 'one', 0]).evaluate().json).toEqual('False');
4747
});
4848
});
4949

5050
// #19: Inequality Evaluation Using Assumptions
5151
// When `x > 4` is assumed, `['Greater', 'x', 0]` should evaluate to True
5252
describe('INEQUALITY EVALUATION USING ASSUMPTIONS', () => {
5353
test(`Greater(x, 0) should be True (x > 4 assumed)`, () => {
54-
expect(ce.box(['Greater', 'x', 0]).evaluate().json).toEqual('True');
54+
expect(ce.expr(['Greater', 'x', 0]).evaluate().json).toEqual('True');
5555
});
5656

5757
test(`Less(x, 0) should be False (x > 4 assumed)`, () => {
58-
expect(ce.box(['Less', 'x', 0]).evaluate().json).toEqual('False');
58+
expect(ce.expr(['Less', 'x', 0]).evaluate().json).toEqual('False');
5959
});
6060

6161
test(`Greater(t, 0) should be True (t > 0 assumed)`, () => {
62-
expect(ce.box(['Greater', 't', 0]).evaluate().json).toEqual('True');
62+
expect(ce.expr(['Greater', 't', 0]).evaluate().json).toEqual('True');
6363
});
6464

6565
test(`Greater(one, 0) should be True (one = 1 assumed)`, () => {
66-
expect(ce.box(['Greater', 'one', 0]).evaluate().json).toEqual('True');
66+
expect(ce.expr(['Greater', 'one', 0]).evaluate().json).toEqual('True');
6767
});
6868

6969
test(`Less(one, 0) should be False (one = 1 assumed)`, () => {
70-
expect(ce.box(['Less', 'one', 0]).evaluate().json).toEqual('False');
70+
expect(ce.expr(['Less', 'one', 0]).evaluate().json).toEqual('False');
7171
});
7272

7373
test(`GreaterEqual(one, 1) should be True`, () => {
74-
expect(ce.box(['GreaterEqual', 'one', 1]).evaluate().json).toEqual('True');
74+
expect(ce.expr(['GreaterEqual', 'one', 1]).evaluate().json).toEqual('True');
7575
});
7676
});
7777

7878
// #20: Tautology and Contradiction Detection
7979
// ce.assume() should return 'tautology' for redundant assumptions and 'contradiction' for conflicting ones
8080
describe('TAUTOLOGY AND CONTRADICTION DETECTION', () => {
8181
test(`assuming one = 1 again should return tautology`, () => {
82-
expect(ce.assume(ce.box(['Equal', 'one', 1]))).toEqual('tautology');
82+
expect(ce.assume(ce.expr(['Equal', 'one', 1]))).toEqual('tautology');
8383
});
8484

8585
test(`assuming one < 0 should return contradiction (one = 1)`, () => {
86-
expect(ce.assume(ce.box(['Less', 'one', 0]))).toEqual('contradiction');
86+
expect(ce.assume(ce.expr(['Less', 'one', 0]))).toEqual('contradiction');
8787
});
8888

8989
test(`assuming x < 0 should return contradiction (x > 4)`, () => {
90-
expect(ce.assume(ce.box(['Less', 'x', 0]))).toEqual('contradiction');
90+
expect(ce.assume(ce.expr(['Less', 'x', 0]))).toEqual('contradiction');
9191
});
9292

9393
test(`assuming x > 0 should return tautology (x > 4 implies x > 0)`, () => {
94-
expect(ce.assume(ce.box(['Greater', 'x', 0]))).toEqual('tautology');
94+
expect(ce.assume(ce.expr(['Greater', 'x', 0]))).toEqual('tautology');
9595
});
9696
});
9797

9898
// #21: Type Inference from Assumptions - IMPLEMENTED
9999
// When assumptions are made, symbol types should be inferred
100100
describe('TYPE INFERENCE FROM ASSUMPTIONS', () => {
101101
test(`x should have type real (x > 4 assumed)`, () => {
102-
expect(ce.box('x').type.toString()).toBe('real');
102+
expect(ce.expr('x').type.toString()).toBe('real');
103103
});
104104

105105
test(`s should have type real (s > 5 assumed)`, () => {
106-
expect(ce.box('s').type.toString()).toBe('real');
106+
expect(ce.expr('s').type.toString()).toBe('real');
107107
});
108108

109109
test(`t should have type real (t > 0 assumed)`, () => {
110-
expect(ce.box('t').type.toString()).toBe('real');
110+
expect(ce.expr('t').type.toString()).toBe('real');
111111
});
112112

113113
test(`one should have type integer (one = 1 assumed)`, () => {
114-
expect(ce.box('one').type.toString()).toBe('integer');
114+
expect(ce.expr('one').type.toString()).toBe('integer');
115115
});
116116

117117
test(`o should have type integer (o = 1 assumed)`, () => {
118-
expect(ce.box('o').type.toString()).toBe('integer');
118+
expect(ce.expr('o').type.toString()).toBe('integer');
119119
});
120120

121121
test(`p should have type integer (p = 11 assumed)`, () => {
122-
expect(ce.box('p').type.toString()).toBe('integer');
122+
expect(ce.expr('p').type.toString()).toBe('integer');
123123
});
124124
});
125125

@@ -187,33 +187,33 @@ describe('ASSUMPTION-BASED SIMPLIFICATION', () => {
187187
test('isPositive returns true when x > 0 is assumed', () => {
188188
const ce = new ComputeEngine();
189189
ce.assume(ce.parse('x > 0'));
190-
expect(ce.box('x').isPositive).toBe(true);
191-
expect(ce.box('x').isNonNegative).toBe(true);
192-
expect(ce.box('x').isNegative).toBe(false);
190+
expect(ce.expr('x').isPositive).toBe(true);
191+
expect(ce.expr('x').isNonNegative).toBe(true);
192+
expect(ce.expr('x').isNegative).toBe(false);
193193
});
194194

195195
test('isNegative returns true when x < 0 is assumed', () => {
196196
const ce = new ComputeEngine();
197197
ce.assume(ce.parse('x < 0'));
198-
expect(ce.box('x').isNegative).toBe(true);
199-
expect(ce.box('x').isNonPositive).toBe(true);
200-
expect(ce.box('x').isPositive).toBe(false);
198+
expect(ce.expr('x').isNegative).toBe(true);
199+
expect(ce.expr('x').isNonPositive).toBe(true);
200+
expect(ce.expr('x').isPositive).toBe(false);
201201
});
202202

203203
test('isNonNegative returns true when x >= 0 is assumed', () => {
204204
const ce = new ComputeEngine();
205205
ce.assume(ce.parse('x \\ge 0'));
206-
expect(ce.box('x').isNonNegative).toBe(true);
206+
expect(ce.expr('x').isNonNegative).toBe(true);
207207
// Could be zero, so not strictly positive
208-
expect(ce.box('x').isPositive).toBe(undefined);
208+
expect(ce.expr('x').isPositive).toBe(undefined);
209209
});
210210

211211
test('isNonPositive returns true when x <= 0 is assumed', () => {
212212
const ce = new ComputeEngine();
213213
ce.assume(ce.parse('x \\le 0'));
214-
expect(ce.box('x').isNonPositive).toBe(true);
214+
expect(ce.expr('x').isNonPositive).toBe(true);
215215
// Could be zero, so not strictly negative
216-
expect(ce.box('x').isNegative).toBe(undefined);
216+
expect(ce.expr('x').isNegative).toBe(undefined);
217217
});
218218

219219
test('assumptions do not leak between engine instances', () => {
@@ -223,6 +223,6 @@ describe('ASSUMPTION-BASED SIMPLIFICATION', () => {
223223
const ce2 = new ComputeEngine();
224224
// x should have unknown sign in ce2
225225
expect(ce2.parse('\\sqrt{x^2}').simplify().latex).toBe('\\vert x\\vert');
226-
expect(ce2.box('x').isPositive).toBe(undefined);
226+
expect(ce2.expr('x').isPositive).toBe(undefined);
227227
});
228228
});

test/compute-engine/benchmarks/expand.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { benchmark, engine } from '../../utils';
66
//
77

88
function expand(e: Expression): Expression {
9-
return engine.box(['Expand', e]).evaluate();
9+
return engine.expr(['Expand', e]).evaluate();
1010
}
1111

1212
const p = engine.parse(`3x^2yz^7 + 7xyz^2 + 4x + xy^4`);
@@ -43,7 +43,7 @@ describe('SymPy Benchmarks', () => {
4343

4444
test.skip(`Expand((2 + 3i)^1000)`, () => {
4545
expect(
46-
benchmark(() => expand(engine.box(['Power', ['Complex', 2, 3], 1000])), {
46+
benchmark(() => expand(engine.expr(['Power', ['Complex', 2, 3], 1000])), {
4747
mem: 3256,
4848
time: 0.09,
4949
exprs: 6,
@@ -56,7 +56,7 @@ describe('SymPy Benchmarks', () => {
5656
benchmark(
5757
() =>
5858
expand(
59-
engine.box(['Power', ['Complex', 2, ['Rational', 3, 4]], 1000])
59+
engine.expr(['Power', ['Complex', 2, ['Rational', 3, 4]], 1000])
6060
),
6161
{
6262
mem: 5200,

test/compute-engine/benchmarks/wester.benchmark.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export const ce = new ComputeEngine();
1313

1414
describe.skip('Wester CAS Test Suite', () => {
1515
test(`Wester 1`, () => {
16-
expect(ce.box(['Factorial', 50]).evaluate()).toMatchInlineSnapshot(
16+
expect(ce.expr(['Factorial', 50]).evaluate()).toMatchInlineSnapshot(
1717
`"[\\"Factorial\\",50]"`
1818
);
1919
});
2020

2121
test(`Wester 2`, () => {
2222
expect(
23-
ce.box(['Factors', ['Factorial', 50]]).evaluate()
23+
ce.expr(['Factors', ['Factorial', 50]]).evaluate()
2424
).toMatchInlineSnapshot(
2525
`"[\\"Pattern\\",[[\\"Pattern\\",\\"Factors\\"],[\\"Pattern\\",\\"Factorial\\"],[\\"Pattern\\",50]]]"`
2626
);
@@ -43,15 +43,15 @@ describe.skip('Wester CAS Test Suite', () => {
4343
// test(`Wester 3`, () => {
4444
// //['Divide', 4861 2520]
4545
// expect(
46-
// ce.box(['Sum', ['Divide', 1, '_'], ['Range', 2, 10]]).evaluate()
46+
// ce.expr(['Sum', ['Divide', 1, '_'], ['Range', 2, 10]]).evaluate()
4747
// ).toMatchInlineSnapshot();
4848
// });
4949

5050
test(`Wester 4`, () => {
5151
// 262537412640768743
5252
// @todo: precision 50
5353
expect(
54-
ce.box(['Exp', ['Multiply', 'Pi', ['Sqrt', 163]]]).N()
54+
ce.expr(['Exp', ['Multiply', 'Pi', ['Sqrt', 163]]]).N()
5555
).toMatchInlineSnapshot(
5656
`"{\\"num\\":\\"262537412640768743.9999999999992500725971981856888793538563373369908627075374103782106479101186073091\\"}"`
5757
);
@@ -62,7 +62,7 @@ describe.skip('Wester CAS Test Suite', () => {
6262
test(`Wester 6`, () => {
6363
expect(
6464
// 0.142857
65-
ce.box(['Divide', 1, 7]).N()
65+
ce.expr(['Divide', 1, 7]).N()
6666
).toMatchInlineSnapshot(
6767
`"{\\"num\\":\\"0.1428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571429\\"}"`
6868
);
@@ -74,7 +74,7 @@ describe.skip('Wester CAS Test Suite', () => {
7474
expect(
7575
// √(2√3+4) -> 1 + √3
7676
ce.parse('\\sqrt{2\\sqrt{3}+4}').evaluate()
77-
// ce.box(['Sqrt', ['Add', ['Multiply', 2, ['Sqrt', 3]], 4]]).evaluate()
77+
// ce.expr(['Sqrt', ['Add', ['Multiply', 2, ['Sqrt', 3]], 4]]).evaluate()
7878
).toMatchInlineSnapshot(
7979
`"[\\"Sqrt\\",[\\"Add\\",4,[\\"Multiply\\",2,[\\"Sqrt\\",3]]]]"`
8080
);
@@ -173,22 +173,22 @@ describe.skip('Wester CAS Test Suite', () => {
173173

174174
test(`Wester 121`, () => {
175175
// Expect False
176-
expect(ce.box(['And', 'True', 'False']).evaluate()).toMatchInlineSnapshot(
176+
expect(ce.expr(['And', 'True', 'False']).evaluate()).toMatchInlineSnapshot(
177177
`"\\"False\\""`
178178
);
179179
});
180180

181181
test(`Wester 122`, () => {
182182
// Expect true
183-
expect(ce.box(['Or', 'x', ['Not', 'x']]).evaluate()).toMatchInlineSnapshot(
183+
expect(ce.expr(['Or', 'x', ['Not', 'x']]).evaluate()).toMatchInlineSnapshot(
184184
`"\\"True\\""`
185185
);
186186
});
187187

188188
test(`Wester 123`, () => {
189189
// Expect x or y
190190
expect(
191-
ce.box(['Or', 'x', 'y', ['And', 'x', 'y']]).evaluate()
191+
ce.expr(['Or', 'x', 'y', ['And', 'x', 'y']]).evaluate()
192192
).toMatchInlineSnapshot(
193193
`"[\\"Or\\",\\"x\\",\\"y\\",[\\"And\\",\\"x\\",\\"y\\"]]"`
194194
);

test/compute-engine/bug-fixes.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ describe('BUG FIXES', () => {
55
describe('Bug #24: forget() should clear assumed values', () => {
66
test('forget() clears values from evaluation context', () => {
77
const ce = new ComputeEngine();
8-
ce.assume(ce.box(['Equal', 'x', 5]));
9-
expect(ce.box('x').evaluate().json).toEqual(5);
8+
ce.assume(ce.expr(['Equal', 'x', 5]));
9+
expect(ce.expr('x').evaluate().json).toEqual(5);
1010

1111
ce.forget('x');
12-
expect(ce.box('x').evaluate().json).toEqual('x');
12+
expect(ce.expr('x').evaluate().json).toEqual('x');
1313
});
1414
});
1515

1616
describe('Bug #25: Scoped assumptions should clean up on popScope()', () => {
1717
test('popScope() removes values set by assumptions in that scope', () => {
1818
const ce = new ComputeEngine();
19-
expect(ce.box('y').evaluate().json).toEqual('y');
19+
expect(ce.expr('y').evaluate().json).toEqual('y');
2020

2121
ce.pushScope();
22-
ce.assume(ce.box(['Equal', 'y', 10]));
23-
expect(ce.box('y').evaluate().json).toEqual(10);
22+
ce.assume(ce.expr(['Equal', 'y', 10]));
23+
expect(ce.expr('y').evaluate().json).toEqual(10);
2424

2525
ce.popScope();
26-
expect(ce.box('y').evaluate().json).toEqual('y');
26+
expect(ce.expr('y').evaluate().json).toEqual('y');
2727
});
2828
});
2929

test/compute-engine/calculus.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,30 +442,30 @@ describe('NUMERICAL INTEGRATION', () => {
442442
describe('LIMIT', () => {
443443
expect(
444444
engine
445-
.box(['Limit', ['Function', ['Divide', ['Sin', 'x'], 'x'], 'x'], 0])
445+
.expr(['Limit', ['Function', ['Divide', ['Sin', 'x'], 'x'], 'x'], 0])
446446
.N().re
447447
).toMatchInlineSnapshot(`1`);
448448

449449
expect(
450450
engine
451-
.box(['Limit', ['Function', ['Divide', ['Sin', 'x'], 'x'], 'x'], 0])
451+
.expr(['Limit', ['Function', ['Divide', ['Sin', 'x'], 'x'], 'x'], 0])
452452
.N().re
453453
).toMatchInlineSnapshot(`1`);
454454

455455
expect(
456456
engine
457-
.box(['NLimit', ['Function', ['Divide', ['Sin', 'x'], 'x'], 'x'], 0])
457+
.expr(['NLimit', ['Function', ['Divide', ['Sin', 'x'], 'x'], 'x'], 0])
458458
.evaluate().re
459459
).toMatchInlineSnapshot(`1`);
460460

461461
expect(
462-
engine.box(['NLimit', ['Divide', ['Sin', '_'], '_'], 0]).evaluate().re
462+
engine.expr(['NLimit', ['Divide', ['Sin', '_'], '_'], 0]).evaluate().re
463463
).toMatchInlineSnapshot(`1`);
464464

465465
// Should be "1"
466466
expect(
467467
engine
468-
.box([
468+
.expr([
469469
'NLimit',
470470
['Function', ['Cos', ['Divide', 1, 'x']], 'x'],
471471
'Infinity',

0 commit comments

Comments
 (0)