Re: round decimal values

2021-06-24 Thread jo
Il Thu, 24 Jun 2021 18:07:07 +0200, Julio Di Egidio ha scritto:

> On 24/06/2021 16:23, jo wrote:
>> Hi,
>> 
>> this code generate 4 values with gaussian distribution (mu=5, sigma=1):
>> 
>> import numpy as np x = np.random.normal(5, 1, 4)
>> print(x)
>> 
>> Output:
>> [5.87879753 3.29162433 3.83024698 4.92997148]
>> 
>> I would like to round the output like this:
>> 
>> [6, 3, 4, 5]
>> 
>> What should I add to the code?
>> 
>> Thank you
> 
> Have a look at numpy.around:
> <https://numpy.org/doc/stable/reference/generated/numpy.around.html>
> 
> HTH,
> 
> Julio

Yes, np.around() works fine.
Thank you.

This is the new code:

import numpy as np  
 
x = np.random.normal(5, 1, 4)

y=np.around(x)

print(x)

print(y)


output:

[4.68551569 3.9610641  6.1119447  4.81012246]
[5. 4. 6. 5.]

Thank you very much,

j.
-- 
https://mail.python.org/mailman/listinfo/python-list


round decimal values

2021-06-24 Thread jo
Hi,

this code generate 4 values with gaussian distribution (mu=5, sigma=1):

import numpy as np   
x = np.random.normal(5, 1, 4)
print(x)

Output:
[5.87879753 3.29162433 3.83024698 4.92997148]

I would like to round the output like this:

[6, 3, 4, 5]

What should I add to the code?

Thank you

j.
-- 
https://mail.python.org/mailman/listinfo/python-list


need help with an egg

2009-08-06 Thread jo
Hi,

I am very new to python

I created an egg on a machine.  The Python version on that  is 2.5.
Copied that egg to a machine which has Python 2.6.

unzip -t Myproj-0.1-py2.5.egg
The above command shows all the files I need

When I run the easy_install, I get the foll. error.  Is it because of
the version?  Or am I doing something wrong?  Or the way I understand
the egg works is wrong.  Can anyone please help?
If it's the version issue, does that mean I cannot use that egg on my
machine with 2.6 version?

Installed /usr/local/lib/python2.6/dist-packages/Myproj-0.1-py2.5.egg
Processing dependencies for Myproj==0.1
Searching for Myproj==0.1
Reading http://pypi.python.org/simple/Myproj/
Couldn't find index page for 'Myproj' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for Myproj==0.1
error: Could not find suitable distribution for Requirement.parse
('Myproj==0.1')

Thank you
Jo
-- 
http://mail.python.org/mailman/listinfo/python-list


starting selenium rc server from python code

2009-08-19 Thread jo
Hi,
Is there anyway to start the selenium rc server within python code?

Thank you
Jo
-- 
http://mail.python.org/mailman/listinfo/python-list


sys.exit call from pythonw.exe gives error

2005-10-27 Thread Jo Schambach
I wrote a python GUI with tkInter and installed it on a windows machine
with the .pyw extension, so it will be executed from pythonw.exe instead
of python.exe, since I didn't want the console window to appear.
My application exits with a call to sys.exit. However, when this call is
executed under pythonw.exe I get an error popup window with the
following messeage:

 start quote 
Microsoft Visual C++ Runtime Library
Runtime Error!
Program: C:\Python24\pythonw.exe

This application has requested the Runtime to terminate in an unusual way.
Please contact the application support team for more information
 end quote 

What am I doint wrong here?

Jo



-- 
Dr Joachim Schambach
The University of Texas at Austin
Department of Physics
1 University Station C1600
Austin, Texas 78712-0264, USA
Phone: (512) 471-1303; FAX: (814) 295-5111
e-mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


array of Tkinter variables?

2005-11-01 Thread Jo Schambach
I want to build an array of entry widgets in python with Tkinter that
all have similar textvariables. I was hoping that I could use an array
of StringVar variables to attach to these widgets, so that I can loop
through the widget creation. But my simple minded approach failed:

for i in range(32):
self.dllAdjust[i] = StringVar()
self.dllAdjust[i].set('000')

gives me the following error:

  File "./config.py", line 787, in setDefaultVals
self.dllAdjust[i] = StringVar()
AttributeError: Configurator instance has no attribute 'dllAdjust'


("Configurator" is the class in which this code fragment appears)

How does one define an array of StringVar? If that is not possible, what
would be an alternative approach to the idea in the  code fragment above?

Jo
-- 
Dr Joachim Schambach
The University of Texas at Austin
Department of Physics
1 University Station C1600
Austin, Texas 78712-0264, USA
Phone: (512) 471-1303; FAX: (814) 295-5111
e-mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


how do i use "tkinter.createfilehandler" with a regular c program?

2005-11-14 Thread Jo Schambach
I am trying to write a GUI with tkinter that displays the stdout from a
regular C/C++ program in a text widget.
The idea i was trying to use was as follows:

1) use "popen" to execute the C/C++ program
2) then use "tkinter.createfilehandler" to create a callback that  would
be called when the C/C++ program creates output on stdout.

Somehow, I can't get this to  work. here is what I have tried so  far:

import sys,os
from Tkinter import *

root = Tk()
mainFrame = Frame(root)
textBox = Text(mainFrame)
textBox.pack(fill=BOTH, expand=YES)
mainFrame.pack(fill=BOTH, expand=YES)

fh = os.popen('/homes/jschamba/tof/pcan/pcanloop')

def readfh(filehandle, stateMask):
global textBox
newText = filehandle.read()
textBox.insert(END, newText)

tkinter.createfilehandler(fh, tkinter.READABLE, readfh)
root.mainloop()


I don't see any of the stdout from my program appear in the textbox.

Does anyone have a short example that I could use as an inspiration for
this task?

I guess what my ultimate goal would be is to create something similar to
the "expectk" call "expect_background", which does exactly what i just
described, i.e. wait for output from a shell/C/C++ program and then do
something in response to this output like insert it into a text widget.
In expect, the following program seems to work:

#!/usr/bin/expectk -f

# disable terminal output
log_user 0

spawn -noecho /homes/jschamba/tof/pcan/pcanloop
set shell $spawn_id
text .shell -relief sunken -bd 1 -width 90 -height 24 -yscrollcommand
{.scroll set}
scrollbar .scroll -command {.shell yview}
pack .scroll -side right -fill y
pack .shell -side bottom -expand true -fill both

expect_background {
-i $shell -re "\[^\x0d]+" {
.shell insert end $expect_out(0,string)
.shell yview -pickplace insert
}
}


Jo
-- 
Dr Joachim Schambach
The University of Texas at Austin
Department of Physics
1 University Station C1600
Austin, Texas 78712-0264, USA
Phone: (512) 471-1303; FAX: (814) 295-5111
e-mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do i use "tkinter.createfilehandler" with a regular c program?

2005-11-14 Thread Jo Schambach
Thanks, that seems to work.
maybe one more question on this subject:

how can i use the callback function to the "createfilehandler" call from
within a class?
in other words, what would be the signature of the callback function, if
 I made it a member of a class?
The documentation says that the callback is called with the arguments:
callback(filehandle, stateMask)
but a class member function always has the "self" argument as is first
argument. So would the syntax be:

class GUI:
def __init__:
.

def filehandlerCallback(self, filehandle, stateMask):
        


Jo
[EMAIL PROTECTED] wrote:
> Compared to your program, I
>  * Made sure that the slave program actually flushed its stdout buffers
>  * didn't call read(), which will by default continue reading until
>it reaches EOF, not merely read the available data
> 
> #!/usr/bin/env python
> import sys, time, Tkinter, itertools, _tkinter, os
> 
> if '-slave' in sys.argv:
> for i in itertools.count():
> time.sleep(1)
> print "This is a line of output:", i
> sys.stdout.flush()
> raise SystemExit
> 
> root = Tkinter.Tk()
> root.wm_withdraw()
> 
> fh = os.popen('%s -slave' % sys.argv[0])
> 
> def reader(*args):
> line = fh.readline()
> if not line:
> print "EOF from slave"
> raise SystemExit
> print "from slave: %r" % line
> 
> _tkinter.createfilehandler(fh, Tkinter.READABLE, reader)
> root.mainloop()


-- 
Dr Joachim Schambach
The University of Texas at Austin
Department of Physics
1 University Station C1600
Austin, Texas 78712-0264, USA
Phone: (512) 471-1303; FAX: (814) 295-5111
e-mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


How to use Pycharm to display the stack and heap python?

2015-01-18 Thread Jo Barton
I am new to programming. Difficult for me to understand code using 
http://www.pythontutor.com/visualize.html#. How to use Pycharm to display the 
stack and heap python?
-- 
https://mail.python.org/mailman/listinfo/python-list


Record Audio Analysis

2006-08-24 Thread Jo Chase
I would like to record audio from a mic and perform some basic analysis on 
the audio wave patterns produced.  What would be the easiest way to 
accomplish this in Python? 


-- 
http://mail.python.org/mailman/listinfo/python-list


Hi,Everyone: what's the most popular xml parser module on python?

2010-04-15 Thread Jo Chan
Hi, everyone~~~  I am new.
What is the most popular xml parser module used on python? Thanks for
answering...

-- 
--
Best Regards

陈松坚
信息科学与技术学院 中山大学 广州大学城 510006
Chen Songjian
School of Information Science & Technology
Sun Yat-sen(Zhongshan) University, Guangzhou Higher Education Mega Center,
China, 510006
Mobile: +86-137-6069-6137
Email:  csj...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hi, Everyone: what's the most popular xml parser module on python?

2010-04-15 Thread Jo Chan
On Thu, Apr 15, 2010 at 6:52 PM, Stefan Behnel  wrote:

> Jo Chan, 15.04.2010 10:52:
> > I just want to get the content from a XML.
>
> That's not a very specific description of what you want to do. What's "the
> content"? The plain text content? Or do you care about the structure? And
> what parts of the structure?
>
>
> > I learn that there are two
> > modules in python handling XML.(SAX and DOM)  Er, I just want to know if
> > there is some open source tools for handling XML which is easier to use
> or
> > has more powerful function.
>
> Try xml.etree.ElementTree, it's certainly much easier to use than the two
> above, and it's also in the stdlib. If you need more powerful features,
> take a look at lxml.etree, which is a (mostly) compatible external package.
>
>
> > By the way, besides  is there any great book for
> > learning python?
>
> That has been answered many times on this list. Check the archives, or look
> through the book references at http://wiki.python.org
>
> Stefan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
--
Best Regards

陈松坚
信息科学与技术学院 中山大学 广州大学城 510006
Chen Songjian
School of Information Science & Technology
Sun Yat-sen(Zhongshan) University, Guangzhou Higher Education Mega Center,
China, 510006
Mobile: +86-137-6069-6137
Email:  csj...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hi, Everyone: what's the most popular xml parser module on python?

2010-04-15 Thread Jo Chan
I want to say I just have to deal with some regular text input (the input
file is as XML format) so I need to read all the nodes out and get what they
are.

Thanks for your great help though. I should have made my point clearer. :)

On Thu, Apr 15, 2010 at 6:52 PM, Stefan Behnel  wrote:

> Jo Chan, 15.04.2010 10:52:
> > I just want to get the content from a XML.
>
> That's not a very specific description of what you want to do. What's "the
> content"? The plain text content? Or do you care about the structure? And
> what parts of the structure?
>
>
> > I learn that there are two
> > modules in python handling XML.(SAX and DOM)  Er, I just want to know if
> > there is some open source tools for handling XML which is easier to use
> or
> > has more powerful function.
>
> Try xml.etree.ElementTree, it's certainly much easier to use than the two
> above, and it's also in the stdlib. If you need more powerful features,
> take a look at lxml.etree, which is a (mostly) compatible external package.
>
>
> > By the way, besides  is there any great book for
> > learning python?
>
> That has been answered many times on this list. Check the archives, or look
> through the book references at http://wiki.python.org
>
> Stefan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
--
Best Regards

陈松坚
信息科学与技术学院 中山大学 广州大学城 510006
Chen Songjian
School of Information Science & Technology
Sun Yat-sen(Zhongshan) University, Guangzhou Higher Education Mega Center,
China, 510006
Mobile: +86-137-6069-6137
Email:  csj...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Jo Chan
Hi,friends.

 I wanna ask if there is a function which is able to take a list as argument
and then return its top-k maximums?
I only know about max which is poorly a top-1 maximum function, now I want
more yet I am lazy enough that don't want to write one by myself.

So please tell me if there is one or not. I really need this soon.
Appreciate a lot.

-- 
--
Best Regards

陈松坚
信息科学与技术学院 中山大学 广州大学城 510006
Chen Songjian
School of Information Science & Technology
Sun Yat-sen(Zhongshan) University, Guangzhou Higher Education Mega Center,
China, 510006
Mobile: +86-137-6069-6137
Email:  csj...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Jo Chan
Cool! Thanks a lot! That's exactly what I want.

Best regards,

Songjian

On Thu, Apr 22, 2010 at 10:04 PM, Chris Rebert  wrote:

> 2010/4/22 Jo Chan :
> > Hi,friends.
> >  I wanna ask if there is a function which is able to take a list as
> argument
> > and then return its top-k maximums?
> > I only know about max which is poorly a top-1 maximum function, now I
> want
> > more yet I am lazy enough that don't want to write one by myself.
>
> http://docs.python.org/library/heapq.html#heapq.nlargest
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>



-- 
--
Best Regards

陈松坚
信息科学与技术学院 中山大学 广州大学城 510006
Chen Songjian
School of Information Science & Technology
Sun Yat-sen(Zhongshan) University, Guangzhou Higher Education Mega Center,
China, 510006
Mobile: +86-137-6069-6137
Email:  csj...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Jo Chan
Yeah... but actually I need something more efficient, like heap.
Thank you for your help though.

Best regards,

Songjian

On Thu, Apr 22, 2010 at 10:04 PM, Tim Golden  wrote:

> On 22/04/2010 14:57, Jo Chan wrote:
> > Hi,friends.
> >
> >   I wanna ask if there is a function which is able to take a list as
> argument
> > and then return its top-k maximums?
> > I only know about max which is poorly a top-1 maximum function, now I
> want
> > more yet I am lazy enough that don't want to write one by myself.
> >
> > So please tell me if there is one or not. I really need this soon.
> > Appreciate a lot.
>
> Assuming top-k doesn't mean something obscurely statistical:
>
> l = [1,2, 3, 4, 5]
> k = 3
> print (sorted (l, reverse=True)[:k])
>
> TJG
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
--
Best Regards

陈松坚
信息科学与技术学院 中山大学 广州大学城 510006
Chen Songjian
School of Information Science & Technology
Sun Yat-sen(Zhongshan) University, Guangzhou Higher Education Mega Center,
China, 510006
Mobile: +86-137-6069-6137
Email:  csj...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Google job leads

2010-08-01 Thread Charles Jo
Dear Colleagues,

I recently started a recruiter project at Google and am working with Partner 
Solutions Organization and recruiting Technical Account Managers for the group 
so I am actively networking with those who may know great software engineers 
with client-facing experience (or wanting to move in that direction) for 
career-defining opportunities.  If there are individuals and organizations that 
I should reach out to, please do let me know -- my office contact information 
is below.

Google office:

Charles Jo
Sales Recruiter, Google
650.253.0375 office
408.668.4226 cell
charle...@google.com

Feedback is always welcome!


Best,

Charles

-- 
Message sent by:

Charles Jo
408.668.4226
charl...@sonic.net

http://bit.ly/zooqdesk http://www.linkedin.com/in/charlesjo 
http://twitter.com/charlesjo http://www.facebook.com/profile.php?id=603461791



-- 
http://mail.python.org/mailman/listinfo/python-list


Is there a OrderedDict which can perform an iteritems() in order?

2010-11-04 Thread Jo Chan
Hello all,

 I have working on a program which need a ordered dictionary that could
perform iteritems() sequentially.
 I found a package on :
http://www.voidspace.org.uk/python/odict.html#creating-an-ordered-dictionary

  but it  could only perform items() in order, but iteritems()...

 Would you help me here?

songjian

11.4



-- 
--
Best Regards

陈松坚
信息科学与技术学院 中山大学 广州大学城 510006
Chen Songjian
School of Information Science & Technology
Sun Yat-sen(Zhongshan) University, Guangzhou Higher Education Mega Center,
China, 510006
Mobile: +86-137-6069-6137
Email:  csj...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list