From 443bf15cdf8796eaacc3fba2efcd1564f2ad4805 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Sat, 19 Dec 2020 13:48:18 -0500 Subject: [PATCH 1/3] help the reimport problem --- tools/pcmparser.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/pcmparser.py b/tools/pcmparser.py index 268020cea..9965195d0 100644 --- a/tools/pcmparser.py +++ b/tools/pcmparser.py @@ -44,7 +44,6 @@ from copy import deepcopy import re -from .getkw import Section, GetkwParser from .pcmdata import CODATAdict, allowedSolvents isAngstrom = False @@ -80,6 +79,9 @@ def parse_pcm_input(inputFile, write_out=False): ... """ + from importlib import reload + from . import getkw + # Set up valid keywords. valid_keywords = setup_keywords() @@ -88,7 +90,8 @@ def parse_pcm_input(inputFile, write_out=False): # Set up a GetKw object and let it parse our input: # here is where the magic happens. - inkw = GetkwParser().parseFile(uppercased) + getkw = reload(getkw) + inkw = getkw.GetkwParser().parseFile(uppercased) # Remove temporary file os.remove(uppercased) inkw.sanitize(valid_keywords) @@ -153,6 +156,8 @@ def setup_keywords(): """ Sets up sections, keywords and respective callback functions. """ + from .getkw import Section + # Top-level section top = Section('toplevel', callback=verify_top) top.set_status(True) From dc41801bdf83013d77343014006f36827ec4e4c1 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Sat, 19 Dec 2020 23:47:46 -0500 Subject: [PATCH 2/3] silence some abc warnings --- tools/pyparsing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/pyparsing.py b/tools/pyparsing.py index a3006c109..c24430d6b 100644 --- a/tools/pyparsing.py +++ b/tools/pyparsing.py @@ -795,7 +795,7 @@ def __dir__(self): return dir(super(ParseResults, self)) + list(self.keys()) -collections.MutableMapping.register(ParseResults) +collections.abc.MutableMapping.register(ParseResults) def col(loc, strg): @@ -2386,7 +2386,7 @@ def __init__(self, exprs, savelist=False): if isinstance(exprs, basestring): self.exprs = [Literal(exprs)] - elif isinstance(exprs, collections.Sequence): + elif isinstance(exprs, collections.abc.Sequence): # if sequence of strings provided, wrap with Literal if all(isinstance(expr, basestring) for expr in exprs): exprs = map(Literal, exprs) @@ -3439,7 +3439,7 @@ def oneOf(strs, caseless=False, useRegex=True): symbols = [] if isinstance(strs, basestring): symbols = strs.split() - elif isinstance(strs, collections.Sequence): + elif isinstance(strs, collections.abc.Sequence): symbols = list(strs[:]) elif isinstance(strs, _generatorType): symbols = list(strs) From 4d0418087b990700d3aea4c4bda2e34055c925d8 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Tue, 22 Dec 2020 00:08:59 -0500 Subject: [PATCH 3/3] avoid filename conflicts in parallel --- src/cavity/ICavity.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cavity/ICavity.cpp b/src/cavity/ICavity.cpp index 842c48907..8dbac31a1 100644 --- a/src/cavity/ICavity.cpp +++ b/src/cavity/ICavity.cpp @@ -57,28 +57,30 @@ ICavity::ICavity(const Molecule & molec) } void ICavity::saveCavity(const std::string & fname) { + std::string ffname = std::tmpnam(nullptr); + // Write everything in a single .npz binary file unsigned int dim = static_cast(nElements_); // Write the number of elements, it will be used to check sanity of the save/load // operations. const unsigned int shape[] = {1}; - cnpy::npz_save(fname, "elements", &dim, shape, 1, "w", false); + cnpy::npz_save(ffname, "elements", &dim, shape, 1, "w", false); // Write weights - cnpy::custom::npz_save(fname, "weights", elementArea_); + cnpy::custom::npz_save(ffname, "weights", elementArea_); // Write element sphere center - cnpy::custom::npz_save(fname, "elSphCenter", elementSphereCenter_); + cnpy::custom::npz_save(ffname, "elSphCenter", elementSphereCenter_); // Write element radius - cnpy::custom::npz_save(fname, "elRadius", elementRadius_); + cnpy::custom::npz_save(ffname, "elRadius", elementRadius_); // Write centers - cnpy::custom::npz_save(fname, "centers", elementCenter_); + cnpy::custom::npz_save(ffname, "centers", elementCenter_); // Write normals - cnpy::custom::npz_save(fname, "normals", elementNormal_); + cnpy::custom::npz_save(ffname, "normals", elementNormal_); for (PCMSolverIndex i = 0; i < nElements_; ++i) { // Write vertices cnpy::custom::npz_save( - fname, "vertices_" + pcm::to_string(i), elements_[i].vertices()); + ffname, "vertices_" + pcm::to_string(i), elements_[i].vertices()); // Write arcs - cnpy::custom::npz_save(fname, "arcs_" + pcm::to_string(i), elements_[i].arcs()); + cnpy::custom::npz_save(ffname, "arcs_" + pcm::to_string(i), elements_[i].arcs()); } }