-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add CSV method to ColumnarDataSource #14519
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
base: branch-3.9
Are you sure you want to change the base?
Conversation
1a7ee80
to
c5b4d1c
Compare
@mattpap - gentle ping. Have you had a chance to look into the TypeScript compile issue with this PR? |
13217f0
to
136ce14
Compare
Notes from today's call with @mattpapTodo in this PR:
Leaving unsolved (or for a future PR):
|
a32a01f
to
0029a90
Compare
My latest code changes are a bit sloppy. Basically I added a function The color scatter example has 4000 circles, each with a color that is a function of the (x, y) coordinates of the circle's center point. When this example gets serialized and deserialized in the browser, the underlying column data source has a column called "fill_color" which contains a 12,000 long Uint8Array. Every three items in that array represent the red, green, and blue values for the color. So the problem is that (before my latest code changes), when this was serialized to CSV, the fill_color column in the CSV only gets the first 4,000 values of those 12,000. So I created a function that gets values from a flat-representation of an ndarray taking into account the shape of the array. I also used the existing pretty printer class to stringify object types rather than use JSON.stringify. Together this results in the following first two lines of CSV for the color_scatter example:
This looks reasonable to me. |
So the code changes are a bit sloppy, but I want to know if this is at least in the right direction. My sense is that there really should be some way to index the NDArray class so that I do not have to create a code fork, i.e.: if (is_NDArray(column)) {
row[c] = ndget(column, r)
} else {
row[c] = column[r]
} But I don't have a good idea of how to go about that. |
For some bizarre mysterious reason I don't understand, after installing and using csv-stringify, I started getting TypeScript compiler errors for usages of setTimeout and setInterval in the codebase. Converting these to window.setTimeout and window.setInterval fixes it. But I need to find out why this compiler error does not appear in branch-3.8 but does after installing csv-stringify
This reverts commit 72818e4.
src/lib/external/csv-stringify.d.ts
0029a90
to
dea346d
Compare
I want to add a few more test cases for the to_csv() method - specifically where the underlying test data source object has columns that are NDArrays, but otherwise this is ready for review so I am going to take it out of draft mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finished self review
I believe @mattpap said that the following failing test is irrelevant to this PR.
But I don't know about the following failing test:
|
Adds
to_csv()
method toColumnDataSource
(via base classColumnarDataSource
).Example usage: