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

py.test -v cppyy_bbhash/tests/test_bbhash_basic.py Fails #2

Open
a3an-de opened this issue Oct 15, 2020 · 2 comments
Open

py.test -v cppyy_bbhash/tests/test_bbhash_basic.py Fails #2

a3an-de opened this issue Oct 15, 2020 · 2 comments

Comments

@a3an-de
Copy link

a3an-de commented Oct 15, 2020

I have faithfully followed your directions, everything went ok except the tests.
Could you give me a hint as to what went wrong ?

Regards, Adrian

This is part of the test listing, it seems that ULong64_t and queries for int are not supported ??

(cppyy-example) a4@a3-Virtual-Machine:~/cppyy-bbhash/build$ py.test -v cppyy_bbhash/tests/test_bbhash_basic.py
======================================================================== test session starts ========================================================================
platform linux -- Python 3.9.0, pytest-6.1.1, py-1.9.0, pluggy-0.13.1 -- /home/a4/miniconda3/envs/cppyy-example/bin/python
cachedir: .pytest_cache
rootdir: /home/a4/cppyy-bbhash/build
collected 18 items

cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[ULong64_t-10] ERROR [ 5%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[ULong64_t-100] ERROR [ 11%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[ULong64_t-1000] ERROR [ 16%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[int-10] PASSED [ 22%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[int-100] PASSED [ 27%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[int-1000] PASSED [ 33%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[unsigned int-10] PASSED [ 38%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[unsigned int-100] PASSED [ 44%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_lookup[unsigned int-1000] PASSED [ 50%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[ULong64_t-10] ERROR [ 55%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[ULong64_t-100] ERROR [ 61%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[ULong64_t-1000] ERROR [ 66%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[int-10] FAILED [ 72%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[int-100] FAILED [ 77%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[int-1000] FAILED [ 83%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[unsigned int-10] FAILED [ 88%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[unsigned int-100] FAILED [ 94%]
cppyy_bbhash/tests/test_bbhash_basic.py::test_mphf_query[unsigned int-1000] FAILED [100%]

============================================================================== ERRORS ===============================================================================
_________________________________________________________ ERROR at setup of test_mphf_lookup[ULong64_t-10] __________________________________________________________

request = <SubRequest 'mphf_type' for <Function test_mphf_lookup[ULong64_t-10]>>

@pytest.fixture(params=['ULong64_t', 'int', 'unsigned int'])
def mphf_type(request):
  return request.param, boomphf.mphf[request.param, boomphf.SingleHashFunctor[request.param]]

cppyy_bbhash/tests/test_bbhash_basic.py:9:


self = <cppyy.Template 'boomphf::SingleHashFunctor' object at 0x7f9e5fc92f40>, args = ('ULong64_t',), newargs = ['boomphf::SingleHashFunctor', 'ULong64_t']
arg = 'ULong64_t'

def __getitem__(self, *args):
  # multi-argument to [] becomes a single tuple argument
    if args and type(args[0]) is tuple:
        args = args[0]

  # construct the type name from the types or their string representation
    newargs = [self.__name__]
    for arg in args:
        if type(arg) == str:
            arg = ','.join(map(lambda x: x.strip(), arg.split(',')))
        newargs.append(arg)
  pyclass = _backend.MakeCppTemplateClass(*newargs)

E TypeError: 'boomphf::SingleHashFunctor<ULong64_t>' is not a known C++ class

../../miniconda3/envs/cppyy-example/lib/python3.9/site-packages/cppyy/_cpython_cppyy.py:79: TypeError

@a3an-de
Copy link
Author

a3an-de commented Oct 16, 2020

I found more data showing error mesaages:

-- Build files have been written to: /home/a4/cppyy-bbhash/build
(cppyy-example) a4@a3-Virtual-Machine:/cppyy-bbhash/build$ make
Scanning dependencies of target bbhash
[ 16%] Linking CXX static library libbbhash.a
[ 16%] Built target bbhash
[ 33%] Generating cppyy_bbhash/cppyy_bbhash.map
ERROR: While parsing: /../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/math.h:65[12] target of using declaration conflicts with declaration already in scope
ERROR: While parsing: /../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/math.h:66[12] target of using declaration conflicts with declaration already in scope
WARNING: While parsing: /home/a4/cppyy-bbhash/bbhash/BooPHF.h:676[40] format specifies type 'long long' but the argument has type 'uint64_t' (aka 'unsigned long')
WARNING: While parsing: /home/a4/cppyy-bbhash/bbhash/BooPHF.h:680[24] format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long')
WARNING: While parsing: /home/a4/cppyy-bbhash/bbhash/BooPHF.h:689[30] format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long')
WARNING: While parsing: /home/a4/cppyy-bbhash/bbhash/BooPHF.h:689[33] format specifies type 'long long' but the argument has type '__gnu_cxx::__alloc_traits<std::allocator, unsigned long>::value_type' (aka 'unsigned long')
WARNING: While parsing: /home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027[8] format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long')
[ 50%] Generating cppyy_bbhash.cpp, cppyy_bbhash/libcppyy_bbhashCppyy.rootmap, cppyy_bbhash/libcppyy_bbhashCppyy_rdict.pcm
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:676:40: warning: format specifies type 'long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
printf("bit array of size %lli: \n",_size);
~~~~ ^~~~~
%lu
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:680:24: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
printf(" (%llu) ",ii);
~~~~ ^

%lu
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:689:30: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
printf("%llu : %lli, ",ii,_ranks[ii]);
~~~~ ^~
%lu
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:689:33: warning: format specifies type 'long long' but the argument has type '__gnu_cxx::__alloc_traits<std::allocator, unsigned long>::value_type'
(aka 'unsigned long') [-Wformat]
printf("%llu : %lli, ",ii,_ranks[ii]);
~~~~ ^~~~~~~~~~
%lu
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:16:25: note: in instantiation of member function 'boomphf::mphf<unsigned short, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<unsigned short, boomphf::SingleHashFunctor>;
^
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:17:25: note: in instantiation of member function 'boomphf::mphf<unsigned int, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<unsigned int, boomphf::SingleHashFunctor>;
^
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:18:25: note: in instantiation of member function 'boomphf::mphf<unsigned long, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<uint64_t, boomphf::SingleHashFunctor<uint64_t>>;
^
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:19:25: note: in instantiation of member function 'boomphf::mphf<unsigned long long, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<unsigned long long, boomphf::SingleHashFunctor>;
^
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:21:25: note: in instantiation of member function 'boomphf::mphf<short, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<short, boomphf::SingleHashFunctor>;
^
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:22:25: note: in instantiation of member function 'boomphf::mphf<int, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<int, boomphf::SingleHashFunctor>;
^
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:23:25: note: in instantiation of member function 'boomphf::mphf<long, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<int64_t, boomphf::SingleHashFunctor<int64_t>>;
^
In file included from input_line_7:3:
In file included from /home/a4/cppyy-bbhash/interface.hh:1:
/home/a4/cppyy-bbhash/bbhash/BooPHF.h:1027:8: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
^~~~~~~~~~~~~~~
/home/a4/cppyy-bbhash/interface.hh:24:25: note: in instantiation of member function 'boomphf::mphf<long long, boomphf::SingleHashFunctor >::totalBitSize' requested here
template class boomphf::mphf<long long, boomphf::SingleHashFunctor>;
^
Scanning dependencies of target cppyy_bbhashCppyy
[ 66%] Building CXX object CMakeFiles/cppyy_bbhashCppyy.dir/cppyy_bbhash.cpp.o
[ 83%] Linking CXX shared library cppyy_bbhash/libcppyy_bbhashCppyy.so
Warning: Unused direct dependencies:
/home/a4/miniconda3/envs/cppyy-example/lib/python3.9/site-packages/cppyy_backend/lib/libCling.so
[ 83%] Built target cppyy_bbhashCppyy
Scanning dependencies of target wheel
[100%] Generating dist/cppyy_bbhash-0.9-py3-none-linux_x86_64.whl
running bdist_wheel

@wlav
Copy link

wlav commented Oct 17, 2020

ULong64_t is a typedef from upstream intended for I/O use (i.e. a guaranteed 64b integer type). However, it was not typedef to uint64_t (the standard type) on all platforms, but to either unsigned long long (Mac, Linux) or uint64_t (Windows). As you can see from the format warnings above, that just isn't portable. Worse, some of the upstream legacy code that was still retained, would transform all occurances of unsigned long long to ULong64_t, even as there is no guarantee that the former will be 64b on all platforms.

For these reasons, ULong64_t is now gone, with the unfortunate side effect that the above test fails. Recommend to use uint64_t instead, or to reintroduce typedef unsigned long long ULong64_t in the test code (on Linux/Mac).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants