Re: Extract the space group generators from Bilbao Crystallographic Server.
On Friday, July 15, 2022 at 11:08:55 AM UTC+8, avi.e...@gmail.com wrote: > I guess Dan, that he may not be seeing what he is working on as a list of > lists of lists with each terminal sublist being of cardinality 4. Maybe > Zhao could look up what methods a list object has that allow you to place > additional items, such as a list of 4 numbers, at the beginning or end or in > middle and select a method that does what he wants. > > But I have to ask where exactly he wants to place this: "[0, 0, 0, 1]" Yes. This must be appended to each of the subsists to construct an affine transformation matrix, as described here [1-3]. [1] https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-doc-trmat [2] https://www.gap-system.org/Manuals/pkg/crystcat/htm/CHAP001.htm#SECT002 [3] https://www.gap-system.org/Manuals/pkg/cryst/htm/CHAP002.htm > Unfortunately, we got no before and after picture, just after. I will > explain what that means at the end but for now, I am making believe what you > show is the before and see what that would mean. > > The list seems to be a representation for a matrix that is 8 by 4 by 4. > Where do you place just the foursome above just once without breaking the > matrix? I mean you can extend it at the bottom by adding four of the above > as in > [ [0, 0, 0, 1], > [0, 0, 0, 1], > [0, 0, 0, 1], > [0, 0, 0, 1] ] > > Or you can take each internal four partner like the first one: > [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0,1, 0], [0, 0, 0, 1]] > And extend each one at the right end by adding a fifth: > > [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0,1, 0], [0, 0, 0, 1], [0, 0, 0, 1]] > > I can think of other transformations albeit I have no idea why this is being > done and what makes sense. > > So first he needs to be clear on where and what he is adding and then think > of a method. > > And BTW, this problem may also be looked at under a transformation. If > allowed to use some modules, it might make sense to feed the data structure > into something that returns a 3-D matrix directly and then use methods that > allow you to tack on parts of other matrices of various dimensions including > one. You can then flip it back into nested list format, if you wish. > > OK, as mentioned earlier, if this is the AFTER then I have to look and see > if it is obvious where the "[0, 0, 0, 1]" was placed to make this: > [[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0,1, 0], [0, 0, 0, 1]], > [[-1, 0, 0, 1], [0,-1, 0, 1/2], [0, 0, 1, 1/2], [0, 0, 0, 1]], > [[-1, 0, 0, 1/2], [0, 1, 0, 1/2], [0, 0,-1, 1], [0, 0, 0, 1]], > [[0, 0, 1, 0], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]], > [[0, 1, 0, 3/4], [1, 0, 0, 1/4], [0, 0, -1, 3/4], [0, 0, 0, 1]], > [[-1, 0, 0, 1/4], [0, -1, 0, 1/4], [0, 0, -1, 1/4], [0, 0, 0, 1]], > [[1, 0, 0, 0], [0, 1, 0, 1/2], [0, 0, 1, 1/2], [0, 0, 0, 1 ]], > [[1, 0, 0, 1/2], [0, 1, 0, 0], [0, 0, 1, 1/2], [0, 0, 0, 1]]] > It looks like you are adding not once copy but eight copies with one each at > the end of the lists within the main list. > > That makes this easy enough so think about what it means to deal with lists > and NOT matrices. > > Your top list contains what I will call an a,b,c,d,e,f,g,h so if you wrote > code like > > Mylist = [ "a", "b", ..., "g", "h"] > > Then you can use a loop to iterate over those or perhaps a construct like > this: > > [ item for item in Mylist ] > > Wil gather them together and place them back in a list, which is useless but > it could be something applied to item like changing to upper case. In your > case, each item will be something like this: > > [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0,1, 0]] > > And you want to extend it by attaching this [0, 0, 0, 1] > > So how do you attach something to a list? Whatever that method is, call it > append and look it up and consider a line of code like: > > [ item.append(something) for item in Mylist ] > > If done right, the above list comprehension loops over one dimension of your > list version of a matrix and adds [0, 0, 0, 1] to the end and then > eventually put the a/b/d/..h components back together to look like what I > THINK you are asking. > > You can make some of the other possible changes using other tricks and > gimmicks like a nested comprehension but at some point, if you work well > with matrices, you may be better off converting your nested list into a > numpy matrix and make your addition another matrix and then use > numpy.concatenate, numpy.vstack and numpy.hstack with proper care with > multiple dimensions to specify what axis they will combine on. > > But doing the full (home)work for you is ... Thank you for your analysis and comments. Best, Zhao > -Original Message- > From: Python-list On > Behalf Of Dan Stromberg > Sent: Thursday, July 14, 2022 10:07 PM > To: hongy...@gmail.com > Cc: Python List > Subject: Re: Extract the space group generators from Bilbao Crystallographic > Server. > > It's good to include what you want to se
Re: [Neuroimaging] what's the problem??????
On Thu, 14 Jul 2022 17:20:55 -0400, declaimed the following: >Dennis, > >I see Nati sent some more code without explaining again what he wants. Yes, >somewhere in this stack of messages he may have said things (that we generally >failed to understand) but it would be helpful to summarize WHY he sent us what >he did or which lines to look at. > And that code seems to be doing a lot of repetitive/unneeded operations... Nothing from from nilearn import ... to masker = ... appears to depend upon the file name "nii" in the loop and should be refactored to the top-level. The try/except block for sklearn looks like another candidate to be pulled out of the file loop. > If your suggestion is right, he may not understand dictionaries as a hashed > data structure where you can access a.items() or a.keys() or a.values() if > you want a list of sorts of the parts, or a[key] if you want a particular > part. > So far as I can tell, the OP only references ONE key in the dictionary, but apparently expects that key to have multiple values. Yet there doesn't seem to be a structure /holding/ multiple values -- unless a["Difumo_names"] is, itself, returning a dictionary on which .values() can be applied. In that case, the list() call is likely redundant as .values() already returned a list (hmmm, is list(some_list) a no-op, or does it wrap some_list into another list -- in the latter case, the indexing will fail as there is only one element to access) >for i in estimator.covariance_: >r=list(a["Difumo_names"].values())[jsa] >jsa=jsa+1 >a=dict() And there is the biggest fault... The OP is completely obliterating the "a" dictionary, so subsequent passes in that loop have nothing to look up. "aas" gets initialized as a dictionary using {}, and never gets any key:value pairs assigned to it, yet there is a print(aas) in the code. And that is as far as I can guess -- given the lack of example input data, example /desired/ output... etc. There are too many apparent errors in that code sample to even attempt to think what a result could be. -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: [Neuroimaging] what's the problem??????
Dennis Lee Bieber schreef op 15/07/2022 om 19:11: ... is, itself, returning a dictionary on which .values() can be applied. In that case, the list() call is likely redundant as .values() already returned a list (hmmm, is list(some_list) a no-op, or does it wrap some_list into another list -- in the latter case, the indexing will fail as there is only one element to access) list(some_list) returns a copy of some_list, a shallow copy to be precise. >>> a = [ [1, 2, 3], [4, 5, 6] ] >>> b = list(a) Both lists are equal: >>> a == b True But not identical: >>> a is b False The sublists are identical though: >>> a[0] is b[0] True >>> a[1] is b[1] True -- "I've come up with a set of rules that describe our reactions to technologies: 1. Anything that is in the world when you’re born is normal and ordinary and is just a natural part of the way the world works. 2. Anything that's invented between when you’re fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. 3. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams, The Salmon of Doubt -- https://mail.python.org/mailman/listinfo/python-list
RE: [Neuroimaging] what's the problem??????
Dennis, I am replying to the group but mainly you as I doubt Nati really reads much of what we write. The use of list() is needed as what comes out of the function may be an object of type dict_keys which is iterable but if you want it in a list form all at once, the idiom he uses is common. In the code below, alternating lines are commands and output, shown by blank lines between pairs. a={"aleph":1,"bet":2, "ג":3} a {'aleph': 1, 'bet': 2, 'ג': 3} a.keys() dict_keys(['aleph', 'bet', 'ג']) list(a.keys()) ['aleph', 'bet', 'ג'] The question you ask is what I speculated on. Is he looking for the content of a specific key in his dictionary called "a" to be something with multiple values like a list or dictionary. BUT my question is whether reading it into numpy and converting the top level to a dictionary, results in being able to store another dictionary within it, or leaves some other data structure that maybe he needs to also be converted, if that can be done. I could waste more time playing around but Nati is not an ideal partner to engage with. I experiment with embedding a dictionary within itself as the second entry and it works fine BUT I bet what Nati has is not that as it was not made like that: a["bet"] = a a {'aleph': 1, 'bet': {...}, 'ג': 3} a["bet"]["aleph"] 1 Now if Nati gave a damn he should do something like I am doing and run his code part way and LOOK at what he has before continuing to use it as if it is what he imagines, or worse, he is copying only part of a recipe cobbled together. And, agreed, Nati has so many things that look like errors, that it is silly to ask why the mess did not work, and better to ask how each piece starting from the top is working or should be adjusted to work. -Original Message- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Friday, July 15, 2022 1:11 PM To: python-list@python.org Subject: Re: [Neuroimaging] what's the problem?? On Thu, 14 Jul 2022 17:20:55 -0400, declaimed the following: >Dennis, > >I see Nati sent some more code without explaining again what he wants. Yes, somewhere in this stack of messages he may have said things (that we generally failed to understand) but it would be helpful to summarize WHY he sent us what he did or which lines to look at. > And that code seems to be doing a lot of repetitive/unneeded operations... Nothing from from nilearn import ... to masker = ... appears to depend upon the file name "nii" in the loop and should be refactored to the top-level. The try/except block for sklearn looks like another candidate to be pulled out of the file loop. > If your suggestion is right, he may not understand dictionaries as a hashed data structure where you can access a.items() or a.keys() or a.values() if you want a list of sorts of the parts, or a[key] if you want a particular part. > So far as I can tell, the OP only references ONE key in the dictionary, but apparently expects that key to have multiple values. Yet there doesn't seem to be a structure /holding/ multiple values -- unless a["Difumo_names"] is, itself, returning a dictionary on which .values() can be applied. In that case, the list() call is likely redundant as .values() already returned a list (hmmm, is list(some_list) a no-op, or does it wrap some_list into another list -- in the latter case, the indexing will fail as there is only one element to access) >for i in estimator.covariance_: >r=list(a["Difumo_names"].values())[jsa] >jsa=jsa+1 >a=dict() And there is the biggest fault... The OP is completely obliterating the "a" dictionary, so subsequent passes in that loop have nothing to look up. "aas" gets initialized as a dictionary using {}, and never gets any key:value pairs assigned to it, yet there is a print(aas) in the code. And that is as far as I can guess -- given the lack of example input data, example /desired/ output... etc. There are too many apparent errors in that code sample to even attempt to think what a result could be. -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list