Git Product home page Git Product logo

jagged-array's People

Contributors

lewisacidic avatar

Watchers

 avatar

jagged-array's Issues

[feature] new __repr__ function

Repr will be broken when we address #14 as the shapes will get quite long vertically.

We should probably realign the repr to look like pydata/sparse for consistency.

[test] configure testing

  • tests with pytest should be runnable with python setup.py test
  • tests should run docstring tests
  • more tests should be written :)

[build] precommit hooks

We should have pre-commit hooks set up

  • black
  • flake8
  • precommit fixers (trailing-whitespace, end-of-file-fixer, check-yaml, debug-statements)
  • reorder-python-imports
  • pyupgrade
  • commitlint

Nice example: pytest

[fix] don't print the dtype if its {int,float}64

Emulate numpy in not printing the dtype if its the same as the base dtypes.

e.g.

>>> np.array([1, 2])
array([1, 2])

>>> np.array([1., 2.])
array([1., 2.])

>>> np.array([1., 2.], np.float32)
array([1., 2.], dtype=float32)

i.e. we should do

>>> JaggedArray([1, 2, 3], [[1, 2]])
JaggedArray(data=[1 2 3],
            shape=[[1 2]])

[feat] smoothe function

We should have an operation to make a jagged dimension smoothe. If all jagged axes are smoothed, we get a numpy array back.

>>> ja = JaggedArray([[0, 1, 2], [3, 4], [5, 6, 7]]); ja
JaggedArray([[0, 1, 2],
             [3, 4],
             [5, 6, 7]])
>>> ja.smoothe()
array([[0, 1],
       [3, 4],
       [5, 6]])

[feat] factory methods

We should have some factory methods, such as

  • array
  • asarray
  • asfortranarray
  • ascontiguousarray

[feature] better indexing support

We can currently slice only in the first dimension,

i.e.

>>> ja = jagged.JaggedArray(np.arange(22), (3, (3, 2, 3), (3, 2, 3))
>>> ja[0] # simple indexing
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])


>>> ja[:2] # slicing
JaggedArray([[[ 0,  1,  2],
              [ 3,  4,  5],
              [ 6,  7,  8]],

             [[ 9, 10],
              [11, 12]]])

>>> ja[::2] # with a step
JaggedArray([[[ 0,  1,  2],
              [ 3,  4,  5],
              [ 6,  7,  8]],

             [[13, 14, 15],
              [16, 17, 18],
              [19, 20, 21]]])

We can't slice in other directions. While this may less useful for jagged arrays, it should be supportable, i.e.

>>> ja[0, 0, 0]
0

>>> ja[0, 0]
array([0, 1, 2])

>>> ja[0, :, 0]
array([0, 3, 6])

>>>ja[:, 0]
JaggedArray([[ 0,  1,  2],
             [ 9, 10],
             [13, 14, 15]])

>>> ja[:, 0, 0]
array([0, 9, 13])

We should also support advanced indexing:

>>> ja[[0, 2]]
JaggedArray([[[ 0,  1,  2],
              [ 3,  4,  5],
              [ 6,  7,  8]],

             [[13, 14, 15],
              [16, 17, 18],
              [19, 20, 21]]])

>>> ja[:, [0, 1]]
JaggedArray([[[ 0,  1,  2],
              [ 3,  4,  5]],

             [[ 9, 10],
              [11, 12]],

             [[13, 14, 15],
              [16, 17, 18]]])

>>> ja[:, [0, 1], [0, 1]]
JaggedArray([[ 0,  4],
             [ 9, 12],
             [13, 17]])


>>> ja[:, [0, 2], [0, 2]]
JaggedArray([[ 0,  8],
             [ 9],
             [13, 21]])

Finally, allow np.newaxis (or None), ... etc.

>>> ja[..., 0, 0]
array([0, 9, 13])

>>> ja[:, np.newaxis]
JaggedArray([[[[ 0,  1,  2],
               [ 3,  4,  5],
               [ 6,  7,  8]]],


             [[[ 9, 10],
               [11, 12]]],


             [[[13, 14, 15],
               [16, 17, 18],
               [19, 20, 21]]]])
)

[feat] strides for slicing

We should implement strides for better slicing support.

These can be a collection over subarrays much as shape / shapes are.

[bug] shape dimensions are unintuitive

Currently, the shape array is oriented so that axis 0 relates to the rest of the dimensions, and axis 1 relates to the first dimension. Why is only known to my thesis-addled brain., as it is not intuitive, especially when slicing it:

>>> ja = JaggedArray(np.arange(22), [[3, 2, 3], [3, 2, 3]])
>>> ja[0]
array([[ 0, 1, 2],
       [3, 4, 5],
       [6 ,7, 8]])
>>> ja.shape[0]  # intuitively, the shape of `ja[0]`, but
array([3, 2, 3])
>>> ja.shape[:, 0]
array([3, 3])

This of course will require quite the refactor, probably better a full rewrite.

[docs] README

Write a good readme, with

  • all the badges
  • one sentence description
  • installation
  • use cases
  • basic examples
  • acknowledgements

[feature] annotate with types

I don't think typing was even a thing when the initial code from scikit-chem was written. It should be relatively easy to add types in now.

[feat] support using dense arrays in concat etc.

Would be good to allow the use of dense arrays in concatenate etc.

This would be trivial to implement simply by converting the dense array to a jagged array, although there could be optimisations made to avoid that overhead.

[fix] reshape arguments broken

Currently, you pass a shape to reshape, ie .

>>> JaggedArray([[0, 1], [2], [3, 4]]).reshape((3, (1, 2, 2))) 
JaggedArray([[0], 
             [1, 2], 
             [3, 4]])

Instead, we should emulate numpy, where the shape are the arguments:

>>> np.arange(25).reshape(5, 5)
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19],
       [20, 21, 22, 23, 24]])

i.e.

>>> JaggedArray([[0, 1], [2], [3, 4]]).reshape(3, (1, 2, 2))
JaggedArray([[0], 
             [1, 2], 
             [3, 4]])

We could also allow passing shapes, like

>>> JaggedArray([[0, 1], [2], [3, 4]]).reshape(shapes=[[1], [2], [2]]) 
JaggedArray([[0], 
             [1, 2], 
             [3, 4]])

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.