Electrostatics / apbs

Software for biomolecular electrostatics and solvation calculations
http://www.poissonboltzmann.org/
Other
96 stars 26 forks source link

Share tool permabug #290

Open EvanKomp opened 6 months ago

EvanKomp commented 6 months ago

Describe the bug Error in complied code for 3.4.1 Darwin that I got from releases: share/apbs/tools/manip/inputgen.py

To Reproduce Run the setSmallest method of Psize with any input.

I don't know where this code is in the repo otherwise I would make a pull to make it look like the pdb2pwr code here https://pdb2pqr.readthedocs.io/en/v3.6.1/_modules/pdb2pqr/psize.html

Here is the current code:

    def setSmallest(self, n):
        """ Compute parallel division in case memory requirement above
        ceiling Find the smallest dimension and see if the number of
        grid points in that dimension will fit below the memory ceiling
        Reduce nsmall until an nsmall^3 domain will fit into memory """
        nsmall = []
        for i in range(3):
            nsmall.append(n[i])
        while 1:
            nsmem = 200.0 * nsmall[0] * nsmall[1] * nsmall[2] / 1024 / 1024
            if nsmem < self.constants["gmemceil"]:
                break
            else:
                i = nsmall.index(max(nsmall))
                nsmall[i] = 32 * ((nsmall[i] - 1) / 32 - 1) + 1
                if nsmall <= 0:
                    sys.stdout.write(
                        "You picked a memory ceiling that is too small\n"
                    )
                    sys.exit(0)

        self.nsmall = nsmall
        return nsmall

Line 174 if nsmall <= 0: perma raises with TypeError since nsmall is a list.

sobolevnrm commented 6 months ago

Wow... that's really bad code and I'm not sure how it got in there. I don't think psize.py gets much use. The best solution might just be deleting this file from future releases.