Skip to content

Revert: REF: do length-checks in boilerplate decorator #34137

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

Merged
merged 21 commits into from
May 17, 2020

Conversation

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented May 12, 2020

closes #34123

As discussed in #34123
let's revert this PR34081 first since it has potentially big impact on some cases in ops.

cc @jbrockmendel @jorisvandenbossche

@pep8speaks
Copy link

pep8speaks commented May 12, 2020

Hello @charlesdong1991! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-05-15 09:02:38 UTC

@@ -460,6 +460,10 @@ def __mul__(self, other):
if not hasattr(other, "dtype"):
# list, tuple
other = np.array(other)
if len(other) != len(self) and not is_timedelta64_dtype(other):
Copy link
Member

Choose a reason for hiding this comment

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

other -> other.dtype

Copy link
Member Author

Choose a reason for hiding this comment

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

done, thanks!

@jbrockmendel
Copy link
Member

small request, otherwise LGTM

@jreback jreback changed the title Revert 34081 Revert: REF: do length-checks in boilerplate decorator May 12, 2020
@jreback jreback added Testing pandas testing functions or related to the test suite and removed Testing pandas testing functions or related to the test suite labels May 12, 2020
@jbrockmendel
Copy link
Member

Can you add test(s) for the behavior that was broken in #34081

@jreback jreback added this to the 1.1 milestone May 13, 2020
@charlesdong1991
Copy link
Member Author

charlesdong1991 commented May 13, 2020

emm, something might have changed alongside, now after this revert pr,

>>> pd.Index([('a', 'b'), ('b', 'c'), ('c', 'a')]) == ('c', 'a')
array([False, False, False])

it returns all False.

@jbrockmendel any idea which PR recently merged could influence this?

@charlesdong1991
Copy link
Member Author

charlesdong1991 commented May 13, 2020

emm, not sure how on earth i could run get array([False, False, True]) result that day, cannot replicate anymore. but seems since 1.0 or later this case returns array([False, False, False]) which i feel is wrong as well as a warning from numpy. i put some comments and todo there and pls let me know if it is appropriate

i could create a new issue to address this if you think is necessary.

@jorisvandenbossche
Copy link
Member

@charlesdong1991 I was also quite sure that I saw the correct behaviour in one of my environments, but also don't know where anymore.

Now, looking at it on 1.0.3, the problem is that it is creating a MultiIndex, and not a plain index with tuples in it. Ensuring we get an Index, I actually get the correct behaviour:

In [14]: pd.Index([('a', 'b'), ('b', 'c'), ('c', 'a')], tupleize_cols=False) == ('c', 'a') 
Out[14]: array([False, False,  True])

(and this example also actually fails on master)

@charlesdong1991
Copy link
Member Author

yeah, indeed, the issue i saw is that in such case, it automatically recognises as a MI, not Index.

@jorisvandenbossche thanks very much, I will add tupleize_cols=False in the test to get the correct result and I will also create an issue to report this case.

@jbrockmendel
Copy link
Member

LGTM

@jreback jreback merged commit 35a1657 into pandas-dev:master May 17, 2020
@jreback
Copy link
Contributor

jreback commented May 17, 2020

thanks @charlesdong1991

can you open a new issue to re-implement this (e.g. essentially a cleanup to revert the revert with appropriate changes).

@charlesdong1991
Copy link
Member Author

ref #34233

cc. @jreback

@charlesdong1991 charlesdong1991 deleted the revert_change branch May 19, 2020 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Index with tuples comparison not working anymore
5 participants