numpy

how to implement this array algorithm in a more efficient way?

旧巷老猫 提交于 2021-02-11 16:45:22
问题 Assuming I have n = 3 lists of same length for example: R1 = [7,5,8,6,0,6,7] R2 = [8,0,2,2,0,2,2] R3 = [1,7,5,9,0,9,9] I need to find the first index t that verifies the n = 3 following conditions for a period p = 2 . Edit: the meaning of period p is the number of consecutive "boxes". R1[t] >= 5, R1[t+1] >= 5 . Here t +p -1 = t+1 , we need to only verify for two boxes t and t+1 . If p was equal to 3 we will need to verify for t , t+1 and t+2 . Note that It's always the same number for which

how to implement this array algorithm in a more efficient way?

流过昼夜 提交于 2021-02-11 16:44:43
问题 Assuming I have n = 3 lists of same length for example: R1 = [7,5,8,6,0,6,7] R2 = [8,0,2,2,0,2,2] R3 = [1,7,5,9,0,9,9] I need to find the first index t that verifies the n = 3 following conditions for a period p = 2 . Edit: the meaning of period p is the number of consecutive "boxes". R1[t] >= 5, R1[t+1] >= 5 . Here t +p -1 = t+1 , we need to only verify for two boxes t and t+1 . If p was equal to 3 we will need to verify for t , t+1 and t+2 . Note that It's always the same number for which

How to put many numpy files in one big numpy file without having memory error?

帅比萌擦擦* 提交于 2021-02-11 15:57:06
问题 I follow this question Append multiple numpy files to one big numpy file in python in order to put many numpy files in one big file, the result is: import matplotlib.pyplot as plt import numpy as np import glob import os, sys fpath ="path_Of_my_final_Big_File" npyfilespath ="path_of_my_numpy_files" os.chdir(npyfilespath) npfiles= glob.glob("*.npy") npfiles.sort() all_arrays = np.zeros((166601,8000)) for i,npfile in enumerate(npfiles): all_arrays[i]=np.load(os.path.join(npyfilespath, npfile))

How to put many numpy files in one big numpy file without having memory error?

孤者浪人 提交于 2021-02-11 15:55:26
问题 I follow this question Append multiple numpy files to one big numpy file in python in order to put many numpy files in one big file, the result is: import matplotlib.pyplot as plt import numpy as np import glob import os, sys fpath ="path_Of_my_final_Big_File" npyfilespath ="path_of_my_numpy_files" os.chdir(npyfilespath) npfiles= glob.glob("*.npy") npfiles.sort() all_arrays = np.zeros((166601,8000)) for i,npfile in enumerate(npfiles): all_arrays[i]=np.load(os.path.join(npyfilespath, npfile))

How to select elements from subsequent numpy arrays stored in pandas series

南笙酒味 提交于 2021-02-11 15:31:42
问题 I've got a Series of numpy arrays: import pandas as pd import numpy as np pd.Series({10: np.array([[0.72260683, 0.27739317, 0. ], [0.7187053 , 0.2812947 , 0. ], [0.71435467, 0.28564533, 1. ], [0.3268072 , 0.6731928 , 0. ], [0.31941951, 0.68058049, 1. ], [0.31260015, 0.68739985, 0. ]]), 20: np.array([[0.7022099 , 0.2977901 , 0. ], [0.6983866 , 0.3016134 , 0. ], [0.69411673, 0.30588327, 1. ], [0.33857735, 0.66142265, 0. ], [0.33244109, 0.66755891, 1. ], [0.32675582, 0.67324418, 0. ]]), 38: np

Create a dict of list using python from csv

柔情痞子 提交于 2021-02-11 15:31:37
问题 I have a csv file with data as below XPATH,ColumName,CSV_File_Name,ParentKey /integration-outbound:IntegrationEntity/integrationEntityDetails/supplier/forms/form[]/id,id,integrationEntityDetailsForms.csv, /integration-outbound:IntegrationEntity/integrationEntityHeader/attachments/attachment[]/id,aid,integrationEntityDetailsForms.csv, /integration-outbound:IntegrationEntity/integrationEntityDetails/supplier/forms/form[]/records/record[]/Internalid,Internalid,integrationEntityDetailsForms.csv,

updating a 3d python plot during a convergence iteration

ぃ、小莉子 提交于 2021-02-11 15:30:09
问题 I try to create a plotting script that plots my data in two 3d structures (with one variable as a color) that I use in a loop in which the data is supposed to converge. I would like to update the figure every iteration, instead of creating a new figure. Any ideas on how I can achieve this? function: import matplotlib.pyplot as plt import numpy as np def colorplot_3D(network, color_variable_1, color_variable_2): net = network X, Y, Z = net['pore.coords'][net.Ps].T X_max, Y_max, Z_max = np.amax

updating a 3d python plot during a convergence iteration

微笑、不失礼 提交于 2021-02-11 15:30:03
问题 I try to create a plotting script that plots my data in two 3d structures (with one variable as a color) that I use in a loop in which the data is supposed to converge. I would like to update the figure every iteration, instead of creating a new figure. Any ideas on how I can achieve this? function: import matplotlib.pyplot as plt import numpy as np def colorplot_3D(network, color_variable_1, color_variable_2): net = network X, Y, Z = net['pore.coords'][net.Ps].T X_max, Y_max, Z_max = np.amax

How to convert mat file to numpy array

时间秒杀一切 提交于 2021-02-11 15:14:27
问题 I want to convert a mat file with size 600 by 600 to numpy array and I got this error "float() argument must be a string or a number, not 'dict'" I am wondering how can I fix it. import numpy as np import scipy.io as sio test = sio.loadmat('Y7.mat') data=np.zeros((600,600)) data[:,:]=test 回答1: In [240]: from scipy.io import loadmat Using a test mat file that I have from past SO questions: In [241]: loadmat('test.mat') Out[241]: {'__header__': b'MATLAB 5.0 MAT-file Platform: posix, Created on:

Issue vectorizing a recursive function that is used in iterative scheme to calculate Numpy array

假如想象 提交于 2021-02-11 15:07:46
问题 I have the following recursive function, def subspaceiterate(A,V,v,j): if j == 0: return v else: v_jm1 = V[:,j-1] v_jm1 = np.reshape(v_jm1,(np.size(V,axis=0),1)) v = v - np.matmul(v_jm1.T,np.matmul(A,v_jm1)) j = j - 1 subspaceiterate(A,V,v,j) A is an mxm matrix whose eigenvalues and eigenvectors I want to compute using an iterative method, V is an mxm matrix that stores my initial guess for the eigenvectors of A , v_j is a particular column of V , and j is an index that I descend and use to