factorize common sample_weight check