ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() CloseEvent Generated
See original GitHub issueThis is the code which was written in 2015 and was working fine. But now it’s giving me error while loading GUI. this function open the browse folder for selecting file. But it throws rhe error.Does it looks like an numpy error ? or matplot error please help. I am not getting any help from any tutorial.
File "D:\llfg\hrs\RS Datasets Viewer\OpenImage.py", line 150, in browse
while (wi < (self.width)) and zero == 0:
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()
CloseEvent Generated
def browse(self):
name = QtGui.QFileDialog.getOpenFileName(None, 'Open File')
FileName.File = name
self.lineEdit_5.setText(str(name))
self.img = open_image(str(name))
self.modname=name
self.img.__class__
(self.height, self.width, self.band) = self.img.shape
arr = self.img.load()
arr.__class__
zero = arr[0][0][0]
wi = 0
sa = 0
while wi < (self.width) and zero == 0:
sa = 0
while sa < (self.height) and zero==0:
zero = arr[sa][wi][0]
sa = sa+1
wi += 1
factor = 7.5/zero
x = 0
bandpath=str(Path.BandFolderPath)
while x<(self.band):
bd = factor*arr[:,:,x]
while bd[0][x]>10 or bd[0][x]<-10:
bd = bd/1.2
self.final_image = bd.astype(np.uint8)
image_display = Image.fromarray(self.final_image)
image_display.save(bandpath+"\Band_0"+str(x+1)+".tif")
x = x+1
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
ValueError: The truth value of an array with more than one ...
array ([1,2]): print(1) --> ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ....
Read more >How to Fix “ValueError: The truth value of an array with more ...
How to Fix “ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()” ; Method...
Read more >The truth value of an array with more than one ... - sopython
The truth value of an array with more than one element is ambiguous. ... That x<5 is not actually a boolean value, but...
Read more >The truth value of an array with more than one element is ...
"ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"
Read more >ValueError: The truth value of an array with more than one element ...
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() CloseEvent Generated #166.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tested with version .2, .3, .4 this file is using the spectral library. shape is from there as i Think .
I am attaching the whole code.
Numpy doesn’t have a
.2
,.3
, or.4
version at any point in remotely recent historyYou should take this up on stackoverflow - there are plenty of competent numpy users there who can direct you back here if there is indeed a bug - but you’ll need to put some effort in to help show them the problem - just pasting all your code isn’t going to get many answers