nicolaspanel / numjs Goto Github PK
View Code? Open in Web Editor NEWLike NumPy, in JavaScript
License: MIT License
Like NumPy, in JavaScript
License: MIT License
I haven't thought deeply about an appropriate API, but would you be interested in a PR (or a discussion about who to structure one) that integrates numpy-parser
to allow loading .npy
files?
Just curious why there's nj.exp(A) but not nj,log(A). I was hoping to use log in a pointwise inverse sigmoid.
Thanks for the awesome library!
Following the instructions for taking FFT, I am trying to concatenate the real and imaginary parts like this:
RI = nj.concatenate(nj.array(my_sound_array), nj.zeros(my_sound_array.length))
This gives me the following error:
numjs.js:22114 Uncaught Error: all the input arrays must have same number of dimensions
at new ValueError (numjs.js:22114)
at Object.concatenate (numjs.js:23242)
How do I overcome this error ?
I got a couple of warnings about Sandbox breakout.
Just thought I should post it. I'm thinking there is a manual solution to upgrade static-eval to version >=2
Any advice or thoughts on if this is a concern, how to change the source dependency etc.
=== npm audit security report ===
┌──────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Sandbox Breakout / Arbitrary Code Execution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ static-eval │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=2.0.0 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ numjs │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ numjs > cwise > static-module > static-eval │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/548 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Sandbox Breakout / Arbitrary Code Execution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ static-eval │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=2.0.0 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ numjs │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ numjs > ndarray-fft > cwise > static-module > static-eval │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/548 │
└───────────────┴──────────────────────────────────────────────────────────────┘
found 2 moderate severity vulnerabilities in 272 scanned packages
2 vulnerabilities require manual review. See the full report for details.
https://nodesecurity.io/advisories/548
It's odd because it is that version 2.0.0 running an update made no change?
What I want to do, is to save the memory usage.
I have a project that will deal with large photos, like a 4000 x 4000 JPEG file. what I want to do is:
const image = nj.images.read('file-path.jpeg')`
image.flatten() // this will cause MEMORY OUT
const typedData = image.XXX? // HOW TO GET THIS?
const base64Text = new Buffer(typedData).toString('base64')
The current operation is use a image.flatten().tolist()
and uses lots of memory, which caused a nodejs OUT OF HEAP MEMORY ERROR. (only add node --max-old-space-size=4096
can make it)
I saw a method of nj.getRawData()
, may I use that? And another question: does it the same function like np.getbuffer()
? If so, why not the same name.
Thanks!
UPDATE: I make a reproduce-able code to demo the problem:
Both flatten()
and reshape()
will not work with very large NdArray, like [8000, 10000].
But a for-loop with NdArray will be ok.
const a = nj.ones([8000, 10000])
console.log('DONE1', a)
/**
* The following two functions will cause
* FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
* flatten()
* reshape()
*/
// a.flatten()
// a.reshape(1, -1)
/**
* The following raw TypeArray will did the job without problem
*/
const [row, col] = a.shape
const typedData = new Float64Array(row * col)
let n = 0
for (let i = 0; i < row; i++) {
for (let j = 0; j < col; j++) {
typedData[n++] = a.get(i, j)
}
}
Will this library work for react-native projects?
Hi,
I tried to run numjs
with RunKit
, it gives me the following error messages:
Error Stack Trace Viewer
Error: Cannot find module './build/Release/sharp.node'
at Module._resolveFilename in core module.js — line 325
at Module._load in core module.js — line 276
at Module.require in core module.js — line 353
at require in core internal/module.js — line 12
at sharp/index.js — line 12
node.js startup…
and when trying to use numjs
in jsbin I don't get the expected results.
It looks like it's giving me back the full constructor in the console instead of the array.
Doing a little REPL testing I found the reshape commend is not working.
> let rangeArray = np.arange(6,12)
> rangeArray
array([ 6, 7, 8, 9, 10, 11])
> rangeArray.reshape( (2,3) )
ValueError: total size of new array must be unchanged
at new ValueError (./node_modules/numjs/src/errors.js:5:21)
at NdArray.reshape (./node_modules/numjs/src/ndarray.js:260:11)
> rangeArray.size
6
> rangeArray.reshape( (1,6) )
array([ 6, 7, 8, 9, 10, 11])
> rangeArray.reshape( (6,1) )
ValueError: total size of new array must be unchanged
at new ValueError (./node_modules/numjs/src/errors.js:5:21)
at NdArray.reshape (./node_modules/numjs/src/ndarray.js:260:11)
This is a question.
I have a data (nda
below) of type ndarray (scijs/ndarray). Its dtype is float32 and underlying storage (nda.data) is a Buffer.
I was able to convert ndarray to NdArray by doing this:
const nja = nj.array(nda.data, 'float32').reshape(nda.shape);
I'd like to know if this is the right way to do. Would it allocate a new buffer under the hood?
(Some documents about migrating from ndarray to numjs(NdArray) would be great.)
Thanks in advance.
I do not know how can I feed data returned by nj.images.rgb2gray to this fft function.
const rgbData = nj.images.read(path.resolve(uplodsDir, `./${filename}`))
const grayData = nj.images.rgb2gray(rgbData)
nj.fft(grayData)
it throw an error "expect last dimension of the array to have 2 values (for both real and imaginary part)"
see numpy doc for more info
I am trying to do something similar to the following in reactjs:
const img = nj.images.read(nimg);
const rimage = nj.images.rgb2gray(img);
let rimg = React.createElement("canvas", {width: 500, height: 500});
console.log(rimg);
nj.images.save(rimage, rimg);
Whenever some condition occurs, I take an input image and try to return a canvas after manipulating it through numjs. But it always throw me an error in the last line (while saving it). The error is like this:
ValueError: expect input to be either an HTML Canvas or a (loaded) Image
How can I resolve this problem ? Please help me out here.
npm ERR! argv "F:\nodejs\node.exe" "F:\nodejs\node_modules\npm\bin\npm-cl
i.js" "install" "numjs" "--save"
npm ERR! node v6.11.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sharp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! F:\nodequant\nodequant\npm-debug.log
I do not know if sometimes the data array has the un-standarded shape, like the following code:
const a = nj.array([0, [1, 2], [2, 3], [[4, [5, 6]]], 4])
console.log(a.shape) // Output: [ 5 ]
My question is: a.shape
will be calculated only with the first-row element.
Should I never use this kind of un-fixed shape?
A related TypeScript issue: DefinitelyTyped/DefinitelyTyped#18508 (comment)
Migration is quite simple, but it's possible to achieve a visually cleaner code as a result, especially when it comes to the functional programming. It's not critical - but I can take care of it.
I think it would simplify further development
Hi, do you know any way to get something similar to linalg, ( with at least linalg.norm) easily ?
Allow creation of ones and zeros matrices that automatically set their shape based on the operations they are submitted to.
This way, I could stop having to do const ones = nj.ones(x.shape);
Edit: Since the reason this would be useful has mostly to do with elementwise operations, maybe an alternative to this would be providing a way to define custom elementwise operations, like the ones provided out of the box (such as nj.sigmoid()
)
Config: Windows 10, Node 7.8, Python 3.53
Do I need special requirements? When I try to install it I have this errors:
~\Documents\GitHub\Theta> npm install numjs
> [email protected] install C:\Users\Orion\Documents\GitHub\Theta\node_modules\sharp
> node-gyp rebuild
C:\Users\Orion\Documents\GitHub\Theta\node_modules\sharp>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\Orion\AppData\Local\Programs\Python\Python35\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:114:15)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Orion\Documents\GitHub\Theta\node_modules\sharp
gyp ERR! node -v v7.8.0
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Orion\Documents\GitHub\Theta\package.json'
npm WARN Theta No description
npm WARN Theta No repository field.
npm WARN Theta No README data
npm WARN Theta No license field.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "numjs"
npm ERR! node v7.8.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sharp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Orion\AppData\Roaming\npm-cache\_logs\2017-04-07T19_39_38_295Z-debug.log
This is a more a question out of curiosity: I notice your package relies on sharp
, which is a package for image resizing written for Node.js. On the readme it says numjs
runs in both: the browser and node.js. I am wondering which parts of numjs
will work and which ones will fail when using numjs
in the browser, assuming this statement is correct and that at least some part of sharp are incompatible lovell/sharp#766 (comment).
Thanks for the clarification and thanks for developing numjs
! :)
When I tried to use NumJs on Node.js, I got an error: Cannot find module 'browserify-shim'
.
NumJs requires browserify-shim
in package.json, but it seems not working -- it is used nowhere. Is browserify-shim
necessary?
NumJs:
> a = nj.array([1,2,3,4,5,6])
array([ 1, 2, 3, 4, 5, 6])
> a.slice([null, null, 2])
array([ 1, 3, 5])
> a.slice([1, null, 2])
array([ 1])
Python:
>>> a = [1,2,3,4,5,6]
>>> a[::2]
[1, 3, 5]
>>> a[1::2]
[2, 4, 6]
Numjs: > a.slice([1, null, 2]): array([ 1])
Python: >>> a[1::2]: [2, 4, 6]
Which as a.slice([1, null, 2])
in numjs behavior is not right.
UPDATE: I can use the following syntax to get the right slice. Does that be designed, or a bug?
> a.slice([1, 6, 2])
array([ 2, 4, 6])
I was wondering if there is something somewhere even though it's not working like numpy
> squareArray
[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]
> let sqAverage = nj.average(squareArray)
TypeError: nj.average is not a function
I had to go into the node_module and install it manually. src/utils.js appears to require the package.
According to numpy
document:
The result of rounding a float is a float. For values exactly halfway between rounded decimal
values, NumPy rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5
round to 0.0, etc.
but numjs.round to the nearest value. I have test:
const x = numjs.array([1.5, 2.5, -0.5, -1, 100])
console.log(nj.round(x).tolist())
got result:
[ 2, 3, -0, -1, 100 ]
sharp 0.20.3 isn't compatible with nodejs 12.
I am getting the following error while installing this lib. I don't seem to get the hang of what is the exact problem
$ npm i numjs
> [email protected] install C:\Users\Prashant\abc\node_modules\deasync
> node ./build.js
`win32-x64-node-8` exists; testing
Binary is fine; exiting
> [email protected] install C:\Users\Prashant\abc\node_modules\sharp
> node-gyp rebuild
C:\Users\Prashant\abc\node_modules\sharp>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: ENOENT: no such file or directory, open 'C:\Program'
gyp ERR! stack at Object.fs.openSync (fs.js:652:18)
gyp ERR! stack at Object.fs.readFileSync (fs.js:553:33)
gyp ERR! stack at readCAFile (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\install.js:466:15)
gyp ERR! stack at download (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\install.js:438:22)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\install.js:185:19
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:48:26
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:5)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Prashant\abc\node_modules\sharp
gyp ERR! node -v v8.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Prashant\AppData\Roaming\npm-cache\_logs\2017-08-31T12_53_03_906Z-debug.log
Any clue ?
Also, do I need python for installing this library?
multidimensional matrix multiplication?
Supported? Example? thanks
First off, thanks for all your work on this project!
I've been trying to use it in a ReactNative project as a numpy replacement for some TensorFlow preprocessing and I ran into a small issue with using the library outside of a NodeJS environment.
Specifically, the functions in src/images/
have dependencies on the path
module and __dirname
variable which don't exist outside of node.
I was able to work around this by only conditionally exporting the images code at the bottom of src/index.js
.
I'd be happy to clean it up a bit and submit a PR if this is a use case you'd be interested in supporting. Cheers.
Allow providing a seed for the random generator, with nj.random.seed(something)
Hi Nicolas, it would be nice to provide some real-world and cpu intensive algorithm examples, like by example LDA that I have put here in modified version of a known JavaScript implementation
This algorithm, when applied to large set of documents or small set with large number of tokens (words) is cpu bound and I beat that it could be improved using your numjs
in some way.
Thanks a lot.
see my project:
https://github.com/RexHuang/GaussNewton.js
I want to get result of following:
Jf = nj.array([[1.3009595627444526,9.007230966684432],[1.6924957839670183,23.436086522021778],[2.201868575113508,45.734101316607926],[2.8645419789086186,79.33095528080969],[3.726653280367031,129.00795614214644],[4.848225222175984,201.4009610995515],[6.30734496560592,305.6835907468525],[8.205600748567576,454.4937036239815]]);
Jf.T.multiply(Jf)
but got error:
Uncaught Error: cwise: Arrays do not all have the same shape!
at muleq_cwise_thunk (eval at n.exports (numjs.min.js:3), :8:71)
at Object.muleq_ndarrayops [as muleq] (eval at o (numjs.min.js:3), :3:42)
at T.multiply (numjs.min.js:3)
at :2:6
I had use matrixjs to solve the problem, pls study from https://github.com/Airblader/matrixjs
Here's some of my implementation:
// var delta = (Jf.T.multiply(Jf)).inv().multiply(Jf.T).multiply(r);
var Mat_Jf=Jf.flatten().tolist().toMatrix(Jf.shape[0],Jf.shape[1]);
var Mat_r=r.flatten().tolist().toMatrix(r.shape[0],r.shape[1]);
var Mat_delta = Mat_Jf.transpose().multiply(Mat_Jf).inverse().multiply(Mat_Jf.transpose()).multiply(Mat_r);
delta=nj.array(Mat_delta.toArray()).reshape(params.shape[0],params.shape[1]);
We also need the implement of inv()
I like numjs, hope we can improve:)
Can it display images from a DICOM
file?
It's listed in the readme, but not in the documentation. I cannot get it to work. Does it exist? Thanks
I think sharp
is quite a heavy dependency for a package, which main concern is working with numbers. Thus I propose to extract the image-related features and put them into their own package.
As I see it, sharp
is also only used for file-io and resizing, the latter I can understand. For file io I'm not sure, why it belongs into this package anyway.
p.s. my personal motivation is using numjs
in electron, though. Had trouble because of sharp compilation errors, though that doesn't make the other points less valid ;)
What is the standard way to create diagonal matrices or identity matrices?
I searched the source very quickly and couldn't find something promising. An example in the readme would be nice.
any implementation of numpy.fromstring?
This module uses Sharp as a dependency, which uses node-gyp as a dependency, which is hard-broken unless you have an out-of-date version of Python installed in your system. Is there a way to use this package without that dependency?
I'm on a quest to allow full on scientific computing in JavaScript, essentially to replace the need for Python source code. To achieve that, I imagine we'll need libraries that more closely mimic the APIs of popular Python libraries. Has this project considered more closely mimicking the numpy API, and how about WebAssembly? With WebAssembly we could potentially tap into the underlying libraries that numpy and others are built off of and get near-native capabilities in Node.js and the browser.
ref: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.rot90.html
Using numjs to drive a 16x16 led matrix and would like to rotate view based on device orientation.
> var m = numjs.array([[1,2],[3,4]], int)
> m
array([[1, 2],
[3, 4]])
> numjs.rot90(m)
array([[2, 4],
[1, 3]])
> numjs.rot90(m, 2)
array([[4, 3],
[2, 1]])
> var m = numjs.arange(8).reshape(2,2,2)
> numjs.rot90(m, 1, [1,2])
array([[[1, 3],
[0, 2]],
-1 as a parameter (one dimension of the shape) of reshape infers the size of the resulting reshaped array with the other shape parameter and the length
newshape : int or tuple of ints
The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.
Would be happy to contribute
How do I convert array created to a JS Array?
thanks.
Log below.
> gyp ERR! configure error
> gyp ERR! stack Error: Python executable "C:\Python35\python.EXE" is v3.5.1, which is not supported by gyp.
> gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
> gyp ERR! stack at failPythonVersion (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:406:14)
> gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:395:9
> gyp ERR! stack at ChildProcess.exithandler (child_process.js:193:7)
> gyp ERR! stack at emitTwo (events.js:100:13)
> gyp ERR! stack at ChildProcess.emit (events.js:185:7)
> gyp ERR! stack at maybeClose (internal/child_process.js:827:16)
> gyp ERR! stack at Socket.<anonymous> (internal/child_process.js:319:11)
> gyp ERR! stack at emitOne (events.js:90:13)
> gyp ERR! stack at Socket.emit (events.js:182:7)
> gyp ERR! stack at Pipe._onclose (net.js:475:12)
> gyp ERR! System Windows_NT 10.0.10586
> gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
> gyp ERR! cwd C:\Users\nash\node_modules\sharp
> gyp ERR! node -v v5.7.0
> gyp ERR! node-gyp -v v3.2.1
> gyp ERR! not ok
> npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\nash\package.json'
> npm WARN nash No description
> npm WARN nash No repository field.
> npm WARN nash No README data
> npm WARN nash No license field.
> npm ERR! Windows_NT 10.0.10586
> npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sharp"
> npm ERR! node v5.7.0
> npm ERR! npm v3.6.0
> npm ERR! code ELIFECYCLE
>
> npm ERR! [email protected] install: `node-gyp rebuild`
> npm ERR! Exit status 1
> npm ERR!
> npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
> npm ERR! Make sure you have the latest version of node.js and npm installed.
> npm ERR! If you do, this is most likely a problem with the sharp package,
> npm ERR! not with npm itself.
> npm ERR! Tell the author that this fails on your system:
> npm ERR! node-gyp rebuild
> npm ERR! You can get information on how to open an issue for this project with:
> npm ERR! npm bugs sharp
> npm ERR! Or if that isn't available, you can get their info via:
> npm ERR! npm owner ls sharp
> npm ERR! There is likely additional logging output above.
It would be very helpful if numjs supported mean/sum/min/max etc. over a specific axis like numpy.
a = nj.random([2,3]);
nj.mean(a, axis=1)
I'm realizing this is not python.
So I'm wondering if there's away to do square bracket reference to the array like.
> rangeArray
array([ 6, 7, 8, 9, 10, 11])
> rangeArray[0,1]
undefined
> rangeArray[0,0:2]
rangeArray[0,0:2]
^
SyntaxError: Unexpected token :
It is possible to overload the square bracket operators. I made a comment about it in this dated thread, but in ES6 and so NodeJS 10 it should be possible.
https://stackoverflow.com/a/46438904/4928388
Hi Nicolas,
Thank you for your work on this package, I think it would be great to be able to only load an indiviual function in the same way that gl-mat4
does : https://github.com/stackgl/gl-mat4
With that package, you're able to write:
var scale = require('gl-mat4').scale
var scale = require('gl-mat4/scale')
And it would be amazing it the same thing were possible with this package, like:
var linspace = require('numjs/linspace');
If this is something you'd consider, I might be able to help, even though it looks like the numpy
methods I'm looking for are not included in your library, but I'll do more digging to find out.
Cheers,
Alvin
Great package... would like to use it from observablehq.com. As far as I can tell, this requires the dist folder to be published on unpkg.com (the package is already there, but is incomplete). I don't know how that would be achieved.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.