Skip to content

Conversation

@stephanwlee
Copy link
Contributor

When closure compilation is turned on, it uses prototype definitions to
mangle and optimize the calls. This made some method not defined
statically problematic and it seems to have turned numeric.div into
something else.

According to numericjs, unlike other methods we use like dot and
transpose, is genearted dynamically from numeric.ops2 and Closure seems
to not handle it well.
https://github.com/sloisel/numeric/blob/master/src/numeric.js

Concretely, it turns numeric.div(a, b) into mangledName(numeric, a) and
this led division operation to infinitely loop.

c = d.slice(0, a.PCA_SAMPLE_SIZE);
c = Oa(numeric, numeric.dot(numeric.transpose(c), c));
var e = numeric.svd(c)

In above code snippet, Oa is the div method.

Fixes #1480

Copy link
Contributor

@nfelt nfelt left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, but it would be great if we could be a little more sure the fix is robust - might be worth adding a TODO above the line unpacking numeric to follow up and a comment explaining that the unpacking is necessary to avoid this issue.

When closure compilation is turned on, it uses prototype definitions to
mangle and optimize the calls. This made some method not defined
statically problematic and it seems to have turned `numeric.div` into
something else.

According to numericjs, unlike other methods we use like dot and
transpose, is genearted dynamically from numeric.ops2 and Closure seems
to not handle it well.
https://github.com/sloisel/numeric/blob/master/src/numeric.js

Concretely, it turns numeric.div(a, b) into mangledName(numeric, a) and
this led division operation to infinitely loop.
```
c = d.slice(0, a.PCA_SAMPLE_SIZE);
c = Oa(numeric, numeric.dot(numeric.transpose(c), c));
var e = numeric.svd(c)
```
In above code snippet, `Oa` is the `div` method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants