Convert a generic object into a NumPy object compliant with atom.
(obj: npt.ArrayLike, atom: Atom)
| 134 | # The next is used in Array, EArray and VLArray, and it is a bit more |
| 135 | # high level than convert_to_np_atom |
| 136 | def convert_to_np_atom2(obj: npt.ArrayLike, atom: Atom) -> np.ndarray: |
| 137 | """Convert a generic object into a NumPy object compliant with atom.""" |
| 138 | # Check whether the object needs to be copied to make the operation |
| 139 | # safe to in-place conversion. |
| 140 | copy = True if atom.type in ["time64"] else copy_if_needed |
| 141 | nparr = convert_to_np_atom(obj, atom, copy) |
| 142 | # Finally, check the byteorder and change it if needed |
| 143 | byteorder = byteorders[nparr.dtype.byteorder] |
| 144 | if byteorder in ["little", "big"] and byteorder != sys.byteorder: |
| 145 | # The byteorder needs to be fixed (a copy is made |
| 146 | # so that the original array is not modified) |
| 147 | nparr = nparr.byteswap() |
| 148 | |
| 149 | return nparr |
| 150 | |
| 151 | |
| 152 | def check_file_access( |
no test coverage detected