import os testscriptdir = os.getcwd() # Test reading/writing print "Testing reading/writing dx files.." dxfilename = os.path.join(testscriptdir, "data", "dxfiles", "AlaDP_3DRISM_smallbuffer.dx.gz") originalgrid = grid.dx2Grid(dxfilename) maxvalue = originalgrid.distribution.max() maxindices = tuple(np.argwhere(originalgrid.distribution == maxvalue)[0]) originalgrid.distribution[maxindices] = maxvalue * 2.0 originalgrid.writedx("modified.dx") newgrid = grid.dx2Grid("modified.dx") newmax = newgrid.distribution.max() assert newmax == maxvalue * 2.0 #cleanup os.remove("modified.dx") # Test shells print "Testing shell-related utilities.." storedprecomputedshells = grid.readshellindices() newshells = grid.precomputeshellindices(40) for storedshell, newshell in zip(storedprecomputedshells, newshells): for storedpoint, newpoint in zip(storedshell, newshell): for storedindex, newindex in zip(storedpoint, newpoint): assert storedindex == newindex
#matplotlib.pyplot.scatter(xset, rdfnearH, color="silver") #matplotlib.pyplot.scatter(xset, rdfnearO, color="red") #matplotlib.pyplot.scatter(xset, rdfnearH2, color="blue") #matplotlib.pyplot.show() #quit() # Test reading/writing print "Testing reading/writing dx files.." originalgrid = grid.dx2Grid(dxfilename) maxvalue = originalgrid.distribution.max() maxindices = tuple(np.argwhere(originalgrid.distribution == maxvalue)[0]) originalgrid.distribution[maxindices] = maxvalue * 2.0 originalgrid.writedx("modified.dx") newgrid = grid.dx2Grid("modified.dx") newmax = newgrid.distribution.max() assert newmax == maxvalue * 2.0 #cleanup del originalgrid del newgrid os.remove("modified.dx") # Test shells print "Testing shell-related utilities.." storedprecomputedshells = grid.readshellindices() newshells = grid.precomputeshellindices(40) for storedshell, newshell in zip(storedprecomputedshells, newshells): for storedpoint, newpoint in zip(storedshell, newshell): for storedindex, newindex in zip(storedpoint, newpoint): assert storedindex == newindex