ivy-llc / ivy

The Unified ML Representation
https://ivy.dev
Other
14.03k stars 5.82k forks source link

[Bug]: Unable to Create ivy.array from List or NumPy Array Containing Strings #28703

Closed muzakkirhussain011 closed 2 months ago

muzakkirhussain011 commented 3 months ago

Bug Explanation

Description

When attempting to create an ivy.array from a list or NumPy array that contains string elements, the operation fails. This is problematic as it limits the ability to work with categorical data in ivy.

Steps to Reproduce Bug

Reproduction Steps

  1. Create a list or NumPy array with string elements: data = ['apple', 'banana', 'cherry']
  2. Attempt to create an ivy.array: ivy_array = ivy.array(data)

Expected Behavior

The expected behavior is for ivy to create an array object that can handle string elements, similar to how NumPy handles arrays of strings.

Actual Behavior

The operation fails with the following error message: ivy.utils.exceptions.IvyException: numpy: nested_map: numpy: nested_map: numpy: default_dtype: numpy: is_complex_dtype: numpy: as_ivy_dtype: Cannot convert to ivy dtype. apple is not supported by NumPy backend.

Environment

Environment

Ivy Version

0.0.9.0

Backend

Device

CPU

abhi2596 commented 2 months ago

data = ['apple', 'banana', 'cherry'] ivy.array(data,dtype=object) the defauly dtype of Ivy array is float, hence we need to pass object dtype when creating a object array

muzakkirhussain011 commented 2 months ago

Thank you for your prompt resolution. I’m closing this issue now.

Best regards