8000 Streamlining the imports by fariza · Pull Request #3 · tacaswell/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Streamlining the imports #3

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 31 commits into from

Conversation

fariza
Copy link
@fariza fariza commented Dec 19, 2013

This came after reading trhought the code trying to understand the flow of things.

Please correct me if I'm wrong

Figuremanager and FigureCanvas

If I understood correctly Figuremanager and FigureCanvas should be reserved for ready to use classes

I removed Figuremanager and FigureCanvas from

  • _backend_gtk3.py
  • backend_gtk3.py
  • _backend_qt4.py
  • backend_qt4.py

Those classes are not usable by as they are they have to be used with Agg or Cairo,.

Callbacks setting

There is no need to duplicate the setting of callbacks, it should remain in backend_gtk3.py and backend_qt4.py.
The Agg or Cairo variants don't need to redefine this.

tacaswell and others added 30 commits December 3, 2013 22:02
This commit refactors backend_bases into two parts, the Gcf
independent parts, which moved to backends/_backend_bases.py, and the
Gcf dependent stuff which stayed in backend_bases.py.  The contents of
backends/_backend_bases.py are bulk imported into backend_bases so
this change should be backwards compatible.

Added an attribute to FigureManagerBase for the _key_press_handler
function.  This might be a stop-gap if the logic in `Gcf.destroy` should
be moved into the FigureManager or canvas classes.
added a static method to FigureManagerQt to gracefully patch in
the Gcf.destroy call back.  As with the _key_press_handler call back
this may be a stop-gap if that logic gets re-factored.
One part (_backend_qt4Agg.py) has no dependencies on Gcf or pyplot,
which are all collected in backend_qt4agg.py.

Should be fully back-wards compatible.
get pop-up graph windows as part of a larger gui application.
Two line-length violations on long urls in comments are left.
changed imports to _backend_bases to avoid implicit Gcf import
one which includes Gcf and one that does not.
_backend_gtkagg.py has no dependence on `Gcf`, backend_gtkagg.py
depends on `Gcf` and maintains reverse compatibility.
Same long url as backend_gkt.py is the lone violation
_backend_gtk3.py does not depend on `Gcf`.

backend_gkt3.py does depend on `Gcf` and maintains reverse compatibility
gcf independent parts.

Same poor naming scheme as everything else in this branch.
updated example to reflect that the class the class
`FigureManagerQTAgg` has been removed.
Added `FigureCanvas` and `FigureManager` aliases to
`_backend_qt4agg.py` and `_backend_qt4.py`.
@tacaswell
Copy link
Owner

The problem with this is that we need to maintain reverse compatibility. I am pretty sure that the existing top level modules export FigureManager so, for now, we need to keep exporting them.

You have a fair point about the call backs design-wise, however one of the goals here is to break nothing. The callbacks used to be in the baseclases in backend_bases so anything that derives from them and ends up public-facing needs to also include them. We don't use those classes anywhere else, but that does not mean no one else is.

I may be taking no reverse incompatible changes a little too seriously. I would like feed back from @mdboom and company on this.

@mdboom
Copy link
mdboom commented Dec 19, 2013

-1 on removing FigureManager from the namespaces

+1 on not redefining the callbacks in *Agg and *Cairo, which should already be there from the base classes.

@tacaswell
Copy link
Owner

Right, I didn't follow through the inheritance/had them siloed wrong in my head last night.

The same thing should be done for backend_gtk*.

@fariza Let me know if you want to make the changes. I want to get this merged before I do the rebase (which I am not looking forward to).

@fariza
Copy link
Author
fariza commented Dec 19, 2013

The FigureManager and FigureCanvas were added only a month ago matplotlib@8159c81

@mdboom Why do you want to expose these two "names" in classes that can not be used directly?
It makes more sense to reserve those for "ready-to-use" classes doesn't it?

@tacaswell I think the best would be just to keep modifing two backends qt4 and Gtk3 until we agree on the way to do it (on the fly assemby by pyplot, or two files per backend, or ....) then we can modify all the rest.
It doesn't make sense to keep modifing more than two just for testing pourposes. If you insist, I will wait for feedback on the previous paragraph and then I will modify it.

@tacaswell
Copy link
Owner

@fariza Fair enough on just doing two at first.

@tacaswell
Copy link
Owner

I am coming around to your suggestion of only exporting FigureCanvas in the case where the canvas being exported is fully useful.

I had not realized how new that naming scheme was.

@pwuertz Can you comment on this?

@pwuertz
Copy link
pwuertz commented Dec 23, 2013

@tacaswell When switching to a different backend for saving figures, FigureCanvasBase.switch_backends() requires a reference to the new FigureCanvas class. Each known file type XY had its own print_XY method for a hardcoded import of FigureCanvasXY from module backendXY.

After matplotlib/matplotlib@8159c81 there is just a mapping from file types to backend modules, which can be modified and extended at runtime. You still need to know the name of a module's FigureCanvasClass though when doing the import. Instead of mapping that name as well I introduced the canonical name FigureCanvas - which basicly adds polymorphism to the backend module system and simplifies the whole process.

At the moment it is safe to omit this alias if you are not planning to use that backend for file saving.

@fariza fariza closed this Feb 6, 2014
@fariza fariza deleted the imports_cleanup branch February 6, 2014 19:02
tacaswell pushed a commit that referenced this pull request Oct 19, 2014
tacaswell pushed a commit that referenced this pull request Oct 1, 2017
This fixes some possible heap buffer overflows, such as the following
triggered by our cmmi10.ttf:

```
ERROR: AddressSanitizer: heap-buffer-overflow on address 0x617000235709 at pc 0x7f95efd3c48a bp 0x7ffe41b6ecc0 sp 0x7ffe41b6ecb0
READ of size 1 at 0x617000235709 thread T0
    #0 0x7f95efd3c489 in utf16be_to_ascii extern/ttconv/pprdrv_tt.cpp:178
    #1 0x7f95efd3c489 in Read_name(TTFONT*) extern/ttconv/pprdrv_tt.cpp:339
    #2 0x7f95efd499ef in read_font(...) extern/ttconv/pprdrv_tt.cpp:1325
    #3 0x7f95efd4c602 in get_pdf_charprocs(...) extern/ttconv/pprdrv_tt.cpp:1420
    #4 0x7f95efd35c22 in py_get_pdf_charprocs src/_ttconv.cpp:217

0x617000235709 is located 1 bytes to the right of 648-byte region [0x617000235480,0x617000235708)
allocated by thread T0 here:
    #0 0x7f9612262a38 in __interceptor_calloc (/usr/lib64/libasan.so.4+0xdea38)
    #1 0x7f95efd3b261 in GetTable(TTFONT*, char const*) extern/ttconv/pprdrv_tt.cpp:140
```
tacaswell pushed a commit that referenced this pull request Jun 28, 2018
commit a05a486
Merge: 6ec4f8f e751286
Author: Ida Hjorth <idahjorth@gmail.com>
Date:   Sun Apr 29 19:07:32 2018 +0200

    Merge pull request #3 from magnunor/idahj_anchored_directionarrows

    Idahj anchored directionarrows

commit e751286
Merge: 3ba79fb 6ec4f8f
Author: Magnus Nord <magnunor@gmail.com>
Date:   Sun Apr 29 09:00:34 2018 +0200

    Merge branch 'NEW_AnchoredDirectionArrows' of github.com:idahj/matplotlib into idahj_anchored_directionarrows

commit 6ec4f8f
Author: Ida <idahjorth@gmail.com>
Date:   Fri Aug 25 13:14:26 2017 +0100

    AnchoredDirectionArrows: Docstring, what's new

commit 19f4a38
Author: Ida <idahjorth@gmail.com>
Date:   Thu Aug 24 14:27:23 2017 +0100

    AnchoredDirectionArrows: Demo docstring

commit d024684
Author: Ida <idahjorth@gmail.com>
Date:   Thu Aug 24 14:09:52 2017 +0100

    AnchoredDirectionArrows: Fix error

commit 27b6bc5
Author: Ida <idahjorth@gmail.com>
Date:   Thu Aug 24 13:58:58 2017 +0100

    AnchoredDirectionArrows: make variable not private

commit c0762d2
Author: Ida <idahjorth@gmail.com>
Date:   Thu Aug 24 13:02:38 2017 +0100

    AnchoredDirectionArrows: Add docstring in demo

commit 88d04d0
Author: Ida <idahjorth@gmail.com>
Date:   Wed Aug 23 14:19:06 2017 +0100

    AnchoredDirectionArrows: docstring, what's new

commit efcca59
Author: Magnus Nord <Magnus.Nord@glasgow.ac.uk>
Date:   Wed Aug 23 13:31:32 2017 +0100

    AnchoredDirectionArrows: add test which uses many of the arguments

commit e200c44
Author: Magnus Nord <Magnus.Nord@glasgow.ac.uk>
Date:   Wed Aug 23 12:06:05 2017 +0100

    AnchoredDirectionArrows: minor docstring changes

commit b6b0ea2
Author: Ida <idahjorth@gmail.com>
Date:   Tue Aug 22 13:28:56 2017 +0100

    AnchoredDirectionArrows: PEP8

commit 5fde65a
Author: Ida <idahjorth@gmail.com>
Date:   Tue Aug 22 13:23:25 2017 +0100

    AnchoredDirectionArrows: Add demo

commit 23f7d5b
Author: Ida <idahjorth@gmail.com>
Date:   Tue Aug 22 11:16:41 2017 +0100

    AnchoredDirectionArrows: Add working unit test

commit 459ae07
Author: Ida <idahjorth@gmail.com>
Date:   Tue Aug 22 10:37:44 2017 +0100

    AnchoredDirectionArrow: first attempt unit test

    Currently not working

commit f4ec0e2
Author: Ida <idahjorth@gmail.com>
Date:   Wed Aug 16 19:31:05 2017 +0100

    Cleanup, bug fix, begin merge overlapping arrows

commit 75e52b0
Author: Magnus Nord <magnunor@gmail.com>
Date:   Mon Aug 14 23:05:30 2017 +0100

    AnchoredDirectionArrows: PEP8 fixes, and improve docstring

commit 4fff775
Author: Ida <idahjorth@gmail.com>
Date:   Mon Aug 14 22:04:22 2017 +0100

    Add AnchoredDirectionArrows class in axes_grid1
tacaswell pushed a commit that referenced this pull request May 21, 2020
tacaswell pushed a commit that referenced this pull request Mar 31, 2023
The attempt to simplify the stride calculation in `a06f343dee3cebf035b74f65ea00b8842af448e9` seems to be the cause of the problem. 
Using an approach equivalent to what was there before hopefully resolves matplotlib#24092.
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.

4 participants
0