Beispiel #1
0
class HypothesisSchema(BaseSchema):
    function = fields.Nested(FunctionSchema)
    _RSS = NumberField(data_key='RSS')
    _rRSS = NumberField(data_key='rRSS')
    _SMAPE = NumberField(data_key='SMAPE')
    _AR2 = NumberField(data_key='AR2')
    _RE = NumberField(data_key='RE')
    _use_median = fields.Bool()
    _costs_are_calculated = fields.Bool()
Beispiel #2
0
def _determine_field(option: ModelerOption):
    if option.range:
        if isinstance(option.range, range):
            if range.step == 1:
                validation = validate.Range(option.range.start, option.range.stop, max_inclusive=False)
            else:
                validation = validate.OneOf(option.range)
        elif isinstance(option.range, Mapping):
            validation = validate.OneOf(list(option.range.values()), labels=list(option.range.keys()))
        else:
            validation = validate.OneOf(option.range)
    else:
        validation = None

    kwargs = {
        'validation': validation,
        'default': option.value,
        'required': False,
        'allow_none': True
    }

    if option.type is int:
        return fields.Int(**kwargs)
    elif option.type is float:
        return NumberField(**kwargs)
    elif option.type is bool:
        return fields.Bool(**kwargs)
    elif option.type is str:
        return fields.Str(**kwargs)
    else:
        return fields.Function(serialize=str, deserialize=option.type, **kwargs)
Beispiel #3
0
class SimpleTermSchema(TermSchema):
    coefficient = None
    term_type = fields.String(validate=validate.OneOf(['polynomial', 'logarithm']))
    exponent = NumberField()

    def create_object(self):
        return SimpleTerm(None, 0)
Beispiel #4
0
class MeasurementSchema(Schema):
    coordinate = fields.Nested(CoordinateSchema)
    metric = fields.Nested(MetricSchema)
    callpath = fields.Nested(CallpathSchema)
    median = NumberField()
    mean = NumberField()
    minimum = NumberField()
    maximum = NumberField()
    std = NumberField()

    @post_load
    def report_progress(self, data, **kwargs):
        if 'progress_bar' in self.context:
            self.context['progress_bar'].update()
        return data

    def create_object(self):
        return Measurement(None, None, None, None)
Beispiel #5
0
class TermSchema(Schema):
    coefficient = NumberField()
Beispiel #6
0
class FunctionSchema(BaseSchema):
    constant_coefficient = NumberField()
    compound_terms: List[CompoundTerm] = fields.List(
        fields.Nested(CompoundTermSchema))