Skip to content

Traitlets #4762

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

Closed
wants to merge 73 commits into from
Closed

Traitlets #4762

wants to merge 73 commits into from

Conversation

rmorshea
Copy link
Contributor

@rmorshea rmorshea commented Jul 23, 2015

Refactoring of Matplotlib with traitlets. See TODO for progress.


This change is Reviewable

in_range = False
if value is None or value is False or value in ['none','']:
# Return transparent if no other default alpha was set
return (0.0, 0.0, 0.0, 1.0)
Copy link
Member

Choose a reason for hiding this comment

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

This is black and opaque, not transparent. I think you want all zeros.

@efiring
Copy link
Member

efiring commented Jul 23, 2015

General strategy question: do you expect to be able to get to the test-and-fix stage (4) with one or a few traits at a time, or do you have to get everything in place before you can make anything work?


stale = Bool(True)

def _stale_changed(self):
Copy link
Member

Choose a reason for hiding this comment

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

This should only trigger on the False -> True transistion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Missed that in the last branch too.

@rmorshea
Copy link
Contributor Author

@efiring I'm hoping to be able to do things in batches. Right now I'm working with stale, transform_set, transform. The only reason I'm not doing large batches is to make tracing bugs easier.

@tacaswell
Copy link
Member

I would start with something simpler, like color or zorder rather than
transform

On Thu, Jul 23, 2015, 2:44 PM Ryan Morshead notifications@github.com
wrote:

@efiring https://github.com/efiring I'm hoping to be able to do things
in batches. Right now I'm working with stale, transform_set, transform.
The only reason I'm not doing large batches is to make tracing bugs easier.


Reply to this email directly or view it on GitHub
#4762 (comment)
.

@efiring
Copy link
Member

efiring commented Jul 23, 2015

On 2015/07/23 8:44 AM, Ryan Morshead wrote:

@efiring https://github.com/efiring I'm hoping to be able to do things
in batches. Right now I'm working with |stale|, |transform_set|,
|transform|. The only reason I'm not doing large batches is to make
tracing bugs easier.

Good. I advocate small batches for exactly that reason: much easier to
find and fix bugs. Better to keep it simple while gaining experience.
These are massively intrusive changes. It would be nice to get a sense
of what they involve, and what sorts of consequences they have, sooner
rather than later.

Do you have any way of evaluating the performance consequences of these
changes?

@efiring
Copy link
Member

efiring commented Jul 23, 2015

On 2015/07/23 8:46 AM, Thomas A Caswell wrote:

I would start with something simpler, like color or zorder rather than
transform

Good idea, though I think that color is actually one of the most
complicated parameters--maybe the most complicated.

@WeatherGod
Copy link
Member

One argument for doing "stale", "transform", etc first is that these are
typically not user-facing, and they have fairly well defined interactions,
yet they have major performance implications. I would think that changes
here would be less intrusive, and fairly obvious if something has gone
wrong.

On Thu, Jul 23, 2015 at 2:55 PM, Eric Firing notifications@github.com
wrote:

On 2015/07/23 8:46 AM, Thomas A Caswell wrote:

I would start with something simpler, like color or zorder rather than
transform

Good idea, though I think that color is actually one of the most
complicated parameters--maybe the most complicated.


Reply to this email directly or view it on GitHub
#4762 (comment)
.

@tacaswell tacaswell mentioned this pull request Jul 31, 2015
@tacaswell tacaswell added this to the proposed next point release milestone Jul 31, 2015
@rmorshea
Copy link
Contributor Author

rmorshea commented Aug 2, 2015

examples/pylab_examples/simple_plot_fps.py
run against master and traitlets branches
(origin/master is up to date with the upstream/master)

-- Master Results --
avg wallclock: 0.0145939850807
avg user: 0.014611467
avg fps: 6852.13801761

-- Traitlets Results --
avg wallclock: 0.0166525568962
avg user: 0.0166520915
avg fps: 6005.08382126

Active TraitTypes:
+ transform
+ transform_set
+ stale
+ axes

* averaged over 2000 iterations

@efiring
Copy link
Member

efiring commented Aug 2, 2015

Thanks for the benchmark results. About a 14% penalty so far, in this
test. What kind of a plot was it?

On 8/2/15, Ryan Morshead notifications@github.com wrote:

-- Master Results --
avg wallclock: 0.0145939850807
avg user: 0.014611467
avg fps: 6852.13801761

-- TRAITLET RESULTS --
avg wallclock: 0.0166525568962
avg user: 0.0166520915
avg fps: 6005.08382126

Active TraitTypes:
+ transform
+ transform_set
+ stale
+ axes

* averaged over 2000 iterations

Reply to this email directly or view it on GitHub:
#4762 (comment)

@rmorshea
Copy link
Contributor Author

rmorshea commented Aug 2, 2015

@efiring test code was taken directly from simple_plot_fps.py

@rmorshea rmorshea force-pushed the traitlets branch 2 times, most recently from 67d84aa to e764f37 Compare August 2, 2015 21:25
@rmorshea
Copy link
Contributor Author

rmorshea commented Aug 2, 2015

Rebased origin/traitlets on top of commits to #4694 made by @AndreLobato for the color TraitType. Updated origin/master to upstream/master then rebased origin/traitlets on top of origin/master. Ran the begining of the test suite again and the first error I encountered occurred when writing to a png from the pdf backend:

File "/Users/RyanMorshead/Coding/GitHub/matplotlib/lib/matplotlib/backends/backend_pdf.py", line 1288, in _writePng
    _png.write_png(data, buffer)
ValueError: Buffer must be RGBA NxMx4 array

Haven't investigated yet, but any chance that's coming from the changes to upstream/master? I wouldn't really expect the TraitTypes to influence that sort of thing.

@tacaswell
Copy link
Member

@rmorshea If that is happening locally, then the problem is out-dated c-cextensions (there was some recent work to improve the pdf backends handling of raster data).

@rmorshea
Copy link
Contributor Author

rmorshea commented Aug 3, 2015

Is that something that requires work on your end to fix? Also, I'm presuming that Travis CI won't be able to build this branch until traitlets is officially supported?

@mdboom
Copy link
Member

mdboom commented Aug 3, 2015

Try deleting the build directory and rebuilding. distutils doesn't do proper dependency resolution for C++ headers.

from .transforms import IdentityTransform, Transform
import contextlib

class exdict(dict):
Copy link
Member

Choose a reason for hiding this comment

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

Might want to inherit from userdict

@rmorshea rmorshea force-pushed the traitlets branch 4 times, most recently from 9784b8c to d09e70e Compare August 15, 2015 05:52
@tacaswell
Copy link
Member

I got the same sort of getattr error three times (once like travis and twice on a different test), but have not been able to reproduce it and get a debugger on it. The failure on the scatter test probably is inducing the other 3 failures.

I can reproduce the sphinx issue locally, but no real guess at what is causing it. I don't think it is something maformed with that intermediate output of the rst file, but I don't know where shpnix keeps them to check...

@@ -575,9 +802,14 @@ def get_sketch_params(self):

May return `None` if no sketch parameters were set.
"""
return self._sketch
msg = ("This has been deprecated to make way for IPython's"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe remove the IPython's here (and elsewhere similar messages appear). This is not to avoid giving credit where credit is due, just that this could imply that we are growing a dependency on IPython, which we aren't.

@mdboom
Copy link
Member

mdboom commented Dec 2, 2015

Frustratingly, I can't reproduce the getattr error either. What version of traitlets are @rmorshea or @tacaswell running? Maybe that's relevant.

I'm looking into the Sphinx issue now...

@rmorshea
Copy link
Contributor Author

rmorshea commented Dec 2, 2015

I'm running Traitlets off master right now.

@tacaswell
Copy link
Member

I copy-pasted the pip source install from .travis.yml.

@rmorshea
Copy link
Contributor Author

I'm going to finish rebasing (as best I can), and see where I'm at:

I feel like I've learned so much since I began this that it might be worth tearing everything down to start again with better practices and better ideas. If I had the time, I'd start from a fresh fork, but since I don't I'm hesitant.

I'll try to figure that out this week though.

@tacaswell

@efiring
Copy link
Member

efiring commented Sep 21, 2016

@rmorshea my impression is that there have been some big changes in traitlets since you started. Is this correct, and if so were they early enough in the process that you were able to take advantage of them? In any case, I'm glad you are able to get back to this now.

@efiring
Copy link
Member

efiring commented Sep 21, 2016

Answering my own question, it looks like the major change was the introduction of decorators, which you are already using. So the difficulties are because of all the mpl changes in the interim.

@rmorshea
Copy link
Contributor Author

rmorshea commented Oct 3, 2016

@efiring, yes. The main outward change to Traitlets has been the new decorator API.

Current plan: rebuild from the ground up, but repurpose my past work wherever possible.

There are three reasons that I want to do this (in order of importance):

  1. My rebase has been pretty painful.
  2. I can write cleaner, and more effective code than when I started this project.
  3. There have been some internal changes to Traitlets that could allow me to build custom tools for Matplotlib that will streamline certain validation, and notification pathways.

@rmorshea
Copy link
Contributor Author

rmorshea commented Feb 7, 2017

Rebase is unreasonably hairy - closing pending #8035 corresponding PR.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Sep 24, 2017
@anntzer anntzer modified the milestones: needs sorting, v3.0 Feb 13, 2018
@tacaswell tacaswell modified the milestones: v3.0, v3.1 Jul 9, 2018
@jklymak
Copy link
Member

jklymak commented Oct 6, 2018

This can be revisited if someone takes up the traitlets torch

@jklymak jklymak closed this Oct 6, 2018
@twmr
Copy link
Contributor

twmr commented Dec 27, 2018

  1. There have been some internal changes to Traitlets that could allow me to build custom tools for Matplotlib that will streamline certain validation, and notification pathways.

@rmorshea Can you elaborate on this one?

@rmorshea
Copy link
Contributor Author

@Thisch it's been a really long time since I've looked at this so without looking I'm not quite sure what parts of traitlets I might have wanted to leverage. If I had to guess it probably has to do with what's included in the traitlets.py file.

I'm happy to advise anyone whose willing to take up the torch since I don't have the time to do it myself.

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

Successfully merging this pull request may close these issues.