Skip to content

Commit

Permalink
Add test for Emitter::sampling_weight()
Browse files Browse the repository at this point in the history
  • Loading branch information
njroussel committed May 29, 2024
1 parent d9751f6 commit cdd489c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/render/tests/test_emitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
import drjit as dr
import mitsuba as mi


def test01_sampling_weight_getter(variants_vec_rgb):
emitter0 = mi.load_dict({
'type': 'constant',
'sampling_weight': 0.1
})
emitter1 = mi.load_dict({
'type': 'constant',
'sampling_weight': 0.3
})

emitter0_ptr = mi.EmitterPtr(emitter0)
emitter1_ptr = mi.EmitterPtr(emitter1)

emitters = dr.select(mi.Bool([True, False, False]), emitter0_ptr, emitter1_ptr)

weight = emitters.sampling_weight()
assert dr.allclose(weight, [0.1, 0.3, 0.3])

params = mi.traverse(emitter1)
params['sampling_weight'] = 0.7
params.update()

weight = emitters.sampling_weight()
assert dr.allclose(weight, [0.1, 0.7, 0.7])

0 comments on commit cdd489c

Please sign in to comment.