Skip to content

ValueError: could not broadcast input array from shape (26,) into shape (26,1) #324

Description

@Stephanowicz

Hi!

Sorry for bothering again :D

Well, this error-text was mentioned in #319 and #321 - but I'm not sure if it is correlated...

I tried the example https://github.com/glumpy/glumpy/blob/master/examples/collection-triangles.py

The error throws up @ line 61 paths.append(P*s+(x,y,(d-1)), closed=True, color=(0,0,0,1))

where append is in agg_fast_path_collection.py @ line 104

the erroneous code is @ line 169:

V['id'] = np.tile([1,-1],len(V)//2)

where
V['id'] array([[0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.], [0.]], dtype=float32) [0:26] : [array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32), array([0.], dtype=float32)] dtype: dtype('float32') max: np.float32(0.0) min: np.float32(0.0) shape: (26, 1) size: 26

and np.tile([-1,1],len(V)//2)
array([ 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) [0:26] : [np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1), np.int64(1), np.int64(-1)] dtype: dtype('int64') max: np.int64(1) min: np.int64(-1) shape: (26,) size: 26

So we have V['id'] with 26 dimensions where each value is in a dimension (shape: (26, 1))
while the tile function returns a onedimensional array with 26 values (shape: (26,))

So, where is the error?
Either the tile function (_shape_base_impl.py) needs to be extended (or there needs to be a different approach)
Or the paths.append(P*s+(x,y,(d-1)), closed=True, color=(0,0,0,1)) is not correct...?

But as this should have been a working example (? :D) there may have been changes in numpy 2.x that trigger this ...

Cheers,

Stephan

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions