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: [unit test] pandas/core/indexes/multi.py:3655: TypeError #48533

Closed
3 tasks done
adrienpacifico opened this issue Sep 13, 2022 · 4 comments
Closed
3 tasks done

BUG: [unit test] pandas/core/indexes/multi.py:3655: TypeError #48533

adrienpacifico opened this issue Sep 13, 2022 · 4 comments
Labels
Build Library building on various platforms Closing Candidate May be closeable, needs more eyeballs

Comments

@adrienpacifico
Copy link
Contributor

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

pytest --pdb pandas/tests/test_multilevel.py

Issue Description

The unit-test

def test_alignment(self):

does not pass.

I am using VSCode with the .devcontainer file (thus in a container), with a linux distribution (pop-os).

Stack trace:

self = <pandas.tests.test_multilevel.TestMultiLevel object at 0x7fc319bae370>

    def test_alignment(self):
        x = Series(
            data=[1, 2, 3], index=MultiIndex.from_tuples([("A", 1), ("A", 2), ("B", 3)])
        )
    
        y = Series(
            data=[4, 5, 6], index=MultiIndex.from_tuples([("Z", 1), ("Z", 2), ("B", 3)])
        )
    
>       res = x - y

pandas/tests/test_multilevel.py:147: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pandas/core/ops/common.py:72: in new_method
    return method(self, other)
pandas/core/arraylike.py:111: in __sub__
    return self._arith_method(other, operator.sub)
pandas/core/series.py:6273: in _arith_method
    self, other = ops.align_method_SERIES(self, other)
pandas/core/ops/__init__.py:168: in align_method_SERIES
    left, right = left.align(right, copy=False)
pandas/core/series.py:4865: in align
    return super().align(
pandas/core/generic.py:9478: in align
    return self._align_series(
pandas/core/generic.py:9585: in _align_series
    join_index, lidx, ridx = self.index.join(
pandas/util/_decorators.py:317: in wrapper
    return func(*args, **kwargs)
pandas/core/indexes/base.py:230: in join
    join_index, lidx, ridx = meth(self, other, how=how, level=level, sort=sort)
pandas/core/indexes/base.py:4725: in join
    return self._join_via_get_indexer(other, how, sort)
pandas/core/indexes/base.py:4747: in _join_via_get_indexer
    join_index = self.union(other)
pandas/core/indexes/base.py:3351: in union
    result = self._union(other, sort=sort)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = MultiIndex([('A', 1),
            ('A', 2),
            ('B', 3)],
           )
other = MultiIndex([('Z', 1),
            ('Z', 2),
            ('B', 3)],
           ), sort = None

    def _union(self, other, sort) -> MultiIndex:
        other, result_names = self._convert_can_do_setop(other)
        if (
            any(-1 in code for code in self.codes)
            and any(-1 in code for code in other.codes)
            or other.has_duplicates
        ):
            # This is only necessary if both sides have nans or other has dups,
            # fast_unique_multiple is faster
            result = super()._union(other, sort)
    
            if isinstance(result, MultiIndex):
                return result
            return MultiIndex.from_arrays(
                zip(*result), sortorder=None, names=result_names
            )
    
        else:
            rvals = other._values.astype(object, copy=False)
>           right_missing = lib.fast_unique_multiple(self._values, rvals)
E           TypeError: Argument 'arrays' has incorrect type (expected list, got numpy.ndarray)

pandas/core/indexes/multi.py:3655: TypeError

Expected Behavior

The test should pass

Installed Versions

INSTALLED VERSIONS ------------------ commit : aea824f python : 3.8.13.final.0 python-bits : 64 OS : Linux OS-release : 5.8.0-7630-generic Version : #32~1609193707~20.10~781bb80-Ubuntu SMP Tue Jan 5 21:29:56 UTC 2 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : C.UTF-8 LANG : C.UTF-8 LOCALE : en_US.UTF-8

pandas : 1.6.0.dev0+119.gaea824f9aa.dirty
numpy : 1.22.4
pytz : 2022.2.1
dateutil : 2.8.2
setuptools : 65.3.0
pip : 22.2.2
Cython : 0.29.32
pytest : 7.1.3
hypothesis : 6.54.5
sphinx : 4.5.0
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : 1.1
pymysql : 1.0.2
psycopg2 : 2.9.3
jinja2 : 3.0.3
IPython : 8.5.0
pandas_datareader: 0.10.0
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : 0.8.3
fsspec : 2021.11.0
gcsfs : 2021.11.0
matplotlib : 3.5.3
numba : 0.55.2
numexpr : 2.8.3
odfpy : None
openpyxl : 3.0.10
pandas_gbq : 0.17.8
pyarrow : 9.0.0
pyreadstat : 1.1.9
pyxlsb : 1.0.9
s3fs : 2021.11.0
scipy : 1.9.1
snappy :
sqlalchemy : 1.4.41
tables : 3.7.0
tabulate : 0.8.10
xarray : 2022.6.0
xlrd : 2.0.1
xlwt : 1.3.0
zstandard : 0.18.0
tzdata : None

@adrienpacifico adrienpacifico added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 13, 2022
@phofl
Copy link
Member

phofl commented Sep 13, 2022

Hi, thanks for your report. You have to rebuild the c extensions. lib.fast_unique_multiple was changed like an hour ago

@phofl phofl added Build Library building on various platforms Closing Candidate May be closeable, needs more eyeballs and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 13, 2022
@adrienpacifico
Copy link
Contributor Author

Thanx @phofl phofl!
Won't it be possible to have a test that check that the c extension has been rebuilt if there is a change to the pandas/_libs file since the last compilation to avoid future mistake like mine? I ran the test_fast.sh file at first, maybe a clever git command could be included there?

@phofl
Copy link
Member

phofl commented Sep 13, 2022

Hm not sure, could you open another issue about this? Theoretically, you could rebuild the extensions from within that file I think

@adrienpacifico
Copy link
Contributor Author

Tests are passing after rebuilding the c extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms Closing Candidate May be closeable, needs more eyeballs
Projects
None yet
Development

No branches or pull requests

2 participants