psychopy.org | Reference | Downloads | Github

Run error "using a non-integer"

Hello,

I am trying to create a task where two pictures come up at a time side-by-side and a dot probe appears behind one of the images. The person must click the 1 or 2 button for left and right indicating which picture the dot probe appears at. All of the pictures are placed into an excel sheet but will not appear when I try to run the task. This error pops up:

############ Running: /home/dimelab/Gaze Task/gazetask1_lastrun.py #############
pyo version 0.7.8 (uses single precision)
/usr/lib/python2.7/dist-packages/openpyxl/worksheet/worksheet.py:374: UserWarning: Call to deprecated function or class get_highest_column (Use the max_column propery.).
def get_highest_column(self):
/usr/lib/python2.7/dist-packages/openpyxl/worksheet/worksheet.py:347: UserWarning: Call to deprecated function or class get_highest_row (Use the max_row property).
def get_highest_row(self):
/usr/lib/python2.7/dist-packages/numpy/ma/core.py:3245: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
_data[indx] = dval
/usr/lib/python2.7/dist-packages/numpy/ma/core.py:3246: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
_mask[indx] = mval

If anyone knows how to fix this please let me know. Thank you!

I’m guessing that there is some crazy unexpected content in your Excel file. Can you export it to a .csv file and use that instead? .csv also has the advantage that it is a simple text format so you can open it in any text editor and see problems that Excel might hide from you.

For some reason indx is not an integer. Convert it with something like

indx = int(indx)

In this case, it seems like indx is a variable created within numpy in response to a call from openpyxl, so it isn’t a variable that the user has direct control over or even access to.

My bad. I focused on the _data[indx] w/o paying attention to where it came from. (numpy/ma.core.py)

I went to look at numpy on GitHub, and although I’m sure that I’m looking at a newer version, the offending section of code is in a __setitem__ method in
class MaskedArray(ndarray):

    if _mask is nomask:
        # Set the data, then the mask
        _data[indx] = dval
        if mval is not nomask:
            _mask = self._mask = make_mask_none(self.shape, _dtype)
            _mask[indx] = mval
    elif not self._hardmask:
        # Set the data, then the mask
        _data[indx] = dval
        _mask[indx] = mval
    elif hasattr(indx, 'dtype') and (indx.dtype == MaskType):
        indx = indx * umath.logical_not(_mask)
        _data[indx] = dval
    else:
        if _dtype.names is not None:
            err_msg = "Flexible 'hard' masks are not yet supported."
            raise NotImplementedError(err_msg)
        mindx = mask_or(_mask[indx], mval, copy=True)
        dindx = self._data[indx]
        if dindx.size > 1:
            np.copyto(dindx, dval, where=~mindx)
        elif mindx is nomask:
            dindx = dval
        _data[indx] = dindx
        _mask[indx] = mindx

Converting the spreadsheet to a CSV would probably help.
The python error is only a DeprecationWarning though, so you would think that the experiment would continue. Is there a PsychoPy setting on what to do with warnings?

Did a google search for

numpy masked array deprecation warning

I found this in the numpy docs:

Deprecations
The ‘full’ and ‘economic’ modes of qr factorization are deprecated.

General
The use of non-integer for indices and most integer arguments has been deprecated. Previously float indices and function arguments such as axes or shapes were truncated to integers without warning. For example arr.reshape(3., -1) or arr[0.] will trigger a deprecation warning in NumPy 1.8., and in some future version of NumPy they will raise an error.

I don’t know if openpyxl has addressed this, but maybe an update of openpyxl is in order.