Skip to content

Commit

Permalink
renamed repository and package from PyAuto to PyCoBi in order to avoi…
Browse files Browse the repository at this point in the history
…d conflicts with PyPI package pyauto
  • Loading branch information
Richert committed Oct 13, 2022
1 parent afe087f commit f96baab
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 63 deletions.
8 changes: 0 additions & 8 deletions .idea/PyAuto.iml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recursive-include pyauto *
recursive-include pycobi *
Binary file removed PyAuto_logo_color.png
Binary file not shown.
Binary file added PyCoBi_logo_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions PyAuto_logo_color.svg → PyCoBi_logo_color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

<img src="./PyAuto_logo_color.png" width="20%" heigth="20%" align="right">
<img src="PyCoBi_logo_color.png" width="20%" heigth="20%" align="right">

*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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions documentation/yaml_initialization.py
Original file line number Diff line number Diff line change
@@ -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)

6 changes: 3 additions & 3 deletions pyauto/__init__.py → pycobi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -31,4 +31,4 @@
__status__ = "Development"
__version__ = "0.6.0"

from .pyauto import PyAuto
from .pycobi import ODESystem
52 changes: 26 additions & 26 deletions pyauto/pyauto.py → pycobi/pycobi.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -178,29 +178,29 @@ 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:
self._branches[new_branch] = {pyauto_key: []}
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)
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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

Expand Down Expand Up @@ -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
----------
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f96baab

Please sign in to comment.