-
Notifications
You must be signed in to change notification settings - Fork 2
fixed delay when switching to a big array (issue 93) #116
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
Conversation
|
oops, forgot to mention issue #93. I will reword/rebase one of the commits to include that. |
… (issue larray-project#93) (so that we compute & redraw the new visible data only once)
also display the exception (even though it is currently unreadable)
…ox for axes >= 10000 elements (issue larray-project#93)
…d out by isfinite
…es per change (issue larray-project#93)
af07b10 to
9e2b379
Compare
|
I flagged all relevant commits with the issue, the last one fixing it. |
| except: | ||
| self.array = LArray([np.nan]) | ||
| except Exception as e: | ||
| self.array = LArray(str(e)) |
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.
the idea is to display the error message in the array widget?
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.
Yes, because I think that is the best place to display it. Having a dialog box popping up would be annoying. The error is currently unreadable because the cell is not automatically enlarged to fit the data, but since we should do that anyway, this will be solved later automatically. The message can still be copy-pasted in that case though. Maybe it would be better for now to use LArray("failed") instead, with a comment in the code saying to change it back to LArray(str(e)) when we automatically resize columns based on the data. I tested LArray("failed") earlier and it displayed nicely (but it was much less informative for me as to why it failed).
| data = la.LArray([]) | ||
| else: | ||
| data = la.aslarray(data) | ||
| axes = data.axes |
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.
IMO, the ArrayEditorWidget should not know what is the type of the data it gets (which is not the case for now...).
That's why I call self.data_adapter.set_data at the beginning of ArrayEditorWidget.set_data.
What I mean is that we will need to be careful once we will be ready to refactor the Adapter (and thus ArrayEditorWidget in the same time).
But for now, current changes are OK.
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.
I don't think this is the right way to approach this. ArrayEditorWidget.set_data should either receive an adapter directly or instantiate one depending on the type of data it received. Having a single adapter instance and using set_data on it like we did cannot work because we will need a different adapter class for different data types.
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.
Could you add a comment as a reminder?
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.
ok
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.
Thanks for the comment.
| # called by set_data and ArrayEditorWidget.accept_changes (this should not be the case IMO) | ||
| # two cases: | ||
| # * set_data should update both scientific and ndigits | ||
| # * toggling scientific checkbox should update only ndigits |
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.
So you want to split _update_digits_scientific in 2 methods?
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.
Ideally yes, but this is tricky to do both efficiently and elegantly because there is some computation that needs to be shared for updating scientific and ndigits. It used to be split in more methods but I just remerged them for efficiency reasons. It is probably possible to have code that is both clean and efficient but I have not spent the time to reach that point and found the efficient version "acceptably clean".
| # TODO: only do so if we would actually display more information | ||
| # 0.00001 can be displayed with 8 chars | ||
| # 1e-05 | ||
| # would |
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.
would what?
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.
no idea, this is an old comment :)
| # - update_data (which sets new data but keeps current filter unchanged) | ||
| def set_data(self, data, bg_value=None, current_filter=None): | ||
| if data is None: | ||
| data = la.LArray([]) |
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.
why moving these 2 lines (if data is None: ...) in ArrayEditorWidget?
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.
Like I tried to explain in the commit comments: just because it makes the internal api simpler: you know what you get. In general, external API should accept as many useful things as possible, internal API should be as simple as possible.
|
Can I merge? |
…t#93) * one of the goal was to make switching from one array to another as fast as possible by cutting down on the repeated calls (to various set_data and datamodel.reset()) * tightened what is accepted by each internal class. There is only one expected type for the data. External facing classes should still accept the same objects. * all internal classes which "hold" data are created without any data in __init__ but require a set_data before they can function. * data_model.reset_minmax needs to be called explicitly. * data_model.reset() needs to be called explicitly when "everything is done"
on the whole array but on a sample (fixes larray-project#93) This means we can miss the actual min/max of the displayed part, so it complexifies the code. Most of this awful code will go away after : * we invert how changes work (store old values instead of new values) * we get decent buffering (in that case the min/max should only be updated when "moving" the buffer.
|
I'll squash the new commit I just added in another commit if you agree with that. |
|
Please do |
70d3ae8 to
febd9f5
Compare
one more big PR :)
also includes misc other fixes/improvements
you might want to review commits individually...