Skip to content

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

Open
@nikmolnar

Description

@nikmolnar

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions