Fixed partition_weighted.
Added a test.