FIX + TST + DOC compute_class_weight

Fixes #1746, #1747. Bug reported and fix proposed by @gatagat.