Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NormalizeMeanToMid EEMS command causes a confusing error with arrays of all 0 and the IgnoreZeros option #14

Open
nikmolnar opened this issue Feb 6, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@nikmolnar
Copy link
Contributor

When NormalizeMeanToMid is passed an array of all 0 values, and the IgnoreZeros options is used, the mean is calculated as essentially:

arr = arr[arr != 0].mean()

This results in a nan value, which when used to determine values below the mean, causes the following exception:

Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.8\lib\site-packages\mpilot\commands.py", line 140, in run
    {[arg.name](http://arg.name/): arg.value for arg in self.arguments}
  File "C:\Python27\ArcGIS10.8\lib\site-packages\mpilot\libraries\eems\fuzzy.py", line 186, in execute
    StartVal=FUZZY_MIN, EndVal=FUZZY_MAX, **kwargs
  File "C:\Python27\ArcGIS10.8\lib\site-packages\mpilot\libraries\eems\basic.py", line 393, in execute
    below_mean = arr[arr <= mean_value]
  File "C:\Python27\ArcGIS10.8\lib\site-packages\numpy\ma\core.py", line 3044, in __getitem__
    dout = ndarray.__getitem__(_data, indx)
IndexError: arrays used as indices must be of integer (or boolean) type

An error is appropriate in this case, but we should recognize this case and raise a more user-friendly exception.

@nikmolnar nikmolnar added the bug Something isn't working label Feb 6, 2023
@nikmolnar nikmolnar self-assigned this Feb 6, 2023
@johngallo
Copy link
Collaborator

johngallo commented Feb 6, 2023

Thanks! And, I suspect the error I am getting when turning these to Ignore Zeros = False is also related. (See email thread). As per email thread, it may be good to give the user the option to allow the above, or to make a related command called something like "Automated Relative Value" that does. Best to look at the prototype, once completed to assess this. I had some incomplete thoughts on this here, but have moved them to my notes since my email thread has a more helpful strawman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants