def validate_features_custom_weight(self, data, features, max_sum): if ( features and data["lots"] and any( [ round( vnmax( [ i for i in features if i.featureOf == "tenderer" or i.featureOf == "lot" and i.relatedItem == lot["id"] or i.featureOf == "item" and i.relatedItem in [j.id for j in data["items"] if j.relatedLot == lot["id"]] ] ), 15, ) > max_sum for lot in data["lots"] ] ) ): raise ValidationError( u"Sum of max value of all features for lot should be less then or equal to {:.0f}%".format(max_sum * 100) ) elif features and not data["lots"] and round(vnmax(features), 15) > max_sum: raise ValidationError( u"Sum of max value of all features should be less then or equal to {:.0f}%".format(max_sum * 100) )
def validate_features(self, data, features): if ( features and data["lots"] and any( [ round( vnmax( [ i for i in features if i.featureOf == "tenderer" or i.featureOf == "lot" and i.relatedItem == lot["id"] or i.featureOf == "item" and i.relatedItem in [j.id for j in data["items"] if j.relatedLot == lot["id"]] ] ), 15, ) > 0.25 for lot in data["lots"] ] ) ): raise ValidationError(u"Sum of max value of all features for lot should be less then or equal to 25%") elif features and not data["lots"] and round(vnmax(features), 15) > 0.25: raise ValidationError(u"Sum of max value of all features should be less then or equal to 25%")
def __call__(self, cls, data, features): if features: for i in features: if i.featureOf == "lot": raise ValidationError(u"Features are not allowed for lots") if data["lots"] and any([ round( vnmax([ i for i in features if i.featureOf == "tenderer" or i.featureOf == "lot" and i.relatedItem == lot["id"] or i.featureOf == "item" and i.relatedItem in [ j.id for j in data["items"] if j.relatedLot == lot["id"] ] ]), 15, ) > 0.3 for lot in data["lots"] ]): raise ValidationError( u"Sum of max value of all features for lot should be less then or equal to 30%" ) elif not data["lots"] and round(vnmax(features), 15) > 0.3: raise ValidationError( u"Sum of max value of all features should be less then or equal to 30%" )
def validate_features(self, data, features): if features and data['lots'] and any([ round(vnmax([ i for i in features if i.featureOf == 'tenderer' or i.featureOf == 'lot' and i.relatedItem == lot['id'] or i.featureOf == 'item' and i.relatedItem in [j.id for j in data['items'] if j.relatedLot == lot['id']] ]), 15) > 0.3 for lot in data['lots'] ]): raise ValidationError(u"Sum of max value of all features for lot should be less then or equal to 30%") elif features and not data['lots'] and round(vnmax(features), 15) > 0.3: raise ValidationError(u"Sum of max value of all features should be less then or equal to 30%")
def validate_features(self, data, features): if features and data['lots'] and any([ round(vnmax([ i for i in features if i.featureOf == 'tenderer' or i.featureOf == 'lot' and i.relatedItem == lot['id'] or i.featureOf == 'item' and i.relatedItem in [j.id for j in data['items'] if j.relatedLot == lot['id']] ]), 15) > 0.3 for lot in data['lots'] ]): raise ValidationError(u"Sum of max value of all features for lot should be less then or equal to 30%") elif features and not data['lots'] and round(vnmax(features), 15) > 0.3: raise ValidationError(u"Sum of max value of all features should be less then or equal to 30%")
def validate_features_custom_weight(self, data, features, max_sum): if features and data['lots'] and any([ round(vnmax([ i for i in features if i.featureOf == 'tenderer' or i.featureOf == 'lot' and i.relatedItem == lot['id'] or i.featureOf == 'item' and i.relatedItem in [j.id for j in data['items'] if j.relatedLot == lot['id']] ]), 15) > max_sum for lot in data['lots'] ]): raise ValidationError(u"Sum of max value of all features for lot should be less then or equal to {:.0f}%".format(max_sum * 100)) elif features and not data['lots'] and round(vnmax(features), 15) > max_sum: raise ValidationError(u"Sum of max value of all features should be less then or equal to {:.0f}%".format(max_sum * 100))
def validate_features_custom_weight(data, features, max_sum): if features: if data["lots"]: if any([ round( vnmax( filter_features( features, data["items"], lot_ids=[lot["id"]])), 15) > max_sum for lot in data["lots"] ]): raise ValidationError( "Sum of max value of all features for lot should be " "less then or equal to {:.0f}%".format(max_sum * 100)) else: if round(vnmax(features), 15) > max_sum: raise ValidationError( "Sum of max value of all features should be " "less then or equal to {:.0f}%".format(max_sum * 100))