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

Unsigned numpy uint64 unsupported #1155

Closed
ghost opened this issue Sep 3, 2018 · 6 comments
Closed

Unsigned numpy uint64 unsupported #1155

ghost opened this issue Sep 3, 2018 · 6 comments
Labels
bug something broken
Milestone

Comments

@ghost
Copy link

ghost commented Sep 3, 2018

Hi, When I used a pandas array of uint64 on plotly, the numbers appear negative.
I know that they cannot be as i force the type to unsigned when i append:
tempDataFrame[YaxisIn].astype(np.uint64)
In this call:
traces.append(go.Scattergl(
x = tempDataFrame[XaxisIn],
y = tempDataFrame[YaxisIn].astype(np.uint64),
mode = 'markers',
marker = dict (line = dict(width = 1)),
name = database + "." + TablesIn + ".notUseful"
)
)

@jonmmease
Copy link
Contributor

Hi @suleimanmashini,

Please provide a full example that demonstrates the issue, with data and imports, formatted in a "fenced code block" https://www.google.com/url?sa=t&source=web&rct=j&url=https://help.github.com/articles/creating-and-highlighting-code-blocks/&ved=2ahUKEwjMq--AgJ_dAhWQl-AKHSQrCG4QFjAAegQICBAD&usg=AOvVaw297etkhd2-RtKM-CXyUZ9h.

Also please include the version of plotly.py you are using.

Thanks!

@ghost
Copy link
Author

ghost commented Sep 4, 2018

Hi @jonmmease ,
ofcourse Heres a code block that recreates the problem. I'm currently using plotly 3.0.2. I appreciate the help!

import plotly.graph_objs as go
import plotly
import pandas as pd
import numpy as np

print(plotly.__version__)

d = { 'xaxis': [1,2,3,4], 'yaxis': [4173500704,4147505216,4147504160,4143500800]}

df = pd.DataFrame(data=d, dtype=np.uint64)

traces = []

print(df.dtypes)

traces.append(go.Scattergl(
    x = df['xaxis'],
    y = df['yaxis'],
    mode = 'markers',
    marker = dict (line = dict(width = 1)),
    name = "sample data"
    )
)

plotly.offline.plot({
    "data": traces
}, auto_open=True)

@ghost
Copy link
Author

ghost commented Sep 4, 2018

This is what I get when running the sample commented above:
screen shot 2018-09-04 at 09 52 49

@jonmmease
Copy link
Contributor

Hi @suleimanmashini ,

Could you try again with plotly.py 3.2.0 (released yesterday)? When I run your example with this version I don't see this issue:

newplot

If that doens't fix it for you, can you post what version of numpy you have installed?

I did notice that trying to plot a figure with a uint64 array breaks the FigureWidget serialization, so I'm going to mark this as a bug either way.

@jonmmease jonmmease added the bug something broken label Sep 6, 2018
@ghost
Copy link
Author

ghost commented Sep 6, 2018

Hey,

updating it fixed the problem for me. Thanks!

jonmmease added a commit that referenced this issue Sep 7, 2018
 1) Preserve numeric numpy types as is in validator out, even if that
    numeric type is not supported as JavaScript TypedArray
 2) Update widget serializer to check numeric numpy arrays for whether
    they are compatible with TypedArrays. If not, serialize as list.
 3) Call to_pydatetime() on pandas datetime series/index values
    when passed to copy_to_readonly_numpy_array. This returns numpy
    array of datetimes (which we already know how to serialize)

Fixes datetime issue in #1160
Fixes FigureWidget issue in #1155
jonmmease added a commit that referenced this issue Sep 8, 2018
* Fix error when setting compound or compound array property to `None`

* Pandas datetime and numpy numeric array fixes

 1) Preserve numeric numpy types as is in validator out, even if that
    numeric type is not supported as JavaScript TypedArray
 2) Update widget serializer to check numeric numpy arrays for whether
    they are compatible with TypedArrays. If not, serialize as list.
 3) Call to_pydatetime() on pandas datetime series/index values
    when passed to copy_to_readonly_numpy_array. This returns numpy
    array of datetimes (which we already know how to serialize)

Fixes datetime issue in #1160
Fixes FigureWidget issue in #1155
@jonmmease
Copy link
Contributor

The FigureWidget issue noted above has been fixed in #1163

@jonmmease jonmmease added this to the v3.2.1 milestone Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

1 participant