Exemplo n.º 1
0
def test_stop_validation():
    def raiser(x):
        raise StopValidation({'something': 'bad'})

    lst = ListType(StringType(), validators=[raiser])

    with pytest.raises(ValidationError) as exc:
        lst.validate('*****@*****.**')

    assert exc.value.messages == {'something': 'bad'}
Exemplo n.º 2
0
 def setUp(self):
     self.listtype = ListType(IntType())
     
     class TestModel(Model):
         the_list = self.listtype
         class Options:
             roles = {
                 'owner': wholelist(),
             }
         
     self.Testmodel = TestModel
     self.testmodel = TestModel()
Exemplo n.º 3
0
class TestSetGetSingleScalarData(unittest.TestCase):
    def setUp(self):
        self.listtype = ListType(IntType())
        
        class TestModel(Model):
            the_list = self.listtype
            class Options:
                roles = {
                    'owner': wholelist(),
                }
            
        self.Testmodel = TestModel
        self.testmodel = TestModel()

    def test_good_value_for_python(self):
        self.testmodel.the_list = [2]
        self.assertEqual(self.testmodel.the_list, [2])

    def test_single_bad_value_for_python(self):
        self.testmodel.the_list = 2
        # since no validation happens, nothing should yell at us        
        self.assertEqual(self.testmodel.the_list, 2) 

    def test_collection_good_values_for_python(self):
        self.testmodel.the_list = [2,2,2,2,2,2]
        self.assertEqual(self.testmodel.the_list, [2,2,2,2,2,2])

    def test_collection_bad_values_for_python(self):
        expected = self.testmodel.the_list = ["2","2","2","2","2","2"]
        actual = self.testmodel.the_list
        # since no validation happens, nothing should yell at us        
        self.assertEqual(actual, expected)  

    def test_good_value_for_json(self):
        expected = self.testmodel.the_list = [2]
        actual = self.listtype.for_json(self.testmodel.the_list)
        self.assertEqual(actual, expected)

    def test_good_values_for_json(self):
        expected = self.testmodel.the_list = [2,2,2,2,2,2]
        actual = self.listtype.for_json(self.testmodel.the_list)
        self.assertEqual(actual, expected)

    def test_good_values_into_json(self):
        self.testmodel.the_list = [2,2,2,2,2,2]
        actual = make_safe_json(self.Testmodel, self.testmodel, 'owner')
        expected = json.dumps({"the_list":[2,2,2,2,2,2]})
        self.assertEqual(actual, expected)

    def test_good_value_into_json(self):
        self.testmodel.the_list = [2]
        actual = make_safe_json(self.Testmodel, self.testmodel, 'owner')
        expected = json.dumps({"the_list":[2]})
        self.assertEqual(actual, expected)

    def test_good_value_validates(self):
        self.testmodel.the_list = [2,2,2,2,2,2]
        result = validate_instance(self.testmodel)
        self.assertEqual(result.tag, 'OK')

    def test_coerceible_value_passes_validation(self):
        self.testmodel.the_list = ["2","2","2","2","2","2"]
        result = validate_instance(self.testmodel)
        self.assertEqual(result.tag, 'OK')

    def test_uncoerceible_value_passes_validation(self):
        self.testmodel.the_list = ["2","2","2","2","horse","2"]
        result = validate_instance(self.testmodel)
        self.assertNotEqual(result.tag, 'OK')
        
    def test_validation_converts_value(self):
        self.testmodel.the_list = ["2","2","2","2","2","2"]
        result = validate_instance(self.testmodel)
        self.assertEqual(result.tag, 'OK')
        converted_data = result.value
        new_list = converted_data['the_list']
        self.assertEqual(new_list, [2,2,2,2,2,2])
Exemplo n.º 4
0
 class QuestionResources(Model):
     pictures = ListType(ModelType(QuestionResource))
Exemplo n.º 5
0
 class PlayerInfo(Model):
     categories = ListType(ModelType(CategoryStatsInfo),
                           default=lambda: [],
                           serialize_when_none=True)
Exemplo n.º 6
0
 class Card(Model):
     users = ListType(ModelType(User), min_size=1, required=True)
Exemplo n.º 7
0
 class User(Model):
     ids = ListType(StringType(required=True))
Exemplo n.º 8
0
class UpdateExecutionReport(BaseExecutionReport):
    instruction_reports = ListType(ModelType(UpdateInstructionReport))
Exemplo n.º 9
0
class CancelExecutionReport(BaseExecutionReport):
    instruction_reports = ListType(ModelType(CancelInstructionReport))
Exemplo n.º 10
0
class SystemStorage(Model):
    temp_unit = StringType(required=True, min_length=1, max_length=1)
    temp_stop = FloatType(required=True)
    temp_fans_on = FloatType(required=True)
    temp_reduce = FloatType(required=True)

    fans_off_delay = IntType(required=True)
    lcd_contrast = IntType(required=True)
    lcd_brightness = IntType(required=True)

    beep_type_key = IntType(required=True)
    beep_type_hint = IntType(required=True)
    beep_type_alarm = IntType(required=True)
    beep_type_done = IntType(required=True)

    beep_enabled_key = BooleanType(required=True)
    beep_enabled_hint = BooleanType(required=True)
    beep_enabled_alarm = BooleanType(required=True)
    beep_enabled_done = BooleanType(required=True)

    beep_volume_key = IntType(required=True, min_value=0, max_value=10)
    beep_volume_hint = IntType(required=True, min_value=0, max_value=10)
    beep_volume_alarm = IntType(required=True, min_value=0, max_value=10)
    beep_volume_done = IntType(required=True, min_value=0, max_value=10)

    calibration = IntType(required=True)
    selected_input_source = IntType(required=True)

    dc_input_low_voltage = FloatType(required=True, min_value=9, max_value=48)
    dc_input_over_voltage = FloatType(required=True)
    dc_input_current_limit = FloatType(required=True,
                                       min_value=1,
                                       max_value=65)

    batt_input_low_voltage = FloatType(required=True,
                                       min_value=9,
                                       max_value=48)
    batt_input_over_voltage = FloatType(required=True)
    batt_input_current_limit = FloatType(required=True,
                                         min_value=1,
                                         max_value=65)

    regenerative_enable = IntType(required=True)
    regenerative_volt_limit = FloatType(required=True,
                                        min_value=9,
                                        max_value=48)
    regenerative_current_limit = FloatType(required=True,
                                           min_value=1,
                                           max_value=65)

    power_priority = IntType(required=True)

    charge_power = ListType(IntType(min_value=5, max_value=800))
    discharge_power = ListType(IntType(min_value=5, max_value=80))
    monitor_log_interval = ListType(IntType)
    monitor_save_to_sd = ListType(BooleanType)

    servo_type = LongType(required=True)
    servo_user_center = LongType(required=True)
    server_user_rate = LongType(required=True)
    server_user_op_angle = LongType(required=True)

    modbus_mode = LongType(required=True)
    modbus_serial_addr = LongType(required=True)
    modbus_serial_baud_rate = LongType(required=True)
    modbus_serial_parity = LongType(required=True)

    @staticmethod
    def modbus(ds1=None, ds2=None, ds3=None):
        if ds1 is not None and ds2 is not None and ds3 is not None:
            storage = SystemStorage()
            storage.set_from_modbus_data(ds1, ds2, ds3)
            return storage
        return None

    def set_from_modbus_data(self, ds1, ds2, ds3):
        dummy1 = None
        (self.temp_unit, self.temp_stop, self.temp_fans_on, self.temp_reduce,
         dummy1, self.fans_off_delay, self.lcd_contrast, self.lcd_brightness,
         dummy1, self.beep_type_key, self.beep_type_hint, self.beep_type_alarm,
         self.beep_type_done, self.beep_enabled_key, self.beep_enabled_hint,
         self.beep_enabled_alarm, self.beep_enabled_done, self.beep_volume_key,
         self.beep_volume_hint, self.beep_volume_alarm,
         self.beep_volume_done) = ds1.data

        (dummy1, self.calibration, dummy1, self.selected_input_source,
         self.dc_input_low_voltage, self.dc_input_over_voltage,
         self.dc_input_current_limit, self.batt_input_low_voltage,
         self.batt_input_over_voltage, self.batt_input_current_limit,
         self.regenerative_enable, self.regenerative_volt_limit,
         self.regenerative_current_limit) = ds2.data

        self.charge_power = [0, 0]
        self.discharge_power = [0, 0]
        self.monitor_log_interval = [0, 0]
        self.monitor_save_to_sd = [False, False]

        (self.charge_power[0], self.charge_power[1], self.discharge_power[0],
         self.discharge_power[1], self.power_priority,
         self.monitor_log_interval[0], self.monitor_log_interval[1],
         self.monitor_save_to_sd[0], self.monitor_save_to_sd[1],
         self.servo_type, self.servo_user_center, self.server_user_rate,
         self.server_user_op_angle, self.modbus_mode, self.modbus_serial_addr,
         self.modbus_serial_baud_rate, self.modbus_serial_parity) = ds3.data

        self.temp_unit = "C" if self.temp_unit is 0 else "F"

        self.temp_stop /= 10.0
        self.temp_fans_on /= 10.0

        self.dc_input_low_voltage /= 10.0
        self.dc_input_current_limit /= 10.0
        self.dc_input_over_voltage /= 10.0

        self.batt_input_low_voltage /= 10.0
        self.batt_input_over_voltage /= 10.0
        self.batt_input_current_limit /= 10.0

        self.regenerative_volt_limit /= 10.0
        self.regenerative_current_limit /= 10.0

    def to_modbus_data(self):
        s1 = (
            0 if self.temp_unit == "C" else 1,
            self.temp_stop * 10,
            self.temp_fans_on * 10,
            self.temp_reduce,
        )

        # Note, the trailing 0 is required, else the lcd_brightness isn't set correctly.
        s2 = (
            self.fans_off_delay,
            self.lcd_contrast,
            self.lcd_brightness,
            0,
        )
        s3 = (
            self.beep_type_key,
            self.beep_type_hint,
            self.beep_type_alarm,
            self.beep_type_done,
            self.beep_enabled_key,
            self.beep_enabled_hint,
            self.beep_enabled_alarm,
            self.beep_enabled_done,
            self.beep_volume_key,
            self.beep_volume_hint,
            self.beep_volume_alarm,
            self.beep_volume_done,
        )
        s4 = (self.calibration, )

        # Note, the trailing 0 is required, else the regenerative_current_limit isn't set correctly.
        s5 = (
            self.selected_input_source,
            self.dc_input_low_voltage * 10,
            self.dc_input_over_voltage * 10,
            self.dc_input_current_limit * 10,
            self.batt_input_low_voltage * 10,
            self.batt_input_over_voltage * 10,
            self.batt_input_current_limit * 10,
            self.regenerative_enable,
            self.regenerative_volt_limit * 10,
            self.regenerative_current_limit * 10,
            0,
        )

        # Note, the trailing 0 is required, else the modbus_serial_parity isn't set correctly.
        s6 = (self.charge_power[0], self.charge_power[1],
              self.discharge_power[0], self.discharge_power[1],
              self.power_priority, self.monitor_log_interval[0],
              self.monitor_log_interval[1], self.monitor_save_to_sd[0],
              self.monitor_save_to_sd[1], self.servo_type,
              self.servo_user_center, self.server_user_rate,
              self.server_user_op_angle, self.modbus_mode,
              self.modbus_serial_addr, self.modbus_serial_baud_rate,
              self.modbus_serial_parity, 0)
        return s1, s2, s3, s4, s5, s6

    @serializable
    def selected_input_source_type(self):
        return "dc" if self.selected_input_source == 0 else "battery"

    @serializable
    def power_priority_description(self):
        if self.power_priority == 0:
            return "average"
        if self.power_priority == 1:
            return "ch1 priority"
        if self.power_priority == 2:
            return "ch2 priority"
Exemplo n.º 11
0
class ChannelStatus(Model):
    channel = IntType(required=True, min_value=0, max_value=1, default=0)
    timestamp = LongType(required=True, default=0)
    curr_out_power = FloatType(required=True, default=0)
    curr_out_amps = FloatType(required=True, default=0)
    curr_inp_volts = FloatType(required=True, default=0)
    curr_out_volts = FloatType(required=True, default=0)
    curr_out_capacity = FloatType(required=True, default=0)
    curr_int_temp = FloatType(required=True, default=0)
    curr_ext_temp = FloatType(required=True, default=0)

    cells = ListType(ModelType(CellStatus), default=[])

    cell_total_ir = FloatType(required=True, default=0)
    cell_total_voltage = FloatType(required=True, default=0)
    cell_count_with_voltage_values = FloatType(required=True, default=0)
    cycle_count = IntType(required=True, default=0)
    control_status = IntType(required=True, default=0)
    run_status = IntType(required=True, default=0)
    run_error = IntType(required=True, default=0)
    dlg_box_id = IntType(required=True, default=0)
    line_intern_resistance = FloatType(required=True, default=0)

    # Optionally added to the response, when a channel status is requested
    status = ModelType(DeviceInfoStatus)

    def __init__(self):
        super(ChannelStatus, self).__init__()
        self.device_id = None

    @staticmethod
    def modbus(device_id=None,
               channel=0,
               header=None,
               cell_v=None,
               cell_b=None,
               cell_i=None,
               footer=None):
        status = ChannelStatus()
        if header is not None and cell_v is not None and cell_b is not None and cell_i is not None and footer is not None:
            status.set_from_modbus_data(device_id, channel, header, cell_v,
                                        cell_b, cell_i, footer)
        return status

    def set_from_modbus_data(self, device_id, channel, data, cell_v, cell_b,
                             cell_i, footer):
        self.device_id = device_id

        self.channel = channel

        self.timestamp = data[0] / 1000.0
        self.curr_out_power = data[1] / 1000.0
        self.curr_out_amps = data[2] / 100.0
        self.curr_inp_volts = data[3] / 1000.0
        self.curr_out_volts = data[4] / 1000.0
        self.curr_out_capacity = data[5]  # mAh sent or taken from batt
        self.curr_int_temp = data[6] / 10.0
        self.curr_ext_temp = data[7] / 10.0

        self.cell_count_with_voltage_values = 0
        self.cell_total_voltage = 0

        cells = []
        for x in range(0, 10):
            if cell_v[x] == 1024:
                continue
            c = CellStatus(x, cell_v[x], cell_b[x], cell_i[x])
            cells.append(c)
            self.cell_total_voltage += c.voltage
            if c.voltage > 0:
                self.cell_count_with_voltage_values += 1

        self.cells = cells

        self.cell_total_ir = footer[0] / 10.0
        self.line_intern_resistance = footer[1] / 10.0
        self.cycle_count = footer[2]
        self.control_status = footer[3]
        self.run_status = footer[4]
        self.run_error = footer[5]
        self.dlg_box_id = footer[6]

        # print "channel: {0}, len cels: {3}, cell_total_volt: {1}, curr_out_volt is: {2}".format(channel,
        #                                                                                         self.cell_total_voltage,
        #                                                                                         self.curr_out_volts,
        #                                                                                         self.cell_count_with_voltage_values)

        # If the charger isn't doing anything, make sure timestamp shows 00:00
        if self.run_status == 0:
            self.timestamp = 0

    def max_charger_input_voltage(self):
        return 0

    @serializable
    def battery_plugged_in(self):
        plugged_in = False

        if self.device_id:
            max_voltage = 0

            # With this, we can work out if the main battery lead is plugged in
            if self.device_id is DEVICEID_406_DUO:
                max_voltage = 22  # because 3.75 * n gives the max voltage?
            elif self.device_id is DEVICEID_308_DUO:
                max_voltage = 30
            elif self.device_id is DEVICEID_4010_DUO:
                max_voltage = 38

            # if there are no balance leads plugged in, zero out the curr_out_volts
            if self.cell_count_with_voltage_values == 0:
                if self.curr_out_volts > max_voltage:
                    plugged_in = False
                else:
                    plugged_in = True

        pcnt_diff = 0
        if self.cell_count_with_voltage_values > 0:
            pcnt_diff = abs(100.0 - (
                (self.curr_out_volts / self.cell_total_voltage) * 100.0))
            # if the difference is too great - then we think that curr_out_volts is total lies
            if pcnt_diff < 3.0:
                plugged_in = True

        # if self.channel == 0:
        #     logger.info("channel: {0}, plugged_in: {1}, cells: {2}, pcnt_diff: {3}, curr_out_volts: {4}, cell_total_voltage: {5}".format(
        #         self.channel,
        #         plugged_in,
        #         self.cell_count_with_voltage_values,
        #         pcnt_diff,
        #         self.curr_out_volts,
        #         self.cell_total_voltage))

        return plugged_in

    @serializable
    def balance_leads_plugged_in(self):
        return self.cell_total_voltage > 0
class MultipleSpecEntity(Model):
    dim_xs = ListType(IntType, required=True, min_size=1)
    problem_names = ListType(StringType, required=True, min_size=1)
    method_optimizations = ListType(StringType, required=True, min_size=1)
    choose_noises = ListType(BooleanType, required=True, min_size=1)
    bounds_domain_xs = ListType(ListType(ModelType(BoundsEntity),
                                         min_size=1,
                                         required=True),
                                required=True,
                                min_size=1)
    number_points_each_dimensions = ListType(ListType(IntType),
                                             min_size=1,
                                             required=True)

    training_names = ListType(StringType, required=False, min_size=1)
    bounds_domains = ListType(ListType(ListType(FloatType)),
                              min_size=1,
                              required=True)
    type_boundss = ListType(ListType(IntType, min_size=1),
                            min_size=1,
                            required=True)
    n_trainings = ListType(IntType, min_size=1, required=True)
    pointss = ListType(ListType(ListType(FloatType)), required=False)
    noises = ListType(BooleanType, required=False)
    n_sampless = ListType(IntType, required=False)
    random_seeds = ListType(IntType, required=True)
    parallels = ListType(BooleanType, required=False)

    # New parameters due to the GP model
    name_models = ListType(StringType, required=False)
    type_kernels = ListType(ListType(StringType), required=True, min_size=1)
    dimensionss = ListType(ListType(IntType), required=True, min_size=1)
    mles = ListType(BooleanType, required=False)
    thinnings = ListType(IntType, required=False)
    n_burnings = ListType(IntType, required=False)
    max_steps_outs = ListType(IntType, required=False)
    training_datas = ListType(BaseType())

    # New parameters due Bayesian quadrature
    x_domains = ListType(ListType(IntType), required=False)
    distributions = ListType(StringType, required=False)
    # parameters_distributions = ListType(DictType(ListType(FloatType)), required=False)
    parameters_distributions = NetlocType(required=False)

    minimizes = ListType(BooleanType, required=False)
    n_iterationss = ListType(IntType, required=False)

    kernel_valuess = ListType(ListType(FloatType), required=False)
    mean_values = ListType(ListType(FloatType), required=False)
    var_noise_values = ListType(ListType(FloatType), required=False)

    caches = ListType(BooleanType, required=False)
    debugs = ListType(BooleanType, required=False)

    same_correlations = ListType(BooleanType, required=False)

    number_points_each_dimension_debugs = ListType(ListType(IntType),
                                                   required=False)

    monte_carlo_sbos = ListType(BooleanType, required=False)
    n_samples_mcs = ListType(IntType, required=False)
    n_restarts_mcs = ListType(IntType, required=False)

    factr_mcs = ListType(FloatType, required=False)
    maxiter_mcs = ListType(IntType, required=False)

    use_only_training_pointss = ListType(BooleanType, required=False)
    n_restartss = ListType(IntType, required=False)
    n_best_restartss = ListType(IntType, required=False)

    n_best_restarts_mcs = ListType(IntType, required=False)

    n_samples_parameterss = ListType(IntType, required=False)

    n_restarts_means = ListType(IntType, required=False)
    n_best_restarts_means = ListType(IntType, required=False)

    method_opt_mcs = ListType(StringType, required=False)
    maxepochs = ListType(IntType, required=False)

    n_samples_parameters_means = ListType(IntType, required=False)

    maxepoch_means = ListType(IntType, required=False)

    threshold_sbos = ListType(FloatType, required=False)

    parallel_trainings = ListType(BooleanType, required=False)

    optimize_only_posterior_means = ListType(BooleanType, required=False)
    start_optimize_posterior_means = ListType(IntType, required=False)

    simplex_domain = ListType(FloatType, required=False)

    # TODO - Complete all the other needed params

    @classmethod
    def from_json(cls, specfile):
        """

        :param specfile:
        :return: MultipleSpecEntity
        """
        with open(path.join(MULTIPLESPECS_DIR, specfile)) as specfile:
            spec = ujson.load(specfile)
            return cls.from_dictionary(spec)

    @classmethod
    def from_dictionary(cls, spec):
        """

        :param spec: dict
        :return: MultipleSpecEntity
        """

        entry = {}
        dim_xs = spec['dim_xs']

        choose_noises = spec['choose_noises']

        bounds_domain_xs_list = spec['bounds_domain_xs']

        bounds_domain_xs = []
        for bound in bounds_domain_xs_list:
            bounds_domain_xs.append(BoundsEntity.to_bounds_entity(bound))

        method_optimizations = spec['method_optimizations']
        problem_names = spec['problem_names']

        number_points_each_dimensions = spec.get(
            'number_points_each_dimensions')

        n_specs = len(dim_xs)

        training_names = spec.get('training_names')
        bounds_domains = spec.get('bounds_domains')
        simplex_domain = spec.get('simplex_domain', n_specs * [None])
        n_trainings = spec.get('n_trainings', n_specs * [10])

        optimize_only_posterior_means = spec.get(
            'optimize_only_posterior_means', n_specs * [False])
        start_optimize_posterior_means = spec.get(
            'start_optimize_posterior_means', n_specs * [0])

        type_boundss = spec.get('type_boundss',
                                [len(bd) * [0] for bd in bounds_domains])

        pointss = spec.get('pointss', None)
        noises = spec.get('noises', n_specs * [False])
        n_sampless = spec.get('n_sampless', n_specs * [0])
        random_seeds = spec.get('random_seeds',
                                n_specs * [DEFAULT_RANDOM_SEED])
        parallels = spec.get('parallels', n_specs * [True])

        name_models = spec.get('name_models',
                               n_specs * ['gp_fitting_gaussian'])
        type_kernels = spec.get('type_kernels')
        dimensionss = spec.get('dimensionss')
        mles = spec.get('mles', n_specs * [True])
        thinnings = spec.get('thinnings', n_specs * [0])
        n_burnings = spec.get('n_burnings', n_specs * [0])
        max_steps_outs = spec.get('max_steps_outs', n_specs * [1])
        training_datas = spec.get('training_datas')

        x_domains = spec.get('x_domains')
        distributions = spec.get('distributions')
        parameters_distributions = spec.get('parameters_distributions',
                                            n_specs * [[]])

        minimizes = spec.get('minimizes', n_specs * [False])
        n_iterationss = spec.get('n_iterationss', n_specs * [5])

        kernel_valuess = spec.get('kernel_valuess')
        mean_values = spec.get('mean_values')
        var_noise_values = spec.get('var_noise_values')

        caches = spec.get('caches', n_specs * [True])
        debugs = spec.get('debugs', n_specs * [False])

        same_correlations = spec.get('same_correlations', n_specs * [True])

        number_points_each_dimension_debugs = spec.get(
            'number_points_each_dimension_debugs')

        monte_carlo_sbos = spec.get('monte_carlo_sbos', n_specs * [True])
        n_samples_mcs = spec.get('n_samples_mcs', n_specs * [5])
        n_restarts_mcs = spec.get('n_restarts_mcs', n_specs * [5])

        factr_mcs = spec.get('factr_mcs', n_specs * [1e12])
        maxiter_mcs = spec.get('maxiter_mcs', n_specs * [1000])

        use_only_training_pointss = spec.get('use_only_training_pointss',
                                             n_specs * [True])
        n_restartss = spec.get('n_restartss', n_specs * [10])
        n_best_restartss = spec.get('n_best_restartss', n_specs * [0])

        n_best_restarts_mcs = spec.get('n_best_restarts_mcs', n_specs * [0])

        n_samples_parameterss = spec.get('n_samples_parameterss',
                                         n_specs * [0])

        n_restarts_means = spec.get('n_restarts_means', n_specs * [100])
        n_best_restarts_means = spec.get('n_best_restarts_means',
                                         n_specs * [10])

        method_opt_mcs = spec.get('method_opt_mcs', n_specs * [DOGLEG])
        maxepochs = spec.get('maxepochs', n_specs * [10])

        n_samples_parameters_means = spec.get('n_samples_parameters_means',
                                              n_specs * [20])

        maxepoch_means = spec.get('maxepoch_means', n_specs * [20])

        threshold_sbos = spec.get('threshold_sbos', n_specs * [[]])

        parallel_trainings = spec.get('parallel_trainings', n_specs * [True])

        entry.update({
            'caches': caches,
            'debugs': debugs,
            'same_correlations': same_correlations,
            'number_points_each_dimension_debugs':
            number_points_each_dimension_debugs,
            'monte_carlo_sbos': monte_carlo_sbos,
            'n_samples_mcs': n_samples_mcs,
            'n_restarts_mcs': n_restarts_mcs,
            'factr_mcs': factr_mcs,
            'maxiter_mcs': maxiter_mcs,
            'use_only_training_pointss': use_only_training_pointss,
            'n_restartss': n_restartss,
            'n_best_restartss': n_best_restartss,
            'n_best_restarts_mcs': n_best_restarts_mcs,
            'n_samples_parameterss': n_samples_parameterss,
            'n_restarts_means': n_restarts_means,
            'n_best_restarts_means': n_best_restarts_means,
            'method_opt_mcs': method_opt_mcs,
            'maxepochs': maxepochs,
            'n_samples_parameters_means': n_samples_parameters_means,
            'maxepoch_means': maxepoch_means,
            'problem_names': problem_names,
            'dim_xs': dim_xs,
            'choose_noises': choose_noises,
            'bounds_domain_xs': bounds_domain_xs,
            'number_points_each_dimensions': number_points_each_dimensions,
            'method_optimizations': method_optimizations,
            'training_names': training_names,
            'bounds_domains': bounds_domains,
            'n_trainings': n_trainings,
            'pointss': pointss,
            'noises': noises,
            'n_sampless': n_sampless,
            'random_seeds': random_seeds,
            'parallels': parallels,
            'type_boundss': type_boundss,
            'name_models': name_models,
            'type_kernels': type_kernels,
            'dimensionss': dimensionss,
            'mles': mles,
            'thinnings': thinnings,
            'n_burnings': n_burnings,
            'max_steps_outs': max_steps_outs,
            'training_datas': training_datas,
            'distributions': distributions,
            'x_domains': x_domains,
            'parameters_distributions': parameters_distributions,
            'n_iterationss': n_iterationss,
            'minimizes': minimizes,
            'kernel_valuess': kernel_valuess,
            'mean_values': mean_values,
            'var_noise_values': var_noise_values,
            'threshold_sbos': threshold_sbos,
            'parallel_trainings': parallel_trainings,
            'optimize_only_posterior_means': optimize_only_posterior_means,
            'start_optimize_posterior_means': start_optimize_posterior_means,
            'simplex_domain': simplex_domain,
        })

        return cls(entry)
class RunSpecEntity(Model):
    problem_name = StringType(required=True)
    method_optimization = StringType(required=True)
    dim_x = IntType(required=True)
    choose_noise = BooleanType(
        required=True)  #I think that we should remove it
    bounds_domain_x = ListType(ModelType(BoundsEntity),
                               min_size=1,
                               required=True)
    number_points_each_dimension = ListType(IntType)  # Only for x
    training_name = StringType(required=True)
    bounds_domain = ListType(ListType(FloatType), min_size=1, required=True)
    type_bounds = ListType(IntType, required=True)
    n_training = IntType(required=True)
    points = ListType(ListType(FloatType), required=False)
    noise = BooleanType(required=False)
    n_samples = IntType(required=False)
    random_seed = IntType(required=True)
    parallel = BooleanType(required=False)

    simplex_domain = IntType(required=False)

    name_model = StringType(required=False)
    type_kernel = ListType(StringType, required=True)
    dimensions = ListType(IntType, required=True)
    mle = BooleanType(required=False)
    thinning = IntType(required=False)
    n_burning = IntType(required=False)
    max_steps_out = IntType(required=False)
    training_data = BaseType()

    x_domain = ListType(IntType, required=False)
    distribution = StringType(required=False)
    parameters_distribution = NetlocType(required=False)

    minimize = BooleanType(required=True)
    n_iterations = IntType(required=True)

    kernel_values = ListType(FloatType)
    mean_value = ListType(FloatType)
    var_noise_value = ListType(FloatType)
    same_correlation = BooleanType(
        required=False)  # Used only for the task kernel

    cache = BooleanType(required=False)
    debug = BooleanType(required=False)

    number_points_each_dimension_debug = ListType(IntType)  #Used to debug.

    # Parameter to estimate sbo by MC
    monte_carlo_sbo = BooleanType(required=False)
    n_samples_mc = IntType(required=False)
    n_restarts_mc = IntType(required=False)
    factr_mc = FloatType(required=False)
    maxiter_mc = IntType(required=False)
    n_best_restarts_mc = IntType(required=False)

    #Acquistion function parameters
    n_restarts = IntType(required=False)
    n_best_restarts = IntType(required=False)

    # We use only training points when reading GP model from cache
    use_only_training_points = BooleanType(required=False)

    # Computes everything using samples of the parameters if n_samples_parameters > 0
    n_samples_parameters = IntType(required=False)

    n_restarts_mean = IntType(required=False)
    n_best_restarts_mean = IntType(required=False)

    method_opt_mc = StringType(required=False)
    maxepoch = IntType(required=False)

    n_samples_parameters_mean = IntType(required=False)
    maxepoch_mean = IntType(required=False)

    threshold_sbo = FloatType(required=False)

    parallel_training = BooleanType(required=False)

    optimize_only_posterior_mean = BooleanType(required=False)
    start_optimize_posterior_mean = IntType(required=False)

    @classmethod
    def from_json(cls, specfile):
        """

        :param specfile: (str)
        :return: RunSpecEntity
        """

        with open(path.join(SPECS_DIR, specfile)) as specfile:
            spec = ujson.load(specfile)
            return cls.from_dictionary(spec)

    @classmethod
    def from_dictionary(cls, spec):
        """
        Create from dict

        :param spec: dict
        :return: RunSpecEntity
        """
        entry = {}
        dim_x = int(spec['dim_x'])
        choose_noise = spec.get('choose_noise', True)

        bounds_domain_x = spec['bounds_domain_x']
        bounds_domain_x = BoundsEntity.to_bounds_entity(bounds_domain_x)

        method_optimization = spec.get('method_optimization', 'SBO')
        problem_name = spec['problem_name']

        number_points_each_dimension = spec.get('number_points_each_dimension')

        training_name = spec.get('training_name')
        bounds_domain = spec.get('bounds_domain')
        n_training = spec.get('n_training', 10)
        type_bounds = spec.get('type_bounds', len(bounds_domain) * [0])

        points = spec.get('points', None)
        noise = spec.get('noise', False)
        n_samples = spec.get('n_samples', 0)
        random_seed = spec.get('random_seed', DEFAULT_RANDOM_SEED)
        parallel = spec.get('parallel', True)

        name_model = spec.get('name_model', 'gp_fitting_gaussian')
        type_kernel = spec.get('type_kernel')
        dimensions = spec.get('dimensions')
        mle = spec.get('mle', True)
        thinning = spec.get('thinning', 0)
        n_burning = spec.get('n_burning', 0)
        max_steps_out = spec.get('max_steps_out', 1)
        training_data = spec.get('training_data')

        x_domain = spec.get('x_domain')
        distribution = spec.get('distribution')
        parameters_distribution = spec.get('parameters_distribution')

        minimize = spec.get('minimize', False)
        n_iterations = spec.get('n_iterations', 5)

        kernel_values = spec.get('kernel_values')
        mean_value = spec.get('mean_value')
        var_noise_value = spec.get('var_noise_value')

        cache = spec.get('cache', True)
        debug = spec.get('debug', False)
        optimize_only_posterior_mean = spec.get('optimize_only_posterior_mean',
                                                False)

        same_correlation = spec.get('same_correlation', False)

        number_points_each_dimension_debug = spec.get(
            'number_points_each_dimension_debug')

        monte_carlo_sbo = spec.get('monte_carlo_sbo', False)
        n_samples_mc = spec.get('n_samples_mc', 100)
        n_restarts_mc = spec.get('n_restarts_mc', 100)

        factr_mc = spec.get('factr_mc', 1e12)
        maxiter_mc = spec.get('maxiter_mc', 1000)

        use_only_training_points = spec.get('use_only_training_points', True)
        n_restarts = spec.get('n_restarts', 10)
        n_best_restarts = spec.get('n_best_restarts', 10)

        n_best_restarts_mc = spec.get('n_best_restarts_mc', 10)

        n_samples_parameters = spec.get('n_samples_parameters', 0)

        n_restarts_mean = spec.get('n_restarts_mean', 1000)
        n_best_restarts_mean = spec.get('n_best_restarts_mean', 100)

        method_opt_mc = spec.get('method_opt_mc', LBFGS_NAME)
        maxepoch = spec.get('maxepoch', 10)

        n_samples_parameters_mean = spec.get('n_samples_parameters_mean', 15)

        maxepoch_mean = spec.get('maxepoch_mean', 15)

        threshold_sbo = spec.get('threshold_sbo')

        parallel_training = spec.get('parallel_training', True)

        start_optimize_posterior_mean = spec.get(
            'start_optimize_posterior_mean', 0)

        entry.update({
            'problem_name':
            problem_name,
            'dim_x':
            dim_x,
            'choose_noise':
            choose_noise,
            'bounds_domain_x':
            bounds_domain_x,
            'number_points_each_dimension':
            number_points_each_dimension,
            'method_optimization':
            method_optimization,
            'training_name':
            training_name,
            'bounds_domain':
            bounds_domain,
            'n_training':
            n_training,
            'points':
            points,
            'noise':
            noise,
            'n_samples':
            n_samples,
            'random_seed':
            random_seed,
            'parallel':
            parallel,
            'type_bounds':
            type_bounds,
            'name_model':
            name_model,
            'type_kernel':
            type_kernel,
            'dimensions':
            dimensions,
            'mle':
            mle,
            'optimize_only_posterior_mean':
            optimize_only_posterior_mean,
            'thinning':
            thinning,
            'n_burning':
            n_burning,
            'max_steps_out':
            max_steps_out,
            'training_data':
            training_data,
            'x_domain':
            x_domain,
            'distribution':
            distribution,
            'parameters_distribution':
            parameters_distribution,
            'minimize':
            minimize,
            'n_iterations':
            n_iterations,
            'kernel_values':
            kernel_values,
            'mean_value':
            mean_value,
            'var_noise_value':
            var_noise_value,
            'cache':
            cache,
            'debug':
            debug,
            'same_correlation':
            same_correlation,
            'number_points_each_dimension_debug':
            number_points_each_dimension_debug,
            'monte_carlo_sbo':
            monte_carlo_sbo,
            'n_samples_mc':
            n_samples_mc,
            'n_restarts_mc':
            n_restarts_mc,
            'factr_mc':
            factr_mc,
            'maxiter_mc':
            maxiter_mc,
            'use_only_training_points':
            use_only_training_points,
            'n_restarts':
            n_restarts,
            'n_best_restarts_mc':
            n_best_restarts_mc,
            'n_best_restarts':
            n_best_restarts,
            'n_samples_parameters':
            n_samples_parameters,
            'n_best_restarts_mean':
            n_best_restarts_mean,
            'n_restarts_mean':
            n_restarts_mean,
            'method_opt_mc':
            method_opt_mc,
            'maxepoch':
            maxepoch,
            'n_samples_parameters_mean':
            n_samples_parameters_mean,
            'maxepoch_mean':
            maxepoch_mean,
            'threshold_sbo':
            threshold_sbo,
            'parallel_training':
            parallel_training,
            'start_optimize_posterior_mean':
            start_optimize_posterior_mean,
        })

        return cls(entry)
Exemplo n.º 14
0
class BaseLot(BaseResourceItem):
    class Options:
        roles = {
            'create': create_role,
            'plain': plain_role,
            'edit': edit_role,
            'view': view_role,
            'listing': listing_role,
            'default': schematics_default_role,
            'Administrator': Administrator_role,
            # Draft role
            'draft': view_role,
            'edit_draft': whitelist('status'),
            # Pending role
            'pending': view_role,
            'edit_pending': edit_role,
            # Pending.deleted role
            'pending.deleted': view_role,
            'edit_pending.deleted': whitelist(),
            # Deleted role
            'deleted': view_role,
            'edit_deleted': whitelist(),
            # Verification role
            'verification': view_role,
            'edit_verification': whitelist(),
            # Recomposed role
            'recomposed': view_role,
            'edit_recomposed': whitelist(),
            # Active.salable role
            'active.salable':  view_role,
            'edit_active.salable': whitelist('status'),
            # pending.dissolution role
            'pending.dissolution': view_role,
            'edit_pending.dissolution': whitelist('status'),
            # Dissolved role
            'dissolved': view_role,
            'edit_dissolved': whitelist(),
            # Active.awaiting role
            'active.awaiting': view_role,
            'edit_active.awaiting': whitelist(),
            # Active.auction role
            'active.auction': view_role,
            'edit_active.auction': edit_role,
            # pending.sold role
            'pending.sold': view_role,
            'edit.pending.sold': whitelist(),
            # Sold role
            'sold': view_role,
            'concierge': whitelist('status'),
            'convoy': whitelist('status', 'auctions'),
            'extract_credentials': whitelist('owner', 'id')
        }

    # lotID should always be the same as the OCID. It is included to make the flattened data structure more convenient.
    lotID = StringType()
    date = IsoDateTimeType()
    title = StringType(required=True)
    title_en = StringType()
    title_ru = StringType()
    description = StringType()
    description_en = StringType()
    description_ru = StringType()
    lotCustodian = ModelType(Organization, required=True)
    documents = ListType(ModelType(Document), default=list())  # All documents and attachments related to the lot.

    _internal_type = None

    if SANDBOX_MODE:
        sandboxParameters = StringType()

    def __local_roles__(self):
        roles = dict([('{}_{}'.format(self.owner, self.owner_token), 'lot_owner')])
        return roles

    def get_role(self):
        root = self.__parent__
        request = root.request
        if request.authenticated_role == 'Administrator':
            role = 'Administrator'
        elif request.authenticated_role == 'concierge':
            role = 'concierge'
        elif request.authenticated_role == 'convoy':
            role = 'convoy'
        else:
            role = 'edit_{}'.format(request.context.status)
        return role

    def __acl__(self):
        acl = [
            (Allow, '{}_{}'.format(self.owner, self.owner_token), 'edit_lot'),
            (Allow, '{}_{}'.format(self.owner, self.owner_token), 'upload_lot_documents'),
        ]
        return acl

    def validate_sandboxParameters(self, *args, **kw):
        if self.mode and self.mode == 'test' and self.sandboxParameters and self.sandboxParameters != '':
            raise ValidationError(u"procurementMethodDetails should be used with mode test")
Exemplo n.º 15
0
class PostValidator(Model):
    title = StringType(max_length=255, min_length=5, required=True)
    markdown_body = StringType(required=True)
    tags = ListType(StringType)
class Contract(BaseContract):
    items = ListType(ModelType(Item))
class Tender(SchematicsDocument, Model):
    """Data regarding tender process - publicly inviting prospective contractors
       to submit bids for evaluation and selecting a winner or winners.
    """
    class Options:
        roles = {
            'plain': plain_role,
            'create': create_role,
            'edit': edit_role,
            'edit_draft': draft_role,
            'edit_active': edit_role,
            'edit_active.awarded': whitelist(),
            'edit_complete': whitelist(),
            'edit_unsuccessful': whitelist(),
            'edit_cancelled': whitelist(),
            'view': view_role,
            'listing': listing_role,
            'draft': enquiries_role,
            'active': enquiries_role,
            'active.awarded': view_role,
            'complete': view_role,
            'unsuccessful': view_role,
            'cancelled': view_role,
            'Administrator': Administrator_role,
            'chronograph': chronograph_role,  # remove after chronograph fix
            'chronograph_view':
            chronograph_view_role,  # remove after chronograph fix
            'default': schematics_default_role,
            'contracting': whitelist('doc_id', 'owner'),
        }

    title = StringType(required=True)
    title_en = StringType()
    title_ru = StringType()
    description = StringType()
    description_en = StringType()
    description_ru = StringType()
    date = IsoDateTimeType()
    tenderID = StringType(
    )  # TenderID should always be the same as the OCID. It is included to make the flattened data structure more convenient.
    items = ListType(
        ModelType(Item),
        required=True,
        min_size=1,
        validators=[validate_cpv_group, validate_items_uniq]
    )  # The goods and services to be purchased, broken into line items wherever possible. Items should not be duplicated, but a quantity of 2 specified instead.
    value = ModelType(
        Value, required=True)  # The total estimated value of the procurement.
    procurementMethod = StringType(
        choices=['open', 'selective', 'limited'], default='limited'
    )  # Specify tendering method as per GPA definitions of Open, Selective, Limited (http://www.wto.org/english/docs_e/legal_e/rev-gpr-94_01_e.htm)
    procurementMethodRationale = StringType(
    )  # Justification of procurement method, especially in the case of Limited tendering.
    procurementMethodRationale_en = StringType()
    procurementMethodRationale_ru = StringType()
    procurementMethodType = StringType(default="reporting")
    procuringEntity = ModelType(
        ProcuringEntity, required=True
    )  # The entity managing the procurement, which may be different from the buyer who is paying / using the items being procured.
    documents = ListType(
        ModelType(Document),
        default=list())  # All documents and attachments related to the tender.
    awards = ListType(ModelType(Award), default=list())
    contracts = ListType(ModelType(Contract), default=list())
    revisions = ListType(ModelType(Revision), default=list())
    status = StringType(
        choices=['draft', 'active', 'complete', 'cancelled', 'unsuccessful'],
        default='active')
    mode = StringType(choices=['test'])
    cancellations = ListType(ModelType(Cancellation), default=list())
    _attachments = DictType(DictType(BaseType),
                            default=dict())  # couchdb attachments
    dateModified = IsoDateTimeType()
    owner_token = StringType()
    owner = StringType()
    if SANDBOX_MODE:
        procurementMethodDetails = StringType()

    create_accreditation = 1
    edit_accreditation = 2
    procuring_entity_kinds = ['general', 'special', 'defense', 'other']
    block_complaint_status = OpenUATender.block_complaint_status

    __parent__ = None
    __name__ = ''

    def __local_roles__(self):
        return dict([('{}_{}'.format(self.owner,
                                     self.owner_token), 'tender_owner')])

    def get_role(self):
        root = self.__parent__
        request = root.request
        if request.authenticated_role == 'Administrator':
            role = 'Administrator'
        elif request.authenticated_role == 'chronograph':
            role = 'chronograph'
        elif request.authenticated_role == 'contracting':
            role = 'contracting'
        else:
            role = 'edit_{}'.format(request.context.status)
        return role

    def __acl__(self):
        return [
            (Allow, 'g:brokers', 'create_award_complaint'),
            (Allow, '{}_{}'.format(self.owner,
                                   self.owner_token), 'edit_tender'),
            (Allow, '{}_{}'.format(self.owner, self.owner_token),
             'upload_tender_documents'),
            (Allow, '{}_{}'.format(self.owner,
                                   self.owner_token), 'edit_complaint'),
        ]

    def initialize(self):
        self.date = get_now()

    def validate_procurementMethodDetails(self, *args, **kw):
        if self.mode and self.mode == 'test' and self.procurementMethodDetails and self.procurementMethodDetails != '':
            raise ValidationError(
                u"procurementMethodDetails should be used with mode test")

    def __repr__(self):
        return '<%s:%r@%r>' % (type(self).__name__, self.id, self.rev)

    @serializable(serialized_name='id')
    def doc_id(self):
        """A property that is serialized by schematics exports."""
        return self._id

    def import_data(self, raw_data, **kw):
        """
        Converts and imports the raw data into the instance of the model
        according to the fields in the model.
        :param raw_data:
            The data to be imported.
        """
        data = self.convert(raw_data, **kw)
        del_keys = [
            k for k in data.keys()
            if data[k] == self.__class__.fields[k].default
            or data[k] == getattr(self, k)
        ]
        for k in del_keys:
            del data[k]

        self._data.update(data)
        return self
Exemplo n.º 18
0
class PresetIndex(Model):
    indexes = ListType(IntType(min_value=0, max_value=255),
                       required=True,
                       min_size=0,
                       max_size=63,
                       default=[])

    @staticmethod
    def modbus(count=None, indexes=None):
        if count is not None and indexes is not None:
            pi = PresetIndex()
            pi.set_from_modbus_data(count, indexes)
            return pi
        return None

    def preset_exists_at_index(self, index):
        return self.indexes[index] != 255

    def index_of_preset_with_memory_slot_number(self, memory_slot_number):
        for index in self.range_of_presets():
            if self.indexes[index] == memory_slot_number:
                return index
        return None

    @property
    def next_available_memory_slot(self):
        for slot_number in range(0, 64):
            # does any index take this?
            memory_slot_number = self.index_of_preset_with_memory_slot_number(
                slot_number)
            if memory_slot_number is None:
                return slot_number
        return None

    def add_to_index(self, new_preset):
        next_memory_slot = self.next_available_memory_slot
        if next_memory_slot is None:
            return None

        next_index = self.first_empty_index_position
        if next_index is None:
            return None

        new_preset.memory_slot = next_memory_slot
        new_preset.use_flag = 0x55aa  # Used
        self.indexes[next_index] = next_memory_slot

        return new_preset

    def range_of_presets(self):
        if self.first_empty_index_position is not None:
            return range(0, self.first_empty_index_position)
        return range(0, 64)

    def is_valid_index(self, index):
        return index in self.range_of_presets()

    def swap(self, index_one, index_two):
        if not self.is_valid_index(index_one):
            message = "Index one {0} is invalid".format(index_one)
            raise ObjectNotFoundException(message)
        if not self.is_valid_index(index_two):
            message = "Index two {0} is invalid".format(index_two)
            raise ObjectNotFoundException(message)

        value1 = self.indexes[index_one]
        value2 = self.indexes[index_two]
        self.indexes[index_one] = value2
        self.indexes[index_two] = value1

    @property
    def number_of_presets(self):
        first_empty_slot = self.first_empty_index_position
        if not first_empty_slot:
            return len(self.indexes)
        return first_empty_slot

    @property
    def first_empty_index_position(self):
        first_empty = None
        for i, index in enumerate(self.indexes):
            if index == 255:
                first_empty = i
                break

        return first_empty

    def delete_item_at_index(self, index, validate=True):
        if self.is_valid_index(index):
            del self.indexes[index]
            if validate:
                self._validate_and_fix_index_list()

    def _validate_and_fix_index_list(self):
        # Add 255's on the end until we have 64 of them
        # this also clears out any other 0's and other stuff.
        if self.first_empty_index_position is not None:
            for index in range(self.first_empty_index_position, 64):
                if index < len(self.indexes):
                    self.indexes[index] = 255
                else:
                    self.indexes.append(255)

        # Indexes must be unique
        set_of_seen = {}
        current_position = 0
        while current_position < self.number_of_presets - 1:
            index_at_this_position = self.indexes[current_position]
            if set_of_seen.get(index_at_this_position, None):
                # if we've already seen it, we should delete this one
                self.delete_item_at_index(current_position, validate=False)

                # Don't inc counter, as we've deleted one
            else:
                set_of_seen[index_at_this_position] = 1
                current_position += 1

    def set_indexes(self, new_value):
        self.indexes = copy.deepcopy(new_value)
        self._validate_and_fix_index_list()

    def set_from_modbus_data(self, count, indexes):
        self.set_indexes(indexes)

    @serializable
    def count(self):
        # The number of non-255 index positions
        return self.number_of_presets

    def to_modbus_data(self):
        v1 = [
            self.number_of_presets,
        ]
        v1.extend(self.indexes[:32])
        v2 = self.indexes[32:]
        return v1, v2
Exemplo n.º 19
0
class ReplaceExecutionReport(BaseExecutionReport):
    instruction_reports = ListType(ModelType(ReplaceInstructionReport))
Exemplo n.º 20
0
 class Group(Model):
     users = ListType(ModelType(User))
Exemplo n.º 21
0
class AccountStatementReport(BetfairModel):
    account_statement = ListType(ModelType(StatementItem))
    more_available = BooleanType()
Exemplo n.º 22
0
def test_compound_fields():
    comments = ListType(ListType, compound_field=StringType)

    assert isinstance(comments.field, ListType)
Exemplo n.º 23
0
 class User(Model):
     ids = ListType(IntType)
Exemplo n.º 24
0
class TaskDTOs(Model):
    """ Describes an array of Task DTOs"""

    tasks = ListType(ModelType(TaskDTO))
Exemplo n.º 25
0
 class PlayerInfo(Model):
     categories = ListType(ModelType(CategoryStatsInfo))
Exemplo n.º 26
0
class StartingPrices(BetfairModel):
    near_price = FloatType()
    far_price = FloatType()
    back_stake_taken = ListType(ModelType(PriceSize))
    lay_liability_taken = ListType(ModelType(PriceSize))
    actual_SP = FloatType()
Exemplo n.º 27
0
 class PlayerInfo(Model):
     following = ListType(StringType)
Exemplo n.º 28
0
class ExchangePrices(BetfairModel):
    available_to_back = ListType(ModelType(PriceSize))
    available_to_lay = ListType(ModelType(PriceSize))
    traded_volume = ListType(ModelType(PriceSize))
Exemplo n.º 29
0
 class QuestionPack(Model):
     id = StringType()
     questions = ListType(ModelType(Question))
Exemplo n.º 30
0
class MarketProfitAndLoss(BetfairModel):
    market_id = StringType()
    commission_applied = FloatType()
    profit_and_losses = ListType(ModelType(RunnerProfitAndLoss))
Exemplo n.º 31
0
class PriceProjection(BetfairModel):
    price_data = ListType(EnumType(constants.PriceData))
    ex_best_offers_overrides = ModelType(ExBestOffersOverrides)
    virtualise = BooleanType()
    rollover_stakes = BooleanType()
Exemplo n.º 32
0
class ClearedOrderSummaryReport(BetfairModel):
    cleared_orders = ListType(ModelType(ClearedOrderSummary), required=True)
    more_available = BooleanType(required=True)
Exemplo n.º 33
0
 def __init__(self):
     ListType.__init__(self, IntType(), min_size=2, max_size=2)
Exemplo n.º 34
0
 class PostParams(SchemaModel):
     role_ids = ListType(IntType(), required=True)