npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

arrayviewer

v4.1.1

Published

View binary array data

Downloads

5

Readme

View binary array data stored in files, from node, the browser and the command line.

Install

npm install -g arrayviewer

Usage

Show the 4th element (-i 3) in an array stored in a file at ./data/a.f32:

arrayviewer ./data/a.f32 -i 3

produces something like,

[126.48208618164062, 127.23143005371094, 136.79074096679688,
-->126.48942565917969
127.26338195800781, 136.84552001953125, 126.47312927246094, 127.27062225341797, ...]

Show the 10th element, with more context (-c 5).

arrayviewer ./data/a.f32 -i 9 -c 5

might produce,

[..., 136.84552001953125, 126.47312927246094, 127.27062225341797, 136.86407470703125, 126.44374084472656,
-->127.25633239746094
136.88494873046875, 126.36851501464844, 127.19410705566406, 136.8431396484375, 126.31245422363281, ...]

Show some extra information with -v,

arrayviewer ./data/a.f32 -i 9 -c 5 -v

Length: 150528
[..., 136.84552001953125, 126.47312927246094, 127.27062225341797, 136.86407470703125, 126.44374084472656,
-->127.25633239746094
136.88494873046875, 126.36851501464844, 127.19410705566406, 136.8431396484375, 126.31245422363281, ...]

Types

Array type is inferred from a file's extension and can be overridden with the -t option.

arrayviewer ./data/a.arr -t int32

Extensions are mapped to a TypedArray in the following way,

extension | TypedArray | type ---------|------------|------------ i8 | Int8Array | int8 u8 | Uint8Array | uint8 i16 | Int16Array | int16 u16 | Uint16Array| uint16 i32 | Int32Array | int32 u32 | Uint32Array | uint32 f32 | Float32Array| float32 f64 | Float64Array | float64

or (for non-binary types) to Javascript types like this,

extension | Result Type | type ---------|-----------|------ json | Object | json key | Object | json txt | String | str csv | String | str tsv | String | str

Any value from the type column may be supplied with the -t option.

If none of these match the file extension (and no explicit type or metadata file is provided), the data will be interpreted as a Uint8Array.

Metadata

arrayviewer ./data/a.f32 -i 9 -c 6 -m

If the -m option is specified it will also look for a file of the same name as the array with the .meta extension. The meta file has the following format

{
	"shape" : [224, 224, 3],
	"type" : "float32"
}

type should be a string containing any of the values listed in the "type" column from the tables above.

These values match the numpy dtypes

In addition to allowing you to specify a type, providing a meta file allows you to index into an array using -i, -j, -k to specify row, column and channel, respectively.

Numpy

Write compatible arrays from numpy like this,

# given array 'a'
f = open('./data/a.f32', 'wb')
f.write(a.astype(np.float32).tostring())
f.close