Source code for api.postprocessor.postprocessor_setup

""" Handling of postprocessing functionality """


import typing
from abc import abstractmethod, ABC

from more.api.postprocessor.simresult_setup import SimresultSetup


[docs] class PostprocessorSetup(ABC): """Entry point for postprocessing API Parameters ---------- proj : Project The project instance """ def __init__(self, proj): self._proj = proj def _get_wrapped_object(self): return self._proj.post
[docs] @abstractmethod def get_simresult(self, name: str) -> 'SimresultSetup': """ Creates a :class:`~api.postprocessor.simresult_setup.SimresultSetup` for an already existing simulation result .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> postprocessor_setup = api.create_postprocessor_setup() .. >>> from more.api_implementations._api_tools.postprocessor.mocking_utils import append_simresult_with_empty_result >>> append_simresult_with_empty_result(proj, 'example_simresult') >>> simresult_setup = postprocessor_setup.get_simresult(name='example_simresult') # The simresult object must already exist .. >>> len(proj.post.simresults) 1 >>> proj.post.simresults[0].name 'example_simresult' >>> from more.post.simresults import Simresults >>> isinstance(proj.post.simresults[0], Simresults) True >>> simresult_setup._simresult == proj.post.simresults[0] True >>> postprocessor_setup.get_simresult(name='non_existent_name') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Parameters ---------- name : str The name of the existing simulation result for which to return a :class:`~api.postprocessor.simresult_setup.SimresultSetup` Returns ------- :class:`~api.postprocessor.simresult_setup.SimresultSetup` A :class:`~api.postprocessor.simresult_setup.SimresultSetup` object for the found simulation results object Raises ------ NameNotFoundError Raised if no simulation result with the given name was found """ pass
[docs] @abstractmethod def remove_simresult(self, name: str) -> 'PostprocessorSetup': """ Removes a simresults object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> postprocessor_setup = api.create_postprocessor_setup() .. >>> from more.api_implementations._api_tools.postprocessor.mocking_utils import append_simresult_with_empty_result >>> append_simresult_with_empty_result(proj, 'example_simresult') >>> postprocessor_setup = postprocessor_setup.remove_simresult(name='example_simresult') # The simresult object must already exist .. >>> isinstance(postprocessor_setup, PostprocessorSetup) True >>> len(proj.post.simresults) 0 >>> postprocessor_setup.remove_simresult(name='non_existent_name') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Parameters ---------- name : str The name of the simresults object to remove Returns ------- self : :class:`~api.postprocessor.postprocessor_setup.PostprocessorSetup` Raises ------ NameNotFoundError Raised if no simresults with the given name exist """ pass
[docs] @abstractmethod def get_simresult_names(self) -> typing.List[str]: """ Gets the names of existing simresults .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> postprocessor_setup = api.create_postprocessor_setup() .. >>> from more.api_implementations._api_tools.postprocessor.mocking_utils import append_simresult_with_empty_result >>> append_simresult_with_empty_result(proj, 'example_simresult 1') >>> append_simresult_with_empty_result(proj, 'example_simresult 2') >>> postprocessor_setup.get_simresult_names() [...] Returns ------- list of strings Names of existing simresults """ pass