How to display a plot in fullscreen

i am trying to display a plot but in fullscreen. This is my code : import numpy as np import pylab as plt a = np.array([1,2,3,4]) b = np.array([1,2,3,4]) plt.plot(a,b,'.') plt.show() But the problem is : this does not display with the fullscreen. ...
more »

2017-02-20 22:02 (1) Answers

Finding points within a bounding box with numpy

I have millions of xyz-coordinates from multiple point cloud files which I am storing inside a 2-dimensional numpy array: [[x1, y1, z1], [x2, y2, z2],..., [xn, yn, zn]]. I want to filter all the points which are inside a specific bounding box descr...
more »

2017-02-20 20:02 (2) Answers

Efficiently construct FEM/FVM matrix

This is a typical use case for FEM/FVM equation systems, so is perhaps of broader interest. From a triangular mesh à la I would like to create a scipy.sparse.csr_matrix. The matrix rows/columns represent values at the nodes of the mesh. The matri...
more »

2017-02-20 17:02 (2) Answers

loading complex numbers with numpy.loadtxt

I know that if I want to save and load arrays of complex numbers with numpy, I can use the method described here: How to save and load an array of complex numbers using numpy.savetxt? . Assume however, that someone did not know about this and saved...
more »

2017-02-20 16:02 (4) Answers

How to extract paches from 3D image in python?

I have a 3D image with size: Deep x Weight x Height (for example: 10x20x30, means 10 images, and each image has size 20x30. Given a patch size is pd x pw x ph (such as pd <Deep, pw<Weight, ph<Height), for example patch size: 4x4x4. The cent...
more »

2017-02-20 06:02 (2) Answers

How to speed up one hot encoder code

I made simple function that will return an output one hot encoded matrix when given as input one vector. import numpy as np def ohc(x): u = list(set(x)) c = len(u) X = np.zeros((len(x), c)) for idx, val in enumerate(x): for ...
more »

2017-02-19 23:02 (3) Answers

Trouble reshaping my data for daily time series

I have a dataset that contains data collected every minute from November 1 to November 15. The time is a column, starting at 11/1/2016 00:00:00 and finishing at 11/15/2016 23:59:59 I am trying to reshape this dataset, so that each minute is a colum...
more »

2017-02-19 23:02 (1) Answers

Fast points in circle test with numpy

I have a large number of (x,y) grid points with integer coordinates which i want to test if they are in small number of circles given by radius and center. The points are some marked parts of an image, which means there are a small number of irregula...
more »

2017-02-19 20:02 (1) Answers

How to refine a mesh in python quickly

I have a numpy array([1.0, 2.0, 3.0]), which is actually a mesh in 1 dimension in my problem. What I want to do is to refine the mesh to get this: array([0.8, 0.9, 1, 1.1, 1.2, 1.8, 1.9, 2, 2.1, 2.2, 2.8, 2.9, 3, 3.1, 3.2,]). The actual array is ver...
more »

2017-02-19 16:02 (2) Answers

Remove pairs of values from NumPy array

I have a NumPy array contours that I got from cv2.findContours and flattened using contours = np.concatenate(contours, axis = 0). It stores coordinates of contours of objects from an image. However, I want to delete coordinates whose either X or Y is...
more »

2017-02-19 16:02 (1) Answers

Pandas conditional statement with NaT

So, I have a dataframe with many variables. The index is uid and the other variables are all dates. I am trying to create flag variables when a certain value is NaT but I can't find the correct statement. I want something like this: auxData['flagI...
more »

2017-02-19 14:02 (1) Answers

Why is the accuracy of my CNN not reproducible?

I want reproducible results for the CNNs I train. Hence I set the seed in my script: import tensorflow as tf tf.set_random_seed(0) # make sure results are reproducible import numpy as np np.random.seed(0) # make sure results are reproducible The...
more »

2017-02-19 12:02 (1) Answers

numpy - Sum of dot products along axis

I have an A x B array and another D x A x A array and am trying to come up with efficient ways to compute the sum of the dot products of two arrays along the D axis (such that the result would be an A x B array). The most obvious way would be to use ...
more »

2017-02-18 20:02 (1) Answers

difference between np.inf and float('Inf')

Is there some difference between NumPy np.inf and float('Inf')? float('Inf') == np.inf returns True, so it seems they are interchangeable, thus I was wondering why NumPy has defined its own "inf" constant, and when should I use one constant instead o...
more »

2017-02-18 14:02 (1) Answers

map in python2 vs python3

I'm a beginner python user and I've ran the following code on both python2.7 and python3.4.3 import matplotlib.pyplot as plt import numpy as np import scipy.stats as stats alpha = 1 n = 100 u = stats.uniform(0,1) F_inverse = lambda u: 1/alpha*np.l...
more »

2017-02-18 03:02 (1) Answers

Boolean masking on multiple axes with numpy

I want to apply boolean masking both to rows and columns. With X = np.array([[1,2,3],[4,5,6]]) mask1 = np.array([True, True]) mask2 = np.array([True, True, False]) X[mask1, mask2] I expect the output to be array([[1,2],[4,5]]) instead of arra...
more »

2017-02-18 01:02 (3) Answers

Python Pandas - Drop row based on value

I have a Pandas dataframe with columns A and B import pandas as pd import numpy as np df = pd.DataFrame(np.random.randint(0,100,size=(10, 2)), columns=list('AB')) I create column C, which is NULL if A > B df['C'] = np.select([ df.A > df.B ...
more »

2017-02-17 21:02 (2) Answers