def test_best_match_signed_vs_unsigned(self):
     d1 = dshape('10, 3, int64')
     match = best_match(h, [d1])
     self.assertEqual(str(match.sig), 'A..., int64 -> A..., int64')
     self.assertEqual(str(match.resolved_sig),
                      '10, 3, int64 -> 10, 3, int64')
     d1 = dshape('4, 5, uint64')
     match = best_match(h, [d1])
     self.assertEqual(str(match.sig), 'A..., uint64 -> A..., uint64')
     self.assertEqual(str(match.resolved_sig),
                      '4, 5, uint64 -> 4, 5, uint64')
Example #2
0
 def best_match(self, impl_kind, argtypes):
     """
     Find the best implementation of `impl_kind` using `argtypes`.
     """
     dispatcher = self.get_dispatcher(impl_kind)
     print('dispatcher overloads:', dispatcher.overloads)
     return best_match(dispatcher, argtypes)
 def test_best_match_ellipses(self):
     d1 = dshape('10, T1, int32')
     d2 = dshape('..., float32')
     match = best_match(g, [d1, d2])
     self.assertEqual(str(match.sig), 'X, Y, float32 -> ..., float32 -> X, int32')
     self.assertEqual(str(match.resolved_sig),
                      '10, T1, float32 -> ..., float32 -> 10, int32')
Example #4
0
 def best_match(self, impl_kind, argtypes, constraints=None):
     """
     Find the best implementation of `impl_kind` using `argtypes`.
     """
     return best_match(self.get_dispatcher(impl_kind),
                       argtypes,
                       constraints=constraints)
Example #5
0
 def best_match(self, impl_kind, argtypes):
     """
     Find the best implementation of `impl_kind` using `argtypes`.
     """
     dispatcher = self.get_dispatcher(impl_kind)
     print('dispatcher overloads:', dispatcher.overloads)
     return best_match(dispatcher, argtypes)
Example #6
0
def _best_match(func_wrapper, argtypes):
    overloaded = func_wrapper.resolve_dispatcher()
    argtypes = [to_blaze(t) for t in argtypes]

    overload = overloading.best_match(overloaded, argtypes)
    scope = determine_scope(overload.func)
    signature = resolve(overload.resolved_sig, scope, {})
    return (overload.func, signature, overload.kwds)
 def test_best_match_broadcasting(self):
     d1 = dshape('10, complex64')
     d2 = dshape('10, float32')
     match = best_match(f, [d1, d2])
     self.assertEqual(str(match.sig),
                      'X, Y, complex[float32] -> X, Y, complex[float32] -> X, Y, complex[float32]')
     self.assertEqual(str(match.resolved_sig),
                      '1, 10, complex[float32] -> 1, 10, complex[float32] -> 1, 10, complex[float32]')
Example #8
0
def _best_match(func_wrapper, argtypes):
    overloaded = func_wrapper.resolve_dispatcher()
    argtypes = [to_blaze(t) for t in argtypes]

    overload = overloading.best_match(overloaded, argtypes)
    scope = determine_scope(overload.func)
    signature = resolve(overload.resolved_sig, scope, {})
    return (overload.func, signature, overload.kwds)
    def test_best_match(self):
        d1 = dshape('10, T1, int32')
        d2 = dshape('T2, T2, float32')
        match = best_match(f, [d1, d2])
        self.assertEqual(str(match.sig),
                         'X, Y, float32 -> X, Y, float32 -> X, Y, float32')

        input = dshape('S, 1, float32 -> T, 1, float32 -> R')
        self.assertEqual(str(unify_simple(input, match.resolved_sig)),
                         '10, 1, float32 -> 10, 1, float32 -> 10, 1, float32')
Example #10
0
 def best_match(self, impl_kind, argtypes, constraints=None):
     """
     Find the best implementation of `impl_kind` using `argtypes`.
     """
     return best_match(self.get_dispatcher(impl_kind), argtypes,
                       constraints=constraints)
 def test_best_match_int_float32_vs_float64(self):
     d1 = dshape('3, int32')
     match = best_match(k, [d1])
     self.assertEqual(str(match.sig), 'A..., float64 -> A..., float64')
     self.assertEqual(str(match.resolved_sig),
                      '3, float64 -> 3, float64')
 def test_best_match_float_int_complex(self):
     d1, d2 = dshapes('3, float64', 'int32')
     match = best_match(j, [d1, d2])
     self.assertEqual(str(match.sig), 'A..., float64 -> A..., float64 -> A..., float64')
     self.assertEqual(str(match.resolved_sig),
                      '3, float64 -> float64 -> 3, float64')