Save a new array in file.
(self)
| 196 | ) |
| 197 | |
| 198 | def _g_create(self) -> int: |
| 199 | """Save a new array in file.""" |
| 200 | self._v_version = obversion |
| 201 | try: |
| 202 | # `Leaf._g_post_init_hook()` should be setting the flavor on disk. |
| 203 | self._flavor = flavor = flavor_of(self._obj) |
| 204 | nparr = array_as_internal(self._obj, flavor) |
| 205 | except Exception: # XXX |
| 206 | # Problems converting data. Close the node and re-raise exception. |
| 207 | self.close(flush=0) |
| 208 | raise |
| 209 | |
| 210 | # Raise an error in case of unsupported object |
| 211 | if nparr.dtype.kind in ["V", "U", "O"]: # in void, unicode, object |
| 212 | raise TypeError( |
| 213 | "Array objects cannot currently deal with void, " |
| 214 | "unicode or object arrays" |
| 215 | ) |
| 216 | |
| 217 | # Decrease the number of references to the object |
| 218 | self._obj = None |
| 219 | |
| 220 | # Fix the byteorder of data |
| 221 | nparr = self._g_fix_byteorder_data(nparr, nparr.dtype.byteorder) |
| 222 | |
| 223 | # Create the array on-disk |
| 224 | try: |
| 225 | # ``self._v_objectid`` needs to be set because would be |
| 226 | # needed for setting attributes in some descendants later |
| 227 | # on |
| 228 | self._v_objectid, self.shape, self.atom = self._create_array( |
| 229 | nparr, self._v_new_title, self.atom |
| 230 | ) |
| 231 | except Exception: # XXX |
| 232 | # Problems creating the Array on disk. Close node and re-raise. |
| 233 | self.close(flush=0) |
| 234 | raise |
| 235 | |
| 236 | # Compute the optimal buffer size |
| 237 | self.nrowsinbuf = self._calc_nrowsinbuf() |
| 238 | # Arrays don't have chunkshapes (so, set it to None) |
| 239 | self._v_chunkshape = None |
| 240 | |
| 241 | return self._v_objectid |
| 242 | |
| 243 | def _g_open(self) -> int: |
| 244 | """Get the metadata info for an array in file.""" |
nothing calls this directly
no test coverage detected