Repository navigation
MRG: Refactor mlab object out of examples - #6464
Conversation
|
|
||
|
|
||
| def _close_all(): | ||
| # XXX This is not implemented yet |
| self.plotter.close() | ||
|
|
||
| def title(self, text): | ||
| # XXX This is not implemented yet |
| renderer.title(title) | ||
| elif title is not None: | ||
| raise TypeError('title must be an instance of `str` or `None`: ' | ||
| '{} was given'.format(type(title))) |
There was a problem hiding this comment.
this should be put in a separate private function. If you decide to make the function public
mne.viz.set_camera(renderer or mlab.figure or scene, view)
you don't need to add any parameter for view to the public API.
thoughts someone?
There was a problem hiding this comment.
maybe a kwargs as extra parameters?
There was a problem hiding this comment.
please no kwargs in public functions if we can
| elevation=view.get('elevation', 90), | ||
| focalpoint=view.get('focalpoint', | ||
| (0., 0., 0.)), | ||
| distance=view.get('distance', 0.6)) |
There was a problem hiding this comment.
I like the view.get('key', or_default). But If you do this, I would do something like:
_check_value(view, (dict, None))
view = dict() if view is None else view
render.set_cammera(azimuth=view.get('azimuth', 90),
elevation=view.get('elevation', 90),
focalpoint=view.get('focalpoint',
(0., 0., 0.)),
distance=view.get('distance', 0.6)))and I even think that if you put the defaults in set_cammera and allow a *kwargs something like this should work:
_check_value(view, (dict, None))
view = dict() if view is None else view
render.set_cammera(**view)There was a problem hiding this comment.
yes it works!!
def set_camera(azimuth=90, elevation=90, focalpoint=(0., 0., 0.),
distance=0.6, **dump_parameters):
print('azimuth :', azimuth,
', elevation :', elevation,
', focalpoint :', focalpoint,
', distance :', distance)
set_camera(**dict())
set_camera(**dict(azimuth='az', focalpoint='focal'))
set_camera(**dict(azimuth='az', not_here='not_here'))There was a problem hiding this comment.
I like it, this is very compact and it's straightforward to pass the parameters that way.
There was a problem hiding this comment.
its a way of saying: I have this dict of paramameters use what you can. Like this the defaults are carried by whoever has knowledge of the defaults (set_camera in this case) otherwise you have to keep passing the defaults.
Notice that you need **dump_parameters otherwise the 3rd call would give you an error. I would log/warn/error if dump_parameters is not empty dict
There was a problem hiding this comment.
or maybe is a good idea to not have dump_parameters like this if you pass something that it's not supposed to be passed it would crash. Up to you
| view = dict() | ||
| if not isinstance(view, dict): | ||
| raise TypeError('view must be an instance of `dict` or None: ' | ||
| '{} was given'.format(type(view))) |
Codecov Report
@@ Coverage Diff @@
## master #6464 +/- ##
==========================================
+ Coverage 89.23% 89.24% +<.01%
==========================================
Files 413 413
Lines 74286 74443 +157
Branches 12277 12292 +15
==========================================
+ Hits 66291 66438 +147
- Misses 5139 5148 +9
- Partials 2856 2857 +1 |
|
This pull request introduces 2 alerts when merging 83a1944 into 5d2f027 - view on LGTM.com new alerts:
|
| ValueError('Watchout. This does not seem to be a simple ' | ||
| 'binary EGI file.') | ||
| raise ValueError('Watchout. This does not seem to be a simple ' | ||
| 'binary EGI file.') |
There was a problem hiding this comment.
nice catch but this should be done is a different PR
There was a problem hiding this comment.
I wasn't sure, I'll open one right now
There was a problem hiding this comment.
By any chance, do you know why it has been reported by LGTM only now?
|
LGTM gets better with time :)
… |
| Parameters | ||
| ---------- | ||
| raw : instance of Raw | ||
| A Raw object containing FIF data. |
| picks: array of int | ||
| Indices of selected channels. | ||
| ch_names: list of str | ||
| The names of the channels. |
There was a problem hiding this comment.
No need for this, just use info['ch_names']
| raw : instance of Raw | ||
| A Raw object containing FIF data. | ||
| picks: array of int | ||
| Indices of selected channels. |
There was a problem hiding this comment.
Move this after con and make the default None with %(picks_data_good)s or so
There was a problem hiding this comment.
When I tried to replace the docstring of picks by %(picks_good_data)s I got the following error:
E AssertionError:
E mne.viz._3d.plot_sensors_connectivity %(picks_good_data)s != picksHow does it work?
|
This pull request introduces 9 alerts when merging 6d72a18 into 9dee0a7 - view on LGTM.com new alerts:
|
|
I'm not sure there is much value in
|
|
Thanks for the feedback, I updated the TODO list accordingly. |
|
With your latest changes, @agramfort , we should be free of any |
|
Nothing in |
|
I would prefer if we move step by step, the focus of this PR is mainly on |
|
Fine by me |
|
I think I found a good compromise for I shall add that with the modifications of the |
Can you update the table so we can keep track? |
|
I already did for the new |
|
Ahh right it's not public. Just make sure it's documented somewhere so we don't forget, like a GitHub issue or code comment. |
|
To be more precise, the following functions of
|
| # text.property.justification = 'center' | ||
| # text.actor.text_scale_mode = 'none' | ||
| # text.property.bold = True | ||
| # text.property.font_size = 40 |
There was a problem hiding this comment.
@GuillaumeFavelier this needs to be cleaned up before merging
|
@larsoner merge if happy |
|
MRG +1 |
|
@massich feel free to merge if diff lgty |
Reference issue
Follow-up of #5822
What does this implement/fix?
I noticed the example scripts still use heavily the object
mlabfrom Mayavi so this PR isolates those calls behind the 3d backend abstraction layer without exposing the private class_Renderer.