Ejemplo n.º 1
0
    def test17_greedy_overloads(self):
        """void*/void** should not pre-empt template instantiations"""

        import cppyy

        ns = cppyy.gbl.T_WithGreedyOverloads

        # check that void* does not mask template instantiations
        g1 = ns.WithGreedy1()
        assert g1.get_size(ns.SomeClass(), True) == -1
        assert g1.get_size(ns.SomeClass()) == cppyy.sizeof(ns.SomeClass)

        # check that void* does not mask template instantiations
        g2 = ns.WithGreedy2()
        assert g2.get_size(ns.SomeClass()) == cppyy.sizeof(ns.SomeClass)
        assert g2.get_size(ns.SomeClass(), True) == -1

        # check that unknown classes do not mask template instantiations
        g3 = ns.WithGreedy3()
        assert g3.get_size(ns.SomeClass()) == cppyy.sizeof(ns.SomeClass)
        assert g3.get_size(cppyy.nullptr, True) == -1
Ejemplo n.º 2
0
    from io import StringIO

import cppyy
import re

cppyy.load_library("/usr/lib/libgsl")  # Change this to your local setting.
cppyy.include("gsl/gsl_matrix.h")
cppyy.include("wrapper_python.h")
cppyy.load_library("libDataTypes")
from cppyy.gbl import wrapperPython

# type matchers numpy -> gsl
tm_np2gsl = dict()
tm_np2gsl['float64'] = ''
tm_np2gsl['float32'] = 'float'
tm_np2gsl[cppyy.sizeof('long') == 4 and 'int32' or 'int64'] = 'long'
tm_np2gsl[cppyy.sizeof('int') == 4 and 'int32' or 'int64'] = 'int'
# etc. for other numpy types

converters = dict()
for key, value in tm_np2gsl.items():
    if key == 'float64':
        converters[key] = 'gsl_matrix_view_array'
    else:
        converters[key] = 'gsl_matrix_%s_view_array' % value

# gsl_matrix decorator


def gsl_matrix_repr(self):
    data, tda = self.data, self.tda