Skip to content

Commit 8ccf101

Browse files
committed
Quick update of several doc strings
1 parent e2345d5 commit 8ccf101

File tree

3 files changed

+147
-24
lines changed

3 files changed

+147
-24
lines changed

mbuild/path/bias.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, site_type, weight, system_coordinates, new_coordinates):
5858
super(TargetType, self).__init__(system_coordinates, new_coordinates)
5959

6060
def __call__(self):
61-
pass
61+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
6262

6363

6464
class AvoidType(Bias):
@@ -69,7 +69,7 @@ def __init__(self, site_type, weight, system_coordinates, new_coordinates):
6969
super(AvoidType, self).__init__(system_coordinates, new_coordinates)
7070

7171
def __call__(self):
72-
pass
72+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
7373

7474

7575
class TargetEdge(Bias):
@@ -80,7 +80,7 @@ def __init__(self, weight, system_coordinates, volume_constraint, new_coordinate
8080
super(TargetEdge, self).__init__(system_coordinates, new_coordinates)
8181

8282
def __call__(self):
83-
pass
83+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
8484

8585

8686
class AvoidEdge(Bias):
@@ -91,7 +91,7 @@ def __init__(self, weight, system_coordinates, volume_constraint, new_coordinate
9191
super(AvoidEdge, self).__init__(system_coordinates, new_coordinates)
9292

9393
def __call__(self):
94-
pass
94+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
9595

9696

9797
class TargetDirection(Bias):
@@ -102,7 +102,7 @@ def __init__(self, direction, weight, system_coordinates, new_coordinates):
102102
super(TargetDirection, self).__init__(system_coordinates, new_coordinates)
103103

104104
def __call__(self):
105-
pass
105+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
106106

107107

108108
class AvoidDirection(Bias):
@@ -113,7 +113,7 @@ def __init__(self, direction, weight, system_coordinates, new_coordinates):
113113
super(AvoidDirection, self).__init__(system_coordinates, new_coordinates)
114114

115115
def __call__(self):
116-
pass
116+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
117117

118118

119119
class TargetPath(Bias):
@@ -124,4 +124,4 @@ def __init__(self, target_path, weight, system_coordinates, new_coordinates):
124124
super(TargetPath, self).__init__(system_coordinates, new_coordinates)
125125

126126
def __call__(self):
127-
pass
127+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")

mbuild/path/path.py

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313

1414

1515
class Path:
16+
"""Creates a path from a given set of coordinates and a bond graph.
17+
This class is designed to be use in mbuild.polymer.Polymer.build_from_path().
18+
This also serves as the base class from which other paths inherit from.
19+
20+
Parameters
21+
----------
22+
N : int, optional
23+
The number of sites belonging to the path.
24+
coordinates : array-like, optional
25+
Creates a path from a pre-defined set of coordinates
26+
bond_graph : networkx.Graph, optional
27+
The graph defining the edges between coordinates
28+
"""
1629
def __init__(self, N=None, coordinates=None, bond_graph=None):
1730
self.bond_graph = bond_graph
1831
# Only N is defined, make empty coordinates array with size N
@@ -67,10 +80,10 @@ def add_edge(self, u, v):
6780
length=float(bond_length),
6881
bond_type=(u_name, v_name),
6982
)
70-
83+
7184
def get_bonded_sites(self):
7285
"""Get all bonded pairs and their bond-vector orientations."""
73-
pass
86+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
7487

7588
def get_coordinates(self):
7689
if isinstance(self.coordinates, list):
@@ -99,6 +112,7 @@ def apply_mapping(self):
99112
"""Mapping other compounds onto a Path's coordinates
100113
101114
mapping = {"A": "c1ccccc1C=C", "B": "C=CC=C"}
115+
mapping = {"A": mb.Compound, "B": mb.Compound}
102116
103117
for bond in bond graph edges:
104118
site u: add compound
@@ -108,7 +122,7 @@ def apply_mapping(self):
108122
set orientation and separation for site v tail port
109123
110124
"""
111-
pass
125+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
112126

113127
def _path_history(self):
114128
"""Maybe this is a method that can be used optionally.
@@ -117,7 +131,7 @@ def _path_history(self):
117131
computation time and resources.
118132
Might be useful for more complicated random walks/branching algorithms
119133
"""
120-
pass
134+
raise NotImplementedError("This feature of mBuild 2.0 has not been implemented yet.")
121135

122136

123137
class HardSphereRandomWalk(Path):
@@ -159,6 +173,23 @@ def __init__(
159173
max_angle : float, required
160174
Maximum angle (radians) used when randomly selecting angle
161175
for the next step.
176+
bead_name : str, default = "_A"
177+
The name assigned to each site in this random walk.
178+
volume_constraint : mbuild.utils.volumes.Constraint, optional
179+
Used to reject moves which are outside of the volume constraint
180+
start_from_path : mbuild.path.Path, optional
181+
An instance of a previous Path to start the random walk from.
182+
This path's sites are used in checking for overlapping sites.
183+
start_from_path_index : int, optional
184+
An index of `start_from_path` used as the starting point for this random walk.
185+
attach_paths : bool, default = False
186+
If True, adds an edge between the starting point of the last path and the first
187+
point of this path.
188+
initial_point : array-like, optional
189+
Used as the coordinate for the first site in this random walk path.
190+
include_compound : mb.Compound, optional
191+
An mBuild compound that is considered in this random walk.
192+
This random walk with reject new points that overlap with the Compound's coordinates.
162193
seed : int, default = 42
163194
Random seed
164195
trial_batch_size : int, default = 5
@@ -167,15 +198,7 @@ def __init__(
167198
random walks.
168199
max_attempts : int, default = 1e5
169200
The maximum number of trial moves to attempt before quiting.
170-
start_from_path : mbuild.path.Path, optional
171-
An instance of a previous Path to start the random walk from.
172-
start_from_path_index : int, optional
173-
The index of `start_from_path` to use as the initial point
174201
for the random walk.
175-
attach_paths : bool, default = False
176-
If True, an edge will be created in the bond graph between
177-
the last point of `start_from_path` and the first point of
178-
this random walk.
179202
tolerance : float, default = 1e-4
180203
Tolerance used for rounding and checking for overlaps.
181204
@@ -776,12 +799,28 @@ def generate(self):
776799

777800

778801
class ZigZag(Path):
802+
"""Generates a path following a zig-zag pattern in a given plane.
803+
804+
Parameters
805+
----------
806+
spacing : float, default = 1.0
807+
The distance between consecutive sites along the path.
808+
angle_deg : float, default = 120.
809+
The rotation applied between segments
810+
sites_per_segment : int, default = 4
811+
The number of sites before rotating and beginning next segment.
812+
plane : str, default = "xy"
813+
The plane that the sites in the path occupy
814+
bond_graph : networkx.Graph
815+
Defines connectivity between sites
816+
817+
"""
779818
def __init__(
780819
self,
781820
N,
782821
spacing=1.0,
783822
angle_deg=120.0,
784-
sites_per_segment=1,
823+
sites_per_segment=4,
785824
plane="xy",
786825
bond_graph=None,
787826
):

mbuild/utils/volumes.py

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33

44

55
class Constraint:
6+
"""
7+
Defines a volume that acts as a constraint in mbuild.path.HardSphereRandomWalk.
8+
This is the base class from which all constraints inherit from.
9+
10+
Notes
11+
-----
12+
Design and implement your own volume constraint by inheriting from this class
13+
and implementing the constraint check in an `is_inside` method.
14+
15+
`is_inside` is expected to return a mask of booleans.
16+
17+
The existing contraints of CuboidConstraint, SphereConstraint, and CylinderConstraint
18+
call numba methods from their respectice `is_inside` method, but that is not a required
19+
implementation to design your own constraint.
20+
"""
621
def __init__(self):
722
pass
823

@@ -12,32 +27,89 @@ def is_inside(self, points, buffer):
1227

1328

1429
class CuboidConstraint(Constraint):
30+
"""Creates a cuboid constraint.
31+
32+
Parameters
33+
----------
34+
Lx : float, required
35+
The length of the volume along the x-axis.
36+
Ly : float, required
37+
The length of the volume along the y-axis.
38+
Lz : float, required
39+
The length of the volume along the z-axis.
40+
center : array-like (1,3), default = (0, 0, 0)
41+
Defines the center of the volume.
42+
"""
1543
def __init__(self, Lx, Ly, Lz, center=(0, 0, 0)):
1644
self.center = np.asarray(center)
1745
self.mins = self.center - np.array([Lx / 2, Ly / 2, Lz / 2])
1846
self.maxs = self.center + np.array([Lx / 2, Ly / 2, Lz / 2])
1947

2048
def is_inside(self, points, buffer):
21-
"""Points and buffer are passed in from HardSphereRandomWalk"""
49+
"""Check a set of coordinates against the volume constraint.
50+
51+
Parameters
52+
----------
53+
points : ndarray (N, 3), required
54+
The set of points to check against the volume constraint.
55+
buffer : float, required
56+
Buffer used for rounding
57+
58+
Returns
59+
-------
60+
Mask of booleans of length N corresponding to each point.
61+
"""
2262
return is_inside_cuboid(
2363
mins=self.mins, maxs=self.maxs, points=points, buffer=buffer
2464
)
2565

2666

2767
class SphereConstraint(Constraint):
68+
"""Creates a spherical constraint.
69+
70+
Parameters
71+
----------
72+
radius : float, required
73+
The radius of the sphere
74+
center : array-like (1,3), default = (0, 0, 0)
75+
Defines the center point of the sphere.
76+
"""
2877
def __init__(self, center, radius):
2978
self.center = np.array(center)
3079
self.radius = radius
3180
self.mins = self.center - self.radius
3281
self.maxs = self.center + self.radius
3382

3483
def is_inside(self, points, buffer):
35-
"""Points and buffer are passed in from HardSphereRandomWalk"""
84+
"""Check a set of coordinates against the volume constraint.
85+
86+
Parameters
87+
----------
88+
points : ndarray (N, 3), required
89+
The set of points to check against the volume constraint.
90+
buffer : float, required
91+
Buffer used for rounding
92+
93+
Returns
94+
-------
95+
Mask of booleans of length N corresponding to each point.
96+
"""
3697
return is_inside_sphere(points=points, sphere_radius=self.radius, buffer=buffer)
3798

3899

39100
class CylinderConstraint(Constraint):
40-
def __init__(self, center, radius, height):
101+
"""Creates a cylindrical constraint.
102+
103+
Parameters
104+
----------
105+
radius : float, required
106+
The radius of the cylinder
107+
height : float, required
108+
The height of the cylinder
109+
center : array-like (1,3), default = (0, 0, 0)
110+
Defines the center point of the sphere.
111+
"""
112+
def __init__(self, radius, height, center=(0, 0, 0)):
41113
self.center = np.array(center)
42114
self.height = height
43115
self.radius = radius
@@ -57,7 +129,19 @@ def __init__(self, center, radius, height):
57129
)
58130

59131
def is_inside(self, points, buffer):
60-
"""Points and buffer are passed in from HardSphereRandomWalk"""
132+
"""Check a set of coordinates against the volume constraint.
133+
134+
Parameters
135+
----------
136+
points : ndarray (N, 3), required
137+
The set of points to check against the volume constraint.
138+
buffer : float, required
139+
Buffer used for rounding
140+
141+
Returns
142+
-------
143+
Mask of booleans of length N corresponding to each point.
144+
"""
61145
return is_inside_cylinder(
62146
points=points,
63147
center=self.center,

0 commit comments

Comments
 (0)