Whew! On Thu, Sep 29, 2016 at 6:03 AM, Rolf Huehne <rolf.hue...@leibniz-fli.de> wrote:
> Hi all, > > forget about it. I have found the problem. Sometimes it already helps to > explain a problem to someone else to get a different look at it. > > The function call querying the array was actually a nested call of > multiple functions and in one of the functions the parameter was > accidetally set to a an empty string because the function initially > wasn't prepared for working with an array as parameter. > > Regards, > Rolf > > Am 29.09.16 um 12:25 schrieb Rolf Huehne: > > Hi all, > > > > I am observing a strange degradation problem with a complex global > > variable, consisting of nested hashes and arrays (Jmol > 14.6.3_2016.09.18): > > > > Immediately after I have added another hash level containing an array > > everything is fine. When I provide the new array as parameter to a > > function it is there. But when I do the same function call again the > > array has become an empty string. > > This is fully reproducible. > > > > I tried to build a simple test system that mimics the levels and how the > > new hash and array are added and queried by another function to > > demonstrate the problem, but wasn't succesful (no degradation). > > The real dataset is quite large. Exported with 'write var' it takes 59 > > megabytes of disk space. A compressed version is temporarily available > > at > > http://jenalib.leibniz-fli.de/ImgLibPDB/tmp/network_data_ > with_genes_of_interest-2016_09_29.txt.gz > > The hash key for the subhash is 'genesOfInterest' and the key for the > > array is 'nodeIds'. > > > > But the system below at least demonstrates the number of hash levels and > > how the new hash and array are added: > > > > ---- Example system -------------- > > testData = [level2: [level3: {}]] > > > > function fillTest(dataRef, count) { > > var level3 = {}; > > var testHash = {}; > > for (var i from [1 count]) { > > testHash[i] = [atomId: i]; > > } > > > > level3 = dataRef..level2..level3; > > level3..level4 = {}; > > level3..level4..level5 = testHash.array("id").select("(atomId)"); > > } > > > > function readTest(testPar) { > > print "type=" + testPar.type; > > print "size=" + testPar.size; > > } > > > > print "==== 1 =====\n" + testData; > > fillTest(testData,5); > > print "==== 2 =====\n" + testData; > > readTest(testData..level2..level3..level4..level5); > > > > ---- Example output -------------- > > ==== 1 ===== > > { > > "level2" : > > { > > "level3" : > > { > > } > > } > > } > > ==== 2 ===== > > { > > "level2" : > > { > > "level3" : > > { > > "level4" : > > { > > "level5" : > > [ > > 1 > > 2 > > 3 > > 4 > > 5 > > ] > > } > > } > > } > > } > > type=array > > size=5 > > ---------------------------------- > > > > Bob, do you have any idea how this can happen? > > > > Maybe I have made a wrong assumption regarding variables in Jmol: > > > > If a hash is provided as a parameter to a function it is used there by > > reference and it is not created a copy used within the function. > > > > The example above at least shouldn't work without the assumption being > true. > > > > The use of the 'level3' variable in the 'fillTest' function is common > > within my system. It is created as a local hash variable to make sure it > > is a hash. And if it is already provided in the parameter hash it is > > replaced by the existing subhash (by reference through '='). If not the > > new hash is inserted at the end of the function into the parameter hash. > > I never observed any problems with this strategy before. The newly added > > data always stayed within the global variable provided as parameter to > > the function. > > > > Regards, > > Rolf > > > > > > ------------------------------------------------------------ > ------------------ > > _______________________________________________ > > Jmol-users mailing list > > Jmol-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/jmol-users > > > > > ------------------------------------------------------------ > ------------------ > _______________________________________________ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > -- Robert M. Hanson Larson-Anderson Professor of Chemistry St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
_______________________________________________ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users