Giter Site home page Giter Site logo

Comments (12)

sdiehl avatar sdiehl commented on July 24, 2024

Github kind of muddled the code formatting, I tried to format it. Did I get the test case right?

from blaze.

FrancescAlted avatar FrancescAlted commented on July 24, 2024

No, I have updated it correctly now. BTW, I like this single liner:

if os.path.exists(path): shutil.rmtree(path)

but probably you don't :)

from blaze.

sdiehl avatar sdiehl commented on July 24, 2024

I can reproduce this issue. It's definitely in Blaze, seems carray does the correct thing.

from blaze.

ovillellas avatar ovillellas commented on July 24, 2024

I've started playing with blaze, as I will start making extra tests for the persistence layer. There seems to be related problems that do not involve persistence at all. The following code may serve as a hint of what's going wrong:

>>> ds = dshape('2,2,int')
>>> a = Array(range(4), ds)

>>> a
Array
  datashape := 2, 2, int 
  values    := [CArray(ptr=4328095024)] 
  metadata  := [manifest, arraylike] 
  layout    := Chunked(dim=0) 
[0 1 2 3]    <---- looks dodgy... shouldn't it be "[[0 1] [2 3]]" ???


>>> a[2]
array(2)  <--- dodgy... bad indexing for a (2,2) array, right?

>>> a[0][0]
IndexError: 0-d arrays can't be indexed

from blaze.

ovillellas avatar ovillellas commented on July 24, 2024

Another update. It seems it is related to the Array constructor.
zeros and ones do result in proper arrays. However, Array looks very dodgy right now:

In [101]: Array(np.eye(6), dshape('2, 2, float64'))
Out[101]: 
Array
  datashape := 2, 2, float64 
  values    := [CArray(ptr=4328164448)] 
  metadata  := [manifest, arraylike] 
  layout    := Chunked(dim=0) 
[ 1.  0.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.  1.  0.  0.  0.
  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  0.  1.]

It seems that it just takes whatever values you pass in the first parameter and makes it a 1-d array out of it. The datashape seems ignored other than to set the datashape attribute. Note that in the example even the the size of the initial data is wrong and is preserved (it enumerates all 36 elements, even as from the datashape point of view only 4 should be present...)

from blaze.

sdiehl avatar sdiehl commented on July 24, 2024

Yeah there is something weird going on in the constructor, especially if you try interpret a numpy array in terms of a datashape that doesn't make sense in terms of the input object. Most of the array objects feed into either numpy or carray and read off the shapes and dtype and then upconvert into datashape as stop-gap measure... seems like its time to remove the stop-gaps and write a proper constructor function.

from blaze.

ovillellas avatar ovillellas commented on July 24, 2024

Ok, I've traced back the problem to carray.

It seems that when the carray is built providing a dtype, it loses the shape of the original array. It seems this is causing this bug.

I am going to add tests in carray to check this code, and try to fix it.

from blaze.

ovillellas avatar ovillellas commented on July 24, 2024

Fixed on commit
f896163 FIX: github blaze issue #14. carray now preserves dimensionality when an732a378 added test_queries from carray

In persist branch

from blaze.

sdiehl avatar sdiehl commented on July 24, 2024

Want to just merge this to trunk whenever you feel the branch is in a good place?

from blaze.

ovillellas avatar ovillellas commented on July 24, 2024

That would be fine. I may just push the whole branch as well... as it only adds the fix and some extra unit-tests for carray.

Right now I am adding a test case for this issue, So I will wait till that one is ready.

from blaze.

ovillellas avatar ovillellas commented on July 24, 2024

The fix needs extra polish

from blaze.

ovillellas avatar ovillellas commented on July 24, 2024

This was fixed in a definitive way. It is in the persist branch

from blaze.

Related Issues (20)

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.