Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Saving list in a list
Post: RE: Saving list in a list
(Mar-08-2021, 02:41 PM)snippsat Wrote: measurements is return a NumPy Array
>>> import numpy as np
>>>
>>> n1 = np.array([0, 1])
>>> n1
array([0, 1])
>>>... |
|
quest_ |
General Coding Help |
3 |
3,131 |
Mar-10-2021, 09:58 AM |
|
|
Thread: Saving list in a list
Post: Saving list in a list
Hello I am trying to save my list into another list. I actually do it but it is saved like
array([0, 0]), array([0, 1])However I want to save like that:
[0,1],[0,0]...my code is here:
results_ = [... |
|
quest_ |
General Coding Help |
3 |
3,131 |
Mar-08-2021, 01:44 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements according to the Input wit...
(Jan-27-2021, 10:05 PM)bowlofred Wrote: Very interesting. Is that a different package? I'm not on ubuntu, so just installed via pip.
For this package, the iterable is the first argument.
>>... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 10:19 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements according to the Input wit...
Ah ok!
indexess will change their order:
Instead of following line
groups_ = more_itertools.grouper(variables, 2)we should write that:
groups_ = more_itertools.grouper(2,variables) |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 09:25 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements according to the Input wit...
(Jan-27-2021, 08:38 PM)bowlofred Wrote: Show the entire code (including imports). Your code seems to work for me....
import itertools
import more_itertools
number =2
for variables in itertools.pr... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 08:44 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements according to the Input wit...
(Jan-27-2021, 07:54 PM)bowlofred Wrote: My variables was just a single list. I'm not completely sure, but maybe you want to run it for each of the groups in your product? Like this?
from itertool... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 08:07 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements according to the Input wit...
(Jan-27-2021, 06:03 PM)bowlofred Wrote: Just make variables an iterator/list whatever of integers then. Here I just set it via range, but it could be set any way.
from itertools import product
fro... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 07:22 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements according to the Input wit...
(Jan-27-2021, 04:40 PM)bowlofred Wrote: Your information is already stored in the list variables. I wouldn't move the data to other names.
Maybe something like this?
from itertools import produc... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 05:41 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements with the order of binary c...
This is the problem already. I do not want to write these variables by hand!
Probably I could not explain my problem to you
I just want to do these 2 line dynamically:
a,ap,b,bp= variables[0],vari... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 10:30 AM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements with the order of binary c...
(Jan-27-2021, 02:36 AM)Larz60+ Wrote: To achieve list as you present, what are the values for number?Number (for these values ) is an integer and its value is 2 for list that I presented above. So I... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-27-2021, 09:26 AM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: RE: Group List Elements with the order of binary c...
(Jan-26-2021, 10:19 PM)Larz60+ Wrote: Quote:However it did not work!
Please elaborate and post any error messages ( complete and unaltered in error tags )
I should get this result(and with old metho... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-26-2021, 10:50 PM |
|
|
Thread: Group List Elements according to the Input with the order of binary combination
Post: Group List Elements according to the Input with th...
Hello,
I have this code scripts:
for variables in itertools.product([0, 1], repeat=(number*2)): # set of variables for a,ap,b,bp,c,cp like 000000 000001 000011....
#a,ap,b,bp,c,cp= variables[0],v... |
|
quest_ |
General Coding Help |
19 |
6,499 |
Jan-26-2021, 08:42 PM |
|
|
Thread: Create variable and list dynamically
Post: RE: Create variable and list dynamically
(Jan-26-2021, 06:49 PM)bowlofred Wrote: The examples I gave showed kron_argument_list() takes an integer as the argument. You're giving a list.
If you want to pass in the actual qbts, that's fine... |
|
quest_ |
General Coding Help |
12 |
4,436 |
Jan-26-2021, 07:14 PM |
|
|
Thread: Create variable and list dynamically
Post: RE: Create variable and list dynamically
(Jan-26-2021, 06:47 PM)nilamo Wrote: (Jan-26-2021, 06:34 PM)quest_ Wrote: Apologize but I did not understand anyhting. Why are we seeing "spam foo 3" instead of "spam foo" when we run "show(*items... |
|
quest_ |
General Coding Help |
12 |
4,436 |
Jan-26-2021, 07:12 PM |
|
|
Thread: Create variable and list dynamically
Post: RE: Create variable and list dynamically
(Jan-25-2021, 11:40 PM)bowlofred Wrote: Yes, it should. I can't actually test it, because I don't have any of your functions or data structures.
You could call the function directly and see the ar... |
|
quest_ |
General Coding Help |
12 |
4,436 |
Jan-26-2021, 06:41 PM |
|
|
Thread: Create variable and list dynamically
Post: RE: Create variable and list dynamically
(Jan-26-2021, 04:52 PM)nilamo Wrote: (Jan-25-2021, 10:47 PM)quest_ Wrote: If I have 2 vaarible, it will be
a = kron(unitary(rz(qt[0])),unitary(rz(qbt[1]))) and if I have 10, it will go...
HOw ca... |
|
quest_ |
General Coding Help |
12 |
4,436 |
Jan-26-2021, 06:34 PM |
|
|
Thread: Create variable and list dynamically
Post: RE: Create variable and list dynamically
(Jan-25-2021, 11:09 PM)bowlofred Wrote: Is that a typo and the second call should be qbt[0] rather than qt[0]? If so, we can probably write a program to index it. If it's not a typo, I don't know ... |
|
quest_ |
General Coding Help |
12 |
4,436 |
Jan-25-2021, 11:33 PM |
|
|
Thread: Create variable and list dynamically
Post: RE: Create variable and list dynamically
(Jan-25-2021, 10:16 PM)bowlofred Wrote: Don't create them as separate variables in your namespace. Instead assign the variables to a collection, and pull out the values as needed. cirq.LineQubit.r... |
|
quest_ |
General Coding Help |
12 |
4,436 |
Jan-25-2021, 10:47 PM |
|
|
Thread: Create variable and list dynamically
Post: Create variable and list dynamically
Hello,
This is a simple function:
number =3
a, b, c = cirq.LineQubit.range(number)And I want to create these variables (a, b, c) dynalically instead of writing by hand. However I know that, creating... |
|
quest_ |
General Coding Help |
12 |
4,436 |
Jan-25-2021, 09:59 PM |
|
|
Thread: len(row) does not count rows correctly
Post: RE: len(row) does not count rows correctly
(Jan-23-2021, 01:49 AM)deanhystad Wrote: import itertools
import numpy as np
newlist2 = [[[0, 0], [1, 1], [1, 1], [0, 0], [1, 1], [0, 0], [0, 0], (0.7853981633974483, 0.7853981633974483)],
... |
|
quest_ |
General Coding Help |
3 |
2,260 |
Jan-23-2021, 10:38 AM |