Skip to content

TST: GH20676 Verify equals operator for list of Numpy arrays #35237

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 3 commits into from
Jul 13, 2020

Conversation

avinashpancham
Copy link
Contributor

@avinashpancham avinashpancham commented Jul 11, 2020



@pytest.mark.parametrize(
"input_data", [[np.array([1, 2]), np.array([1, 2])]],
Copy link
Member

Choose a reason for hiding this comment

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

You can in-line this data in the test since is parameterizing over 1 value

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Jul 12, 2020
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @avinashpancham lgtm. as a follow-up test_equals in pandas\tests\generic\test_generic.py could be split and the Series tests moved here.

@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Jul 12, 2020
@avinashpancham
Copy link
Contributor Author

avinashpancham commented Jul 12, 2020

@simonjayhawkins Moved the Series.equals tests from generic/test_generic.py to series/methods/test_equals.py. But I think I found a bug while restructuring the tests such that they are in the same style. This raises a ValueError instead of False. If this is a bug that should be addressed then I would like to help (if possible given my little experience).

Code Sample, a copy-pastable example if possible

arr = np.array([1, 2])
s1 = pd.Series([arr, arr])
s2 = s1.copy()

s1[1] = 9
s1.equals(s2)

Problem description
Series.qquals operation fails when comparing two Series that have a single value and list at the same position.

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Expected Output
False

Output of pd.show_versions()
INSTALLED VERSIONS

commit : 33df259
python : 3.8.3.final.0
python-bits : 64
OS : Darwin
OS-release : 19.5.0
Version : Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8

Output of pd.show_versions()
pandas : 1.1.0.dev0+2090.g33df25994.dirty
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.1.1.post20200710
Cython : 0.29.21
pytest : 5.4.3
hypothesis : 5.19.0
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : 4.5.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.7.4
fastparquet : 0.4.0
gcsfs : 0.6.2
matplotlib : 3.2.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : 0.17.1
pytables : None
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.0
sqlalchemy : 1.3.18
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.15.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.50.1

@jreback jreback added the Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff label Jul 13, 2020
@jreback
Copy link
Contributor

jreback commented Jul 13, 2020

@simonjayhawkins Moved the Series.equals tests from generic/test_generic.py to series/methods/test_equals.py. But I think I found a bug while restructuring the tests such that they are in the same style. This raises a ValueError instead of False. If this is a bug that should be addressed then I would like to help (if possible given my little experience).

Code Sample, a copy-pastable example if possible

arr = np.array([1, 2])
s1 = pd.Series([arr, arr])
s2 = s1.copy()

s1[1] = 9
s1.equals(s2)

Problem description
Series.qquals operation fails when comparing two Series that have a single value and list at the same position.

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Expected Output
False

Output of pd.show_versions()

INSTALLED VERSIONS
commit : 33df259
python : 3.8.3.final.0
python-bits : 64
OS : Darwin
OS-release : 19.5.0
Version : Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8

Output of pd.show_versions()
pandas : 1.1.0.dev0+2090.g33df25994.dirty
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.1.1.post20200710
Cython : 0.29.21
pytest : 5.4.3
hypothesis : 5.19.0
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : 4.5.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.7.4
fastparquet : 0.4.0
gcsfs : 0.6.2
matplotlib : 3.2.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : 0.17.1
pytables : None
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.0
sqlalchemy : 1.3.18
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.15.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.50.1

@avinashpancham can you file a new issue about this on master. thanks.

@jreback jreback merged commit 859eb6a into pandas-dev:master Jul 13, 2020
@jreback
Copy link
Contributor

jreback commented Jul 13, 2020

thanks @avinashpancham

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.Series.equals() fails for Series containing iterable objects
4 participants