Browse Source

Python2 compatibility fix

Timo Dritschler 3 years ago
parent
commit
641d5f64fc
1 changed files with 6 additions and 3 deletions
  1. 6 3
      KCG/widgets/FrequencyExtractWidget.py

+ 6 - 3
KCG/widgets/FrequencyExtractWidget.py

@@ -294,12 +294,16 @@ class FrequencyExtractWidget(kcgw.KCGWidgets):
         rLeft = ceil(region[0]) if region[0] >=0 else 0
         rRight = ceil(region[1]) if region[1] < len(self.fftYValues) else len(self.fftYValues)
 
+
+        #Python2 wants this to be specifically cast to integers
+        rLeft = int(rLeft)
+        rRight = int(rRight)
+
         #Make sure the region is within the boundaries of our data array
         if rLeft >= len(self.fftYValues) or rRight < 0:
             self.freqText.setText("Region boundaries out of data range")
             self.line.hide()
             self.isFreqValid = False
-            self.freqText.setText("NaN")
             return
 
         #If the region is not really a region, ignore it
@@ -307,7 +311,6 @@ class FrequencyExtractWidget(kcgw.KCGWidgets):
             self.freqText.setText("Region too small")
             self.line.hide()
             self.isFreqValid = False
-            self.freqText.setText("NaN")
             return
     
         chunk = self.fftYValues[rLeft:rRight]
@@ -325,7 +328,7 @@ class FrequencyExtractWidget(kcgw.KCGWidgets):
         indexInData = rLeft + maxIndexInChunk
 
         #We are basically just repeating what the plot item also did to
-        #determine the X-Axis labeling, and use it calculate the X-Value
+        #determine the X-Axis labeling, and use it to calculate the X-Value
         #at the index we have identified
         xAxisScale = (self.data.fftMaxFreq() - self.data.fftFreqDist()) / float(self.fftYValues.shape[0])