Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise warning if geometry is out of bounds #270

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

fgrunewald
Copy link
Member

No description provided.

@fgrunewald fgrunewald requested a review from pckroon September 8, 2022 10:26
Copy link
Member

@pckroon pckroon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks on warning formatting, and I suggest _check_geometry_def returns a boolean, that will help reuse further down the road (maybe accompanied by a name change is_sane_constraint or something).

polyply/src/build_file_parser.py Outdated Show resolved Hide resolved
polyply/src/build_file_parser.py Outdated Show resolved Hide resolved
polyply/src/build_file_parser.py Outdated Show resolved Hide resolved
polyply/src/build_file_parser.py Show resolved Hide resolved
polyply/src/build_file_parser.py Outdated Show resolved Hide resolved
@fgrunewald fgrunewald added the enhancement New feature or request label Sep 10, 2022
@fgrunewald
Copy link
Member Author

@pckroon this PR exploded little, but you were asking for it (sort of). 😄 I had to make a proper copy method for meta-molecule, because I realised that one of the tests of the build-file parser was compromised as the copy method of graph doesn't actually set attributes of the subclass. I think this is a network problem. Now that is fixed and the build file tests are stricter.

But it appears the whole testing of Logging also needs an overhaul.

raise NotImplementedError(msg)
G = self.__class__(force_field=self.force_field,
mol_name=self.mol_name)
G.molecule = self.molecule
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this one. It seems more efficient to return a molecule instead of a copy of a molecule but then it really depends on wether you want to change the molecule attributes or not. Any ideas on a sensible default, perhaps have a argument like copy_molecule=False?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmn, I'm hesitant to add extra arguments to this method. Where is this (indirectly) called?
I would err on the side of function over speed. Wrong results are worse than slow results imo.

pckroon
pckroon previously approved these changes Sep 12, 2022
@pckroon pckroon self-requested a review September 12, 2022 13:35
@pckroon pckroon dismissed their stale review September 12, 2022 13:35

Missed commits

Comment on lines +276 to +287
"""
Raise a warning if the point of reference
for the geometry type is too close to the
origin.

Parameters
----------
geom_def: dict
dict with entries: resname, start, stop, point, parameters
geom_type: str
one of sphere, cylinder, rectangle
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring needs updating

point = geom_def['parameters'][1]
if geom_type == "sphere":
radius = geom_def['parameters'][2]
if any( i >= j for i, j in zip([radius, radius, radius], point)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is checking the cardinal axes enough? Or you do need to do (point**2).sum() vs 3*radius**2?


if geom_type == "cylinder":
r, z = geom_def['parameters'][2:4]
if z >= point[2] or any(r >= j for j in point[:2]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment about radius

raise NotImplementedError(msg)
G = self.__class__(force_field=self.force_field,
mol_name=self.mol_name)
G.molecule = self.molecule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmn, I'm hesitant to add extra arguments to this method. Where is this (indirectly) called?
I would err on the side of function over speed. Wrong results are worse than slow results imo.

Comment on lines +82 to +88
with caplog.at_level(logging.WARNING):
result = polyply.src.build_file_parser.BuildDirector._base_parser_geometry(tokens, _type)
for record in caplog.records:
assert record.levelname == "WARNING"
break
else:
assert False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to test len(records)?

Comment on lines +260 to +266
copy_mol = meta_mol.copy()
assert list(meta_mol.nodes) == list(copy_mol.nodes)
assert meta_mol.force_field == copy_mol.force_field
assert meta_mol.molecule == copy_mol.molecule
for node in meta_mol.nodes:
for key, attr in meta_mol.nodes[node].items():
assert attr == copy_mol.nodes[node][key]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not thorough enough: modify copy_mol (or mol) and assert the other is not affected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants