Compatibility issues (of glu) with numpy v.2.x · Issue #323 · glumpy/glumpy · GitHub
Skip to content

Compatibility issues (of glu) with numpy v.2.x #323

Description

@Stephanowicz

Hi there,

I just installed and tried glumpy and stumbled over several compatibility issues with numpy.

I'm using

  • glumpy 1.2.1
  • numpy 2.3.0

on Windows 11
OpenGL shading language version : 4.60 NVIDIA
OpenGL ES shading language version : 3.2

I can only speak for this version of numpy, but I think this is starting with numpy 2.0

  1. in /gloo/variable.py
    in class Uniform(Variable):
    in def set_data(self, data):
    line 280:
    self._data[...] = np.array(data,copy=False).ravel()

copy=false rises an error
accroding to numpy (https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword) np.asarray is preferred over np.array and can mostly be used without copy=false.

So I changed this line to
self._data[...] = np.asarray(data).ravel()
and the error disappears
in this file are many other lines with np.array(data,copy=False) - maybe they need to be changed, too?

  1. in /gloo/program.py
    in function def active_uniforms(self):
    in line 453/454:

         name, size, gtype = gl.glGetActiveUniform(self.handle, i)
         name = name.decode()
    

    name.decode rises an error
    'numpy.ndarray' object has no attribute 'decode'

    the name returned by gl.glGetActiveUniform is:

    [117 95 118 105 101 119 0 0 0 0 0 0 0 0 0 0 0 0]

    (wich is 'u_view' in ASCII)
    dunno if this GL-version dependant?

    so I made a workaround :

   name = name.tobytes().decode("ascii").strip()  
   name = ''.join(char for char in name if (ord(char) > 32 and ord(char) < 128))  

wich fixed it
(first line is converting to ASCII - second line removes the "0" chars)

Maybe there have been made changes to the decode function?

Cheers,

Stephan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions