Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Image data can not convert to float #23

Open
andyrenshengjun opened this issue Dec 11, 2019 · 0 comments
Open

TypeError: Image data can not convert to float #23

andyrenshengjun opened this issue Dec 11, 2019 · 0 comments

Comments

@andyrenshengjun
Copy link

I run below example code:

from ipymol import viewer as pymol
pymol.start()   # Start PyMOL RPC server
pymol.do('fetch 3uex, struct, async=0;')
pymol.do('remove solvent; ')

# smoothing parameters
pymol.do('alter all, b=10; alter all, q=1; set gaussian_resolution, 7.6;')
pymol.do('map_new map, gaussian, 1, n. C+O+N+CA, 5; isosurface surf, map, 1.5;')

# color struct according to atom count
pymol.do('spectrum count, rainbow, struct')

# color the map based on the b-factors of the underlying protein
pymol.do('cmd.ramp_new("ramp", "struct", [0,10,10], "rainbow") ')
 
# set the surface color
pymol.do('cmd.set("surface_color", "ramp", "surf")')
 
# hide the ramp and lines
pymol.do('disable ramp; hide lines;')

pymol.do('show sticks, org; show spheres, org;')

pymol.do('color magenta, org')
pymol.do('set_bond stick_radius, 0.13, org; set sphere_scale, 0.26, org;')
 
pymol.do('set_bond stick_radius, 0.13, org; set_bond stick_color, white, org; set sphere_scale, 0.26, org;')

pymol.do('set_view (\
    -0.877680123,    0.456324875,   -0.146428943,\
    0.149618521,   -0.029365506,   -0.988305628,\
    -0.455291569,   -0.889327347,   -0.042500813,\
    -0.000035629,    0.000030629,  -37.112102509,\
    -3.300258160,    6.586110592,   22.637466431,\
     8.231912613,   65.999290466,  -50.000000000 );')

pymol.do('ray;')

pymol.show()
pymol.do('png png0.png;')

Got below error message:
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
37 pymol.do('ray;')
38
---> 39 pymol.show()
40 pymol.do('png png0.png;')

/usr/local/lib/python3.5/dist-packages/ipymol/core.py in show(self)
112 ax = fig.add_subplot(111)
113 ax.axis('off')
--> 114 ax.imshow(np.asarray(self.to_png()))
115 return fig
116

/usr/local/lib/python3.5/dist-packages/matplotlib/init.py in inner(ax, data, *args, **kwargs)
1803 "the Matplotlib list!)" % (label_namer, func.name),
1804 RuntimeWarning, stacklevel=2)
-> 1805 return func(ax, *args, **kwargs)
1806
1807 inner.doc = _add_data_doc(inner.doc,

/usr/local/lib/python3.5/dist-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5481 resample=resample, **kwargs)
5482
-> 5483 im.set_data(X)
5484 im.set_alpha(alpha)
5485 if im.get_clip_path() is None:

/usr/local/lib/python3.5/dist-packages/matplotlib/image.py in set_data(self, A)
640 if (self._A.dtype != np.uint8 and
641 not np.can_cast(self._A.dtype, float, "same_kind")):
--> 642 raise TypeError("Image data cannot be converted to float")
643
644 if not (self._A.ndim == 2

TypeError: Image data cannot be converted to float
`

And tried with previous fix as below, it still doesn't work
in ipymol core.py change to: from PIL import Image
ipymol: 0.2, install from the latest code
pymol: 1.8.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant