Numpy Modular arithmetic
Hi, How can I define in numpy a matrix that uses operations modulo 2? For example: 0 0 1 0 1 0 1 1 + 0 1 = 1 0 Thanks! ...
Hi, How can I define in numpy a matrix that uses operations modulo 2? For example: 0 0 1 0 1 0 1 1 + 0 1 = 1 0 Thanks! ...
I have this dictionary goodDay= {'Class':[1,1,0,0,0,1,0,1,0,1], 'grade':[1,0,0,1,0,1,0,1,0,1]} I want to traverse the values of first key and also of second and put this condition to check: If value of K2 is 1 how many times is K1 is 1 and K1 is 0 and if K2 is 0 how many times is K1 is 0 and K1 is 1. ...
I am attempting to write a zc.buildout package that installs some of it's requirements into the parts directory. Any idea how this can be done? The reason for this is because the zc.buildout application itself is being distributed out, but parts of my package cannot go with it. So instead i would like to install them into the project/pa...
I use the built in json for python 2.6. I'm having tons of trouble parsing jsons like this: { name: 'some name' value: 'some value' } I found two reasons - ' doesn't work. You need " the keys of the dictionary need to be strings. I.e "name"/"value" Am I missing something? Is there a way to parse this kind of dictionary using th...
Hi, in python, I would like to use: from pylab import * Then use plot provided in this module. However, the curves I plot were not what I want: Say two lists: x = [1, 2, 3, 4] y = [1.4, 5.6, 6, 3.5] and I am after a plot method that can plot the following chart: Plot a line that joins the points: (1, 0) and (1, 1.4) Plot a line that join...
Hi, I have a scientific application that I built in Python (the application's 'critical areas' are optimized with Cython, for increased speed). Every instance of the application is given a text file (with parameters) an an input. The application reads the parameters from the text file and, using data that is stored in the hard drive, r...
I have a class called Cell: class Cell: def __init__(self, value, color, size): self._value = value self._color = color self._size = size # and other methods... Cell._value will store a string, integer, etc. (whatever I am using that object for). I want all default methods that would normally use the ...
Let's say you have some time-consuming work to do when a module/class is first imported. This functionality is dependent on a passed in variable. It only needs to be done when the module/class is loaded. All instances of the class can then use the result. For instance, I'm using rpy2: import rpy2.robjects as robjects PATH_TO_R_SOUR...
The Dictionary is as given below: goodDay= {'Class':[1,1,0,0,0,1,0,1,0,1], 'Grade':[1,0,0,1,0,1,0,1,0,1]} I want to code this way that i should get the count of "1" and also "0" in Class when my grade has value "1" and also vice versa i.e. when my grade has value "0". So i will have to traverse through the list values for both and ...
Which libraries do you use for machine learning for C/C++, Python, Java? ...
How do I invert a color mapped image? I have a 2D image which plots data on a colormap. I'd like to read the image in and 'reverse' the color map, that is, look up a specific RGB value, and turn it into a float. For example: using this image: http://matplotlib.sourceforge.net/_images/mri_demo.png I should be able to get a 440x360 ma...
Is there any difference between moving the mouse in windows using the following two techniques? win32api.SetCursorPos((x,y)) vs: nx = x*65535/win32api.GetSystemMetrics(0) ny = y*65535/win32api.GetSystemMetrics(1) win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE|win32con.MOUSEEVENTF_MOVE,nx,ny) Does anything happen differently in ...
I'm trying to simulate a mouse click on a window. I currently have success doing this as follows (I'm using Python, but it should apply to general win32): win32api.SetCursorPos((x,y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0) This works fine. However, if the click hap...
I've read about when to use assert vs. exceptions, but I'm still not "getting it". It seems like whenever I think I'm in a situation where I should use assert, later on in development I find that I'm "looking before I leap" to make sure the assert doesn't fail when I call the function. Since there's another Python idiom about preferrin...
I want to authenticate the administrator username's password. The administrator username is not a domain account but a local system account. I am trying to do this in Python, but any code even if it is .NET, VC++ would be fine. Thanks ...
dear all, As a matter of general interest I'm wondering if there's a more elegant/efficient way to do this. I have a function that compares two start/end tuples of dates returning true if they intersect. from datetime import date def date_intersection(t1, t2): t1start, t1end = t1[0], t1[1] t2start, t2end = t2[0], t2[1] if ...
So, is there an image processing library for Python 3.1? There is Python imaging Library (PIL) but the last supported Python version is 2.6. ...
import datetime, json x = {'alpha': {datetime.date.today(): 'abcde'}} print json.dumps(x) The above code fails with a TypeError since keys of JSON objects need to be strings. The json.dumps function has a parameter called default that is called when the value of a JSON object raises a TypeError, but there seems to be no way to do this ...
Python{ 'Good' : '0', 'Bad' :'9', 'Lazy' : '7'} I need to access the key names dynamically in a program. Eg. a= raw_input (" which is the final attribute:") for i in python.items(): if python.items()[i] == a: finalAttribute = python.items()[i] This giving me error saying Traceback (most recent call last): File "C:/Python...
although there are many posts on the internet as well as some posts on stack overflow, I still want to ask about this nasty python "import" problem. OK. so, the open source code organization is usually like this: project/src/model.py; project/test/testmodel.py if I put the famous __init__.py in project directory and also in src/ and ...