mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Make matrix dependency optional for now in subset (WIP)
This commit is contained in:
parent
bd2e68e3ab
commit
c8b02fb9f2
@ -5,7 +5,7 @@ import { errorTransform } from './utils/errorTransform'
|
||||
import { createSubset } from '../../function/matrix/subset'
|
||||
|
||||
const name = 'subset'
|
||||
const dependencies = ['typed', 'matrix']
|
||||
const dependencies = ['typed', '?matrix']
|
||||
|
||||
export const createSubsetTransform = /* #__PURE__ */ factory(name, dependencies, ({ typed, matrix }) => {
|
||||
const subset = createSubset({ typed, matrix })
|
||||
|
||||
@ -72,7 +72,7 @@ import {
|
||||
} from './plain/number'
|
||||
|
||||
import { factory } from './utils/factory'
|
||||
import { noMatrix, noSubset } from './utils/noop'
|
||||
import { noSubset } from './utils/noop'
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// classes and functions
|
||||
@ -171,7 +171,6 @@ export { createNumber } from './type/number'
|
||||
export { createString } from './type/string'
|
||||
export { createBoolean } from './type/boolean'
|
||||
export { createParser } from './expression/function/parser'
|
||||
export const createMatrix = /* #__PURE__ */ factory('matrix', [], () => noMatrix) // FIXME: needed now because subset transform needs it. Remove the need for it in subset
|
||||
|
||||
// expression
|
||||
export { createNode } from './expression/node/Node'
|
||||
|
||||
@ -6,9 +6,10 @@ import { validateIndex } from '../../utils/array'
|
||||
import { getSafeProperty, setSafeProperty } from '../../utils/customs'
|
||||
import { DimensionError } from '../../error/DimensionError'
|
||||
import { factory } from '../../utils/factory'
|
||||
import { noMatrix } from '../../utils/noop'
|
||||
|
||||
const name = 'subset'
|
||||
const dependencies = ['typed', 'matrix']
|
||||
const dependencies = ['typed', '?matrix']
|
||||
|
||||
export const createSubset = /* #__PURE__ */ factory(name, dependencies, ({ typed, matrix }) => {
|
||||
/**
|
||||
@ -48,6 +49,10 @@ export const createSubset = /* #__PURE__ */ factory(name, dependencies, ({ typed
|
||||
return typed(name, {
|
||||
// get subset
|
||||
'Array, Index': function (value, index) {
|
||||
if (!matrix) {
|
||||
noMatrix()
|
||||
}
|
||||
|
||||
const m = matrix(value)
|
||||
const subset = m.subset(index) // returns a Matrix
|
||||
return index.isScalar()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user