Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

deleting last column of ctable raises TypeError #306

Closed
suntzu86 opened this issue Jun 14, 2016 · 0 comments
Closed

deleting last column of ctable raises TypeError #306

suntzu86 opened this issue Jun 14, 2016 · 0 comments

Comments

@suntzu86
Copy link

suntzu86 commented Jun 14, 2016

If we are deleting the last column, then self.dtype == numpy.dtype([]) and so creation of arr1 fails:
https://github.com/Blosc/bcolz/blob/master/bcolz/ctable.py#L590

    589         # Update _arr1 for the new dtype
--> 590         self._arr1 = np.empty(shape=(1,), dtype=self.dtype)
    591
    592         if not keep:

TypeError: Empty data-type

This means purge and flush are never called on the deleted column.

Example:

test_ctable = bcolz.ctable(numpy.zeros(2, dtype='f8, i4'))
test_ctable.delcol('f0')
test_ctable.delcol('f1')  # fails with the above error

Probably not too critical since I imagine it's uncommon to delete everything like this.

Note: deleting the last col further puts the object in a broken state. This is the output from trying to print test_ctable after I ran the above 2 delcol statements.

In [671]: test_ctable
Out[671]: ---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
virtualenv_run/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
    697                 type_pprinters=self.type_printers,
    698                 deferred_pprinters=self.deferred_printers)
--> 699             printer.pretty(obj)
    700             printer.flush()
    701             return stream.getvalue()

virtualenv_run/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj)
    381                             if callable(meth):
    382                                 return meth(obj, self, cycle)
--> 383             return _default_pprint(obj, self, cycle)
    384         finally:
    385             self.end_group()

virtualenv_run/lib/python2.7/site-packages/IPython/lib/pretty.pyc in _default_pprint(obj, p, cycle)
    501     if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs:
    502         # A user-provided repr. Find newlines and replace them with p.break_()
--> 503         _repr_pprint(obj, p, cycle)
    504         return
    505     p.begin_group(1, '<')

virtualenv_run/lib/python2.7/site-packages/IPython/lib/pretty.pyc in _repr_pprint(obj, p, cycle)
    692     """A pprint that just redirects to the normal repr function."""
    693     # Find newlines and replace them with p.break_()
--> 694     output = repr(obj)
    695     for idx,output_line in enumerate(output.splitlines()):
    696         if idx:

virtualenv_run/lib/python2.7/site-packages/bcolz/ctable.pyc in __repr__(self)
   1394
   1395     def __repr__(self):
-> 1396         nbytes, cbytes, cratio = self._get_stats()
   1397         snbytes = utils.human_readable_size(nbytes)
   1398         scbytes = utils.human_readable_size(cbytes)

virtualenv_run/lib/python2.7/site-packages/bcolz/ctable.pyc in _get_stats(self)
   1387             nbytes += column.nbytes
   1388             cbytes += column.cbytes
-> 1389         cratio = nbytes / float(cbytes)
   1390         return (nbytes, cbytes, cratio)
   1391

ZeroDivisionError: float division by zero
CarstVaartjes pushed a commit to CarstVaartjes/bcolz that referenced this issue Jul 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant