Creating 1D texture from a float32 or float64 array

Hi
im attempting to create a 1D texture using the following code:
import numpy as np
def setup1dTex(tex_array):
tex = Texture()
tex.setup_1d_texture(tex_array.nbytes,tex.T_float,Texture.F_luminance)
tex.setRamImage(tex_array)
tex.setMagfilter(SamplerState.FT_linear)
tex.setMinfilter(SamplerState.FT_linear)
tex.setWrapU(Texture.WM_clamp)
return tex
d1_tex = setup1dTex(float32_array)

However i get the following error:

----> 7 tex.setRamImage(tex_array)
8
9 tex.setMagfilter(SamplerState.FT_linear)

AssertionError: compression != CM_off || image.size() == do_get_expected_ram_image_size(cdata) at line 5498 of panda/src/gobj/texture.cxx

it works as expected when the array is np.uint8 and format is T_unsigned_byte , i have tried many things i cant get this to work , any help appreciated

You should pass the number of texels (which is in your case equivalent to the number of elements in the array) to the setup1dTexture call, rather than the number of bytes.

I kid you not i did see another post of a similar type where you ,Sir did mention a similar thing and i did try that as it didnt work however now that i tried it again it did…gremlins… , CRAZY! but its working so thank you very much Sir your replies to questions has thought me more then you will know !