
I’ve found a bug in add_site_family(), the input for other_vectors should be a list, but I used a tulpe, the error message I got is not correct. Code: lat = kwant.lattice.general([(1, 0), (sin_30, cos_30)], [(0, 0), (0, 1 / sqrt(3))]) a, b = lat.sublattices sym_lead = kwant.TranslationalSymmetry(lat.vec((1, 0))) sym_lead.add_site_family(a, other_vectors=(1, -2)) Error message: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-73-c9cfa5f61ce2> in <module>() 4 sym_lead = kwant.TranslationalSymmetry(lat.vec((1, 0))) 5 ----> 6 sym_lead.add_site_family(a, other_vectors=(1, -2)) /usr/local/lib/python2.7/site-packages/kwant/lattice.pyc in add_site_family(self, fam, other_vectors) 572 573 if np.linalg.matrix_rank(m) < num_vec: --> 574 raise ValueError('other_vectors and symmetry periods are not ' 575 'linearly independent.') 576 ValueError: other_vectors and symmetry periods are not linearly independent.

Hi, I’ve found a bug in add_site_family(), the input for other_vectors should
be a list, but I used a tulpe, the error message I got is not correct.
You say that you use a tuple as the parameter `other_vectors` for the `add_site_family` function. When I look at your code I see the following:
sym_lead.add_site_family(a, other_vectors=(1, -2))
While this certainly produces an error, it is not because you have used a tuple; the following also produces the same error: sym_lead.add_site_family(a, other_vectors=[1, -2]) (I use a list instead of a tuple for `other_vectors`). The reason this produces an error is because you have passed a sequence of *integers*, whereas the documentation states: other_vectors : list of lists of integers http://kwant-project.org/doc/1.0/reference/generated/kwant.lattice.Translati... i.e. you need to pass a **sequence of sequences of integers**. For your case where you only wish to add a single vector (because 2D) you should do the following: sym_lead.add_site_family(a, other_vectors=[ [1, -2] ]) Note I have passed a list containing a single element, where that single element is itself a list of integers. You are not limited to using lists, you could equivalently use tuples: sym_lead.add_site_family(a, other_vectors=( (1, -2), )) (note the comma which denotes a tuple with a single element), or you could use a mix of the two. It is true that the documentation should specify a **sequence of sequences of integers** rather than a **list of lists of integers**, as the former is more general, however I think in the context it is clear. Hope this clarifies a bit, Joe

Hi Joe, Thank you for your elaborate explanation. When I send the e-mail I had already solved the issue. The “bug” I reported was merely that it gave the wrong error message: “ValueError: other_vectors and symmetry periods are not linearly independent.”. While it should tell me something along the lines: “Use list of lists of integers.” Best, Bas On Wed, Feb 25, 2015 at 8:58 PM, Joseph Weston <joseph.weston08@gmail.com> wrote:
Hi, I’ve found a bug in add_site_family(), the input for other_vectors should
be a list, but I used a tulpe, the error message I got is not correct.
You say that you use a tuple as the parameter `other_vectors` for the `add_site_family` function. When I look at your code I see the following:
sym_lead.add_site_family(a, other_vectors=(1, -2))
While this certainly produces an error, it is not because you have used a tuple; the following also produces the same error: sym_lead.add_site_family(a, other_vectors=[1, -2]) (I use a list instead of a tuple for `other_vectors`). The reason this produces an error is because you have passed a sequence of *integers*, whereas the documentation states: other_vectors : list of lists of integers http://kwant-project.org/doc/1.0/reference/generated/kwant.lattice.Translati... i.e. you need to pass a **sequence of sequences of integers**. For your case where you only wish to add a single vector (because 2D) you should do the following: sym_lead.add_site_family(a, other_vectors=[ [1, -2] ]) Note I have passed a list containing a single element, where that single element is itself a list of integers. You are not limited to using lists, you could equivalently use tuples: sym_lead.add_site_family(a, other_vectors=( (1, -2), )) (note the comma which denotes a tuple with a single element), or you could use a mix of the two. It is true that the documentation should specify a **sequence of sequences of integers** rather than a **list of lists of integers**, as the former is more general, however I think in the context it is clear. Hope this clarifies a bit, Joe

Actually, I think the error message is technically correct. The two integers are just two vectors in a one-dimensional vector space, and as such they are not linearly independent. This is a special case of the general statement that no set of n+1 vectors on an n-dimensional vector space can be linearly independent. (I'm not saying that the message could not be more helpful, but merely that it is not actually wrong.) Ted Pudlik On Thu, Feb 26, 2015 at 11:35 AM, Bas Nijholt <basnijholt@gmail.com> wrote:
Hi Joe,
Thank you for your elaborate explanation.
When I send the e-mail I had already solved the issue.
The “bug” I reported was merely that it gave the wrong error message: “ValueError: other_vectors and symmetry periods are not linearly independent.”.
While it should tell me something along the lines: “Use list of lists of integers.”
Best,
Bas
On Wed, Feb 25, 2015 at 8:58 PM, Joseph Weston <joseph.weston08@gmail.com> wrote:
Hi,
I’ve found a bug in add_site_family(), the input for other_vectors
should be a list, but I used a tulpe, the error message I got is not correct.
You say that you use a tuple as the parameter `other_vectors` for the `add_site_family` function. When I look at your code I see the following:
sym_lead.add_site_family(a, other_vectors=(1, -2))
While this certainly produces an error, it is not because you have used a tuple; the following also produces the same error:
sym_lead.add_site_family(a, other_vectors=[1, -2])
(I use a list instead of a tuple for `other_vectors`). The reason this produces an error is because you have passed a sequence of *integers*, whereas the documentation states:
other_vectors : list of lists of integers
http://kwant-project.org/doc/1.0/reference/generated/kwant.lattice.Translati...
i.e. you need to pass a **sequence of sequences of integers**. For your case where you only wish to add a single vector (because 2D) you should do the following:
sym_lead.add_site_family(a, other_vectors=[ [1, -2] ])
Note I have passed a list containing a single element, where that single element is itself a list of integers. You are not limited to using lists, you could equivalently use tuples:
sym_lead.add_site_family(a, other_vectors=( (1, -2), ))
(note the comma which denotes a tuple with a single element), or you could use a mix of the two. It is true that the documentation should specify a **sequence of sequences of integers** rather than a **list of lists of integers**, as the former is more general, however I think in the context it is clear.
Hope this clarifies a bit,
Joe

Hi,
Actually, I think the error message is technically correct. The two integers are just two vectors in a one-dimensional vector space, and as such they are not linearly independent. This is a special case of the general statement that no set of n+1 vectors on an n-dimensional vector space can be linearly independent.
The error message says "not linearly independent with symmetry periods". In this case the input interpretation can be that there are two 1D vectors provided. The symmetry period is 2D, and so the linear independence of these isn't defined. Also a correct way to provide two 1D vectors would be [[a], [b]], not [a, b], and [a, b] isn't even an allowed input value at all. So this really requires an extra check. Best, Anton
(I'm not saying that the message could not be more helpful, but merely that it is not actually wrong.)
Ted Pudlik
On Thu, Feb 26, 2015 at 11:35 AM, Bas Nijholt <basnijholt@gmail.com> wrote:
Hi Joe,
Thank you for your elaborate explanation.
When I send the e-mail I had already solved the issue.
The “bug” I reported was merely that it gave the wrong error message: “ValueError: other_vectors and symmetry periods are not linearly independent.”.
While it should tell me something along the lines: “Use list of lists of integers.”
Best,
Bas
On Wed, Feb 25, 2015 at 8:58 PM, Joseph Weston <joseph.weston08@gmail.com> wrote:
Hi,
I’ve found a bug in add_site_family(), the input for other_vectors should be a list, but I used a tulpe, the error message I got is not correct.
You say that you use a tuple as the parameter `other_vectors` for the `add_site_family` function. When I look at your code I see the following:
sym_lead.add_site_family(a, other_vectors=(1, -2))
While this certainly produces an error, it is not because you have used a tuple; the following also produces the same error:
sym_lead.add_site_family(a, other_vectors=[1, -2])
(I use a list instead of a tuple for `other_vectors`). The reason this produces an error is because you have passed a sequence of *integers*, whereas the documentation states:
other_vectors : list of lists of integers
http://kwant-project.org/doc/1.0/reference/generated/kwant.lattice.Translati...
i.e. you need to pass a **sequence of sequences of integers**. For your case where you only wish to add a single vector (because 2D) you should do the following:
sym_lead.add_site_family(a, other_vectors=[ [1, -2] ])
Note I have passed a list containing a single element, where that single element is itself a list of integers. You are not limited to using lists, you could equivalently use tuples:
sym_lead.add_site_family(a, other_vectors=( (1, -2), ))
(note the comma which denotes a tuple with a single element), or you could use a mix of the two. It is true that the documentation should specify a **sequence of sequences of integers** rather than a **list of lists of integers**, as the former is more general, however I think in the context it is clear.
Hope this clarifies a bit,
Joe

Hi Bas,
The “bug” I reported was merely that it gave the wrong error message: “ValueError: other_vectors and symmetry periods are not linearly independent.”.
While it should tell me something along the lines: “Use list of lists of integers.”
Yes, now I reread your original email I realise that it was perfectly clear; I was not very awake yesterday evening when I replied! It seems that Anton has picked this up anyway; thanks for your bug report! Joe

Bas Nijholt wrote:
I’ve found a bug in add_site_family(), the input for other_vectors should be a list, but I used a tulpe, the error message I got is not correct.
Hi Bas, Thanks for having reported this. I’ve fixed this issue in the development version of Kwant that will become version 1.1 [1]. In general, we are always interested to hear about error messages that Kwant’s users find confusing. Christoph [1] http://git.kwant-project.org/kwant/commit/?id=b6ec5a877794bb854668483d6268ff...
participants (6)
-
Anton Akhmerov
-
Bas Nijholt
-
Christoph Groth
-
Joseph Weston
-
Joseph Weston
-
Ted Pudlik