Skip to content
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 error message and tests for plot_motion. #2841

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

JoeZiminski
Copy link
Contributor

@JoeZiminski JoeZiminski commented May 13, 2024

This PR closes #2725 by adding an error message when ax or axes arguments are passed, these are backend_kwargs which are not supported for this function.

This is slightly suboptimal as the documentation still says they are accepted, but at least it is clear what to do when it does go wrong. I looked into making the function support passing axes but it would make things very complicated for (I don't think?) not too much benefit.

I also added tests for the function and made a couple of minor changes:

  • Added a little more explanation to the docstrings..
  • renamed the variables x and y to make slightly more descriptive.
  • renamed x-axis label Times [s] to Time [s].

I had a couple of questions:

  • The motion_lim is documented as Tuple or None but it actually expects an int. I guess this could be changed to accept a Tuple similar to depth_lim?
  • at the moment the widget object .ax is set to an empty Axes object. Maybe it would be clearer to set this to None as it is unused?

Also a more general question, the matplotlib and scipy imports are not at the top of the file, and I see the tests do not expect scipy to be installed. I guess the logic is the same for matplotlib which is why it is not top of file? Personally I would add any 'core' python modules to the general dependencies and then there is less maintenance required to have to workaround users potentially not having them installed. I don't think anyone will have trouble installing matplotlib or scipy unlike heavier modules such as numba. However may there are other considerations (e.g. docker images?).

@JoeZiminski JoeZiminski changed the title Tidy and test motion plots Add error message and tests for plot_motion. May 13, 2024
@alejoe91 alejoe91 added the widgets Related to widgets module label May 14, 2024
@alejoe91
Copy link
Member

I had a couple of questions:

  • The motion_lim is documented as Tuple or None but it actually expects an int. I guess this could be changed to accept a Tuple similar to depth_lim?

Yeah I think that sounds super reasonable

  • at the moment the widget object .ax is set to an empty Axes object. Maybe it would be clearer to set this to None as it is unused?

Agreed

Also a more general question, the matplotlib and scipy imports are not at the top of the file, and I see the tests do not expect scipy to be installed. I guess the logic is the same for matplotlib which is why it is not top of file? Personally I would add any 'core' python modules to the general dependencies and then there is less maintenance required to have to workaround users potentially not having them installed. I don't think anyone will have trouble installing matplotlib or scipy unlike heavier modules such as numba. However may there are other considerations (e.g. docker images?).

The idea behind core VS full is that core can be used as a super lightweight module only to use the SI data model, e.g., from a third party package. Adding main Python modules to core could result in dependencies issues for these kind of 3rd party minimal usage.

@JoeZiminski
Copy link
Contributor Author

Thanks @alejoe91! I've made the related changes, this is now ready for review.

Out of interest what kind of third-party apps need low-overhead installations? This would be useful for me to know in general when thinking about dependencies on other packages.

before motion correction.
2) 'Corrected peak depth' displayed the peak location for all detected spikes
over time after motion correction.
3) 'Motion vectors' plot shows the estimated displacement per channel
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually think I got this wrong, it is displacement across binned depths, not channels? In general I can fix these docstring to better use the terminology from the drift correction tutorial.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I think I have fixed it now, by replacing "per channel" with "per spatial bin".

Comment on lines +43 to +44
backend : Union[None, "matplotlib"]
Determines the plotting backend. Only "matplotlib" currently supported.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
backend : Union[None, "matplotlib"]
Determines the plotting backend. Only "matplotlib" currently supported.

This is automatically generated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @samuelgarcia, you mean it defaults to None -> "matplotlib" and so never needs to be set? If so, in can it be removed entirely as an argument tot his class? If it cannot be removed (e.g. to keep consistency with BaseWidget) I would suggest to add as docstring parameter anyway to avoid confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
widgets Related to widgets module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plot_motion does not accept axes or ax argument
3 participants