qpython -(contact list command) - contacts

I wrote this command in editor qpython3 in my Android Handy.(Mi A3)
Why I get (name not define) this error?
MY CODE:
a = contactsGetIds()
print(a)
Error:
/data/user/0/org.qpython.qpy3/files/bin/qpython3-android5.sh /storage/emulated/0/qpython/scripts3/.last_tmp.py && exit
thon/scripts3/.last_tmp.py && exit <
Traceback (most recent call last):
File "/storage/emulated/0/qpython/scripts3/.last_tmp.py", line 1, in
a = contactsGetIds()
NameError: name 'contactsGetIds' is not defined
1|:/ $

Related

pycairo error: “no current point defined” when trying to use TeeSurface

I'm trying to use a cairo.TeeSurface (pycairo version '1.21.0') to redirect input to multiple surfaces, but I cannot make it work, here is my code:
>>> import cairo
>>> s1 = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500,500)
>>> s2 = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500,500)
>>> s3 = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500,500)
>>> s = cairo.TeeSurface(s1)
>>> s.add(s2)
>>> s.add(s3)
>>> c = cairo.Context(s)
After above iniziatilation if I try to draw a line I get an error:
>>> c.rel_line_to(100,100)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cairo.Error: no current point defined
I tried to set explicitly a point but I get the same error:
>>> c.move_to(10,10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cairo.Error: no current point defined
For sure I must have misunderstood something, any clue would be appreciated.

How to find expected value of np.array using scipy.stats?

I am trying to get the expected value of a NumPy array but I am running into a problem when I pass my array into the function here is an example of what is happening:
a = np.ones(10)
stats.rv_continuous.expect(args=a)
I get this error:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
stats.rv_continuous.expect(args=a)
TypeError: expect() missing 1 required positional argument: 'self'
If I try stats.rv_continuous.expect(a) , I get this error:
'numpy.ndarray' object has no attribute '_argcheck'
Can someone tell me how to get scipy.stats to work with an array?
update:
following bob's comment I changed the code to:
st=stats.rv_continuous()
ev = st.expect(args=signal_array)
print(ev)
where signal_array is a numpy array. However I now get this error:
Traceback (most recent call last):
File "C:\Users\...\OneDrive\Área de Trabalho\TickingClock\Main.py", line 35, in <module>
ev = st.expect(args=signal_array)
File "C:\Users\...\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 2738, in expect
vals = integrate.quad(fun, lb, ub, **kwds)[0] / invfac
File "C:\Users\...\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\integrate\quadpack.py", line 351, in quad
retval = _quad(func, a, b, args, full_output, epsabs, epsrel, limit,
File "C:\Users\...\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\integrate\quadpack.py", line 465, in _quad
return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
File "C:\Users\...\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 2722, in fun
return x * self.pdf(x, *args, **lockwds)
File "C:\Users\...\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 1866, in pdf
args, loc, scale = self._parse_args(*args, **kwds)
TypeError: _parse_args() got multiple values for argument 'loc'

RuntimeError using Networkx on Example code

Following the examples on https://networkx.github.io/documentation/stable/reference/drawing.html, I tried the following code:
import networkx as nx
G = nx.complete_graph(5)
A = nx.nx_agraph.to_agraph(G)
H = nx.nx_agraph.from_agraph(A)
I get a RuntimeError as follows:
H = nx.nx_agraph.from_agraph(A)
Traceback (most recent call last):
File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1750, in iteritems
ah = gv.agnxtattr(self.handle, self.type, ah)
StopIteration: agnxtattr
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<ipython-input-10-19c378da806e>", line 1, in <module>
H = nx.nx_agraph.from_agraph(A)
File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/networkx/drawing/nx_agraph.py", line 85, in from_agraph
N.graph.update(A.graph_attr)
File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1740, in keys
return list(self.__iter__())
File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1743, in __iter__
for (k, v) in self.iteritems():
RuntimeError: generator raised StopIteration
This error is so basic that I suspect there's a problem with the package itself. Any suggestions on how I can try to troubleshoot this one?

Can I write an ipython script that quits ipython?

I would like a script that does something like:
x = 1
x += 1
exit
when I just type these in sequentially to ipython.
If I try just putting these in script.py and doing %run script.py, it doesn't work (neither does %run -i):
In [1]: %run test.py
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/Users/david/nice_pngs/test.py in <module>()
1 x = 1
2 x += 1
----> 3 exit
NameError: name 'exit' is not defined
In [2]: %run -i test.py
In [3]:

passthru() + Pipe in subprocess = Traceback (most recent call last): (…) in stdout=subprocess.PIPE)

I've got an error when I'm using passthru() to call a python script (using subprocess and pipe) with PHP.
Here is the error:
Traceback (most recent call last):
File "…/Desktop/h.py", line 11, in stdout=subprocess.PIPE)
#set up the convert command and direct the output to a pipe
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/subprocess.py", line 593, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/subprocess.py", line 1079, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
The PHP passthru:
<?php
passthru("/usr/bin/python2.5 /Users/Nagar/Desktop/h.py $argument1 $argument2 1 2>&1");
?>
My Python line which cause the error:
p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE) #set up the convert command and direct the output to a pipe
How to use stdout=subprocess.PIPE properly in the subprocess?
Looking forward your answers.
It looks like your PATH doesn't have the directory including the "convert" command. Try replacing:
p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE)
with:
p1 = subprocess.Popen(['/full/path/to/convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE)
where "/full/path/to/convert" might be something like "/usr/bin/convert".
It's because it needs to be executed through a shell, so you need to set shell argument to True:
p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE, shell=True)convert command and direct the output to a pipe