Skip to content

Arguments to matrix operations appear to be modified by side effect #2990

@gwhitney

Description

@gwhitney
          fair enough ....

step 1: I create a scope,

        if (decaySliceApiCall.isSuccess) {
            const scope = {}
            channels.map((channel) => {
                scope[`Ch${channel}`] = {}
                decays.map((decay) => {
                    scope[`Ch${channel}`][`D${decay}`] = decaySliceApiCall.data.data.z.channels[`${channel}`].decays[`${decay}`]
                })
            })
            setScope(scope)

the scope looks like:

image

e.g Ch0.D10 is a 2D array of numbers

if I use the expression Ch0.D40./Ch2.D40 ....

let expression = "Ch0.D40./Ch2.D40"
        if (scope) {
            let localScope = { ...scope }
            try {
                //math.evaluate('fImage=' + expression, localScope).toArray()

                const node = math.parse(expression)
                const code = node.compile()
                console.log(code.evaluate(localScope))
                
            } catch (error) {
                console.error(error);
            }
        }

the outpur is an Error

image

interestingly,

if i change the expression to:

const node = math.parse('Ch2.D40')

the the output is fine:
image

hope this helps.

Originally posted by @pramod-bls in #2596 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions