mirror of
https://github.com/nwchemgit/nwchem.git
synced 2026-07-21 06:25:21 -04:00
Make bandit a mandatory test and fix some typos
This commit is contained in:
parent
370aaf701c
commit
4a7fa658bb
22 changed files with 69 additions and 69 deletions
2
.github/workflows/lint_python.yml
vendored
2
.github/workflows/lint_python.yml
vendored
|
|
@ -9,7 +9,7 @@ jobs:
|
|||
- run: pip install --upgrade pip wheel
|
||||
- run: pip install bandit black codespell flake8 flake8-2020 flake8-bugbear
|
||||
flake8-comprehensions isort mypy pytest pyupgrade safety
|
||||
- run: bandit --recursive --skip B101 . || true # B101 is assert statements
|
||||
- run: bandit --recursive --skip B101,B110,B306,B307,B311,B605,B607 .
|
||||
- run: black --check . || true
|
||||
- run: codespell || true # --ignore-words-list="" --skip="*.css,*.js,*.lock"
|
||||
- run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ def lookup_dois(doi_table):
|
|||
def print_bibliography(bibliography):
|
||||
"""Print the list of bibliography entries."""
|
||||
for reference in bibliography:
|
||||
print( reference )
|
||||
print(reference)
|
||||
|
||||
def main ():
|
||||
"""Run the whole thing (limited capability at the moment)"""
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# vi:ts=4:et
|
||||
|
||||
# Collect DOI-s from text files and write the list of unique DOI-s.
|
||||
# DOI-s are indicated by the preceeding "DOI:" or "doi:" string.
|
||||
# DOI-s are indicated by the preceding "DOI:" or "doi:" string.
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import sys
|
||||
|
|
@ -76,7 +76,7 @@ def remove_duplicates(doi_table):
|
|||
def print_dois(doi_table):
|
||||
"""Print the list of DOI-s."""
|
||||
for doi in doi_table:
|
||||
print( doi )
|
||||
print(doi)
|
||||
|
||||
def main ():
|
||||
"""Run the whole thing (limited capability at the moment)"""
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Date: Mon Nov 27 14:14:54 2017 -0800
|
|||
|
||||
svn replaced by git
|
||||
|
||||
* let's go back to the previos commit a7055a28bc6efa8e6ceff79ae541d5e0b8d8a8b8
|
||||
* let's go back to the previous commit a7055a28bc6efa8e6ceff79ae541d5e0b8d8a8b8
|
||||
|
||||
$ git reset --hard a7055a28bc6efa8e6ceff79ae541d5e0b8d8a8b8
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Occasionally, we might want to get updates from master into branch *test* using:
|
|||
When ready to merge into master:
|
||||
|
||||
git checkout master (we are now on master branch)
|
||||
git pull (make sure master is upto date)
|
||||
git pull (make sure master is up to date)
|
||||
git merge test
|
||||
If there are any conflicts, fix those files manually, commit the fixed files and then: (git merge abort if something seems wrong to abort the merge process)
|
||||
git push
|
||||
|
|
|
|||
|
|
@ -79,10 +79,10 @@ if __name__ == '__main__':
|
|||
a=GenericAtom.fromPDBrecord(aline2)
|
||||
print(a.groupTag())
|
||||
print(a.coord)
|
||||
print(a.dct )
|
||||
print(a.dct)
|
||||
b=GenericAtom.fromPDBrecord(aline3)
|
||||
print(b.coord)
|
||||
print(b.dct )
|
||||
print(b.dct)
|
||||
print(GenericAtom.bondlength(a,b),GenericAtom.bonded(a,b))
|
||||
print(a.covRadius()+b.covRadius())
|
||||
c=GenericAtom.fromPDBrecord(aline1)
|
||||
|
|
|
|||
|
|
@ -147,10 +147,10 @@ if __name__ == '__main__':
|
|||
# a=GenericAtom.fromPDBrecord(aline2)
|
||||
# print(a.groupTag())
|
||||
# print(a.coord)
|
||||
# print(a.dct )
|
||||
# print(a.dct)
|
||||
# b=GenericAtom.fromPDBrecord(aline3)
|
||||
# print(b.coord)
|
||||
# print(b.dct )
|
||||
# print(b.dct)
|
||||
# print(GenericAtom.bondlength(a,b),GenericAtom.bonded(a,b))
|
||||
# print(a.covRadius()+b.covRadius())
|
||||
# c=GenericAtom.fromPDBrecord(aline1)
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ if __name__ == '__main__':
|
|||
print(r, a1.name(), a2.name())
|
||||
print(res1.get_bonded(a2, "O"))
|
||||
name = None
|
||||
print((filter(lambda a: name is None or a.elemName()==name,res1.atoms )))
|
||||
print((filter(lambda a: name is None or a.elemName()==name,res1.atoms)))
|
||||
print(GenericResidue.hbonded(res0,res1))
|
||||
print("HERE COMES PDB RECORD")
|
||||
print(res0.toPDBrecord(1))
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class MySystem(object):
|
|||
if GenericResidue.spec_bonded(ri, rj):
|
||||
G.add_edge(j+1,i+1,name="special")
|
||||
|
||||
print("all",[(u,v) for u,v,d in G.edges_iter(data=True)] )
|
||||
print("all",[(u,v) for u,v,d in G.edges_iter(data=True)])
|
||||
esolute = [(u,v,d) for u,v,d in G.edges_iter(data=True) if (u in solute or v in solute) and d['name']=='hbond' ]
|
||||
print("solute-solute",esolute)
|
||||
|
||||
|
|
@ -157,10 +157,10 @@ class MySystem(object):
|
|||
print("double solute",esolute2)
|
||||
|
||||
esolvent= [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solvent and v in solvent) and d['name']=='hbond']
|
||||
print("solvent-solvent",esolvent )
|
||||
print("solvent-solvent",esolvent)
|
||||
|
||||
especial= [(u,v) for u,v,d in G.edges_iter(data=True) if d['name']=='special' ]
|
||||
print(especial )
|
||||
print(especial)
|
||||
|
||||
G=nx.relabel_nodes(G,lambda x: str(x))
|
||||
pos0=nx.spectral_layout(G)
|
||||
|
|
@ -217,7 +217,7 @@ class MySystem(object):
|
|||
elif GenericResidue.spec_bonded(self.reslist[i], self.reslist[j]):
|
||||
G.add_edge(i+1,j+1,name="special")
|
||||
|
||||
print("all",[(u,v) for u,v,d in G.edges_iter(data=True)] )
|
||||
print("all",[(u,v) for u,v,d in G.edges_iter(data=True)])
|
||||
esolute = [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solute or v in solute) and d['name']=='hbond' ]
|
||||
print(esolute)
|
||||
|
||||
|
|
@ -225,10 +225,10 @@ class MySystem(object):
|
|||
print(esolute2)
|
||||
|
||||
esolvent= [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solvent and v in solvent) and d['name']=='hbond']
|
||||
print(esolvent )
|
||||
print(esolvent)
|
||||
|
||||
especial= [(u,v) for u,v,d in G.edges_iter(data=True) if d['name']=='special' ]
|
||||
print(especial )
|
||||
print(especial)
|
||||
|
||||
pos0=nx.spectral_layout(G)
|
||||
pos=nx.spring_layout(G,iterations=500,pos=pos0)
|
||||
|
|
@ -415,8 +415,8 @@ class MySystem(object):
|
|||
|
||||
def info(self):
|
||||
for tag,res in self.residues.iteritems():
|
||||
print(tag )
|
||||
print(res )
|
||||
print(tag)
|
||||
print(res)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# sim0 = MySystem("test")
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class PDBAtomParser(object):
|
|||
|
||||
@staticmethod
|
||||
def record(name,buf):
|
||||
# print(inspect.getsource(PDBAtomParser.recordName) )
|
||||
# print(inspect.getsource(PDBAtomParser.recordName))
|
||||
ir=PDBAtomParser.irec[name]
|
||||
atype=PDBAtomParser.atype[name]
|
||||
value = buf[ir[0]:ir[1]]
|
||||
|
|
@ -59,7 +59,7 @@ class PDBAtomParser(object):
|
|||
@staticmethod
|
||||
def getDict(buf):
|
||||
# d = dict((name,PDBAtomParser.record(name,buf))
|
||||
# for name in PDBAtomParser.irec.iterkeys() )
|
||||
# for name in PDBAtomParser.irec.iterkeys())
|
||||
d={}
|
||||
for name in PDBAtomParser.irec.iterkeys():
|
||||
value=PDBAtomParser.record(name,buf)
|
||||
|
|
@ -82,8 +82,8 @@ if __name__ == '__main__':
|
|||
aline2="ATOM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
aline3="ATTM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
|
||||
print(PDBAtomParser.record("name",aline2) )
|
||||
print(PDBAtomParser.record("name",aline1) )
|
||||
print(PDBAtomParser.record("name",aline2))
|
||||
print(PDBAtomParser.record("name",aline1))
|
||||
print(PDBAtomParser.getDict(aline1))
|
||||
print(PDBAtomParser.getDict(aline2))
|
||||
print(PDBAtomParser.getDict(aline3))
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class PDBAtomRecord(object):
|
|||
returns value of the "name" field in the provided "buf" buffer
|
||||
always returns None value if buffer is not of ATOM or HETATM type
|
||||
'''
|
||||
# print(inspect.getsource(PDBAtomRecord.fieldName) )
|
||||
# print(inspect.getsource(PDBAtomRecord.fieldName))
|
||||
if not PDBAtomRecord.test(buf):
|
||||
return None
|
||||
ir=PDBAtomRecord.irec[name]
|
||||
|
|
@ -91,8 +91,8 @@ if __name__ == '__main__':
|
|||
aline2="ATOM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
aline3="ATTM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
|
||||
print(PDBAtomRecord.field("name",'') )
|
||||
print(PDBAtomRecord.field("name",aline3) )
|
||||
print(PDBAtomRecord.field("name",''))
|
||||
print(PDBAtomRecord.field("name",aline3))
|
||||
print(PDBAtomRecord.dct(aline1))
|
||||
print(PDBAtomRecord.dct(aline2))
|
||||
print(PDBAtomRecord.dct(aline3))
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ if __name__ == '__main__':
|
|||
|
||||
print("The distance between these two atoms is", Atom.bondlength(a, b))
|
||||
|
||||
print("PDB record for second atom with starting index 5 and resid 23" )
|
||||
print("PDB record for second atom with starting index 5 and resid 23")
|
||||
print(b.toPDBrecord(id_atom=5,id_res=23))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ large format 6 digits can be used. However, for applications it is
|
|||
useful to be able to convert to and from the large format.
|
||||
|
||||
The large format is specified by providing the PDB keyword "LRGPDB"
|
||||
before the first "ATOM" or "HETATM" keywork.
|
||||
before the first "ATOM" or "HETATM" keyword.
|
||||
|
||||
This converter detects what format the input PDB file is in and
|
||||
generates a PDB output file in the other format.
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ Features:
|
|||
Builtin PlotItem types:
|
||||
|
||||
* 'Data(array1)' -- data from a Python list or NumPy array
|
||||
(permits additional option 'cols' )
|
||||
(permits additional option 'cols')
|
||||
* 'File("filename")' -- data from an existing data file (permits
|
||||
additional option 'using' )
|
||||
additional option 'using')
|
||||
* 'Func("exp(4.0 * sin(x))")' -- functions (passed as a string
|
||||
for gnuplot to evaluate)
|
||||
* 'GridData(m, x, y)' -- data tabulated on a grid of (x,y) values
|
||||
|
|
@ -245,7 +245,7 @@ class Func(PlotItem):
|
|||
|
||||
gnuplot> plot sin(x)
|
||||
|
||||
The argument to the contructor is a string which is a expression.
|
||||
The argument to the constructor is a string which is a expression.
|
||||
Example:
|
||||
|
||||
g.plot(Func("sin(x)", with_="line 3"))
|
||||
|
|
@ -302,10 +302,10 @@ def write_array(f, set,
|
|||
A general recursive array writer. The last four parameters allow a
|
||||
great deal of freedom in choosing the output format of the
|
||||
array. The defaults for those parameters give output that is
|
||||
gnuplot-readable. But using, for example, ( ',', '{', '}', ',\\n'
|
||||
) would output an array in a format that Mathematica could
|
||||
read. item_sep should not contain '%' (or if it does, it should be
|
||||
escaped to '%%' ) since item_sep is put into a format string.
|
||||
gnuplot-readable. But using, for example, ( ',', '{', '}', ',\\n')
|
||||
would output an array in a format that Mathematica could read.
|
||||
item_sep should not contain '%' (or if it does, it should be
|
||||
escaped to '%%') since item_sep is put into a format string.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ class File(PlotItem):
|
|||
'<file>' can be either a string holding the filename of an
|
||||
existing file, or it can be an object of a class derived from
|
||||
'AnyFile' (such as a 'TempArrayFile'). Keyword arguments
|
||||
recognized (in addition to those recognized by 'PlotItem' ):
|
||||
recognized (in addition to those recognized by 'PlotItem'):
|
||||
|
||||
'using=<n>' -- plot that column against line number
|
||||
'using=<tuple>' -- plot using a:b:c:d etc.
|
||||
|
|
@ -611,7 +611,7 @@ class Gnuplot:
|
|||
options; a string, which is plotted as a Func; or
|
||||
anything else, which is plotted as a Data.
|
||||
'hardcopy' -- replot the plot to a postscript file (if filename
|
||||
argument is specified) or pipe it to lpr othewise.
|
||||
argument is specified) or pipe it to lpr otherwise.
|
||||
If the option `color' is set to true, then output
|
||||
color postscript.
|
||||
'replot' -- replot the old items, adding any arguments as
|
||||
|
|
@ -769,7 +769,7 @@ class Gnuplot:
|
|||
'splot(item, ...)' -- Clear the current plot and create a new
|
||||
3-d plot containing the specified items. Arguments can
|
||||
be of the following types:
|
||||
'PlotItem' (e.g., 'Data', 'File', 'Func', 'GridData' ) -- This
|
||||
'PlotItem' (e.g., 'Data', 'File', 'Func', 'GridData') -- This
|
||||
is the most flexible way to call plot because the
|
||||
PlotItems can contain suboptions. Moreover, PlotItems
|
||||
can be saved to variables so that their lifetime is
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import array
|
|||
|
||||
'''
|
||||
A simple class and helper functions to read and compute with a
|
||||
Guassian cube file as produced by NWChem with the DPLOT module.
|
||||
Gaussian cube file as produced by NWChem with the DPLOT module.
|
||||
It can read the file (or tabulate any function) and then compute the
|
||||
value at an arbitrary interior point using tri-linear interpolation.
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ def read_i_f_f_f(f):
|
|||
return int(line[0]), float(line[1]), float(line[2]), float(line[3])
|
||||
|
||||
def read_atom(f):
|
||||
''' Read line from Guassian cube file containing atomic info '''
|
||||
''' Read line from Gaussian cube file containing atomic info '''
|
||||
line = f.readline().lstrip().rstrip().split()
|
||||
return int(line[0]), (float(line[2]), float(line[3]), float(line[4]))
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ def numderiv(func,x,step,eps):
|
|||
|
||||
Some care is taken to adjust the step so that the gradient and
|
||||
Hessian diagonal are estimated with about 4 digits of precision
|
||||
but some noise is unavaoidable due either to the noise in the
|
||||
but some noise is unavoidable due either to the noise in the
|
||||
function or cubic/higher terms in the Taylor expansion.
|
||||
'''
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ def geom_set_coords(name,coords):
|
|||
|
||||
def bond_length(i,j): # atoms numbered 1,2,...
|
||||
#
|
||||
# Return the distance betwen atoms i and j in user
|
||||
# Return the distance between atoms i and j in user
|
||||
# units in the default geometry
|
||||
#
|
||||
coords = geom_get_coords('geometry')
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from string import uppercase
|
|||
|
||||
class Excel:
|
||||
'''
|
||||
Wrapper for MS Excel derived from that in Python Programing on Win32
|
||||
Wrapper for MS Excel derived from that in Python Programming on Win32
|
||||
'''
|
||||
def __init__(self,filename=None):
|
||||
'''
|
||||
|
|
@ -125,7 +125,7 @@ class Excel:
|
|||
|
||||
Optionally, you specify only the top-left corner of range in
|
||||
row1, cell1 and specify row2<=0 - the other coordinate is figured
|
||||
out from the dimension of the data. This can always be overriden by
|
||||
out from the dimension of the data. This can always be overridden by
|
||||
specifying the full range coordinates.
|
||||
|
||||
If no coordinates are given, the data is put into the top left
|
||||
|
|
@ -146,7 +146,7 @@ class Excel:
|
|||
|
||||
def getContiguousRange(self, row1, col1, sheet=1):
|
||||
'''
|
||||
Returns data in the range which forms a continguous
|
||||
Returns data in the range which forms a contiguous
|
||||
block with top-left corner in cell (row1,col1).
|
||||
|
||||
Starting from the specified cell, scan down/across
|
||||
|
|
@ -208,14 +208,14 @@ class Excel:
|
|||
|
||||
charttype = 'xy' ... XY scatter plot with lines and points.
|
||||
. First series is X. Others are y1, y2, etc.
|
||||
. = 'surface' ... Surfce plot of a scalar function of
|
||||
. = 'surface' ... Surface plot of a scalar function of
|
||||
. two variables. Data should be a grid of the function.
|
||||
. = 'contour' or 'colorcontour' ... Contour plot of a scalar
|
||||
. function of two variables. Data should be a grid of
|
||||
. values.
|
||||
xmin and xmax = min/max values of the x or category axis
|
||||
. It defaults to autoscale by Excel. This only applies to
|
||||
. XY plots (since the surfce/contor plots do not use
|
||||
. XY plots (since the surface/contor plots do not use
|
||||
. values for the category axes ... they use string labels)
|
||||
ymin and ymax = min/max values of the y or value axis
|
||||
. It defaults to auto by Excel. Applies to all charts.
|
||||
|
|
@ -239,7 +239,7 @@ class Excel:
|
|||
try:
|
||||
charttype = charttypes[charttype]
|
||||
except KeyError:
|
||||
print('Excel.chartSelectedRange: Unkown charttype', charttype, ' defaulting to XY')
|
||||
print('Excel.chartSelectedRange: Unknown charttype', charttype, ' defaulting to XY')
|
||||
charttype = charttypes['xy']
|
||||
|
||||
# Make the chart and set how the data will be interpreted
|
||||
|
|
@ -307,21 +307,21 @@ class Excel:
|
|||
|
||||
def a1(self, row, col, absrow=0, abscol=0):
|
||||
'''
|
||||
Return a string that may be used to adress the cell in
|
||||
a formula. The row and/or column adress may be made absolute
|
||||
Return a string that may be used to address the cell in
|
||||
a formula. The row and/or column address may be made absolute
|
||||
by setting absrow/col to true values.
|
||||
|
||||
Internally we are adressing cells in the spreadsheet using
|
||||
Internally we are addressing cells in the spreadsheet using
|
||||
integers (row,col), which is what Excel calls R1C1 style
|
||||
references. But, unless the user has turned-on R1C1 style
|
||||
adressing (unlikely!) this will not work in formulae
|
||||
so we must translate to the usual adressing style, called A1,
|
||||
addressing (unlikely!) this will not work in formulae
|
||||
so we must translate to the usual addressing style, called A1,
|
||||
which uses letters for the columns and numbers for the rows,
|
||||
writing the column index first.
|
||||
|
||||
E.g., A1 = R1C1 = (1,1), and B3 = R3C2 = (3,2).
|
||||
|
||||
Absolute adresses are preceded with a $ symbol.
|
||||
Absolute addresses are preceded with a $ symbol.
|
||||
'''
|
||||
ar = ac = ''
|
||||
if absrow: ar = '$'
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#
|
||||
# f(x,y) := (x+y)^2*h(x,y) - x^2*h(x,0) - y^2*h(0,y)
|
||||
#
|
||||
# so we need to distinguish every invokation based on the arguments passed in.
|
||||
# so we need to distinguish every invocation based on the arguments passed in.
|
||||
# In addition, in our case, h is actually implemented as a subroutine that
|
||||
# returns the function value and the values of the various derivatives. The
|
||||
# inputs and outputs are stored in arrays. The steps required are:
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ class Window:
|
|||
# right projection
|
||||
#
|
||||
# 6/18/03 we promoted right projection logic here, just to reserve
|
||||
# the same consequtive sets of indexes for the externals.
|
||||
# the same consecutive sets of indexes for the externals.
|
||||
# If externals have different indexes, the factorization will
|
||||
# break. The actual insertion of right projection occurs later.
|
||||
#
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def stringtooperatorsequence(expression):
|
|||
"""Converts a string to an operatorsequence object"""
|
||||
# Syntax of the string is rather loosely defined as:
|
||||
# (1) Numerical factor (with no permutation allowed) (optional), summation (optional), amplitudes (optional), normal ordered sequence,
|
||||
# (2) Numerical factor can be an arithmatic expression such as (1.0/4.0),
|
||||
# (2) Numerical factor can be an arithmetic expression such as (1.0/4.0),
|
||||
# (3) Summation starts with either "SUM" or "sum" followed by a parenthesis of indexes,
|
||||
# (4) Indexes can be either in one-letter notation (a-h, A-H for virtuals, i-o, I-O for occupieds, p-z, P-Z for either, case matters)
|
||||
# or in OCE notation (p1,p2 for virtuals, h3,h4 for occupieds, g5,g6 for either, no overlap in numbering)
|
||||
|
|
@ -745,7 +745,7 @@ class Factor:
|
|||
raise RuntimeError("unrealistic factor")
|
||||
fraction = abs(int(1.0/coefficient))
|
||||
if (1.0/float(fraction) != abs(coefficient)):
|
||||
print(" !!! WARNING !!! inaccurate arithmatic")
|
||||
print(" !!! WARNING !!! inaccurate arithmetic")
|
||||
if (fraction == 1):
|
||||
frac = ""
|
||||
else:
|
||||
|
|
@ -1903,7 +1903,7 @@ class ListOperatorSequences:
|
|||
print(" ! Warning! a cyclic contraction is found")
|
||||
# self.simplifythree(verbose)
|
||||
self.simplifytwo(verbose)
|
||||
# the followings do not seem to affect the result, yet it costs enormous memory & time
|
||||
# the following do not seem to affect the result, yet it costs enormous memory & time
|
||||
# self.simplifyfour(1)
|
||||
self = copy.deepcopy(self.deletezero())
|
||||
return self
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ def picknfromlist(n,list):
|
|||
return result
|
||||
|
||||
def pick1fromlist(choices,list):
|
||||
"""Appends one additional non-overlapping choice of an integer from the list to the exisiting choices"""
|
||||
"""Appends one additional non-overlapping choice of an integer from the list to the existing choices"""
|
||||
newchoices = []
|
||||
for choice in choices:
|
||||
for i in list:
|
||||
|
|
@ -672,7 +672,7 @@ class Factor:
|
|||
if (abs(coefficient) < 1.0):
|
||||
fraction = abs(int(1.0/coefficient))
|
||||
if (1.0/float(fraction) != abs(coefficient)):
|
||||
print(" !!! WARNING !!! inaccurate arithmatic")
|
||||
print(" !!! WARNING !!! inaccurate arithmetic")
|
||||
if (fraction == 1):
|
||||
frac = ""
|
||||
else:
|
||||
|
|
@ -718,7 +718,7 @@ class Factor:
|
|||
if (abs(coefficient) < 1.0):
|
||||
fraction = abs(int(1.0/coefficient))
|
||||
if (1.0/float(fraction) != abs(coefficient)):
|
||||
print(" !!! WARNING !!! inaccurate arithmatic")
|
||||
print(" !!! WARNING !!! inaccurate arithmetic")
|
||||
if (fraction == 1):
|
||||
frac = ""
|
||||
else:
|
||||
|
|
@ -2612,7 +2612,7 @@ class ListTensorContractions:
|
|||
return self
|
||||
|
||||
def pythongen(self,filename="NONAME"):
|
||||
"""Genrates a python code for debugging purposes"""
|
||||
"""Generates a python code for debugging purposes"""
|
||||
|
||||
pythoncode = []
|
||||
newline = "# This is a Python program generated by Tensor Contraction Engine v.1.0"
|
||||
|
|
@ -5777,12 +5777,12 @@ class OperationTree:
|
|||
nselfindex = len(selfcopy.contraction.tensors[0].indexes)
|
||||
if (nselfindex != len(anothercopy.contraction.tensors[0].indexes)):
|
||||
if (verbose):
|
||||
print("output tensors imcompatible")
|
||||
print("output tensors incompatible")
|
||||
return 0
|
||||
for nindex in range(nselfindex):
|
||||
if (not selfcopy.contraction.tensors[0].indexes[nindex].isidenticalto(anothercopy.contraction.tensors[0].indexes[nindex])):
|
||||
if (verbose):
|
||||
print("output tensors imcompatible")
|
||||
print("output tensors incompatible")
|
||||
return 0
|
||||
|
||||
# check if the factors (permutation operators) are compatible
|
||||
|
|
@ -7010,7 +7010,7 @@ class OperationTree:
|
|||
return newcode
|
||||
|
||||
def pythongen(self,filename="NONAME"):
|
||||
"""Genrates a python code for debugging purposes"""
|
||||
"""Generates a python code for debugging purposes"""
|
||||
|
||||
pythoncode = []
|
||||
|
||||
|
|
@ -7139,7 +7139,7 @@ class OperationTree:
|
|||
return pythoncode
|
||||
|
||||
def fortran90(self,filename="NONAME",mode="nopermutation",excitation=[],deexcitation=[],intermediate=[],general=[]):
|
||||
"""Genrates a partial Fortran90 code for debugging purposes"""
|
||||
"""Generates a partial Fortran90 code for debugging purposes"""
|
||||
# Mode = "permutation" : writes a code which takes index permutation into account
|
||||
# Mode = "nopermutation" : writes a code without index permutation considered
|
||||
# Mode = "analysis" : stdouts a plan of implementation with index permutation
|
||||
|
|
@ -7345,7 +7345,7 @@ class OperationTree:
|
|||
subcommon = subcommonone
|
||||
else:
|
||||
subcommon = supercommontwo
|
||||
# DEEXCITATION EXTENTION FROM HERE ...
|
||||
# DEEXCITATION EXTENSION FROM HERE ...
|
||||
superlocalparticleone = []
|
||||
superlocalparticletwo = []
|
||||
superlocalholeone = []
|
||||
|
|
@ -9470,7 +9470,7 @@ class Code:
|
|||
self.statements = copy.deepcopy(newstatements)
|
||||
|
||||
def removeredundantio(self):
|
||||
"""Removes unneccesary GATODRA-DRATOGA pairs"""
|
||||
"""Removes unnecessary GATODRA-DRATOGA pairs"""
|
||||
|
||||
newstatements = []
|
||||
temporary = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue