NameError: name 'minColor' is not defined #73

Open
opened 2024-05-13 22:49:06 +02:00 by Benjamin_Loison · 0 comments
./extract_noise.py
Computing extremes of images:   0%|                                                                                 | 0/50 [00:00<?, ?it/s]`treatImage`: minColor = None
Computing extremes of images:   0%|                                                                                 | 0/50 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./extract_noise.py", line 75, in <module>
    treatImage(imageFileName, computeExtremes = True, color = color)
  File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./extract_noise.py", line 61, in treatImage
    imageNpArray = getImageNpArray(imageFilePath, computeExtremes, color, DENOISER)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 165, in getImageNpArray
    print(f'`getImageNpArray` {minColor = }')
                               ^^^^^^^^
NameError: name 'minColor' is not defined

https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/commits/branch/master/datasets/raise/extract_noise.py

utils.py:

  • getImageNpArray

utils.py:

def updateExtremes(minColor, maxColor):
    minColor = 42
    maxColor = 43
    return minColor, maxColor

def getColorMeans():
    imageNpArray = getImageNpArray()

def getImageNpArray(computeExtremes):
    #print(f'`getImageNpArray` a {minColor = }')
    global minColor, maxColor
    print(f'`getImageNpArray` b {minColor = }')
    if computeExtremes:
        minColor, maxColor = updateExtremes(minColor, maxColor)

extract_noise.py:

from utils import getImageNpArray

minColor = None
maxColor = None

def treatImage(computeExtremes = False):
    print(f'`treatImage` {minColor = }')
    imageNpArray = getImageNpArray(computeExtremes)

treatImage(computeExtremes = True)
print(f'`main` {minColor = }')

Seems related to the Stack Overflow question 3400525.

```bash ./extract_noise.py ``` ``` Computing extremes of images: 0%| | 0/50 [00:00<?, ?it/s]`treatImage`: minColor = None Computing extremes of images: 0%| | 0/50 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./extract_noise.py", line 75, in <module> treatImage(imageFileName, computeExtremes = True, color = color) File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./extract_noise.py", line 61, in treatImage imageNpArray = getImageNpArray(imageFilePath, computeExtremes, color, DENOISER) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 165, in getImageNpArray print(f'`getImageNpArray` {minColor = }') ^^^^^^^^ NameError: name 'minColor' is not defined ``` https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/commits/branch/master/datasets/raise/extract_noise.py `utils.py`: - `getImageNpArray` `utils.py`: ```python def updateExtremes(minColor, maxColor): minColor = 42 maxColor = 43 return minColor, maxColor def getColorMeans(): imageNpArray = getImageNpArray() def getImageNpArray(computeExtremes): #print(f'`getImageNpArray` a {minColor = }') global minColor, maxColor print(f'`getImageNpArray` b {minColor = }') if computeExtremes: minColor, maxColor = updateExtremes(minColor, maxColor) ``` `extract_noise.py`: ```python from utils import getImageNpArray minColor = None maxColor = None def treatImage(computeExtremes = False): print(f'`treatImage` {minColor = }') imageNpArray = getImageNpArray(computeExtremes) treatImage(computeExtremes = True) print(f'`main` {minColor = }') ``` Seems related to [the Stack Overflow question 3400525](https://stackoverflow.com/q/3400525).
Benjamin_Loison added the
bug
medium priority
medium
labels 2024-05-13 22:49:06 +02:00
Sign in to join this conversation.
No description provided.