parameters: (bsdf_type, extra, wi=[0, 0, 1], ctx=None)
return_statement: return sample_functor, pdf_functor
docstring: Adapter to test BSDF sampling using the Chi^2 test.
  
      Parameter ``bsdf_type`` (string):
          Name of the BSDF plugin to instantiate.
  
      Parameter ``extra`` (string):
          Additional XML used to specify the BSDF's parameters.
  
      Parameter ``wi`` (array(3,)):
          Incoming direction, in local coordinates.
docstring_summary: Adapter to test BSDF sampling using the Chi^2 test.
docstring_tokens: Adapter to test BSDF sampling using the Chi^2 test .
function: def BSDFAdapter(bsdf_type, extra, wi=[0, 0, 1], ctx=None):
      """
      Adapter to test BSDF sampling using the Chi^2 test.
  
      Parameter ``bsdf_type`` (string):
          Name of the BSDF plugin to instantiate.
  
      Parameter ``extra`` (string):
          Additional XML used to specify the BSDF's parameters.
  
      Parameter ``wi`` (array(3,)):
          Incoming direction, in local coordinates.
      """
  
      from mitsuba.render import BSDFContext, SurfaceInteraction3f
      from mitsuba.core import Float
      from mitsuba.core.xml import load_string
  
      if ctx is None:
          ctx = BSDFContext()
  
      def make_context(n):
          si = SurfaceInteraction3f.zero(n)
          si.wi = wi
          ek.set_slices(si.wi, n)
          si.wavelengths = []
          return (si, ctx)
  
      def instantiate(args):
          xml = """<bsdf version="2.0.0" type="%s">
              %s
          </bsdf>""" % (bsdf_type, extra)
          return load_string(xml % args)
  
      def sample_functor(sample, *args):
          n = ek.slices(sample)
          plugin = instantiate(args)
          (si, ctx) = make_context(n)
          bs, weight = plugin.sample(ctx, si, sample[0], [sample[1], sample[2]])
  
          w = Float.full(1.0, ek.slices(weight))
          w[ek.all(ek.eq(weight, 0))] = 0
          return bs.wo, w
  
      def pdf_functor(wo, *args):
          n = ek.slices(wo)
          plugin = instantiate(args)
          (si, ctx) = make_context(n)
          return plugin.pdf(ctx, si, wo)
  
      return sample_functor, pdf_functor
function_tokens: def BSDFAdapter ( bsdf_type , extra , wi = [ 0 , 0 , 1 ] , ctx = None ) : from mitsuba . render import BSDFContext , SurfaceInteraction3f from mitsuba . core import Float from mitsuba . core . xml import load_string if ctx is None : ctx = BSDFContext ( ) def make_context ( n ) : si = SurfaceInteraction3f . zero ( n ) si . wi = wi ek . set_slices ( si . wi , n ) si . wavelengths = [ ] return ( si , ctx ) def instantiate ( args ) : xml = """<bsdf version="2.0.0" type="%s">
              %s
          </bsdf>""" % ( bsdf_type , extra ) return load_string ( xml % args ) def sample_functor ( sample , * args ) : n = ek . slices ( sample ) plugin = instantiate ( args ) ( si , ctx ) = make_context ( n ) bs , weight = plugin . sample ( ctx , si , sample [ 0 ] , [ sample [ 1 ] , sample [ 2 ] ] ) w = Float . full ( 1.0 , ek . slices ( weight ) ) w [ ek . all ( ek . eq ( weight , 0 ) ) ] = 0 return bs . wo , w def pdf_functor ( wo , * args ) : n = ek . slices ( wo ) plugin = instantiate ( args ) ( si , ctx ) = make_context ( n ) return plugin . pdf ( ctx , si , wo ) return sample_functor , pdf_functor