GithubHelp home page GithubHelp logo

fibertree's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fibertree's Issues

`__getitem__` fails to raise IndexError

With the following code:

z = Tensor(rank_ids=["M", "N"])
z.setName("Z")
z.setMutable(True)

z_m = z.getRoot()
#
# Hack to fill in all the entries in z
# This allows us to pretend the tensor is dense
#
n_fiber = Fiber(coords=range(N), initial=1)
m_fiber = Fiber(coords=range(M), initial=1)

for m, (z_n, _) in z_m << m_fiber:
    for n, (z_ref, _) in z_n << n_fiber:
        z_ref <<= 0
        
z.getRoot()[0][0]

There were two problems:

  • The first indexing operation z.getRoot()[0] wants to raise an IndexError. I think this shouldn't happen.
  • The code fails to raise the IndexError.

Traceback follows.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[11], line 17
     14     for n, (z_ref, _) in z_n << n_fiber:
     15         z_ref <<= 0
---> 17 z.getRoot()[0][0]

File /usr/local/lib/python3.8/dist-packages/fibertree/core/fiber.py:1874, in Fiber.__getitem__(self, keys)
   1871     key += len(self)
   1873 if key < 0 or key >= len(self):
-> 1874     raise(IndexError, f"The index ({key}) is out of range")
   1876 new_payload = self.payloads[key]
   1878 if len(key_cdr):
   1879     # Recurse down the fiber tree

TypeError: exceptions must derive from BaseException

Populate operator does not account for non-zero default empty values

The populate operator (<< or _lshift_) currently has the following specs:

An explicit zero in the input will NOT generate a corresponding coordinate in the output

This needs to be updated to an "explicit empty value in the input will NOT generate a corresponding coordinate in the output."

For example, suppose b1_n below has default empty value as -1. Currently, the below code does NOT populate b2_n with coordinates where payloads are 0, even though in this case, 0 is a valid non-empty value.

b1_n = Fiber.fromUncompressed([0, 1, 2, 0, -1], default=-1)
for n, (b2_s, b1_val) in b2_n << b1_n:
   #Bug! this will never print 0 or 3 
   #    (the coordinates for  value 0), but it will 
   #     incorrectly print 4
   print(n)

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.