MCPcopy Create free account
hub / github.com/PyTables/PyTables / convert_to_np_atom2

Function convert_to_np_atom2

tables/utils.py:136–149  ·  view source on GitHub ↗

Convert a generic object into a NumPy object compliant with atom.

(obj: npt.ArrayLike, atom: Atom)

Source from the content-addressed store, hash-verified

134# The next is used in Array, EArray and VLArray, and it is a bit more
135# high level than convert_to_np_atom
136def 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
152def check_file_access(

Callers 3

appendMethod · 0.85
appendMethod · 0.85
__setitem__Method · 0.85

Calls 1

convert_to_np_atomFunction · 0.85

Tested by

no test coverage detected