Skip to content

[Bug]: ivy.array(0)[None] (adding dimention to a 0-dimentional array) UnboundLocalError: cannot access local variable 'array_queries' where it is not associated with a value #28838

@34j

Description

@34j

Bug Explanation

> python -c "import ivy; ivy.array(0)[..., None]"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 643, in _handle_view_indexing
    ret = fn(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/data_classes/array/array.py", line 429, in __getitem__
    return ivy.get_item(self._data, query)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 912, in _handle_nestable
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 968, in _handle_partial_mixed_function
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 643, in _handle_view_indexing
    ret = fn(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 456, in _inputs_to_ivy_arrays
    return fn(*ivy_args, **ivy_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 328, in _handle_array_function
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 761, in _handle_device
    with ivy.DefaultDevice(ivy.default_device(dst_dev)):
  File "./venv/lib/python3.11/site-packages/ivy/functional/ivy/device.py", line 128, in __exit__
    raise exc_val
  File "./venv/lib/python3.11/site-packages/ivy/func_wrapper.py", line 762, in _handle_device
    return ivy.handle_soft_device_variable(*args, fn=fn, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/functional/ivy/device.py", line 133, in handle_soft_device_variable
    return ivy.current_backend().handle_soft_device_variable(*args, fn=fn, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/functional/backends/numpy/device.py", line 68, in handle_soft_device_variable
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/functional/ivy/general.py", line 2812, in get_item
    query, target_shape, vector_inds = _parse_query(query, x_shape)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./venv/lib/python3.11/site-packages/ivy/functional/ivy/general.py", line 3001, in _parse_query
    indices = array_queries.reshape((*target_shape, len(x_shape)))
              ^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'array_queries' where it is not associated with a value

Steps to Reproduce Bug

python -c "import ivy; ivy.array(0)[None]"
python -c "import ivy; ivy.array(0)[..., None]"

This works:

python -c "import numpy as np; np.array(0)[None]"
python -c "import numpy as np; np.array(0)[..., None]"
python -c "import ivy; ivy.array([0])[..., None]"
python -c "import ivy; ivy.set_backend('torch'); ivy.array(0)[..., None]"
python -c "import ivy; ivy.set_backend('numpy'); ivy.array(0)[..., None]"

Environment

Ubuntu 22.04

Ivy Version

0.0.9.16 and 1.0.0.0

Backend

  • NumPy
  • TensorFlow
  • PyTorch
  • JAX

Device

CPU

Metadata

Metadata

Assignees

Labels

Bug ReportReport bugs detected in Ivy.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions