Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arrayviewer

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arrayviewer

View binary array data

  • 4.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

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,

extensionTypedArraytype
i8Int8Arrayint8
u8Uint8Arrayuint8
i16Int16Arrayint16
u16Uint16Arrayuint16
i32Int32Arrayint32
u32Uint32Arrayuint32
f32Float32Arrayfloat32
f64Float64Arrayfloat64

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

extensionResult Typetype
jsonObjectjson
keyObjectjson
txtStringstr
csvStringstr
tsvStringstr

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

Keywords

FAQs

Package last updated on 15 Mar 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc