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

Error evaluating numpy array. #378

Closed
fabioz opened this issue Aug 20, 2020 · 1 comment
Closed

Error evaluating numpy array. #378

fabioz opened this issue Aug 20, 2020 · 1 comment

Comments

@fabioz
Copy link
Collaborator

fabioz commented Aug 20, 2020

@fabloz I was able to perform the steps you proposed and with the new version of debugpy, the debugger now crashes instead of freezing. I created a very simple python setup for you in order to validate whether the problem is fixed. If you require more information let me know.

Example python scripts

is_scalar.py module

import torch
import numpy as np


def is_scalar(obj):
    """Recursive function that checks whether a input

    Args:
        obj (object): Object for which you want to check if it is a scalar.

    Returns:
        boole: Boolean specifying whether the object is a scalar.
    """

    # Check if obj is scalar
    if type(obj) in [int, float]:
        return True
    elif type(obj) == np.ndarray:
        if obj.__len__() > 1:
            return is_scalar(obj)
        else:
            return False
    elif type(obj) == torch.Tensor:
        if obj.__len__() > 1:
            return is_scalar(obj)
        else:
            return False
    elif type(obj) == str:
        return obj.isnumeric()
    else:
        return False

test_debugger.py script

import numpy as np

from is_scalar import is_scalar

print(is_scalar(1), "True")
print(is_scalar([1]), "False")
print(is_scalar(np.array(2)), "True")  # I'm here
pass

Steps to reproduce (Also see gif)

  1. Put both the test_debugger.py and is_scalar.py script in the same folder.
  2. Run the test_debugger script while placing a breakpoint on the pass statement.
  3. Create a new np array in the debugger console test_array = np.array(2).
  4. Try to inspect this new test_array and see the debugger hanging in the old debugpy version.
  5. In the new pulled version of debugpy the debugger crashes while giving the following error:
IndexError: too many indices for array

Gif

debugpy_problem

Full Error message

To see the full error message go to this gist.

Debugpy (old version) logs

The logs for when I'm using the old version can be found in this gist.

Debugpy (new version) logs

The logs for when I'm using the new version can be found in this gist.

@fabioz
Copy link
Collaborator Author

fabioz commented Aug 20, 2020

Note: this was reported by @rickstaa
at: #274 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant