How to use the marshmallow.fields.Float function in marshmallow

To help you get started, we’ve selected a few marshmallow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samuelcolvin / pydantic / benchmarks / test_marshmallow.py View on Github external
def __init__(self, allow_extra):
        class LocationSchema(Schema):
            latitude = fields.Float(allow_none=True)
            longitude = fields.Float(allow_none=True)

        class SkillSchema(Schema):
            subject = fields.Str(required=True)
            subject_id = fields.Integer(required=True)
            category = fields.Str(required=True)
            qual_level = fields.Str(required=True)
            qual_level_id = fields.Integer(required=True)
            qual_level_ranking = fields.Float(default=0)

        class Model(Schema):
            id = fields.Integer(required=True)
            client_name = fields.Str(validate=validate.Length(max=255), required=True)
            sort_index = fields.Float(required=True)
            # client_email = fields.Email()
            client_phone = fields.Str(validate=validate.Length(max=255), allow_none=True)

            location = fields.Nested(LocationSchema)

            contractor = fields.Integer(validate=validate.Range(min=0), allow_none=True)
            upstream_http_referrer = fields.Str(validate=validate.Length(max=1023), allow_none=True)
            grecaptcha_response = fields.Str(validate=validate.Length(min=20, max=1000), required=True)
            last_updated = fields.DateTime(allow_none=True)
            skills = fields.Nested(SkillSchema, many=True)
github cmdmnt / commandment / commandment / profiles / plist_schema.py View on Github external
class ProfileSchema(Schema):
    PayloadDescription = fields.Str(attribute='description')
    PayloadDisplayName = fields.Str(attribute='display_name')
    PayloadExpirationDate = fields.DateTime(attribute='expiration_date')
    PayloadIdentifier = fields.Str(attribute='identifier', required=True)
    PayloadOrganization = fields.Str(attribute='organization')
    PayloadUUID = fields.UUID(attribute='uuid')
    PayloadRemovalDisallowed = fields.Bool(attribute='removal_disallowed')
    PayloadType = fields.Function(lambda obj: 'Configuration', attribute='payload_type')
    PayloadVersion = fields.Function(lambda obj: 1, attribute='version')
    PayloadScope = EnumField(PayloadScope, attribute='scope')
    RemovalDate = fields.DateTime(attribute='removal_date')
    DurationUntilRemoval = fields.Float(attribute='duration_until_removal')
    ConsentText = fields.Nested(ConsentTextSchema())
    PayloadContent = fields.Method('get_payloads', deserialize='load_payloads')

    def get_payloads(self, obj):
        payloads = []

        for payload in obj.payloads:
            schema = schema_for(payload.type)
            if schema is not None:
                result = schema().dump(payload)
                payloads.append(result.data)
            else:
                print('Unsupported PayloadType: {}'.format(payload.type))

        return payloads
github labd / commercetools-python-sdk / src / commercetools / schemas / _tax_category.py View on Github external
"TaxCategoryReplaceTaxRateActionSchema",
    "TaxCategoryResourceIdentifierSchema",
    "TaxCategorySchema",
    "TaxCategorySetDescriptionActionSchema",
    "TaxCategorySetKeyActionSchema",
    "TaxCategoryUpdateActionSchema",
    "TaxCategoryUpdateSchema",
    "TaxRateDraftSchema",
    "TaxRateSchema",
]


class SubRateSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.SubRate`."
    name = marshmallow.fields.String(allow_none=True)
    amount = marshmallow.fields.Float(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.SubRate(**data)


class TaxCategoryDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.TaxCategoryDraft`."
    name = marshmallow.fields.String(allow_none=True)
    description = marshmallow.fields.String(allow_none=True, missing=None)
    rates = marshmallow.fields.Nested(
        nested="commercetools.schemas._tax_category.TaxRateDraftSchema",
        unknown=marshmallow.EXCLUDE,
github polyaxon / polyaxon / polyaxon_schemas / ml / constraints.py View on Github external
kernel_constraint:
        UnitNorm:
          axis: 1
    ```
    """

    IDENTIFIER = "UnitNorm"
    SCHEMA = UnitNormSchema

    def __init__(self, axis=0):
        self.axis = axis


class MinMaxNormSchema(BaseSchema):
    min_value = fields.Float(default=0.0, missing=0.0)
    max_value = fields.Float(default=1.0, missing=1.0)
    rate = fields.Float(default=1.0, missing=1.0)
    axis = fields.Int(default=0, missing=0)

    @staticmethod
    def schema_config():
        return MinMaxNormConfig


class MinMaxNormConfig(BaseConfig):
    """MinMaxNorm weight constraint.

    Constrains the weights incident to each hidden unit
    to have the norm between a lower bound and an upper bound.

    Args:
        min_value: the minimum norm for the incoming weights.
github introlab / OpenIMU / OpenImu Installer / OpenIMU / PythonAPI / lib / lib_openimu / schemas.py View on Github external
executionTime = fields.Float(as_string = False);
    resultName = fields.Str();
    date = fields.Str();
    startTime = fields.Str();
    endTime = fields.Str();
    measureUnit = fields.Str();
    algorithmId = fields.Str();
    algorithmName = fields.Str();
    algorithmParameters = fields.Nested(ParameterInfo, many=True);
    recordId = fields.Str();
    recordImuPosition = fields.Str();
    recordImuType = fields.Str();
    recordName = fields.Str();

class Sensor(Schema):
    x = fields.Float(as_string = False)
    y = fields.Float(as_string = False)
    z = fields.Float(as_string = False)
    t = fields.Int(as_string = False)
    ref = fields.Str()

class RecordRequest(Schema):
    record = fields.Nested(Record)
    accelerometres = fields.Nested(Sensor, many=True)
    magnetometres = fields.Nested(Sensor, many=True)
    gyrometres = fields.Nested(Sensor, many=True)

class TimeFilter(Schema):
    beginDateTime = fields.DateTime(as_string = False)
    endDateTime = fields.DateTime(as_string=False)

class DataSort(Schema):
github pmatigakis / Huginn / huginn / schemas.py View on Github external
from marshmallow import Schema, fields


class AccelerationsSchema(Schema):
    x = fields.Float()
    y = fields.Float()
    z = fields.Float()
    p_dot = fields.Float()
    q_dot = fields.Float()
    r_dot = fields.Float()
    u_dot = fields.Float()
    v_dot = fields.Float()
    w_dot = fields.Float()
    gravity = fields.Float()


class VelocitiesSchema(Schema):
    p = fields.Float()
    q = fields.Float()
    r = fields.Float()
    u = fields.Float()
    v = fields.Float()
    w = fields.Float()
github ryanleary / patter / patter / config / corpora.py View on Github external
class AugmentationConfig(Schema):
    manifest_path = fields.String(load_from="manifest")
    min_snr_db = fields.Float()
    max_snr_db = fields.Float()
    min_speed_rate = fields.Float()
    max_speed_rate = fields.Float()
    min_shift_ms = fields.Float()
    max_shift_ms = fields.Float()
    min_gain_dbfs = fields.Float()
    max_gain_dbfs = fields.Float()


class AugmentationSpec(Schema):
    aug_type = fields.String(load_from="type", required=True)
    prob = fields.Float(required=True, validate=Range(0, 1))

    cfg = fields.Nested(AugmentationConfig, load_from="config")


class CorporaConfiguration(Schema):
    min_duration = fields.Float(missing=None)
    max_duration = fields.Float(missing=None)
    datasets = fields.Nested(DatasetConfig, load_from="dataset", many=True)
    augmentation = fields.Nested(AugmentationSpec, many=True, missing=[])
github karma0 / nombot / nombot / generics / exchange.py View on Github external
auth_active = f.Str()
    auth_trade = f.Str()
    auth_updated = f.Str()



class RefreshBalanceSchema(GenericSchema):
    """Used to refresh a balance on an account"""
    auth_id = f.Str(required=True)


class BalanceSchema(ResultSchema):
    """A balance for a given currency or auth_id"""
    balance_curr_code = f.Str(required=True)
    balance_amount_avail = f.Float()
    balance_amount_held = f.Float()
    balance_amount_total = f.Float()
    btc_balance = f.Float()
    last_price = f.Float()


class OrderSchema(ResultSchema):
    """Order"""
    exch_name = f.Str(required=True)
    mkt_name = f.Str(required=True)
    limit_price = f.Float(required=True)
    operator = f.Str()
    order_id = f.Int(required=True)
    order_type = f.Str(required=True)
    order_price_type = f.Str(required=True)
    order_status = f.Str(required=True)
    quantity = f.Float(required=True)
github pmatigakis / Huginn / huginn / schemas.py View on Github external
equivalent_airspeed = fields.Float()
    ground_speed = fields.Float()


class OrientationSchema(Schema):
    phi = fields.Float()
    theta = fields.Float()
    psi = fields.Float()


class AtmosphereShema(Schema):
    pressure = fields.Float()
    sea_level_pressure = fields.Float()
    temperature = fields.Float()
    sea_level_temperature = fields.Float()
    density = fields.Float()
    sea_level_density = fields.Float()


class ForcesSchema(Schema):
    x_body = fields.Float()
    y_body = fields.Float()
    z_body = fields.Float()
    x_wind = fields.Float()
    y_wind = fields.Float()
    z_wind = fields.Float()
    x_total = fields.Float()
    y_total = fields.Float()
    z_total = fields.Float()


class InitialConditionSchema(Schema):
github facultyai / marshmallow-dataframe / src / marshmallow_dataframe / dataframe.py View on Github external
from collections import defaultdict

import pandas as pd
import numpy as np
import marshmallow as ma
from typing import NamedTuple, List, Union, Dict

__all__ = ["Dtypes", "RecordsDataFrameSchema", "SplitDataFrameSchema"]

DTYPE_KIND_TO_FIELD_CLASS = {
    "i": ma.fields.Int,
    "u": ma.fields.Int,
    "f": ma.fields.Float,
    "O": ma.fields.Str,
    "U": ma.fields.Str,
    "S": ma.fields.Str,
    "b": ma.fields.Bool,
    "M": ma.fields.DateTime,
    "m": ma.fields.TimeDelta,
}

_DEFAULT_FIELD_OPTIONS = {"required": True, "allow_none": True}

DTYPE_KIND_TO_FIELD_OPTIONS: Dict[str, Dict[str, bool]] = defaultdict(
    lambda: _DEFAULT_FIELD_OPTIONS
)
# Integer columns in pandas cannot have null values, so we allow_none for all
# types except int
DTYPE_KIND_TO_FIELD_OPTIONS["i"] = {"required": True}