- Timestamp:
- 08/07/20 22:26:57 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/FramsticksCLI.py
r1021 r1024 192 192 193 193 def getSimplest(self, genetic_format) -> str: 194 assert len(genetic_format) == 1, "Genetic format should be a single character"195 194 files = self.__runCommand(self.GETSIMPLEST_CMD + " " + genetic_format + " ", [], self.GETSIMPLEST_FILE, self.GENO_SAVE_FILE_FORMAT["RAWGENO"]) 196 195 with open(files[-1]) as f: … … 200 199 201 200 202 def evaluate(self, genotype: str): 203 """ 204 Returns: 205 Dictionary -- genotype evaluated with self.EVALUATE_COMMAND. Note that for whatever reason (e.g. incorrect genotype), 206 the dictionary you will get may be empty or partially empty and may not have the fields you expected, so handle such cases properly. 207 """ 208 files = self.__runCommand(self.EVALUATE_CMD, [genotype], self.EVALUATE_FILE, self.GENO_SAVE_FILE_FORMAT["NATIVEFRAMS"]) 201 def evaluate(self, genotype_list: List[str]): 202 """ 203 Returns: 204 List of dictionaries containing the performance of genotypes evaluated with self.EVALUATE_COMMAND. 205 Note that for whatever reason (e.g. incorrect genotype), the dictionaries you will get may be empty or 206 partially empty and may not have the fields you expected, so handle such cases properly. 207 """ 208 assert isinstance(genotype_list, list) # because in python str has similar capabilities as list and here it would pretend to work too, so to avoid any ambiguity 209 files = self.__runCommand(self.EVALUATE_CMD, genotype_list, self.EVALUATE_FILE, self.GENO_SAVE_FILE_FORMAT["NATIVEFRAMS"]) 209 210 with open(files[-1]) as f: 210 211 data = json.load(f) … … 278 279 parser = argparse.ArgumentParser(description='Run this program with "python -u %s" if you want to disable buffering of its output.' % sys.argv[0]) 279 280 parser.add_argument('-path', type=ensureDir, required=True, help='Path to Framsticks CLI without trailing slash.') 280 parser.add_argument('-exe', required=False, help='Executable name. If not given, "frams.exe" or "frams.linux" is assumed .')281 parser.add_argument('-exe', required=False, help='Executable name. If not given, "frams.exe" or "frams.linux" is assumed depending on the platform.') 281 282 parser.add_argument('-genformat', required=False, help='Genetic format for the demo run, for example 4, 9, or S. If not given, f1 is assumed.') 282 283 parser.add_argument('-pid', required=False, help='Unique ID of this process. Only relevant when you run multiple instances of this class simultaneously but as separate processes, and they use the same Framsticks CLI executable. This value will be appended to the names of created files to avoid conflicts.') … … 320 321 print("\tCrossover (Offspring):", offspring) 321 322 print('\tDissimilarity of Parent1 and Offspring:', framsCLI.dissimilarity([parent1, offspring])[0, 1]) 322 print('\tPerformance of Offspring:', framsCLI.evaluate( offspring))323 print('\tPerformance of Offspring:', framsCLI.evaluate([offspring])) 323 324 print('\tValidity of Parent1, Parent 2, and Offspring:', framsCLI.isValid([parent1, parent2, offspring])) 324 325
Note: See TracChangeset
for help on using the changeset viewer.