3
votes
2answers
38 views

Numpy array assignment inside class

I am using Python 3.2.3 with NumPy 1.6.1. I would be very grateful if someone could explain me what does NumPy do when I try to access (in two different ways) an element of a NumPy array. Code: ...
0
votes
2answers
131 views

Python - FFT leads to wrong physical meanings

I am new to Python. I intend to do Fourier Transform to an array of discrete points, (time, acceleration), and plot the result out. I copy and paste the sample FFT code, and modify accordingly. ...
0
votes
1answer
47 views

Use numpy in python3 - Ubuntu

I'm trying to use numpy with python3 in Ubuntu 12.04. The command python3 in the terminal returns: Python 3.2.3 (default, Oct 19 2012, 20:13:42) [GCC 4.6.3] on linux2 When I try to import numpy I ...
-2
votes
3answers
80 views

Converting plain text list into array in python program [closed]

The TextFile.txt file contains: 1 one 2 two 3 three 4 four 5 five The python program: file = open ("x.txt", "r") for item in file: x = item.split ('\s') import numpy as np ...
1
vote
1answer
44 views

Efficient way to iterate through numpy arrays in parallel and create a new resultant array

I have 3 numpy arrays dm_w, dm_s and dm_p. I am in need of iterating through these arrays in parallel, do some computation based on a check condition as shown in code below. My code works well for ...
0
votes
0answers
51 views

numpy genfromtxt issues in Python3

I'm trying to use genfromtxt with Python3 to read a simple csv file containing strings and numbers. For example, something like (hereinafter "test.csv"): 1,a 2,b 3,c with Python2, the following ...
0
votes
1answer
72 views

OS X 10.7 + Python 3.3 + numpy + matplotlib

I have been trying to get Matplotlib running in 3.3 with no luck. I downloaded the latest github repos for matplotlib, which depends on numpy. For numpy I did 'python3 setup.py build ...
0
votes
1answer
71 views

TypeError when using Matplotlib's strpdate2num with Python 3.2

In my current project I want to read some experimental data from a text file into Python using the following code: import numpy as np from matplotlib.dates import strpdate2num data = ...
0
votes
1answer
87 views

Error when importing numba in Python 3

I have just installed numba in my Ubuntu 13.04 via pip-3.3, as an alternative to numpy and cython to make calculations, but every time i try to import it in Python i get a "Segmentation fault (core ...
-1
votes
4answers
68 views

How the program has control with the break statement [closed]

Could anybody explain this program and output of this? I am having doubt at if statement. I'm not able to understand how break statement works in this: for n in range(2, 10): for x in range(2, ...
0
votes
1answer
97 views

ECG filter in python

I'm new to Python, I hope not to obvious questions, need some urgent help. I have a file with the signal, I have to answer the questions: a) present a statistical description of the original signal ...
0
votes
1answer
38 views

How do I enable the REFS_OK flag in nditer in numpy in Python 3.3?

Does anyone know how one goes about enabling the REFS_OK flag in numpy? I cannot seem to find a clear explanation online. My code is: import sys import string import numpy as np import pandas as pd ...
0
votes
1answer
34 views

Build numpy for python3 when python not installed in /usr

Fedora 18, x86_64. Okay, so: I have installed python3 in ~/utils/src/python3/Python-3.3.0/ so that it's available on NFS and I don't have to reinstall it on every machine in the lab. I want to ...
3
votes
3answers
130 views

use of // in python

I am new in python programming. I have come to piece of program in which if (pos.x//1,pos.y//1) not in self.cleaned: self.cleaned.append((pos.x//1,pos.y//1)) is used. It might be silly of me. ...
0
votes
1answer
38 views

python numerically solving an equation with no sign change between the upper and lower bound

I am trying to solve an equation but I am unable to use brentq since there is no sign change. How could I find the value of r? >>> import numpy as np >>> >>> def f(r): ...
1
vote
1answer
77 views

TypeError: can't multiply sequence by non-int of type 'float' : prblem with NumPy arrays

I am pretty new to Python.I know this error occurs when one tries to multiply a string with a fraction i.e float. In my case , I can't figure out how can a numpy floating point array be a string. ...
2
votes
1answer
234 views

AttributeError: 'numpy.ndarray' object has no attribute '_hold'

I am using numpy and matplotlib in Python3. The following code is causing the error: import matplotlib from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from ...
3
votes
1answer
88 views

Maximum recursion depth exceeded when using a numpy.bytes_ object in string formatting

The code should speak for itself: $ python Python 3.3.0 (default, Dec 22 2012, 21:02:07) [GCC 4.7.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> ...
3
votes
1answer
87 views

Delimiter of numpy.savetxt

I am trying to write a numpy array to a .txt file using numpy.savetxt. To the best I can tell, the following code follows the documentation: z = np.array([1,2,3]) ...
2
votes
1answer
185 views

ASCII string as dtype for numpy array of strings in Python 3

NumPy's string dtype seems to correspond to Python's str and thus to change between Python 2.x and 3.x: In Python 2.7: In [1]: import numpy as np In [2]: np.dtype((np.str_, 1)).itemsize Out[2]: 1 ...
0
votes
1answer
98 views

Python crash when downloading image as numpy array

Why does the following code crash python? Is there an easier/better way to download an image and convert it to a numpy array? from pylab import * from urllib import request ...
0
votes
1answer
78 views

image feature detection with large structuring element

I am trying to extract some features from an image but each of the extracted features are really small. The easiest way to extract larger features seems to be to use a larger structuring element but ...
0
votes
0answers
528 views

Python 2.7 vs. 3.3 Performance [closed]

As of now, how does the overall performance / efficiency of Python 2.7 compare to 3.3? I use Python for academic research, so am always concerned with reducing the time to run experiments, since ...
0
votes
1answer
142 views

Weighted sum of adjacent values in numpy array

What is the easiest/fastest way to take a weighted sum of values in a numpy array? Example: Solving the heat equation with the Euler method length_l=10 time_l=10 u=zeros((length_l,length_l))# (x,y) ...
1
vote
3answers
145 views

Indices of resampled array in scipy

I have two 1D-array, of the same length, containing a time series and value series, for example t = linspace(0, 5, 5) # [0, 1.25, 2.5, 3.75, 5] x = array(range(10, 25)) # [10, 11, 12, 13, 14] I ...
2
votes
1answer
41 views

Why should I give `savetxt` a file opened in binary rather than text mode?

I was bitten by the following numpy behaviour: In [234]: savetxt(open('/tmp/a.dat', 'wt'), array([1, 2, 3])) --------------------------------------------------------------------------- TypeError ...
2
votes
1answer
471 views

Numpy import in PyCharm yields “Cannot locate working compiler”

I am new to Python and PyCharm, installed PyCharm 2.6 (on Mac OSX) and tried to import NumPy for Python 3.3. JetBrains support file tells me to install Cython which also yields "Cannot locate working ...
3
votes
3answers
183 views

Python running slower than MATLAB

I am translating a numerical method that I wrote in MATLAB to Python. For some reason the Python code, which is almost identical, runs considerably slower. Here U and V are the unknowns which are ...
3
votes
2answers
758 views

Trouble installing numpy for Python 3.3 on OSX 10.8

I had a working Python 3.2 system with Numpy, but I let Homebrew upgrade to Python 3.3, so I have to install all packages again. This fails for pip3 install numpy with this very large output. Can you ...
9
votes
3answers
151 views

Make the sum of integers in a matrix maximal by multiplying rows and columns by -1

Having a Matrix M of size m, n over integers, what would be a good algorithm to transform it such that the sum of all elements is maximal? The only operations allowed are multiplying by -1 ...
-1
votes
1answer
405 views

Combining rows in DataFrame

I have a pandas DataFrame with 18 columns and about 10000 rows. My first 3 columns have separate values for YEAR, MONTH, and DAY. I need to merge these three columns and have the entire date in one ...
1
vote
1answer
252 views

installing numpy using python3.2 Mac OSX Lion

Trying to build numpy on OSX Lion. I followed the instructions from this post, using a replacing 10.6 with 10.7 for LDSHARED. However when I run setup.py it seems like it is still using 10.6?? how do ...
1
vote
2answers
144 views

Python Pandas: Vectorized operation bug?

Date series looks something like this. In [89]: db.close[:5] Out[89]: datetime 2012-06-28 23:58:00 1.243925 2012-06-28 23:59:00 1.244125 2012-06-29 00:00:00 1.244065 2012-06-29 00:01:00 ...
1
vote
1answer
80 views

Python 3.x IndexError while using nested For loops

So I've been trying to code a tabletop game that I made a long time ago - I'm working on the graphic section now, and I'm trying to draw the 9x7 tile map using nested For loops: I'm using the numpy ...
0
votes
1answer
53 views

Dtype work in FROM but not IMPORT

I swear I read almost all the "FROM vs IMPORT" questions before asking this. While going through the NumPy tutorial I was using: import numpy as np but ran into trouble when declaring dtype of a ...
-1
votes
1answer
403 views

installing numpy for python 3.1.2 on Ubuntu 10.04

I've searched everywhere I could and I couldn't find appropriate answer. I don't know how to install numpy so I could use it in Geany with python 3.1.2. It only works for python 2.6.5. I'm new to ...
1
vote
1answer
283 views

Using converter function in genfromtxt fails

When I try to read a space separated file using genfromtxt and using a converter function to convert numbers with a comma as decimal separator, I get a type error. It seems there is something wrong ...
1
vote
1answer
1k views

Numpy in Python 3 on OSX?

I'm running Python 3.3 on OSX Lion (10.7), and tried installing numpy via pip: pip install numpy This is into a virtual environment created with virtualenvwrapper. However, I get: $ pip install ...
1
vote
2answers
215 views

python3 conversion between cvxopt.matrix and numpy.array

python: python3.2 cvxopt: 1.1.5 numpy: 1.6.1 I read http://abel.ee.ucla.edu/cvxopt/examples/tutorial/numpy.html import cvxopt import numpy as np cvxopt.matrix(np.array([[7, 8, 9], [10, 11, 12]])) ...
0
votes
2answers
1k views

Adding Header to Numpy array

I have an array I would like to add a header for. This is what i have now: 0.0,1.630000e+01,1.990000e+01,1.840000e+01 1.0,1.630000e+01,1.990000e+01,1.840000e+01 ...
1
vote
1answer
577 views

StringIO in python3

I am using python 3.2.1 and I can't import the StringIO module. I use io.StringIO and it works but i can't use it with genfromtxt of numpy like this: x="1 3\n 4.5 8" ...
1
vote
1answer
1k views

Python 3.2 64 Bit Numpy install - LaPack error

I have python's latest 3.2.3 64bit installed on my Windows 7 laptop. I have been trying to use pip to install the packages. However I am receiving a Lapack error. C:\Users\renshaw ...
0
votes
1answer
232 views

install python3-numpy via Synaptic but cannot import module numpy in python3

The same think happens for python3-scipy. I installed python-numpy/scipy, python3-numpy/scipy/ using Synaptic. But they are installed under python3 not python3.2. My system is Ubuntu 12. Can anyone ...
0
votes
2answers
152 views

How to work with matplotlib?

I can not import matplotlib.pyplot/matplotlib.pylab and if I have to download where from I may download? I am using Python3.2.1 on Windows7(64 bit). But without a separate download how come ...
0
votes
1answer
252 views

How to install and run pandas python library in Eclipse Juno?

I am using pydev plugin in Eclipse Juno for my python programming in windows 7 and i am using python 3.2, it works fine while running python application which using standard python packages. For my ...
1
vote
1answer
95 views

using list instead-of numpy array

I have lists (and list of lists) as standard data-structure (most of my functions returns list/list of lists). But now I have to use some Numpy functions. Do I have to convert all lists to numpy array ...
5
votes
2answers
323 views

MATLAB-like array indexing with Numpy

In both MATLAB and Numpy, arrays can be indexed by arrays. However, the behavior is different. Let me explain this by an example. MATLAB: >> A = rand(5,5) A = 0.1622 0.6020 0.4505 ...
1
vote
1answer
161 views

Curl error while installing numpy and matplotlib for Python 3 on Mac OS X 10.6

Matplotlib has recently released a python 3 compatible version. To install matplotlib, you need numpy. I was following the instructions here for installing matplotlib. I tried installing numpy ...
6
votes
1answer
337 views

Storing Python objects in a Python list vs. a fixed-length Numpy array

In doing some bioinformatics work, I've been pondering the ramifications of storing object instances in a Numpy array rather than a Python list, but in all the testing I've done the performance was ...
6
votes
2answers
2k views

Python's sum vs. NumPy's numpy.sum

What are the differences in performance and behavior between using Python's native sum function and NumPy's numpy.sum? sum works on NumPy's arrays and numpy.sum works on Python lists and they both ...

1 2
15 30 50 per page