
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
ndarray-unsqueeze
Advanced tools
Add singleton dimensions to an ndarray
This module takes an input ndarray and either appends a singleton dimension (a dimension of length one) or inserts it before a specific dimension.
var ndarray = require('ndarray')
var unsqueeze = require('ndarray-unsqueeze')
unsqueeze(ndarray([1, 2, 3, 4], [2, 2]))
// => ndarray([1, 2, 3, 4], [2, 2, 1])
unsqueeze(ndarray([1, 2, 3, 4], [2, 2]), 0)
// => ndarray([1, 2, 3, 4], [1, 2, 2])
Note that ndarrays have no concept of row or column vectors. If you need a matrix explicitly representing a row or column vector, you can use unsqueeze:
var show = require('ndarray-show')
// Create a 3 x 1 matrix by appending a singleton dimension:
show(unsqueeze(ndarray([1,2,3])))
// => 1.000
// 2.000
// 3.000
// Create a 1 x 3 matrix by prepending a singleton dimension:
show(unsqueeze(ndarray([1,2,3]), 0))
// => 1.000 2.000 3.000
$ npm install ndarray-unsqueeze
require('ndarray-unsqueeze')(input[, axis])Arguments:
input: The input ndarray to be unsqueezeaxes (optional): An integer index of the dimension at which to insert the singleton dimension. If unspecified, singleton dimension is appended to the shape.Returns: A new array view of the unsqueezed ndarray (i.e. a new ndarray object with the same underlying data).
© 2016 Ricky Reusser. MIT License.
FAQs
Add singleton dimensions to an ndarray
The npm package ndarray-unsqueeze receives a total of 122 weekly downloads. As such, ndarray-unsqueeze popularity was classified as not popular.
We found that ndarray-unsqueeze demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.