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

Using hv.Vectorfield: AttributeError: 'float' object has no attribute 'cos' #3784

Closed
ahuang11 opened this issue Jun 19, 2019 · 2 comments · Fixed by #4040
Closed

Using hv.Vectorfield: AttributeError: 'float' object has no attribute 'cos' #3784

ahuang11 opened this issue Jun 19, 2019 · 2 comments · Fixed by #4040
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@ahuang11
Copy link
Collaborator

import numpy as np
import holoviews as hv
hv.extension('bokeh')
hv.VectorField(([-1, 0, 1, 2, 3], np.deg2rad([0, 45, 90, 180, 360])))

image

@ahuang11 ahuang11 changed the title Using hv.Vectorfield error Using hv.Vectorfield: AttributeError: 'float' object has no attribute 'cos' Jun 19, 2019
@ahuang11
Copy link
Collaborator Author

ahuang11 commented Jun 19, 2019

from @ea42gh

>>> h=hv.VectorField(([-1, 0, 1, 2, 3], np.deg2rad([0, 45, 90, 180, 360])))
>>> h.data
   x         y Angle Magnitude
0 -1  0.000000   NaN       NaN
1  0  0.785398   NaN       NaN
2  1  1.570796   NaN       NaN
3  2  3.141593   NaN       NaN
4  3  6.283185   NaN       NaN

This works:
hv.VectorField(([-1, 0, 1, 2, 3], [-1, 0, 1, 2, 3], np.deg2rad([0, 45, 90, 180, 360])))

So maybe a better error for not enough dimensions?

@philippjfr
Copy link
Member

Definitely down to the datatype and missing nans:

np.cos(np.array([float('nan')], dtype='object'))

The solution here is that to ensure that the pandas interface will not let you create an vectorfield without all the dimensions.

@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Oct 3, 2019
@philippjfr philippjfr added this to the v1.12.6 milestone Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants