The case where `weights` is given is not covered by a unit test ... can you add an example?