choice

Is it valid to have a 'choice' of 'group' elements when defining an XML Schema (XSD)

ぐ巨炮叔叔 提交于 2019-12-05 02:04:37
Is it valid to have a 'choice' or 'group' elements when defining an XML Schema (XSD) i.e. is the following valid <xs:complexType name="HeaderType"> <xs:sequence> <xs:element name="reservation-number" type="ReservationNumberType" minOccurs="1" maxOccurs="1" nillable="false" /> <xs:choice minOccurs="1" maxOccurs="1"> <xs:group ref="ReservationGroup" /> <xs:group ref="CancellationGroup"/> </xs:choice> </xs:sequence> </xs:complexType> Where an XML message can represent, for example, either a new reservation or a cancellation of an existing reservation. If the message is for a reservation, then it

initial value for django form choice field ignored

时光总嘲笑我的痴心妄想 提交于 2019-12-04 23:46:13
I have this form: class UserUsesSourceForm(forms.Form): # some fields here username = forms.CharField(label=("Username"), max_length=30, help_text = ("Required")) provider = forms.ChoiceField(widget=forms.Select(), choices=SOURCES_CHOICES, initial=SOURCES_CHOICES[1]) The available choices are: E = 'e' A = 'a' SOURCES_CHOICES = ( (A, 'A'), (E, 'E'), ) The view: form = UserUsesSourceForm(initial={"username":request.user.username, 'provider':SOURCES_CHOICES[1]})return render_to_response('update_datasource.html', context_instance=RequestContext(request, params)) And the template: <form action=""

Django - Choices for Models

时间秒杀一切 提交于 2019-12-04 17:23:38
I have been searching and looking through docs, but I want to ask and confirm for the best solution here. Trying to define model choices. 'yes, no and not sure' choice From Radio Select How would I define for Multiple Choices Simple Example: In my models.py, I have class Property(models.Model): name = models.CharField() class Feature(models.Model): YES_CHOICES = ( # example of 1, there can be only one selection ('YES', 'Yes'), ('NO', 'No'), ('NOT_SURE', 'Not Sure') ) PARKING_CHOICES = ( # example of 2, there can be multiple selections ('GARAGE', 'Garage'), ('STREET', 'Street'), ('PRIVATE_LOT',

Linux命令-read

巧了我就是萌 提交于 2019-12-02 18:27:33
[chenjl@ipha-dev71-1 yysoft]$ read -p "check run the script is the mysql server? (y/n) " choice check run the script is the mysql server? (y/n) y [chenjl@ipha-dev71-1 yysoft]$ echo $choice y 详细解释: p是prompt的缩写,指提示信息 read -p "check run the script is the mysql server? (y/n) " choice 以上命令回车后会显示 check run the script is the mysql server? (y/n) 之后用户输入的内容会被保存到choice变量中 来源: https://www.cnblogs.com/wang-mengmeng/p/11757676.html

Symfony2 Choice field validation not working

和自甴很熟 提交于 2019-12-02 04:08:55
I have a form in Symfony 2.7.10 which definition looks like this: <?php // ... class RecipeType extends AbstractType { // ... /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder // ... ->add('meal_schema', 'choice', [ 'label' => 'Mealtime schema', 'choices' => [ 'breakfast' => 'Breakfast', 'second_breakfast' => 'Second breakfast', 'lunch' => 'Lunch', 'dinner' => 'Dinner', 'snack' => 'Snack', 'supper' => 'Supper', ], 'multiple' => true, 'expanded' => true, 'label_attr' => ['class' => 'col-md-2'

Java Input not working (Beginner)

为君一笑 提交于 2019-12-01 22:52:54
For some reason, my code will not accept input on the last line "What would you like to order: " Could anyone tell me what my error is here? It is compiling correctly and everything. I am only a beginner so please tell me in basic terms. import java.util.Scanner; import java.util.*; class RestaurantMain { public static void main(String[] args) { //Create an array list ArrayList menu = new ArrayList(); //Variables// int choice; int customerChoice; boolean trueFalse; int restart = 0; String choice2; String addItems = ""; int menuCount = 0; int indexCount = 0; String item = ""; //Import input

随机商品猜价格

时光毁灭记忆、已成空白 提交于 2019-12-01 07:13:37
import java.util.Scanner; public class QuessMachine01 { int num; String name; int money; int choice; public void initial(){ num = (int)(Math.random()*10/3+1); switch (num) { case 1: dian(); break; case 2: zxc(); break; case 3: dianshuihu(); break; } } public void dian(){ name = "电动自行车" ; money = 1000; } public void zxc(){ name = "自行车" ; money = 500; } public void dianshuihu(){ name = "电水壶" ; money = 200; } public void guess(){ Scanner in = new Scanner (System.in); for (int i = 0; i < 4; i++) { if (i!=0) { System.out.println("在猜一次吧!"); choice = in.nextInt(); } if (i<3) { if (money==choice) {

numpy.random.choice vs random.choice

ぐ巨炮叔叔 提交于 2019-12-01 06:02:48
Why does numpy.random.choice not work the same as random.choice? When I do this : >>> random.choice([(1,2),(4,3)]) (1, 2) It works. But when I do this: >>> np.random.choice([(1,2), (3,4)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "mtrand.pyx", line 1393, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:15450) ValueError: a must be 1-dimensional How do I achieve the same behavior as random.choice() in numpy.random.choice()? Well np.random.choice as noted in the docs, expects a 1D array and your input when expressed as an array would be 2D . So, it

Sampling without replacement from a given non-uniform distribution in TensorFlow

北慕城南 提交于 2019-12-01 03:53:58
I'm looking for something similar to numpy.random.choice(range(3),replacement=False,size=2,p=[0.1,0.2,0.7]) in TensorFlow. The closest Op to it seems to be tf.multinomial(tf.log(p)) which takes logits as input but it can't sample without replacement. Is there any other way to do sampling from a non-uniform distribution in TensorFlow? Thanks. You could just use tf.py_func to wrap numpy.random.choice and make it available as a TensorFlow op: a = tf.placeholder(tf.float32) size = tf.placeholder(tf.int32) replace = tf.placeholder(tf.bool) p = tf.placeholder(tf.float32) y = tf.py_func(np.random

numpy.random.choice vs random.choice

…衆ロ難τιáo~ 提交于 2019-12-01 03:32:01
问题 Why does numpy.random.choice not work the same as random.choice? When I do this : >>> random.choice([(1,2),(4,3)]) (1, 2) It works. But when I do this: >>> np.random.choice([(1,2), (3,4)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "mtrand.pyx", line 1393, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:15450) ValueError: a must be 1-dimensional How do I achieve the same behavior as random.choice() in numpy.random.choice()? 回答1: Well np.random