nextnanoevo.utils package
Submodules
nextnanoevo.utils.jsonHandler module
- class nextnanoevo.utils.jsonHandler.JsonHandler(file_path, directory=None)
Bases:
object
A utility class for handling JSON files. The current implementation is not thread safe (not good for parallel execution). FOR DEVELOPERS: in the future, consider using a thread-safe implementation, by locking the file when writing to it.
- Args:
file_path (str): The path to the JSON file. directory (str, optional): The directory where the JSON file is located. Defaults to None.
- Attributes:
file_path (str): The absolute path to the JSON file.
- Methods:
load_data: Loads the data from the JSON file. write_data: Writes data to the JSON file. add_data: Adds new data to the JSON file.
Methods
add_data
(path, new_data)Adds new data to the JSON file.
Loads the data from the JSON file.
write_data
(data)Writes data to the JSON file.
- add_data(path, new_data)
Adds new data to the JSON file.
- Args:
path (str): The path to the location where the new data should be added. new_data (any): The new data to be added.
- Raises:
ValueError: If the key already exists in the specified path.
- load_data()
Loads the data from the JSON file.
- Returns:
dict: The loaded data from the JSON file, or an empty dictionary if the file doesn’t exist.
- write_data(data)
Writes data to the JSON file.
- Args:
data (dict): The data to be written to the JSON file.
nextnanoevo.utils.logger module
- nextnanoevo.utils.logger.create_simulation_files(directory=None)
- nextnanoevo.utils.logger.create_simulation_logger(directory=None, logger_name='Simulation_00_00_00')
nextnanoevo.utils.utils module
- nextnanoevo.utils.utils.are_same_functions(func1, func2)
- nextnanoevo.utils.utils.convert_json_to_arrays_evolution(json_data)
Converts the JSON data to numpy arrays for the evolution process.
Parameters: - json_data (dict): The JSON data containing the simulation results.
Returns: - headers (list): The list of column headers for the numpy array. - array (numpy.ndarray): The numpy array containing the converted data.
- nextnanoevo.utils.utils.dominates(fitness_a, fitness_b)
Check if fitness_a dominates fitness_b.
- nextnanoevo.utils.utils.extract_non_dominated_indices_from_fitness(fitness_values)
- nextnanoevo.utils.utils.extract_non_dominated_solutions(pop)
- nextnanoevo.utils.utils.extract_non_dominated_solutions_indices(pop)
- nextnanoevo.utils.utils.filter_non_dominated_solutions(solution_values, fitness_values)
- nextnanoevo.utils.utils.get_last_generation_from_json_log(dict_log)
Returns the last generation from the json log.
- nextnanoevo.utils.utils.pareto_message(keep_front)
- nextnanoevo.utils.utils.unique_file_path(file_path, max_attempts=10000)
Returns a unique file path. If the provided file path exists, appends a number to the end (before the file extension) to make it unique. Exits if the counter exceeds max_attempts.