read an array for the specified node (off of group
(self, key: str, start: int | None = None, stop: int | None = None)
| 3065 | self.set_attrs() |
| 3066 | |
| 3067 | def read_array(self, key: str, start: int | None = None, stop: int | None = None): |
| 3068 | """read an array for the specified node (off of group""" |
| 3069 | import tables |
| 3070 | |
| 3071 | node = getattr(self.group, key) |
| 3072 | attrs = node._v_attrs |
| 3073 | |
| 3074 | transposed = getattr(attrs, "transposed", False) |
| 3075 | |
| 3076 | if isinstance(node, tables.VLArray): |
| 3077 | ret = node[0][start:stop] |
| 3078 | dtype = getattr(attrs, "value_type", None) |
| 3079 | if dtype is not None: |
| 3080 | ret = pd_array(ret, dtype=dtype) |
| 3081 | else: |
| 3082 | dtype = getattr(attrs, "value_type", None) |
| 3083 | shape = getattr(attrs, "shape", None) |
| 3084 | |
| 3085 | if shape is not None: |
| 3086 | # length 0 axis |
| 3087 | ret = np.empty(shape, dtype=dtype) |
| 3088 | else: |
| 3089 | ret = node[start:stop] |
| 3090 | |
| 3091 | if dtype and dtype.startswith("datetime64"): |
| 3092 | # reconstruct a timezone if indicated |
| 3093 | if dtype == "datetime64": |
| 3094 | dtype = "datetime64[ns]" |
| 3095 | tz = getattr(attrs, "tz", None) |
| 3096 | ret = _set_tz(ret, tz, dtype) |
| 3097 | |
| 3098 | elif dtype and dtype.startswith("timedelta64"): |
| 3099 | if dtype == "timedelta64": |
| 3100 | # This was written back before we started writing |
| 3101 | # timedelta64 units |
| 3102 | ret = np.asarray(ret, dtype="m8[ns]") |
| 3103 | else: |
| 3104 | ret = np.asarray(ret, dtype=dtype) |
| 3105 | |
| 3106 | if transposed: |
| 3107 | return ret.T |
| 3108 | else: |
| 3109 | return ret |
| 3110 | |
| 3111 | def read_index( |
| 3112 | self, key: str, start: int | None = None, stop: int | None = None |
no test coverage detected