Skip to content

Commit

Permalink
Remove much cout... Bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Jan 22, 2025
1 parent c67bad5 commit b96007d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 47 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ jobs:
- name: Run tests
run: |
# Install specific branch of pyNeuroML
pip install git+https://github.com/NeuroML/pyNeuroML.git@experimental
pip install c302
pip install neuron
pip list
which nrniv
export NEURON_HOME=/home/runner/.local
./run_all_tests.sh
- name: Generated file info
run: |
ls -alt simulations/*
- name: Final version info
run: |
Expand Down
6 changes: 2 additions & 4 deletions main_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def __init__(self, tstop=100, dt=0.005, activity_file=None, verbose=True):

def set_timestep(self, dt):

print('Setting timestep...')
print('Setting timestep to %s...'%dt)

dt = float('{:0.1e}'.format(dt)) * 1000.0 # memory issue fix

Expand All @@ -173,13 +173,11 @@ def set_timestep(self, dt):
import neuron
self.h = neuron.h
except Exception as e:
return 'Python import error: %s..'%e
raise Exception('Python import error in C302NRNSimulation: %s..'%e)

self.ns = NeuronSimulation(self.tstop, dt)
print_("Initialised C302NRNSimulation of length %s ms and dt = %s ms..."%(self.tstop,dt))

return 'Success...' # for debugging...


def save_results(self):

Expand Down
10 changes: 5 additions & 5 deletions run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
set -ex

# No c302
python sibernetic_c302.py -test -noc302 -duration 0.1
python3 sibernetic_c302.py -test -noc302 -duration 0.1

python sibernetic_c302.py -test -noc302 -duration 0.054 -logstep 3
python3 sibernetic_c302.py -test -noc302 -duration 0.054 -logstep 3

# c302
python sibernetic_c302.py -test -duration 1.1 -c302params C1
python3 sibernetic_c302.py -test -duration 1.1 -c302params C1

# c302 + half_resolution
python sibernetic_c302.py -test -duration 1 -c302params C0 -configuration worm_alone_half_resolution
python3 sibernetic_c302.py -test -duration 1 -c302params C0 -configuration worm_alone_half_resolution

# c302 + TestMuscle
python sibernetic_c302.py -test -duration 20 -c302params C0 -reference TargetMuscle -configuration worm_alone_half_resolution -logstep 500
python3 sibernetic_c302.py -test -duration 20 -c302params C0 -reference TargetMuscle -configuration worm_alone_half_resolution -logstep 500


4 changes: 2 additions & 2 deletions sibernetic_c302.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pprint
pp = pprint.PrettyPrinter(indent=4)

script_version = '0.1.7' # This will change at different rate to C++ code...
script_version = '0.1.8' # This will change at different rate to C++ code...

DEFAULTS = {'duration': 2.0,
'dt': 0.005,
Expand Down Expand Up @@ -412,7 +412,7 @@ def run(a=None,**kwargs):

if not a.noc302 and successful:

announce("Generating images for neuronal activity...")
announce("Generating images for neuronal activity (via %s in %s)..."%(lems_file, sim_dir))

results = pynml.reload_saved_data(lems_file,
base_dir=sim_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool load_to = false;
bool skip_display_particles = false;
bool skip_display_membranes = false;
bool skip_display_connections = false;
std::string version = "0.0.7";
std::string version = "0.0.8";

int usage() {
std::cout
Expand Down
48 changes: 16 additions & 32 deletions src/owSignalSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,62 +80,48 @@ SignalSimulator::SignalSimulator(const std::string &simFileName,

// Import the file as a Python module.
pModule = PyImport_Import(pName);
std::cout << "1) Py module "<< s <<" imported..." << std::endl;
if (PyErr_Occurred())
PyErr_Print();

PyObject *pModule2 = PyImport_Import(PyUnicode_FromString("sys"));
if (PyErr_Occurred())
PyErr_Print();


std::cout << "2) all good" << std::endl;
// Build the name of a callable class
if (pModule != nullptr) {
std::cout << "3) class: " << simClassName << std::endl;
pClass = PyObject_GetAttrString(pModule, simClassName.c_str());
if (PyErr_Occurred())
PyErr_Print();
} else {

std::cout << "4) Good..." << std::endl;
throw std::runtime_error("Python module not loaded, have you set "
"PYTHONPATH?\nTry: \n\n export "
"PYTHONPATH=$PYTHONPATH:./src\n");
"PYTHONPATH=$PYTHONPATH:.\n");
}
std::cout << "5) pClass: " << pClass << std::endl;
// Create an instance of the class
if (PyCallable_Check(pClass)) {
std::cout << "6) callable.." << std::endl;

try {
pInstance = PyObject_CallObject(pClass, nullptr);
} catch (const std::exception& ex)
{
std::cout << "Error: " << ex.what() << std::endl;
}
std::cout << "7) No error" << std::endl;

try {
pInstance = PyObject_CallObject(pClass, nullptr);
} catch (const std::exception& ex)
{
std::cout << "Error: " << ex.what() << std::endl;
}

if (PyErr_Occurred())
{
std::cout << "errrr" << std::endl;
std::cout << "Error at PyObject_CallObject" << std::endl;
PyErr_Print();

}
PyObject *dt = Py_BuildValue("f", timeStep); // Create tuple of arguments for initialization
PyObject *pFuncName = Py_BuildValue("s", "set_timestep");
std::cout << "Calling " << pFuncName << std::endl;
//pInstance = PyObject_CallMethod(pInstance, "set_timestep", "(f)", timeStep);

try {
PyObject *output = PyObject_CallMethodObjArgs(pInstance, pFuncName, dt, nullptr);
std::cout << "Here's the output: " << output << std::endl;
try {
PyObject_CallMethodObjArgs(pInstance, pFuncName, dt, nullptr);

} catch (const std::exception& ex)
{
std::cout << "Error: " << ex.what() << std::endl;
}
} catch (const std::exception& ex)
{
std::cout << "Error: " << ex.what() << std::endl;
}

std::cout << "8) Good..." << std::endl;
if (PyErr_Occurred())
PyErr_Print();
Py_DECREF(dt);
Expand All @@ -147,8 +133,6 @@ SignalSimulator::SignalSimulator(const std::string &simFileName,
"callable! Try: export "
"PYTHONPATH=$PYTHONPATH:./src");
}

std::cout << "999" << std::endl;
}

std::vector<float> SignalSimulator::run() {
Expand Down

0 comments on commit b96007d

Please sign in to comment.