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

BUG: Fix TypeError raised in libreduction #28643

Merged
merged 1 commit into from
Oct 2, 2019

Conversation

jbrockmendel
Copy link
Member

This is a PITA and I'm not 100% happy with the solution here, open to suggestions.

There is a call to util.get_value_at(labels, i) that raises TypeError if labels is not an ndarray. This fixes that by checking for non-ndarray and handling that case correctly.

There is also a case in master where we get an UnboundLocalError by referencing result before it is assigned. This patches that to raise a ValueError instead, but AFAICT fixing the ndarray bug above made it so that the UnboundLocalError case is no longer reached in the tests. i.e. this change is definitely more correct, but we don't have a test case specific to it.

I'm also not wild about the specific exception-catching on L297-307 in core.apply, but don't see a viable alternative. Suggestions welcome.

values = self.values
index = self.obj._get_axis(self.axis)
labels = self.agg_axis
empty_arr = np.empty(len(index), dtype=values.dtype)
dummy = Series(empty_arr, index=index, dtype=values.dtype)

# Preserve subclass for e.g. test_subclassed_apply
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing test test_subclassed_apply needs this

@jbrockmendel
Copy link
Member Author

Gentle ping; this is a blocker for further progress in groupby/apply/resample exception catching

@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label Oct 2, 2019
@jreback jreback added this to the 1.0 milestone Oct 2, 2019
@jreback
Copy link
Contributor

jreback commented Oct 2, 2019

This is a PITA and I'm not 100% happy with the solution here, open to suggestions

agreed, but ok for now :->

@jreback jreback merged commit 0436570 into pandas-dev:master Oct 2, 2019
@jbrockmendel jbrockmendel deleted the faster31 branch October 2, 2019 20:24
galuhsahid added a commit to galuhsahid/pandas that referenced this pull request Oct 4, 2019
* master: (22 commits)
  DOC: fix PR09,PR08 errors for pandas.Timestamp (pandas-dev#28739)
  WEB: Add diversity note to team.md (pandas-dev#28630)
  DOC: Minor fixes in pandas/testing.py docstring. (pandas-dev#28752)
  TST: port maybe_promote tests from pandas-dev#23982 (pandas-dev#28764)
  Bugfix/groupby datetime issue (pandas-dev#28569)
  reenable codecov (pandas-dev#28750)
  CLN: Centralised _check_percentile (pandas-dev#27584)
  DEPR: Deprecate Index.set_value (pandas-dev#28621)
  CLN: Fix typo in contributing.rst (pandas-dev#28761)
  Fixed docstring errors in pandas.period range and pandas.PeriodIndex (pandas-dev#28756)
  BUG: Fix TypeError raised in libreduction (pandas-dev#28643)
  DOC: Pandas.Series.drop docstring PR02 (pandas-dev#27976) (pandas-dev#28742)
  DOC: Fixed doctring errors PR08, PR09 in pandas.io (pandas-dev#28748)
  TST: Fix broken test cases where Timedelta/Timestamp raise (pandas-dev#28729)
  REF: Consolidate alignment calls in DataFrame ops (pandas-dev#28638)
  BUG: Fix dep generation (pandas-dev#28734)
  Added doctstring to fixture (pandas-dev#28727)
  DOC: Fixed PR06 docstrings errors in pandas.timedelta_range (pandas-dev#28719)
  replaced safe_import with a corresponding test decorator (pandas-dev#28731)
  BUG: Fix RangeIndex.get_indexer for decreasing RangeIndex (pandas-dev#28680)
  ...
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants