Skip to content

fix #66 : Compare colors #68

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 2 commits into from
Sep 13, 2017

Conversation

alixdamman
Copy link
Contributor

No description provided.

raise ValueError("Expected None or LinearGradient instance for `bg_gradient` argument")
if bg_value is not None and not (isinstance(bg_value, np.ndarray) and bg_value.ndim == 2):
raise ValueError("Expected None or 2D Numpy ndarray with shape {} for `bg_value` argument"
.format(self._data.shape))
Copy link
Collaborator

Choose a reason for hiding this comment

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

you use the precise shape in the error message but not in the check. I guess you should replace bg_value.ndim == 2 by bg_value.shape == self._data.shape.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I should.

value = bg_value.data.flat[idx]
return self.bg_gradient[value]
i, j = index.row(), index.column()
return self.bg_gradient[self.bg_value[i][j]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not use self.bg_value[i, j]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot that bg_value is a Numpy ndarray.

@@ -92,8 +101,9 @@ def set_data(self, data, bg_gradient=None, bg_value=None, current_filter=None):
if current_filter is None:
self.current_filter = {}
self.la_data = la.aslarray(data)
self.bg_value = la.aslarray(bg_value) if bg_value is not None else None
self.bg_gradient = bg_gradient
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think storing/handling the bg_gradient in the adapter adds any value.

Copy link
Contributor Author

@alixdamman alixdamman Sep 13, 2017

Choose a reason for hiding this comment

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

Well, the changes made in PR #64 works fine as long as we do not play with user defined gradient.
In case of user defined gradient, it is overwritten as soon as we call the method reset_minmax() from DataArrayModel.
In the current commit, bg_gradient is first overwritten by reset_minmax() and then reset to the user defined gradient but the call to self.data_model.set_background(self.bg_gradient, bg_value_2D) at the end of update_filtered_data in the Adapter. This is bad, I know...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, that will do for now. I will fix that in the "gradient combobox" branch I just spoke about because I need to touch that code anyway.

@gdementen
Copy link
Collaborator

could you squash the 2 commits?

@alixdamman alixdamman merged commit eb36846 into larray-project:master Sep 13, 2017
@alixdamman alixdamman deleted the compare_colors_66 branch September 13, 2017 19:34
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