3
votes
0answers
13 views

Add values to a Scipy sparse matrix with indexes and values

I'm working in a program for Power System analysis and I need to work with sparse matrices. There is a routine where I fill a sparse matrix just with the following call: self.A = bsr_matrix((val, ...
1
vote
1answer
27 views

Python: Assign list to multidimensional array element

I want to do an assignment to a multidimensional array where each element of the array is 3 short integers: a = ndarray([3,3,3], dtype='u2,u2,u2') a[2,2,2] = [1,2,3] Traceback (most recent call ...
1
vote
1answer
23 views

Create 2 dimensional array with 2 one dimensional array

I used numpy and scipy and there some funtion really care about the dimension of the array I have a function name CovexHull(point) which accept the point as 2 dimensional array. hull = ...
1
vote
0answers
33 views

ValueError: numpy.dtype has the wrong size, try recompiling

I just installed pandas and statsmodels package on my python 2.7 When I tried "import pandas as pd", this error message comes out. Can anyone help? Thanks!!! numpy.dtype has the wrong size, try ...
-1
votes
0answers
27 views

Flattening an image file with numpy into a 1d array

i am trying to read a file from disk, convert it to grayscale and then convert it into a 1d array. image_file = Image.open(filename) # convert image to black and white image_file = ...
2
votes
1answer
16 views

How to output a Numpy array to a file object for Picloud

I have a matrix-factorization process that I'm running on picloud. The output is a set of numpy arrays (ndarray). Now, I want to save it to my bucket, but I'm not able to zero in on the right way to ...
3
votes
1answer
44 views

Why increment an indexed array behave as documented in numpy user documentation?

The example The documentation about assigning value to indexed arrays shows an example with unexpected results for those naive programmers. >>> x = np.arange(0, 50, 10) >>> x ...
3
votes
2answers
36 views

Finding whether a list contains a particular numpy array

import numpy as np a = np.eye(2) b = np.array([1,1],[0,1]) my_list = [a, b] a in my_list returns true, but b in my_list returns "ValueError: The truth value of an array with more than one element ...
3
votes
0answers
65 views

Numpy, dot products on multidimensional arrays

I have some doubts on the numpy.dot product. I define a matrix 6x6 like: C=np.zeros((6,6)) C[0,0], C[1,1], C[2,2] = 129.5, 129.5, 129.5 C[3,3], C[4,4], C[5,5] = 25, 25, 25 C[0,1], C[0,2] = 82, 82 ...
7
votes
1answer
55 views

Python NumPy log2 vs MATLAB

I'm a Python newbie coming from using MATLAB extensively. I was converting some code that uses log2 in MATLAB and I used the NumPy log2 function and got a different result than I was expecting for ...
1
vote
0answers
58 views

What is wrong in this Python code for Regularized Linear Regression?

I wrote code with numpy(theta, X is numpy array): def CostRegFunction(X, y, theta, lambda_): m = len(X) # add bias unit X = np.concatenate((np.ones((m,1)),X),1) H = np.dot(X,theta) ...
1
vote
2answers
47 views

Equivalent of Matlab's fread() 'float64' in Python

I have a binary file which I'm able to open in MATLAB, but unable to open in Python. The binary file is encoded as a 'double float,' thus read by MATLAB with the following line: ...
0
votes
1answer
36 views

Apply non-linear regression for multi dimension data samples in Python

I have installed Numpy and SciPy, but I'm not quite understand their documentation about polyfit. For exmpale, Here's my three data samples: [-0.042780748663101636, -0.0040771571786609945, ...
-2
votes
1answer
29 views

checking if pandas dataframe is indexed?

Is it possible to check if a pandas dataframe is indexed? Check if DataFrame.set_index(...) was ever called on the dataframe? I could check if df.index is a numeric list but that's not a perfect test ...
2
votes
0answers
53 views

Numpy array: sequence too large

I have an array of size 11 called 'wavelength' and a larger array of size n called 'MN'. And 'model' is an m by n array. I'm doing this: for i in xrange(10+len(wavelength)-2): ...

1 2 3 4 5 386
15 30 50 per page