11import operator
2+ from functools import partial
23from paths_cli .wizard .parameters import ProxyParameter
34from paths_cli .wizard .plugin_classes import (
45 LoadFromOPS , WizardParameterObjectPlugin , WizardObjectPlugin ,
78from paths_cli .wizard .helper import EvalHelperFunc , Helper
89from paths_cli .wizard .core import interpret_req
910import paths_cli .compiling .volumes
10- from functools import partial
11+
1112
1213def _binary_func_volume (wizard , context , op ):
1314 wizard .say ("Let's make the first constituent volume:" )
@@ -28,6 +29,7 @@ def _binary_func_volume(wizard, context, op):
2829_LAMBDA_STR = ("What is the {minmax} allowed value for "
2930 "'{{obj_dict[cv].name}}' in this volume?" )
3031
32+
3133CV_DEFINED_VOLUME_PLUGIN = WizardParameterObjectPlugin .from_proxies (
3234 name = "CV-defined volume (allowed values of CV)" ,
3335 category = "volume" ,
@@ -57,24 +59,33 @@ def _binary_func_volume(wizard, context, op):
5759 compiler_plugin = paths_cli .compiling .volumes .CV_VOLUME_PLUGIN ,
5860)
5961
62+
6063INTERSECTION_VOLUME_PLUGIN = WizardObjectPlugin (
6164 name = 'Intersection of two volumes (must be in both)' ,
6265 category = "volume" ,
6366 intro = ("This volume will be the intersection of two other volumes. "
6467 "This means that it only allows phase space points that are "
6568 "in both of the constituent volumes." ),
6669 builder = partial (_binary_func_volume , op = operator .__and__ ),
70+ description = ("Create a volume that is the intersection of two existing "
71+ "volumes -- that is, all points in this volume are in "
72+ "both of the volumes that define it." ),
6773)
6874
75+
6976UNION_VOLUME_PLUGIN = WizardObjectPlugin (
7077 name = 'Union of two volumes (must be in at least one)' ,
7178 category = "volume" ,
7279 intro = ("This volume will be the union of two other volumes. "
7380 "This means that it allows phase space points that are in "
7481 "either of the constituent volumes." ),
7582 builder = partial (_binary_func_volume , op = operator .__or__ ),
83+ description = ("Create a volume that is the union of two existing "
84+ "volumes -- that is, any point in either of the volumes "
85+ "that define this are also in this volume" ),
7686)
7787
88+
7889NEGATED_VOLUME_PLUGIN = WizardObjectPlugin (
7990 name = 'Complement of a volume (not in given volume)' ,
8091 category = 'volume' ,
@@ -83,15 +94,19 @@ def _binary_func_volume(wizard, context, op):
8394 builder = lambda wizard , context : ~ VOLUMES_PLUGIN (
8495 wizard , volume_set_context (wizard , context , None )
8596 ),
97+ description = ("Create a volume that includes every that is NOT "
98+ "in the existing volume." ),
8699)
87100
101+
88102_FIRST_STATE = ("Now let's define state states for your system. "
89103 "You'll need to define {n_states_string} of them." )
90104_ADDITIONAL_STATES = "Okay, let's define another stable state."
91105_VOL_DESC = ("You can describe this as either a range of values for some "
92106 "CV, or as some combination of other such volumes "
93107 "(i.e., intersection or union)." )
94108
109+
95110def volume_intro (wizard , context ):
96111 as_state = context .get ('depth' , 0 ) == 0
97112 n_states = len (wizard .states )
@@ -106,24 +121,32 @@ def volume_intro(wizard, context):
106121 intro += [_VOL_DESC ]
107122 return intro
108123
124+
109125def volume_set_context (wizard , context , selected ):
110126 depth = context .get ('depth' , 0 ) + 1
111127 new_context = {
112128 'depth' : depth ,
113129 }
114130 return new_context
115131
132+
116133def volume_ask (wizard , context ):
117134 as_state = context .get ('depth' , 0 ) == 0
118135 obj = {True : 'state' , False : 'volume' }[as_state ]
119136 return f"What describes this { obj } ?"
120137
138+
139+ VOLUME_FROM_FILE = LoadFromOPS ('volume' )
140+
121141VOLUMES_PLUGIN = WrapCategory (
122142 name = 'volume' ,
123143 intro = volume_intro ,
124144 ask = volume_ask ,
125145 set_context = volume_set_context ,
126- helper = "No volume help yet"
146+ helper = ("This will define a (hyper)volume in phase space. States and "
147+ "interfaces in OPS are described by volumes. You can combine "
148+ "ranges along different CVs in any way you want to defined the "
149+ "volume." )
127150)
128151
129152if __name__ == "__main__" : # no-cov
0 commit comments