Return whether a value is considered to be a homogeneous array
(v)
| 188 | |
| 189 | |
| 190 | def is_homogeneous_array(v): |
| 191 | """ |
| 192 | Return whether a value is considered to be a homogeneous array |
| 193 | """ |
| 194 | np = get_module("numpy", should_load=False) |
| 195 | pd = get_module("pandas", should_load=False) |
| 196 | if ( |
| 197 | np |
| 198 | and isinstance(v, np.ndarray) |
| 199 | or (pd and isinstance(v, (pd.Series, pd.Index))) |
| 200 | or (isinstance(v, nw.Series)) |
| 201 | ): |
| 202 | return True |
| 203 | if is_numpy_convertable(v): |
| 204 | np = get_module("numpy", should_load=True) |
| 205 | if np: |
| 206 | v_numpy = np.array(v) |
| 207 | # v is essentially a scalar and so shouldn't count as an array |
| 208 | if v_numpy.shape == (): |
| 209 | return False |
| 210 | else: |
| 211 | return True # v_numpy.dtype.kind in ["u", "i", "f", "M", "U"] |
| 212 | return False |
| 213 | |
| 214 | |
| 215 | def is_simple_array(v): |
no test coverage detected