Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of bounds checking / handling in cut, qcut #1409

Closed
wesm opened this issue Jun 6, 2012 · 0 comments
Closed

Out of bounds checking / handling in cut, qcut #1409

wesm opened this issue Jun 6, 2012 · 0 comments
Milestone

Comments

@wesm
Copy link
Member

wesm commented Jun 6, 2012

currently:


In [5]: cut(frame.data1, [-4, -2, 0, 2, 1])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/wesm/code/pandas/<ipython-input-5-dcb858d11751> in <module>()
----> 1 cut(frame.data1, [-4, -2, 0, 2, 1])

/home/wesm/code/pandas/pandas/tools/tile.pyc in cut(x, bins, right, labels, retbins, precision)
     93         bins = np.asarray(bins)
     94         if (np.diff(bins) < 0).any():
---> 95             raise ValueError('bins must increase monotonically.')
     96 
     97     return _bins_to_cuts(x, bins, right=right, labels=labels,

ValueError: bins must increase monotonically.

In [6]: cut(frame.data1, [-4, -2, 0, 1])
Out[6]: ---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/home/wesm/code/pandas/<ipython-input-6-19824849af62> in <module>()
----> 1 cut(frame.data1, [-4, -2, 0, 1])

/home/wesm/code/repos/ipython/IPython/core/displayhook.pyc in __call__(self, result)
    236             self.start_displayhook()
    237             self.write_output_prompt()
--> 238             format_dict = self.compute_format_data(result)
    239             self.write_format_data(format_dict)
    240             self.update_user_ns(result)

/home/wesm/code/repos/ipython/IPython/core/displayhook.pyc in compute_format_data(self, result)
    148             MIME type representation of the object.
    149         """
--> 150         return self.shell.display_formatter.format(result)
    151 
    152     def write_format_data(self, format_dict):

/home/wesm/code/repos/ipython/IPython/core/formatters.pyc in format(self, obj, include, exclude)
    124                     continue
    125             try:
--> 126                 data = formatter(obj)
    127             except:
    128                 # FIXME: log the exception

/home/wesm/code/repos/ipython/IPython/core/formatters.pyc in __call__(self, obj)
    445                 type_pprinters=self.type_printers,
    446                 deferred_pprinters=self.deferred_printers)
--> 447             printer.pretty(obj)
    448             printer.flush()
    449             return stream.getvalue()

/home/wesm/code/repos/ipython/IPython/lib/pretty.pyc in pretty(self, obj)
    352                 if callable(obj_class._repr_pretty_):
    353                     return obj_class._repr_pretty_(obj, self, cycle)
--> 354             return _default_pprint(obj, self, cycle)
    355         finally:
    356             self.end_group()

/home/wesm/code/repos/ipython/IPython/lib/pretty.pyc in _default_pprint(obj, p, cycle)
    472     if getattr(klass, '__repr__', None) not in _baseclass_reprs:
    473         # A user-provided repr.
--> 474         p.text(repr(obj))
    475         return
    476     p.begin_group(1, '<')

/home/wesm/code/pandas/pandas/core/factor.pyc in __repr__(self)
     54     def __repr__(self):
     55         temp = 'Factor:%s\n%s\nLevels (%d): %s'
---> 56         values = np.asarray(self)
     57         return temp % ('' if self.name is None else self.name,
     58                        repr(values), len(self.levels), self.levels)

/home/wesm/epd/lib/python2.7/site-packages/numpy/core/numeric.pyc in asarray(a, dtype, order)
    233 
    234     """
--> 235     return array(a, dtype, copy=False, order=order)
    236 
    237 def asanyarray(a, dtype=None, order=None):

/home/wesm/code/pandas/pandas/core/factor.pyc in __array__(self, dtype)
     47 
     48     def __array__(self, dtype=None):
---> 49         return com.take_1d(self.levels, self.labels)
     50 
     51     def __len__(self):

/home/wesm/code/pandas/pandas/core/common.pyc in take_1d(arr, indexer, out, fill_value)
    235         if out is None:
    236             out = np.empty(n, dtype=arr.dtype)
--> 237         take_f(arr, _ensure_int64(indexer), out=out, fill_value=fill_value)
    238     else:
    239         out = ndtake(arr, indexer, out=out)

/home/wesm/code/pandas/pandas/_algos.so in pandas._algos.take_1d_object (pandas/src/generated.c:19923)()

IndexError: Out of bounds on buffer access (axis 0)
@wesm wesm closed this as completed in 8f94009 Jun 12, 2012
yarikoptic added a commit to neurodebian/pandas that referenced this issue Jun 21, 2012
Version 0.8.0 beta 2

* tag 'v0.8.0b2': (37 commits)
  RLS: 0.8.0 beta 2
  BUG: bytes_to_str for read_csv
  BUG: import BytesIO for py3compat
  BUG: fix compat errors for yahoo data reader
  ENH: convert datetime.datetime ourselves, 15x speedup
  Make tox work across versions of Python from 2.5 to 3.2
  Reenable py31 and py32 in .travis.yml
  TST: test coverage
  TST: oops, delete stray line
  REF: factor out ujson extension into pandasjson for now
  TST: eliminate copies in datetime64 serialization; don't copy data in DatetimeIndex, close pandas-dev#1320
  DOC: refresh time zone docs close pandas-dev#1447
  BUG: always raise exception when concat keys aren't found in passed levels, close pandas-dev#1406
  ENH: implement passed quantile array to qcut and document that plus factors, close pandas-dev#1407
  ENH: clearer out of bounds error message in cut/qcut, close pandas-dev#1409
  ENH: allow renaming of index levels when concatenating, close pandas-dev#1419
  BUG: fix MultiIndex bugs described in pandas-dev#1401
  DOC: release notes
  BUG: implement multiple DataFrame.join / merge on non-unique indexes by multiple merges, close pandas-dev#1421
  REF: remove offset names from pandas namespace
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant