Not sure if this is the best solution - but the error being thrown if weights was passed as, for example, a list, was very uninformative.