Okay, I recently tried to generate repeats of some the earliest image data I saved. I know each one is missing a lot of data, but I figured my code should attempt to produce an image using the available data. Generating anything that was missing (randomly).

So, let’s have a look at what I need to fix/refactor. Perhaps just the repeat data without needing to refactor any code. Fingers crossed.

And, on the pythonanywhere site I am getting an error rather consistently: ValueError: operands could not be broadcast together with shapes (1024,) (2048,). I expect this is tied to my prior refactoring. So, let’s sort that first.

Bugs, Bugs, …

Well the one above was fixed rather quickly. I just uploaded all the refactored files and restarted the app. But, now I am getting another one.

  File "/home/barkncats/mysite/main.py", line 613, in sp_gnarly
    r_xs, r_ys, m_xs, m_ys, m2_xs, m2_ys = sad.get_curve_data('gnarly', request.form, g.t_pts)
  File "/home/barkncats/mysite/sp_app_data.py", line 184, in get_curve_data
    proc_curve_form(f_data, i_type)
  File "/home/barkncats/mysite/sp_app_data.py", line 535, in proc_curve_form
    if u_whl.isnumeric():
AttributeError: 'list' object has no attribute 'isnumeric'

And, once it starts, any attempt to generate and image goes bad. Unless I generate a repeat; which seems to fix whatever using the manual form broke. As long as I am using the just ‘Draw it!’ functionality things seem to work. Once I select ‘Give me choices!’ and submit the form, things break. At least I now have a pretty good idea where I have to look.

And looking at the data on the display page, the issue appears to be related to the randomly occuring use of multiple wheel types to generate images. But it didn’t turn out to be why I thought that was the case. But it was related.

Pays to really read the documentation. In the function get_curve_data(i_type, f_data, p_pts) I use Flask’s to_dict() method to generate a dictionary from the request.form object. I.E. f_data = f_data.to_dict(flat=False). I do so because I want to at random intervals change the wheel shape data. Here’s the docs.

ImmutableMultiDict.to_dict(flat=True)

Return the contents as regular dict. If flat is True the returned dict will only have the first item present, if flat is False all values will be returned as lists.

Parameters: flat – If set to False the dict returned will have lists with all the values in it. Otherwise it will only contain the first value for each key.
<br.> Returns: a dict

Not sure why I chose flat=False, as the repeat image data dictionary is actually already flat. But I got what it said: lists! Removed that argument and bingo!

Maybe I can now get back to my original purpose.

Fix Old Repeats

As near as I can tell, the first 28 repeat image datasets do not currently produce an image. And, each one will need to be manually edited. Going to be a lot of work. Hope it isn’t all for naught.

I expect this is going to be a series of attempts to plot older repeat image data. Each will generate an error which I will then fix. And repeat.

But first I think I will compare the latest version of the repeat data with that of the first repeat image.

d_rpt.append(
{
'i_typ': 'mosaic',
'shape': 't',
'wheels': '3',
'k_f': 2,
'cgv': 1,
'freqs': [1, 7, 7],
'wds': [1, 0.554072220504108j, 0.5360955718153062],
'hts': [1, 0.7143622794074377, 0.46450502181680864],
'ln_sz': '3',
'cmap': 'PuRd',
'c_nbr': '16',
'c_cyc': [],
'c_lpha': None,
'c_ndx': None,
'do_bg': 'true',
'c_bg': 'RdPu',
'abg': [],
'bg_lpha': None,
'npts': 1024,
'sz': 8,
'dpi': 72,
'b_mrgn': None,
'how': 'between adjacent datarows with overlap',
'clw_pct': 'false',
'clwc': '8',
'clwpp': '12',
'm_inc': None,
'ntr': 'r',
'shp_mlt': 'false',
'u_agn': 'false',
'torb': 'top',
'drows': '1',
'r_mlt': 'false',
'do_drpt': 'false',
'ani_step': 8,
}
)
d_rpt.append(
{
'i_typ': '',
'shape': '',
'shp_mlt': 'false',
'wheels': '',
'k_f': 2,
'cgv': 1,
'freqs': [],
'wds': [],
'hts': [],
'ln_sz': '2',
'cmap': '',
'c_cyc': [],
'c_lpha': 0.75,
'c_ndx': 8,
'do_bg': 'true',
'c_bg': '',
'abg': [],
'bg_lpha': 0.18,
'npts': 1024,
'sz': 8,
'dpi': 72,
'b_mrgn': None,
'mrgn': None,
'how': '',
'c_div': 8,
'c_frq': 128,
'h_frq': 64,
'm1': '',
'm2': '',
'm_sz': 512,
'c_strt': 0,

'clw_pct': 'false',
'clwc': '8',
'clwpp': '12',
'm_inc': None,
'u_agn': 'false',
'torb': 'top',
'drows': '0',
'c_nbr': '16',
'r_btw': '1',

'r_mlt': 'false',
'mlts': [],
'ntr': '3',
'lld_deg': [],
'y_mlt': 0.5,
'trdy': 1.061,
'do_qd': [],
'do_qd2': [],
't2t_btw': [],

'do_drpt': 'false',
'ani_step': 8,
}
)

Going to add the missing rows to the first one and see what happens. I will also match the order of the current version of the data dictionary.

And, just like that it worked. Just 27 time consuming edits to go.

Done

Took a bit of time, but I now get an image generated for all the images for which I have data in the repeats module. Even if it is not the one I had thought I had saved. But, I can now play with them and save the additional data for a variation I like.

Resources

  • werkzeug.ImmutableMultiDict.to_dict