void init_density()

in src/density_wrapper.cpp [105:128]


void init_density(nb::module_ &m) {
  using namespace datasketches;

  prepare_numpy();

  // generic kernel function
  nb::class_<kernel_function, KernelFunction>(m, "KernelFunction",
      nb::intrusive_ptr<kernel_function>(
      [](kernel_function *kf, PyObject *po) noexcept { kf->set_self_py(po); }),
     "A generic base class from which user-defined kernels must inherit.")
    .def(nb::init())
    .def("__call__", &kernel_function::operator(), nb::arg("a"), nb::arg("b"),
      "A method to evaluate a kernel with given inputs a and b.\n\n"
      ":param a: An input vector\n:type a: numpy array\n"
      ":param b: An input vector\n:type b: numpy array\n"
      ":return: A vector similarity score\n:rtype: float"
      )
    ;

  // the old sketch names can almost be defined, but the kernel_function_holder won't work in init()
  //bind_density_sketch<float, gaussian_kernel<float>>(m, "density_floats_sketch");
  //bind_density_sketch<double, gaussian_kernel<double>>(m, "density_doubles_sketch");
  bind_density_sketch<double, kernel_function_holder>(m, "density_sketch");
}