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

Nondeterministic behaviour and question on layering template rectangles #53

Open
gazzar opened this issue May 21, 2020 · 5 comments
Open

Comments

@gazzar
Copy link

gazzar commented May 21, 2020

I'm trying to use fifi to layout images. It's common to inset images, colourbars etc. within other images or build figures where images overlay other images. This should be possible if there is a way to control the ordering of rectangles within a template layer, or render into separate template layers but I can't work out if this is possible. In fact the output from fifi seems nondeterministic, rendering some plot elements above or below others regardless of the ordering of the template rectangles, and ordered differently when rerunning the identical script+template.

@florisvb
Copy link
Collaborator

florisvb commented May 21, 2020 via email

@florisvb
Copy link
Collaborator

florisvb commented May 21, 2020 via email

@gazzar
Copy link
Author

gazzar commented May 22, 2020

Thanks for looking at this so quickly Floris!
I pip installed your modified version directly from github, verified that I have the version with your changes, and made the changes to the layout and make_mplfigures in my script but I actually don't see any change in behaviour. However, I suspected maybe the nondeterministic behaviour was something to do with the dictionary key ordering changes made in Python 3.6 since you have been mentioning key ordering. I observe the nondeterministic behaviour in my Python 3.5 conda environment. I can't remember why I decided to use 3.5; probably because the figurefirst readme says python 3.5+. Now I've created a Python 3.8 environment and the nondeterminism has gone. However, the axes_order dict is not being respected for me and it seems to simply use the rectangle object ordering in Inkscape. I reverted to the original vanilla layout and make_mplfigures calls:
layout = FigureLayout(str(TEMPLATE))
layout.make_mplfigures()
and the behaviour is the same. To be honest, this is what I had hoped the default behaviour would be originally. For now, specifying the order in the template makes more sense for what I am doing, although I understand it would be nice to have control over that from the other side. I guess the take-home is you may need to use an OrderedDict if you want to maintain backward compatibility for Python 3.5, but I personally don't think it's worth bothering.

I'm happy to send you my figure or try things out on my system if you want to get to the bottom of why the axes_order isn't being respected for me.

@florisvb
Copy link
Collaborator

florisvb commented May 22, 2020 via email

@clbarnes
Copy link
Collaborator

Although it's not stated in the lifecycle PEP, Django claims 3.5 is going EOL in September, so I would personally not be too upset if it had to fall by the wayside a little early. Alternatively we could throw in a shim like

import sys
if sys.version_info < (3, 6):
    from collections import OrderedDict as dict

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

No branches or pull requests

4 participants