scipy.optimize.least_squares for more than one dimension?
Yesterday I wanted to move from optimize.leastsq to least_squares. I have data depending on four variables and want to fit a function in four variables to this data. This works with leastsq but not with least_squares. Am I trying to do something least_squares is not capable of? Disclaimer: I was burning midnight oil... TIA /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: scipy.optimize.least_squares for more than one dimension?
Den 2023-06-30 skrev Martin Schöön : > Yesterday I wanted to move from optimize.leastsq to > least_squares. I have data depending on four variables > and want to fit a function in four variables to this > data. This works with leastsq but not with least_squares. > > Am I trying to do something least_squares is not capable > of? > > Disclaimer: I was burning midnight oil... > Problem solved. Yes, least_squares can, of course, handle multi-dimensional situations. Me burning midnight oil was the problem. I have been tinkering a bit with scipy.optimize.least_squares tonight. All simple examples I tried worked regardless of number of dimensions. I went back to my old code and found a couple of basic mistakes. Done. /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: Old matplotlib animation now fails
Den 2024-10-15 skrev MRAB : > On 2024-10-15 21:16, Martin Schöön via Python-list wrote: >> Some years ago I created a Python program that reads GPS data and >> It is the second to last line that throws an error: >> >> l.set_data(x0, y0) >> >> The error messages drills down to something called >> "/home/.../matplotlib/lines.py", line 1289, in set_xdata >> >> and tells me 'x must be a sequence' >> > """ > Help on function set_data in module matplotlib.lines: > > set_data(self, *args) > Set the x and y data. > > Parameters > -- > *args : (2, N) array or two 1D arrays > > See Also > > set_xdata > set_ydata > """ > > So, the arguments should be arrays: > > For example: > > x0, y0 = np.array([0.0]), np.array([0.0]) > > Has the API changed at some point? > So it seems. Thanks for the quick reply. /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: Old matplotlib animation now fails
Den 2024-10-15 skrev Stefan Ram : > Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?= wrote or quoted: >>l.set_data(x0, y0) > > Well, I got to say, it's pretty rad that you're rocking Python! > That language is the bee's knees, for real. > > As for your question, here's my two cents off the cuff: > Could it be that the newer Matplotlib versions are jonesing > for something like "l.set_data( [ x0 ],[ y0 ])" in that spot? > Thanks, that was quick and adding square brackets fixed my code. Me rocking Python? /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: Old matplotlib animation now fails
Den 2024-10-16 skrev Stefan Ram : > Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?= wrote or quoted: >>Me rocking Python? > >|to rock >|1. To use. To make do with, usually to great effect. >|"You don't need to make up the guest bed; we can rock the couch." > Urban Dictionary (2005) - Aaron Peckham (editor) (1979-04-03/), > Andrews McMeel Publishing, Kansas City > That is a use and meaning of rock I was not aware of. An example of what I use this Python code for (track top right): https://shorturl.at/m3ZKp (Youtube's compression algorithm clearly did not like this video.) /Martin -- https://mail.python.org/mailman/listinfo/python-list
Old matplotlib animation now fails
Some years ago I created a Python program that reads GPS data and creates an animation stored in an mp4 file. Not very elegant but it worked. Not very original as it was based on the example found here: https://shorturl.at/dTCZZ Last time it worked was about a year ago. Since then I have moved to a later version of Debian and Conda and as a consequence a later version of Python 3 (now 3.12.2). Now my code fails. I have downloaded the latest version of the example and it also fails. It is the second to last line that throws an error: l.set_data(x0, y0) The error messages drills down to something called "/home/.../matplotlib/lines.py", line 1289, in set_xdata and tells me 'x must be a sequence' I have started to dig around in matplotlib's documentation but my strategy is clearly wanting. I don't really know where to start looking for information on how to correct my code. Hence, this call for help. Any ideas? TIA /Martin -- https://mail.python.org/mailman/listinfo/python-list