Skip to content

Commit

Permalink
Fixes in table when strings stored as objects
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlopaciuk committed Jun 21, 2024
1 parent 10766f6 commit bb76ecf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions xdeps/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __getitem__(self, key):
raise IndexError(
f"Cannot find `{key}` in table index `{self.table._index}`")
elif hasattr(key, "dtype"):
if key.dtype.kind in "SU":
if key.dtype.kind in "SUO":
if self.table._multiple_row_selections:
mask[self.table._get_names_indices(key)] = True
else:
Expand Down Expand Up @@ -220,7 +220,7 @@ def __init__(
index_cache=None,
cast_strings=True
):
self._data = data
self._data = {kk: data[kk] for kk in data.keys()}

self._col_names = list(data.keys() if col_names is None else col_names)
for kk in self._col_names:
Expand All @@ -229,7 +229,8 @@ def __init__(
raise ValueError(f"Column `{kk}` is not a numpy array")
else:
if cast_strings and vv.dtype.kind in "SU":
data[kk] = np.array(vv, dtype=object)
vv = np.array(vv, dtype=object)
self._data[kk] = vv
self._index = index
self._count_sep = count_sep
self._offset_sep = offset_sep
Expand Down Expand Up @@ -550,7 +551,7 @@ def show(
colwidth = len(cc)
width += colwidth + 1
if width < maxwidth:
if coltype in "SU":
if coltype in "SUO":
fmt.append("%%-%ds" % (colwidth))
else:
fmt.append("%%%ds" % colwidth)
Expand Down

0 comments on commit bb76ecf

Please sign in to comment.