Conversation
Verified suggestions by copilot. The main ones are: - added " if statements " to catch extreme cases - fixed function return to formulate lists
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
|
||
| # Check if it's an array of fill values | ||
| if unique_vals == inp._FillValue: | ||
| if unique_vals.item == inp._FillValue: |
There was a problem hiding this comment.
The removed version will never be true since numpy.unique returns a 1D array if the axis argument is left unspecified or None. https://numpy.org/doc/stable/reference/generated/numpy.unique.html
The second added version (which admittedly Copilot suggested) will fail and throw an exception for anything but a single-element array, which is not going to be the majority of datasets/variables. I would probably just compare unique_vals == np.array([inp._FillValue]) or something similar, but I don't know how this would operate for masked arrays.
>>> import numpy as np
>>>arr = np.array([1, 2])
>>> arr.item()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: can only convert an array of size 1 to a Python scalar
Please address and add unit tests for this case.
|
Commit message should be more specific. Right now I wouldn't know what code the changes affected looking at the commit summary. I would change this to something like: Amending the commit message and force pushing would be OK. |
Verified suggestions by copilot. The main ones are: