Git Product home page Git Product logo

dynarray's Introduction

Dynarray

CircleCI

Dynamically growable Numpy arrays. They function exactly like normal numpy arrays, but support appending new elements.

Installation

Simply install from PyPI: pip install dynarray

Quickstart

Create an empty one-dimensional array and append elements to it:

from dynarray import DynamicArray

array = DynamicArray()

for element in range(10):
    array.append(element)

Create a multidimensional array and append rows:

from dynarray import DynamicArray

# The leading dimension is None to denote that this is
# the dynamic dimension
array = DynamicArray((None, 20, 10))

array.append(np.random.random((20, 10)))
array.extend(np.random.random((100, 20, 10)))

print(array.shape)  # (101, 20, 10)

Slice and perform arithmetic like with normal numpy arrays:

from dynarray import DynamicArray

array = DynamicArray(np.ones((100, 10)), dtype=np.float16)

assert array[10:11].sum() == 10.0
print(array[10])
array[10] *= 0.0
assert array[10].sum() == 0.0

Shrink to fit to minimize memory usage when no further resizing is needed:

from dynarray import DynamicArray

array = DynamicArray(np.ones((100, 10)), dtype=np.float16)
array.extend(np.ones((50, 10)))

assert array.capacity == 200
array.shrink_to_fit()
assert array.capacity == 150

dynarray's People

Contributors

maciejkula avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.