how to plot the FFT of a list of values
I have 16 values of the period sequence 1, 2, 4, 8, 1, 2, 4, 8, ... I compute its fourier transform using >>> from scipy import fft, ifft >>> x = [1,2,4,8,1,2,4,8] >>> fft(x) array([ 30. +0.j, 0. +0.j, -6.+12.j, 0. +0.j, -10. +0.j, 0. +0.j, -6.-12.j, 0. +0.j]) Now how can I plot these values? I would like to plot 16 values. What do I need to do here? Can you show an example? -- https://mail.python.org/mailman/listinfo/python-list
Re: how to plot the FFT of a list of values
On Sat, Dec 5, 2020 at 9:20 AM Boris Dorestand wrote: > I have 16 values of the period sequence 1, 2, 4, 8, 1, 2, 4, 8, ... I > compute its fourier transform using > > >>> from scipy import fft, ifft > >>> x = [1,2,4,8,1,2,4,8] > >>> fft(x) > array([ 30. +0.j, 0. +0.j, -6.+12.j, 0. +0.j, -10. +0.j, 0. +0.j, > -6.-12.j, 0. +0.j]) > > Now how can I plot these values? I would like to plot 16 values. What > do I need to do here? Can you show an example? > Maybe https://stackoverflow.com/questions/17445720/how-to-plot-complex-numbers-argand-diagram-using-matplotlib ? -- https://mail.python.org/mailman/listinfo/python-list
Learning tkinter - a grid problem
Hi!
Why this example does not work?
--
from tkinter import *
root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
T.grid(row=0,column=0)
S.grid(row=0,column=1)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
txt="""This is a very big text
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Last line
"""
T.insert(END,txt)
mainloop()
-
I would like it to work more or less like this
-
from tkinter import *
root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
S.pack(side=RIGHT,fill=Y)
T.pack(side=LEFT,fill=Y)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
txt="""This is a very big text
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Last line
"""
T.insert(END,txt)
mainloop()
-
Thanks for any help
Paulo
--
https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
On 2020-12-05 18:56, Paulo da Silva wrote:
Hi!
Why this example does not work?
There are a few bits of configuration missing:
--
from tkinter import *
root=Tk()
root.geometry("400x200")
Add:
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, weight=0)
S=Scrollbar(root)
T=Text(root)
T.grid(row=0,column=0)
S.grid(row=0,column=1)
Change to:
T.grid(row=0, column=0, sticky=NSEW)
S.grid(row=0, column=1, sticky=NS)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
txt="""This is a very big text
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Last line
"""
T.insert(END,txt)
mainloop()
-
[snip]
--
https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
Às 20:20 de 05/12/20, MRAB escreveu:
> On 2020-12-05 18:56, Paulo da Silva wrote:
>> Hi!
>>
>> Why this example does not work?
>>
> There are a few bits of configuration missing:
>
>> --
>> from tkinter import *
>>
>> root=Tk()
>> root.geometry("400x200")
>
> Add:
>
> root.grid_rowconfigure(0, weight=1)
> root.grid_columnconfigure(0, weight=1)
> root.grid_columnconfigure(1, weight=0)
>
>> S=Scrollbar(root)
>> T=Text(root)
>> T.grid(row=0,column=0)
>> S.grid(row=0,column=1)
>
> Change to:
>
> T.grid(row=0, column=0, sticky=NSEW)
> S.grid(row=0, column=1, sticky=NS)
>
>> S.config(command=T.yview)
>> T.config(yscrollcommand=S.set)
>> txt="""This is a very big text
>> -
Ok, thank you.
--
https://mail.python.org/mailman/listinfo/python-list
Re: how to plot the FFT of a list of values
Am 05.12.20 um 18:16 schrieb Boris Dorestand: I have 16 values of the period sequence 1, 2, 4, 8, 1, 2, 4, 8, ... I compute its fourier transform using from scipy import fft, ifft x = [1,2,4,8,1,2,4,8] fft(x) array([ 30. +0.j, 0. +0.j, -6.+12.j, 0. +0.j, -10. +0.j, 0. +0.j, -6.-12.j, 0. +0.j]) Now how can I plot these values? I would like to plot 16 values. What do I need to do here? Can you show an example? Usually, for the FFT of real input data, you plot only the magnitude or square of the complex array, and usually on a logscale. So: import pylab import numpy as np fx = fft(x) pylab.semilogy(np.abs(fx)) pylab.show() Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Bot
Try Selenium (preferred) or Mechanize. I recently used Selenium with Chrome for automated unittests of a web app, including a login screen. You could fire up the selenium script in a cron job at the desired time. On 1 Dec 2020 09:53, Álvaro d'Ors wrote: Hi guys, I'm new here, can anyone help me built a bot than can input data in a website? This is not for spam purposes, I just need to reserve a place in the library at the university but they are completed in a matter of minutes and I can't waste time "camping" the website. Thank you Nestares D. Álvaro -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Regarding Regex timeout behavior to minimize CPU consumption
Hi, Timeout: no idea. But check out re.compile and re.iterfind as they might speed things up. I often compile a regex once upon import, then use it in functions On 27 Nov 2020 13:33, Shahique Khan wrote: Hi Team, I have noticed if our regex sometimes does not give a result and on that time regex took more time in returning response (empty response). My Question is can we set a timeout parameter (in seconds/millisecond) with re.find or anywhere in code to avoid CPU consumption if regex takes more time in execution. Below is the example, which take more time in execution: (in this case can we set timeout to kill the execution to avoid CPU consumption) regex = r'data-stid="section-room-list"[\s\S]*?>\s*([\s\S]*?)\s*' \ r'(?:class\s*=\s*"\s*sticky-book-now\s*"|\s*|id\s*=\s*"Location")' rooms_blocks_to_be_replace = re.findall(regex, html_template) Please help me, I will be very thankful for this. Thanks, -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Regarding Regex timeout behavior to minimize CPU consumption
On 2020-12-05 23:42:11 +0100, [email protected] wrote: >Timeout: no idea. But check out re.compile and re.iterfind as they might >speed things up. I doubt that compiling regular expressions helps the OP much. Compiled regular expressions are cached, but more importantly, if a match takes long enough that specifying a timeout is useful, the time is almost certainly not spent compiling, but matching - most likely backtracking from lots of promising but ultimately unsuccessful partial matches. > regex = r'data-stid="section-room-list"[\s\S]*?>\s*([\s\S]*?)\s*' \ > > > r'(?:class\s*=\s*"\s*sticky-book-now\s*"|\s*|id\s*=\s*"Location")' > rooms_blocks_to_be_replace = re.findall(regex, html_template) This part: \s*([\s\S]*?)\s*' looks dangerous from a performance point of view. If that can be rewritten with less potential for backtracking, it might help. Generally, it should be possible to implement a timeout for any operation by either scheduling an alarm with signal.alarm or by executing the operation in a separate thread and killing the thread if it takes too long. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | [email protected] |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
