Linked Questions
33 questions linked to/from Comparing two NumPy arrays for equality, element-wise
22
votes
3
answers
55k
views
Testing if all values in a numpy array are equal [duplicate]
I have a numpy one dimensional array c that is supposed to be filled with the contents of
a + b. I'm first executing a + b on a device using PyOpenCL.
I want to quickly determine the correctness of ...
0
votes
1
answer
757
views
How to check whether two three dimensional numpy arrays are the same? [duplicate]
I have a numpy array with shape (1,x,1) and the second one also with shape (1,x,1). I wonder how can I check whether they are the same? Examples:
1.
First:
[[[ 2]
[ 3]
[ 4]
[ 5]
[ 6]
[ 7]
...
-1
votes
1
answer
625
views
Boolean expression with numpy arrays [duplicate]
Basically i am trying out boolean expressions with numpy arrays , for example something like this:
import numpy as np
a = np.array([1,0,1])
b = np.array([0,1,1])
c = np.array([1,0,1])
if (a ==b) or ...
0
votes
0
answers
35
views
Why aren't my matrices being correctly compared? [duplicate]
Hi I am writing some long code so I will post a snippet of it here.
Basically I have made an iterative code that builds a matrix of zeros, and a number that appears somewhere within those zeros to act ...
30
votes
7
answers
36k
views
Compare (assert equality of) two complex data structures containing numpy arrays in unittest
I use Python's unittest module and want to check if two complex data structures are equal. The objects can be lists of dicts with all sorts of values: numbers, strings, Python containers (lists/tuples/...
13
votes
8
answers
17k
views
Check if two numpy arrays are identical
Suppose I have a bunch of arrays, including x and y, and I want to check if they're equal. Generally, I can just use np.all(x == y) (barring some dumb corner cases which I'm ignoring now).
However ...
13
votes
5
answers
1k
views
Why does using "==" return a Series instead of bool in pandas?
I just can't figure out what "==" means at the second line:
- It is not a test, there is no if statement...
- It is not a variable declaration...
I've never seen this before, the thing is data.ctage==...
10
votes
2
answers
31k
views
How do I compare 2D lists for equality in Python?
Given two lists:
a = [[1,2],[3,4]]
b = [[1,2],[3,4]]
How would I write compare such that:
compare(a,b) => true
2
votes
4
answers
30k
views
check two arrays for matching elements given the same index and return number of matches
Given two arrays, is there a numpy non-loop way to check if each ith index matches between the arrays, aka check for every i if a[i]==b[i]?
a = np.array([1,2,3,4,5,6,7,8])
b = np.array([2,3,4,5,6,7,8,...
7
votes
2
answers
9k
views
Keras error "You must feed a value for placeholder tensor"
I have simple seq2seq model:
import seq2seq
import numpy as np
import keras.backend as K
from seq2seq.models import Seq2Seq
from keras.models import Model
from keras.models import Sequential
from ...
8
votes
3
answers
6k
views
Comparing numpy array of dtype object
My question is "why?:"
aa[0]
array([[405, 162, 414, 0,
array([list([1, 9, 2]), 18, (405, 18, 207), 64, 'Universal'],
dtype=object),
0, 0, 0]], dtype=object)
aaa
array([[405, ...
3
votes
3
answers
10k
views
Finding the difference between two numpy arrays
I have two arrays both from text file. By observation, it totally looks the same. However when I test the equivalence of the two arrays, they fail - element wise, shape wise etc.. I used the numpy ...
5
votes
1
answer
1k
views
How to port a specific C module to Python 3?
There is a thinning pip package that is currently getting compiled only with Python2.
When I install it with sudo pip install thinning and then attempt to import thinning, I get an error:
...
1
vote
3
answers
3k
views
Python: Compare Elements of two arrays
I want to compare elements of two numpy arrays and delete the elements of one of those arrays if the eucledean distance between the coordinates is smaller than 1 and the time is the same. data_CD4 ...
3
votes
3
answers
1k
views
Comparing two arrays throws a warning. Any workaround for this?
I have 2 np.array() as below. When I compare the two using "==", I get an output but with a deprecation warning. There is no warning when comparing 2 arrays with a same matrix.
What's the ...