diff --git a/.idea/PyAuto.iml b/.idea/PyAuto.iml deleted file mode 100644 index 7a9b148..0000000 --- a/.idea/PyAuto.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 5591a5b..6f244f8 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index e7368c0..44bb945 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -recursive-include pyauto * +recursive-include pycobi * diff --git a/PyAuto_logo_color.png b/PyAuto_logo_color.png deleted file mode 100644 index a56696c..0000000 Binary files a/PyAuto_logo_color.png and /dev/null differ diff --git a/PyCoBi_logo_color.png b/PyCoBi_logo_color.png new file mode 100644 index 0000000..3fa4df5 Binary files /dev/null and b/PyCoBi_logo_color.png differ diff --git a/PyAuto_logo_color.svg b/PyCoBi_logo_color.svg similarity index 93% rename from PyAuto_logo_color.svg rename to PyCoBi_logo_color.svg index e7bdf2a..30ae294 100644 --- a/PyAuto_logo_color.svg +++ b/PyCoBi_logo_color.svg @@ -9,9 +9,9 @@ viewBox="0 0 283.5 283.5" style="enable-background:new 0 0 283.5 283.5;" xml:space="preserve" - sodipodi:docname="RectiPy_logo_color.svg" + sodipodi:docname="PyCoBi_logo_color.svg" inkscape:version="1.2 (dc2aedaf03, 2022-05-15)" - inkscape:export-filename="PyAuto_logo_color.png" + inkscape:export-filename="PyCoBi_logo_color.png" inkscape:export-xdpi="400" inkscape:export-ydpi="400" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" @@ -54,9 +54,9 @@ inkscape:window-height="1017" id="namedview64" showgrid="false" - inkscape:zoom="0.8324515" - inkscape:cx="154.96398" - inkscape:cy="209.02119" + inkscape:zoom="1.1772642" + inkscape:cx="0.849427" + inkscape:cy="203.86248" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" @@ -127,7 +127,7 @@ xml:space="preserve" id="flowRoot883" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:53.3333px;line-height:125%;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';letter-spacing:0px;word-spacing:0px;fill:#287758;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - transform="translate(-4.5388211,5.6726803)">PyAuto + id="flowPara889">PyCoBi diff --git a/README.md b/README.md index d0ca644..642c1e4 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,25 @@ -# PyAuto +# PyCoBi -[![License](https://img.shields.io/github/license/pyrates-neuroscience/PyAuto.svg)](https://github.com/pyrates-neuroscience/PyAuto) +[![License](https://img.shields.io/github/license/pyrates-neuroscience/PyCoBi.svg)](https://github.com/pyrates-neuroscience/PyCoBi) - + -*PyAuto* is a Python interface to *Auto-07p* [1]. It still requires user-supplied Fortran files for parameter continuations, -but allows for a more intuitive usage of *Auto-07p* commands within Python scripts. It provides direct access to -solutions, branches, and their properties (i.e. special solutions, eigenvalues, etc.) as well as a range of plotting +*PyCoBi* is a **Py**thon tool for parameter **co**ntinuations and automated **bi**furcation analysis. +It provides a Python interface to *Auto-07p* [1], allowing for a more intuitive usage of *Auto-07p* commands within Python scripts. +It provides direct access to solutions, branches, and their properties (i.e. special solutions, eigenvalues, etc.) as well as a range of plotting functions to visualize bifurcation diagrams and solutions. +Finally, it allows to automatically generate the user-supplied Fortran routines via [PyRates](https://github.com/pyrates-neuroscience/PyRates), +such that *Auto-07p* can be fully used/controlled from within a single Python script, +without the need to supply additional non-Python files. **Use Example:** Use examples will be provided here soon. For now, have a look at the [this example](https://pyrates.readthedocs.io/en/latest/auto_analysis/continuation.html#sphx-glr-auto-analysis-continuation-py) which demonstrates how to create the required Fortran files for *Auto-07p* via [PyRates](https://github.com/pyrates-neuroscience/PyRates) -and use them to run a 1D parameter continuation and bifurcation detection via *PyAuto*. +and use them to run a 1D parameter continuation and bifurcation detection via *PyCoBi*. Installation ============ -To use *PyAuto*, it is required to install [Auto-07p](https://github.com/auto-07p/auto-07p). +To use *PyCoBi*, it is required to install [Auto-07p](https://github.com/auto-07p/auto-07p). You can follow these [installation instructions](https://github.com/auto-07p/auto-07p/tree/master/doc) for detailed information on how to install *Auto-07p* in your specific setup. Note that it is not required to manually set any path variables, since *PyAuto* will take care of that for you. @@ -52,15 +55,15 @@ After that, in the same directory, execute the following call from within the Py python setup.py install ``` -**Step 5:** Install *PyAuto* +**Step 5:** Install *PyCoBi* -Use `pip` to install the latest stable version of *PyAuto* +Use `pip` to install the latest stable version of *PyCoBi* ```shell -pip install pyauto +pip install pycobi ``` -Alternatively, the development version of *PyAuto* can be installed by cloning the github +Alternatively, the development version of *PyCoBi* can be installed by cloning the github repository and using the `setup.py` for installation (see steps 1 and 4). References diff --git a/documentation/yaml_initialization.py b/documentation/yaml_initialization.py index 07bce83..84830c5 100644 --- a/documentation/yaml_initialization.py +++ b/documentation/yaml_initialization.py @@ -1,5 +1,5 @@ -from pyauto import PyAuto +from pycobi import ODESystem -a = PyAuto.from_yaml("model_templates.neural_mass_models.qif.qif", - auto_dir="", init_cont=False) +a = ODESystem.from_yaml("model_templates.neural_mass_models.qif.qif", + auto_dir="", init_cont=False) diff --git a/pyauto/__init__.py b/pycobi/__init__.py similarity index 87% rename from pyauto/__init__.py rename to pycobi/__init__.py index f76165a..2771e1a 100644 --- a/pyauto/__init__.py +++ b/pycobi/__init__.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- # # -# PyAuto software framework for parameter continuation and automated bifurcation detection. See also: -# https://github.com/pyrates-neuroscience/PyAuto +# PyCoBi software framework for parameter continuation and automated bifurcation detection. See also: +# https://github.com/pyrates-neuroscience/PyCoBi # # Copyright (C) 2021-2022, Richard Gast. # @@ -31,4 +31,4 @@ __status__ = "Development" __version__ = "0.6.0" -from .pyauto import PyAuto +from .pycobi import ODESystem diff --git a/pyauto/pyauto.py b/pycobi/pycobi.py old mode 100755 new mode 100644 similarity index 97% rename from pyauto/pyauto.py rename to pycobi/pycobi.py index b85bb9d..68d93aa --- a/pyauto/pyauto.py +++ b/pycobi/pycobi.py @@ -9,7 +9,7 @@ import pickle -class PyAuto: +class ODESystem: def __init__(self, working_dir: str = None, auto_dir: str = None, init_cont: bool = True, **kwargs) -> None: @@ -68,8 +68,8 @@ def from_yaml(cls, path: str, working_dir: str = None, auto_dir: str = None, ini Returns ------- - PyAuto - PyAuto instance. + ODESystem + PyCoBi instance. """ # preparations @@ -85,7 +85,7 @@ def from_yaml(cls, path: str, working_dir: str = None, auto_dir: str = None, ini _ = template.get_run_func(func_name, dt, file_name=file_name_full, backend="fortran", float_precision="float64", auto=True, vectorize=False, **kwargs) - # initialize pyauto + # initialize pycobi return cls(working_dir=working_dir, auto_dir=auto_dir, init_cont=init_cont, e=func_name, c="c.ivp", **init_kwargs) @@ -122,18 +122,18 @@ def run(self, variables: list = None, params: list = None, get_stability: bool = # extract starting point of continuation if 'IRS' in auto_kwargs or 's' in auto_kwargs: - raise ValueError('Usage of keyword arguments `IRS` and `s` is disabled in pyauto. To start from a previous' + raise ValueError('Usage of keyword arguments `IRS` and `s` is disabled in pycobi. To start from a previous' 'solution, use the `starting_point` keyword argument and provide a tuple of branch ' 'number and point number as returned by the `run` method.') if not starting_point and self._last_cont > 0: raise ValueError('A starting point is required for further continuation. Either provide a solution to ' - 'start from via the `starting_point` keyword argument or create a fresh pyauto instance.') + 'start from via the `starting_point` keyword argument or create a fresh pycobi instance.') if origin is None: origin = self._last_cont elif type(origin) is str: origin = self._results_map[origin] elif type(origin) is not int: - origin = origin.pyauto_key + origin = origin.pycobi_key # call to auto constants = auto_kwargs.pop('c', None) @@ -169,7 +169,7 @@ def run(self, variables: list = None, params: list = None, get_stability: bool = params=params, timeseries=get_timeseries, stability=get_stability, period=get_period, eigenvals=get_eigenvals, lyapunov_exp=get_lyapunov_exp) - # store solution and extracted information in pyauto + # store solution and extracted information in pycobi #################################################### # merge auto solutions if necessary and create key for auto solution @@ -178,21 +178,21 @@ def run(self, variables: list = None, params: list = None, get_stability: bool = # get key from old solution and merge with new solution solution_old = self.get_solution(origin) - pyauto_key = solution_old.pyauto_key + pyauto_key = solution_old.pycobi_key solution, summary = self.merge(pyauto_key, solution, summary, new_icp) elif name == 'bidirect:cont2' and not bidirectional and 'DS' in auto_kwargs and auto_kwargs['DS'] == '-': # get key from old solution and merge with new solution solution_old = self.auto_solutions[self._last_cont] - pyauto_key = solution_old.pyauto_key + pyauto_key = solution_old.pycobi_key solution, summary = self.merge(pyauto_key, solution, summary, new_icp) else: - # create pyauto key for solution + # create pycobi key for solution pyauto_key = self._cont_num + 1 if self._cont_num in self.auto_solutions else self._cont_num - solution.pyauto_key = pyauto_key + solution.pycobi_key = pyauto_key # set up dictionary fields in _branches for new solution if new_branch not in self._branches: @@ -200,7 +200,7 @@ def run(self, variables: list = None, params: list = None, get_stability: bool = elif pyauto_key not in self._branches[new_branch]: self._branches[new_branch][pyauto_key] = [] - # store auto solution under unique pyauto cont + # store auto solution under unique pycobi cont self.auto_solutions[pyauto_key] = solution self._last_cont = pyauto_key self._branches[new_branch][pyauto_key].append(new_icp) @@ -229,12 +229,12 @@ def merge(self, key: int, cont, summary: dict, icp: tuple): Parameters ---------- key - PyAuto identifier under which the merged solution should be stored. Must be equal to identifier of first + PyCoBi identifier under which the merged solution should be stored. Must be equal to identifier of first continuation. cont auto continuation object that should be merged with the continuation object under `key`. summary - PyAuto continuation summary that should be merged with continuation summary under `key`. + PyCoBi continuation summary that should be merged with continuation summary under `key`. icp Continuation parameter that was used in both continuations that are to be merged. """ @@ -244,9 +244,9 @@ def merge(self, key: int, cont, summary: dict, icp: tuple): # call merge in auto solution = self._auto.merge(self.auto_solutions[key] + cont) - solution.pyauto_key = key + solution.pycobi_key = key - # store solution in pyauto + # store solution in pycobi self.auto_solutions[key] = solution self._last_cont = solution @@ -278,7 +278,7 @@ def merge(self, key: int, cont, summary: dict, icp: tuple): return solution, summary_final def get_summary(self, cont: Optional[Union[Any, str, int]] = None, point=None) -> dict: - """Extract summary of continuation from PyAuto. + """Extract summary of continuation from PyCoBi. Parameters ---------- @@ -299,7 +299,7 @@ def get_summary(self, cont: Optional[Union[Any, str, int]] = None, point=None) - elif cont is None: summary = self.results[self._last_cont] else: - summary = self.results[cont.pyauto_key] + summary = self.results[cont.pycobi_key] # return continuation or point summary if not point: @@ -396,8 +396,8 @@ def to_file(self, filename: str, include_auto_results: bool = False, **kwargs) - for key in kwargs: if hasattr(self, key): - print(f'WARNING: {key} is an attribute of PyAuto instances. To be able to build a new instance of ' - f'PyAuto via the `from_file` method from this file, you need to provide a different attribute ' + print(f'WARNING: {key} is an attribute of PyCoBi instances. To be able to build a new instance of ' + f'PyCoBi via the `from_file` method from this file, you need to provide a different attribute ' f'name.') try: @@ -501,7 +501,7 @@ def plot_trajectory(self, vars: Union[list, tuple], cont: Union[Any, str, int], time = self.extract(['time'], cont=cont, point=point)['time'] except KeyError: raise ValueError("Could not find time variable on solution to apply cutoff to. Please consider " - "adding the keyword argument `get_timeseries` to the `PyAuto.run()` call for which" + "adding the keyword argument `get_timeseries` to the `PyCoBi.run()` call for which" "the phase space trajectory should be plotted.") idx = np.where(time > cutoff) for key, val in results.items(): @@ -766,7 +766,7 @@ def from_file(cls, filename: str, auto_dir: str = None) -> Any: if type(attr) is dict: attr.update(val) else: - raise AttributeError(f'Attribute {key} is already contained on this PyAuto instance and cannot be ' + raise AttributeError(f'Attribute {key} is already contained on this PyCoBi instance and cannot be ' f'set.') else: setattr(pyauto_instance, key, val) @@ -1063,11 +1063,11 @@ def _get_axis_lims(x: np.array, padding: float = 0.) -> tuple: return x_min - x_pad, x_max + x_pad -def continue_period_doubling_bf(solution: dict, continuation: Union[str, int, Any], pyauto_instance: PyAuto, +def continue_period_doubling_bf(solution: dict, continuation: Union[str, int, Any], pyauto_instance: ODESystem, max_iter: int = 1000, iteration: int = 0, precision: int = 3, pds: list = [], **kwargs) -> tuple: """Automatically continue a cascade of period doubling bifurcations. Returns the labels of the continuation and the - pyauto instance they were run on. + pycobi instance they were run on. Parameters ---------- @@ -1121,7 +1121,7 @@ def continue_period_doubling_bf(solution: dict, continuation: Union[str, int, An def codim2_search(params: list, starting_points: list, origin: Union[str, int, Any], - pyauto_instance: PyAuto, max_recursion_depth: int = 3, recursion: int = 0, periodic: bool = False, + pyauto_instance: ODESystem, max_recursion_depth: int = 3, recursion: int = 0, periodic: bool = False, kwargs_2D_lc_cont: dict = None, kwargs_lc_cont: dict = None, kwargs_2D_cont: dict = None, precision=2, **kwargs) -> dict: """Performs automatic continuation of codim 1 bifurcation points in 2 parameters and searches for codimension 2 diff --git a/setup.py b/setup.py index 1075d4a..71ff7a8 100644 --- a/setup.py +++ b/setup.py @@ -24,9 +24,9 @@ with open("README.md", "r", encoding="utf8") as fh: DESCRIPTION = fh.read() -setup(name='pyauto', +setup(name='pycobi', version=VERSION, - description='Parameter continuation and bifurcation analysis tool', + description='Python tool for parameter continuation and bifurcation analysis', long_description=DESCRIPTION, author="Richard Gast", author_email='richard.gast@northwestern.edu',