Skip to content
Open
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
18 changes: 6 additions & 12 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,40 +205,34 @@ module.exports = {
{
target: './src/compute-engine/tensor/**',
from: './src/compute-engine/symbolic/**',
message:
'tensor/ must not import from symbolic/.',
message: 'tensor/ must not import from symbolic/.',
},
{
target: './src/compute-engine/tensor/**',
from: './src/compute-engine/library/**',
message:
'tensor/ must not import from library/.',
message: 'tensor/ must not import from library/.',
},
{
target: './src/compute-engine/tensor/**',
from: './src/compute-engine/compilation/**',
message:
'tensor/ must not import from compilation/.',
message: 'tensor/ must not import from compilation/.',
},

// interval/ cannot import from symbolic/, library/, compilation/
{
target: './src/compute-engine/interval/**',
from: './src/compute-engine/symbolic/**',
message:
'interval/ must not import from symbolic/.',
message: 'interval/ must not import from symbolic/.',
},
{
target: './src/compute-engine/interval/**',
from: './src/compute-engine/library/**',
message:
'interval/ must not import from library/.',
message: 'interval/ must not import from library/.',
},
{
target: './src/compute-engine/interval/**',
from: './src/compute-engine/compilation/**',
message:
'interval/ must not import from compilation/.',
message: 'interval/ must not import from compilation/.',
},

// Type definition files (types-*.ts) cannot import from implementation layers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {
JsonSerializationOptions,
PatternMatchOptions,
SimplifyOptions,
TransformOptions,
IComputeEngine as ComputeEngine,
Scope,
Tensor,
Expand All @@ -38,6 +39,7 @@ import { toAsciiMath } from './ascii-math';
// Dynamic import for serializeJson to avoid circular dependency
import { cmp, eq, same } from './compare';
import { CancellationError } from '../../common/interruptible';
import { transform } from './transform';
import { isSymbol, isString, isNumber, isFunction } from './type-guards';

// Lazy reference to break circular dependency:
Expand Down Expand Up @@ -774,6 +776,10 @@ export abstract class _BoxedExpression implements Expression {
return null;
}

transform(options: TransformOptions): Expression | null {
return transform(this, options);
}

has(_v: string | string[]): boolean {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/compute-engine/boxed-expression/boxed-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ export class BoxedFunction

let evaluateFn: Expression | Promise<Expression> | undefined;
try {
const opts = {
const opts: Partial<EvaluateOptions> & { engine?: ComputeEngine } = {
numericApproximation,
engine,
signal: options?.signal,
Expand Down
2 changes: 1 addition & 1 deletion src/compute-engine/boxed-expression/canonical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function canonicalForm(
// Partial canonicalization produces a structural expression, not a fully
// canonical one. This allows subsequent .canonical calls to perform full
// canonicalization.
if (isFunction(expr) && expr.isCanonical) {
if (isFunction(expr) && forms.length > 0) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not a test to this... but changing this appeared to correct some behaviours whilst outlining the tests for transform. Throughout the partial-canonicalization process, appears that sometimes the expression is 'intermediarily' not marked as canonical.

expr = expr.engine.function(expr.operator, [...expr.ops!], {
form: 'structural',
});
Expand Down
Loading
Loading