-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add RowArrayAdapter #416
base: main
Are you sure you want to change the base?
Add RowArrayAdapter #416
Conversation
The whole point of this is to convert datatypes to the one c2m expects. No clue why I was returning an array instead of a SupportDataPointType.
When specifying the adapter, you now specify exactly what type of datapoint it will return. This makes it easier for typescript to reason around things.
1) Rows can't be accessed with [], they must be accessed with .at() All arrays support .at(), and only .at() can be overridden 2) Tests should function the same whether using an array for data or an array adapter: The tests are now parameterized (_adapter_uilities.ts) to be run 11 times w/ p-values [0, .1, .2, ..., 1], where each data array has p chances to be replaced with an array adapter. Each could be run slightly different, and every combination of real array/adapter array should pass and provide the correct error. There are specific cases where this isn't true, and it is commented.
Linter error because |
Thanks for contributing! This use case has given me a lot to think about. My one concern is that whoever implements their own adapter would need to keep up with all the methods we use against the data. It looks like you implemented I think that this could potentially present a large maintenance problem moving forward. Do you have any thoughts about handling that? |
Thank you so much for the analysis and response! It could stay a hidden feature for quite a while (in a separate branch), and I'd be willing to maintain the experiment for a year to see if it works, and I'm writing You are correct about implementing those methods, that is my plan. Breaking can be seen as a feature as well, not a bug, especially for large integrations like w/ It is IMO always better to break instead of propagating undefined behavior. I want
I'd like to continue with the investigation while releasing other solutions for a full integration with plotly in the meantime, I think it'll get done w/in two weeks. It's also a good exercise for me to learn more about the But otherwise, |
The array adapter interface accepts a type <T>, just like any other array which wants to know what it is an array of. Previously, there had been enforcements of SupportedDataPointType as the type of T, which still isn't a terrible idea, but a) probably won't matter unless users are using typescript importing types and b) makes testing validation inconvenient because certain tests validate vanilla number arrays (number[]) instead of SupportedDataPointType[], as that is a shortcut to SimpleDataPoint (a supported type).
On track for full integration w/ plotly! Quick question, @julianna-langston, I noticed that in |
fyi - I went through all the cases I could find of That change is currently live in 1.16.2 |
:-O Much help! Thanks so much! I needed some positive vibes Technical note for myself: I'm writing in the technical comments that "RowArrayAdapter" doesn't support heterogeneous data,
From a technical perspective it could, although it's not a need for plotly, for whom it is technically impossible. In |
into pikul-feature-array-adapter Note, this merge required massaging. es-lint complained more, maybe because the merge included an update, and I had to bring the RowArrayAdapter types into c2mChart.ts to satisfy it wrt to convertDataRow(), which I didn't have to do before the merge. I didn't see any _code_ in the merge that would have changed this behavior, so I assume it's a dependency issue. There were a couple conflicts in utils.ts where I had been working, but I will make a note in the pull request julianna-langston#416
Hi @julianna-langston! Was that conversion The thing is, I reverted it for now and I'm going to leave some notes here while we sort this. Apologies for the complexities.
Unrelated notes that I will need once this is sorted:
which can probably be eliminate later.
|
I did the conversion by hand. I un-did the As for c2m changing numbers, it shouldn't be. Do you have an example where c2m changes the data provided to it? If you're seeing side effects, I would definitely consider that a bug and try to fix it as soon as I can. |
Hi! That sounds good to me, I'll review it all as well today.
About changing data, I just wanted to make sure I didn't mislead: after
these changes, c2m will not be able to change data, without throwing errors
during testing, which sounds like is actually a good thing!
El mié, 17 de abr. de 2024 3:41 p. m., Julianna Langston <
***@***.***> escribió:
… I did the conversion by hand. I un-did the .at() in assignment (oops),
and used .at() in the checkForNumberInput. Does this work for you?
#450 <#450>
As for c2m changing numbers, it shouldn't be. Do you have an example where
c2m changes the data provided to it? If you're seeing side effects, I would
definitely consider that a bug and try to fix it as soon as I can.
—
Reply to this email directly, view it on GitHub
<#416 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHHLRFIDKKHWZFPJ5NBH7WDY53M6DAVCNFSM6AAAAABEPRWO2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRSGIZTKOJXGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hi,
This is the start of an experimental feature that allow developers of visual chart libraries to, instead of copying data into a
c2m
handle, givec2m
a read-only view into the memory object of the original visual chart library.The benefits are
a) Reducing memory (RAM) usage by an order of magnitude
b) Clearly delineating which code controls the data
c) Relatively small addition (<<6kB full size)
Concept
For example, to store data,
plotly
uses a dictionary of arrays{ x:[], y:[] }
, andc2m
uses an array of dictionaries[ {x:, y:}, {x:, y:} ]
. The current solution is to create a newc2m
style object containing a copy of all data, but this adapter allows us to create a class that will return ac2m
style object upon request without copying and transforming the entireplotly
object.Challenges
The only downside is that
c2m
expects full access to the native arrays, but we can't override the index operator[]
. Luckily, all arrays support.at()
as a synonym, and we can override that. But wheneverc2m
wants to index into a row, it has to use.at()
, not[]
, since the adapter is not a real array, it is just array-like access to another object.Testing
My solution for testing, since the adapter should work anywhere a
(number | SupportedDataPointType)[]
does, is to randomly wrap test data in the adapter w/o changing any test parameters. Tests where this is necessary are then parameterized to be run N times w/ frequency of data-wrapping increasing. Every possible mixture of types should work with the adapter. This testing could be pared down with maturity.TODO