Skip to content

unpack nested containers to a single level array

Notifications You must be signed in to change notification settings

vinceniko/matryoshka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Matryoshka

author: Vincent Nikolayev

Overview

Unpacks any array with nested-array type-containers to a 1D array.

Features

  • Able to preserve empty containers at their indices
  • Able to preserve full strings or unpack them to single length strings ie. 'st' vs. ['s', 't']
  • Pass in additional iterable types
  • Implements recursion

Requires

  • numpy: for the sole reason of passing in its ndarray type

Usage

array = [[[1], 2], ([3], [[4]]), (), 'string']

unpack(array)
out: [1, 2, 3, 4, (), 'string']

unpack(array, preserve_empties=False)
out: [1, 2, 3, 4, 'string']

unpack(array, preserve_empties=False, types=[str])
out: [1, 2, 3, 4, 's', 't', 'r', 'i', 'n', 'g']

About

unpack nested containers to a single level array

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages