Skip to content

Serialise NumPy arrays as any other array #394

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

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

vthemelis
Copy link
Contributor

@vthemelis vthemelis commented Jan 27, 2023

Signed-off-by: Vasilis Themelis [email protected]

Fixes #393

Allow showing NumPy arrays as normal arrays in the grid. There is no distinction made between normal arrays and NumPy arrays once they are serialised but I assume that this is fine as there is not difference between normal floats and NumPy floats either (say).

Added a small unit test to assert that no exception is thrown when initialising a DataGrid object out of a DataFrame that includes np.array objects of various shapes.

Also:

  • Simplify the _data_to_json function in terms of branching;
  • Remove unneeded checks for int;
  • Eliminate unused argument of _data_to_json;

I also noticed that ipydatagrid flattens arrays before showing them on the grid. I might change that on a separate PR.

@vthemelis
Copy link
Contributor Author

@martinRenou, does this look okay to merge now?

martinRenou
martinRenou previously approved these changes Feb 20, 2023
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@vthemelis
Copy link
Contributor Author

@martinRenou , thanks for looking into this again. It looks like the lint step of the build is broken for some reason. I opened and issue for this (#402). The failure doesn't seem relevant to this PR.

Is it okay if I merge this PR in the meantime or shall we fix the build first?

Also:
* Simplify the _data_to_json function in terms of branching;
* Remove unneeded checks for int;
* Eliminate unused argument of _data_to_json;

Signed-off-by: Vasilis Themelis <[email protected]>
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@martinRenou martinRenou merged commit 24f1586 into jupyter-widgets:main Feb 24, 2023
@vthemelis vthemelis deleted the np-array branch February 24, 2023 09:12
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

Successfully merging this pull request may close these issues.

Display DataFrames that have columns of NumPy arrays
2 participants