Skip to content

Conversation

@gdementen
Copy link
Collaborator

@gdementen gdementen commented Nov 10, 2017

one more big PR :)

also includes misc other fixes/improvements

you might want to review commits individually...

@gdementen
Copy link
Collaborator Author

oops, forgot to mention issue #93. I will reword/rebase one of the commits to include that.

@gdementen gdementen changed the title bigarrayspeed fixed delay when switching to a big array (issue 93) Nov 10, 2017
@gdementen
Copy link
Collaborator Author

I flagged all relevant commits with the issue, the last one fixing it.

@gdementen gdementen requested a review from alixdamman November 10, 2017 12:06
gdementen added a commit to gdementen/larray that referenced this pull request Nov 10, 2017
except:
self.array = LArray([np.nan])
except Exception as e:
self.array = LArray(str(e))
Copy link
Contributor

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?

Copy link
Collaborator Author

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
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Collaborator Author

@gdementen gdementen Nov 10, 2017

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
Copy link
Contributor

Choose a reason for hiding this comment

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

would what?

Copy link
Collaborator Author

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([])
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

gdementen added a commit to larray-project/larray that referenced this pull request Nov 14, 2017
@alixdamman
Copy link
Contributor

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.
@gdementen
Copy link
Collaborator Author

I'll squash the new commit I just added in another commit if you agree with that.

@alixdamman
Copy link
Contributor

Please do

@gdementen gdementen merged commit 959fa6e into larray-project:master Nov 21, 2017
@gdementen gdementen deleted the bigarrayspeed branch November 21, 2017 10:28
gdementen added a commit to larray-project/larray that referenced this pull request Aug 31, 2018
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.

2 participants