betse merge requestshttps://staging.gitlab.com/betse/betse/-/merge_requests2016-07-25T18:20:51Zhttps://staging.gitlab.com/betse/betse/-/merge_requests/1Windows Support2016-07-25T18:20:51Zusername-removed-613407Windows Support## Plotting Backend
This merge fixes issue #3. The problem was exactly what @leycec predicted: Windows and **Tk** are not happy bedfellows. Switching to **Qt4Agg** as the default on Windows seems to have remedied the screaming death th...## Plotting Backend
This merge fixes issue #3. The problem was exactly what @leycec predicted: Windows and **Tk** are not happy bedfellows. Switching to **Qt4Agg** as the default on Windows seems to have remedied the screaming death that immediately follows plot display.
## Path Delimiters
After a lengthy perusal of BETSE's source, I found exactly no path separator issues. Judicious use of `os.path.join` made sure that the are not a problem! Any that I might have missed don't seem to be causing any trouble, so can't we all just get along?
## Tests
All tests are passing under Windows 7 and Windows 10.https://staging.gitlab.com/betse/betse/-/merge_requests/2Interactive REPL + Non-interactive Scripting2016-08-01T23:48:07Zusername-removed-613407Interactive REPL + Non-interactive ScriptingThis is an attempt to implement a working interactive REPL and a simple scripting environment for BETSE in response to issue #2.
## Scripting
As suggested by @leycec, we've created a submodule `betse.script` (it just seems more aprop...This is an attempt to implement a working interactive REPL and a simple scripting environment for BETSE in response to issue #2.
## Scripting
As suggested by @leycec, we've created a submodule `betse.script` (it just seems more apropos than `betse.be`). The purpose of the module is the provide all of the bare necessities necessary for getting along in a scripting or interactive environment. The intended use as: `import betse.script as be`.
The `betse.script` submodule has two submodules `api` and `runner`. The former provides a convenience API for scripting and the REPL. Functions such as `seed`, `initialize` and `simulate` are provided to do exactly what they sound like they do... but conveniently. The latter provides the script-calling mechanism `run_script` which takes a single file path, or a sequence of file paths , and executes the scripts sequentially within the local environment. `run_script` takes several arguments that I will not detail here, but it is fairly flexible in terms of its namespace side-effects: dirty and isolated (the default) modes are provided. The `run_script` function can be used in the interactive REPL or baked into the core BETSE CLI.
## REPL
So far we have two REPL implementations, one is [ptpython](https://github.com/jonathanslenders/ptpython)-based and the other is [code](https://docs.python.org/3.5/library/code.html)-based. If ptpython is present, then it is the default, with code as a fallback. The API is designed so that if we wanted to we could add a configuration option that allows the users to choose which they prefer.
Both REPLs have store their history in a history file, though because ptpython appears to have a non-`readline` compatible file format each REPL keeps a separate history. Hopefully they will be merged in a future commit?
The REPL provides all of the imports and API functions imported from `betse.script` as well as the `run_script` function.
## Usage
The interactive environment can be started using `betse repl`. This subcommand takes no arguments. Script execution is only available within the interactive environment at the moment.
The user has two options for running simulations. They can use the standard BETSE CLI commands, interspersed with `betse repl` commands. Alternatively, the interactive environment has access to the `SimRunner` class and provides a handful of convenience functions that can be used to run the various simulation steps. An example is as below:
# An Interactive Use Case
$ betse repl
[betse] Welcome to <<BETSE 0.4.0 | CPython 3.5.2 | Windows 7>>.
>>> runner = seed("sample.yaml")
[betse] Seeding simulation with configuration file "sample.yaml".
...
[betse] Electrostatic pressure: True
>>> initialize(runner)
[betse] Initializing simulation with configuration file "sample.yaml".
...
[betse] Plotting animation "Efield_gj"...
<betse.science.simrunner.SimRunner object at 0x0000000004BDD278>
>>> sim, cells, p = load_init("sample.yaml")
>>> cells.cell_number
176
>>> run_script("active_info.py")
[betse] Computing active information at each cell membrane.
...
[betse] Animating local active information...
## A Work In Progress
This is all a work in progress, so please let me know what you think in the comments section!