Open kameyer226 opened 4 years ago
Here is minimum work example.
import WrightTools as wt
# works
if False:
size = [2, 1]
energies = [0, .5, 1]
wt.diagrams.WMEL.Artist(size, energies)
# breaks
if True:
size = [1, 1]
energies = [0, .5, 1]
wt.diagrams.WMEL.Artist(size, energies)
with a terminal output of
runfile('C:/Users/darien/Desktop/test.py', wdir='C:/Users/darien/Desktop')
Traceback (most recent call last):
File "C:\Users\darien\Desktop\test.py", line 13, in <module>
wt.diagrams.WMEL.Artist(size, energies)
File "c:\users\darien\source\wrighttools\WrightTools\diagrams\WMEL.py", line 229, in __init__
fig, (subplots) = plt.subplots(size[1], size[0], figsize=figsize)
File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib-3.2.0-py3.7-win-amd64.egg\matplotlib\pyplot.py", line 1177, in subplots
fig = figure(**fig_kw)
File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib-3.2.0-py3.7-win-amd64.egg\matplotlib\pyplot.py", line 546, in figure
**kwargs)
File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib-3.2.0-py3.7-win-amd64.egg\matplotlib\backend_bases.py", line 3324, in new_figure_manager
fig = fig_cls(*args, **kwargs)
File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib-3.2.0-py3.7-win-amd64.egg\matplotlib\figure.py", line 349, in __init__
raise ValueError('figure size must be positive finite not '
ValueError: figure size must be positive finite not [0, 2.5]
The problem is this line: https://github.com/wright-group/WrightTools/blob/ca9f389c4c87e801546f41861faf03ca8440118c/WrightTools/diagrams/WMEL.py#L228
The values in this line (6.0, 2.5) seem rather arbitrary. Depending on value of number_of_interactions
the int()
will give you 0,1 etc. In @kameyer226's case, (1 * ((4 + 1.0) / 6.0))=0.83333
and int
rounds to 0.
@untzag do you have historic perspective as to why this line of code is the way it is?
You mean the code is actually stalling right at that line?
From: Darien Morrow notifications@github.com Sent: Thursday, March 19, 2020 8:36 AM To: wright-group/WrightTools WrightTools@noreply.github.com Cc: KENT ALBERT MEYER kentmeyer@wisc.edu; Author author@noreply.github.com Subject: Re: [wright-group/WrightTools] .diagrams.WMEL.Artist unable to create size [1,1] object (#939)
Here is minimum work example.
import WrightTools as wt
if False: size = [2, 1] energies = [0, .5, 1] wt.diagrams.WMEL.Artist(size, energies)
if True: size = [1, 1] energies = [0, .5, 1] wt.diagrams.WMEL.Artist(size, energies)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/wright-group/WrightTools/issues/939#issuecomment-601181870, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOY7HGF7UEAH7AJDMHFZKGLRIINU3ANCNFSM4LHE3I2Q.
@kameyer226 the code is actually breaking at https://github.com/wright-group/WrightTools/blob/ca9f389c4c87e801546f41861faf03ca8440118c/WrightTools/diagrams/WMEL.py#L229
but it breaks because of how we calculate figsize
We may consider the following options:
1) explicitly checking to make sure figsize=[x, y]
has x>0
and y>0
.
2) using wt.artists.create_figure
instead of plt.subplots
3) use int(np.ceil(arg)) instead of int(arg) in L228.
Using ceil is easiest though I don't know the results of a full range of size[0] and number_of_interactions.
My Python is limited, in line 229, what is going on with the left hand side of the expression?
From: Darien Morrow notifications@github.com Sent: Thursday, March 19, 2020 8:54 AM To: wright-group/WrightTools WrightTools@noreply.github.com Cc: KENT ALBERT MEYER kentmeyer@wisc.edu; Mention mention@noreply.github.com Subject: Re: [wright-group/WrightTools] .diagrams.WMEL.Artist unable to create size [1,1] object (#939)
We may consider the following options:
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/wright-group/WrightTools/issues/939#issuecomment-601192011, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOY7HGCAOZXKTIRPUG3MO33RIIP3FANCNFSM4LHE3I2Q.
@kameyer226 thanks so much for opening an issue
On line 229 we are doing something called unpacking by assignment. The plt.subplots
function returns an iterable (like a list).
We are taking the first element of that list (zero index) and assigning it as fig. The remaining elements we are putting into a tuple named subplots
.
regarding the issue at hand, I like @darienmorrow's suggestion of ceil
---but I know that's just a quick fix. If anyone is motivated to overhaul the parameterization I give my blessing---I have no particular love for the WMEL code as it currently exists
look in our gallery for some WMEL figure examples: http://wright.tools/en/stable/auto_examples/index.html
@kameyer226, can I ask why you need such a tiny tiny WMEL diagram?
Also, you can invoke ceil only if the quantity is less than 1. All other times perhaps just get truncated by int. That's probably another method.
A single WMEL may be useful if you want to call attention to a specific diagram of a group. You can enlarge that WMEL and add more descriptors. This enables viewers to extrapolate for the other diagrams. That's one example. Also, for TRIVE, for example, the oddball "TRIVE-Raman" diagram is a sort of special outlier not necessarily part of the main group.
This is also a learning experience to learn how to rectify issues with GitHub code, so I don't know how important this is for wrighttools.
From: Blaise Thompson notifications@github.com Sent: Thursday, March 19, 2020 9:49 AM To: wright-group/WrightTools WrightTools@noreply.github.com Cc: KENT ALBERT MEYER kentmeyer@wisc.edu; Mention mention@noreply.github.com Subject: Re: [wright-group/WrightTools] .diagrams.WMEL.Artist unable to create size [1,1] object (#939)
@kameyer226https://github.com/kameyer226 thanks so much for opening an issue
On line 229 we are doing something called unpacking by assignment. The plt.subplotshttps://matplotlib.org/3.2.0/api/_as_gen/matplotlib.pyplot.subplots.html function returns an iterable (like a list).
We are taking the first element of that list (zero index) and assigning it as fig. The remaining elements we are putting into a tuplehttps://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences named subplots.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/wright-group/WrightTools/issues/939#issuecomment-601221873, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOY7HGF3B3GTLLURPRXFSXTRIIWH5ANCNFSM4LHE3I2Q.
Artist is unable to plot a single WMEL diagram. SIZE must be greater than [1, 1] in order for a plot to generate. A libpng error results at size =[1,1] .
Flag thrown at File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 532, in print_png self.figure.dpi, metadata=metadata)