Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bcolz/ctable.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def cparams(self):
@property
def dtype(self):
"The data type of this object (numpy dtype)."
if getattr(self, '_dtype', None):
return self._dtype

names, cols = self.names, self.cols
l = []
for name in names:
Expand All @@ -150,7 +153,8 @@ def dtype(self):
t = (name, col.dtype) if col.ndim == 1 else \
(name, (col.dtype, col.shape[1:]))
l.append(t)
return np.dtype(l)
self._dtype = np.dtype(l)
return self._dtype

@property
def names(self):
Expand Down Expand Up @@ -487,6 +491,8 @@ def addcol(self, newcol, name=None, pos=None, move=False, **kwargs):

# Insert the column
self.cols.insert(name, pos, newcol)
# Trigger update of dtype cache
self._dtype = None
# Update _arr1
self._arr1 = np.empty(shape=(1,), dtype=self.dtype)

Expand Down Expand Up @@ -540,6 +546,8 @@ def delcol(self, name=None, pos=None, keep=False):
if not keep:
col.purge()

# Trigger update of dtype cache
self._dtype = None
# Update _arr1
self._arr1 = np.empty(shape=(1,), dtype=self.dtype)

Expand Down