Helper function to cast a result back into an array with the appropriate dtype if an object array must be used as an intermediary.
(result, output_dtype_like=None)
| 58 | |
| 59 | |
| 60 | def _to_bytes_or_str_array(result, output_dtype_like=None): |
| 61 | """ |
| 62 | Helper function to cast a result back into an array |
| 63 | with the appropriate dtype if an object array must be used |
| 64 | as an intermediary. |
| 65 | """ |
| 66 | ret = numpy.asarray(result.tolist()) |
| 67 | dtype = getattr(output_dtype_like, 'dtype', None) |
| 68 | if dtype is not None: |
| 69 | return ret.astype(type(dtype)(_get_num_chars(ret)), copy=False) |
| 70 | return ret |
| 71 | |
| 72 | |
| 73 | def _clean_args(*args): |
no test coverage detected