Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
fail-fast: false

steps:
Expand Down
7 changes: 4 additions & 3 deletions pyneuroml/neuron/analysis/HHanalyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
Implementation of the pynml-modchananalysis command
"""

import typing
import argparse
import logging
import re
import subprocess
import sys
from math import log
from typing import Optional

import matplotlib.pyplot as pylab
import neuron
from pylab import *

from pyneuroml.utils import get_state_color
from pyneuroml.utils.cli import build_namespace

Expand Down Expand Up @@ -137,7 +138,7 @@ def remove_comments(txt):
return clear_txt


def get_states(txt: str) -> typing.List[str]:
def get_states(txt: str) -> list[str]:
"""Get list of states from mod file text.

:param txt: mod file text
Expand All @@ -157,7 +158,7 @@ def get_states(txt: str) -> typing.List[str]:
return state_list


def get_suffix(txt: str) -> typing.Optional[str]:
def get_suffix(txt: str) -> Optional[str]:
"""Get suffix mod file text

:param txt: mod file text
Expand Down
21 changes: 20 additions & 1 deletion pyneuroml/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Copyright 2024 NeuroML contributors
"""


import os

from pyneuroml import JNEUROML_VERSION
Expand All @@ -25,3 +24,23 @@ def get_path_to_jnml_jar() -> str:
"jNeuroML-%s-jar-with-dependencies.jar" % JNEUROML_VERSION,
)
return jar_path


try:
from contextlib import chdir # Python 3.11+
except ImportError:
from contextlib import contextmanager

@contextmanager
def chdir(path):
"""chdir context manager for python < 3.11

:param path: path to change to
:type path: str or os.PathLike
"""
prev_cwd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(prev_cwd)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ install_requires =
graphviz
typing; python_version<"3.5"
lxml
numpy<2.0.0
numpy
sympy
ppft[dill]

Expand Down
22 changes: 11 additions & 11 deletions tests/neuron/test_neuron_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,31 @@
Copyright 2023 NeuroML contributors
"""


import unittest
import logging
import tempfile
import pytest
import pathlib
import tempfile
import unittest

import pytest

from pyneuroml.neuron import (
load_hoc_or_python_file,
morphinfo,
export_mod_to_neuroml2,
get_utils_hoc,
getinfo,
export_mod_to_neuroml2,
load_hoc_or_python_file,
morphinfo,
)

from . import load_olm_cell


logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


class TestNeuronUtils(unittest.TestCase):

"""Test Neuron Utils"""

def test_hoc_loader(self):
def test_hoc_loader1(self):
"""Test hoc loader util function"""
with tempfile.NamedTemporaryFile(mode="w", suffix=".hoc") as f:
print(
Expand All @@ -47,6 +44,7 @@ def test_hoc_loader(self):

self.assertTrue(load_hoc_or_python_file(f.name))

def test_hoc_loader2(self):
with tempfile.NamedTemporaryFile(mode="w", suffix=".hoc") as f:
print(
"""
Expand All @@ -56,8 +54,10 @@ def test_hoc_loader(self):
flush=True,
)

self.assertFalse(load_hoc_or_python_file(f.name))
with self.assertRaises(RuntimeError):
load_hoc_or_python_file(f.name)

def test_hoc_loader3(self):
# loading python files is not yet implemented
with tempfile.NamedTemporaryFile(mode="w", suffix=".py") as f:
print(
Expand Down
Loading
Loading