Skip to content

Commit 6308a59

Browse files
authored
Merge pull request #86 from ModECI/development
To v0.3.7; support for py 3.13
2 parents 729e0aa + fbf1924 commit 6308a59

File tree

7 files changed

+38
-36
lines changed

7 files changed

+38
-36
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
29+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
3030
runs-on: [ubuntu-latest, macos-latest, windows-latest]
3131
exclude:
3232
- runs-on: macos-latest
@@ -49,7 +49,6 @@ jobs:
4949
- name: Install package
5050
run: |
5151
python -m pip install --upgrade pip
52-
pip install 'numpy<2.0.0' # due to lingering issues with other modules & numpy...
5352
pip install .[dev]
5453
5554
- name: Lint with flake8
@@ -61,6 +60,7 @@ jobs:
6160
pip list
6261
6362
- name: Run simple examples
63+
shell: bash
6464
run: |
6565
cd examples
6666
python document.py
@@ -70,6 +70,7 @@ jobs:
7070
python test.py
7171
7272
- name: Test NeuroML examples
73+
shell: bash
7374
run: |
7475
7576
cd examples/neuroml2
@@ -78,6 +79,7 @@ jobs:
7879
# Note: NeuroML files will be validated with OMV below
7980
8081
- name: Test SBML examples
82+
shell: bash
8183
run: |
8284
8385
cd examples/sbml
@@ -126,7 +128,6 @@ jobs:
126128
# Run OMV tests on all engines
127129
cd examples
128130
omv all -V
129-
130131
omv list -V # list installed engines
131132
132133
- name: Final version info

docs/sphinx/source/api/Contributors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Modelspec contributors
44

55
This page list names and Github profiles of contributors to Modelspec, listed in no particular order.
6-
This page is generated periodically, most recently on 2025-02-05.
6+
This page is generated periodically, most recently on 2025-04-16.
77

88
- Padraig Gleeson ([@pgleeson](https://github.com/pgleeson))
99
- Manifest Chakalov ([@mqnifestkelvin](https://github.com/mqnifestkelvin))

setup.cfg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ classifiers =
2626
Programming Language :: Python :: 3.10
2727
Programming Language :: Python :: 3.11
2828
Programming Language :: Python :: 3.12
29+
Programming Language :: Python :: 3.13
2930
Topic :: Scientific/Engineering
3031
Topic :: Software Development
3132
Typing :: Typed
@@ -44,7 +45,7 @@ install_requires =
4445
typing_compat;python_version<'3.8'
4546

4647

47-
python_requires = >=3.7
48+
python_requires = >=3.8
4849
include_package_data = True
4950
package_dir =
5051
=src
@@ -83,8 +84,8 @@ docs =
8384

8485
dev =
8586
flake8
86-
pyneuroml>=0.7.2
87-
NeuroMLlite>=0.5.3
87+
pyneuroml>=1.3.15
88+
NeuroMLlite>=0.6.1
8889
python-libsbml
8990
modelspec[test]
9091
pre-commit

src/modelspec/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.3.6"
1+
__version__ = "0.3.7"
22

33
from .base_types import Base, define, has, field, fields, optional, instance_of, in_
44

src/modelspec/base_types.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,9 @@ def _is_child_field(cls, field_name: str) -> bool:
566566

567567
# Check if the type of the field is a list or dict
568568
collection_arg = None
569-
if get_origin(f.type) == list and len(get_args(f.type)) > 0:
569+
if get_origin(f.type) is list and len(get_args(f.type)) > 0:
570570
collection_arg = get_args(f.type)[0]
571-
elif get_origin(f.type) == dict and len(get_args(f.type)) > 0:
571+
elif get_origin(f.type) is dict and len(get_args(f.type)) > 0:
572572
collection_arg = get_args(f.type)[1]
573573

574574
try:
@@ -641,16 +641,16 @@ def _is_base_type(
641641
value = get_origin(value)
642642

643643
return (
644-
value == int
645-
or value == str
646-
or value == bool
647-
or value == float
648-
or (can_be_list and value == list)
649-
or (can_be_dict and value == dict)
650-
or (can_be_ndarray and value == numpy.ndarray)
644+
value is int
645+
or value is str
646+
or value is bool
647+
or value is float
648+
or (can_be_list and value is list)
649+
or (can_be_dict and value is dict)
650+
or (can_be_ndarray and value is numpy.ndarray)
651651
or (can_be_none and value is None)
652652
or (can_be_eval_expr and cls._is_evaluable_expression(value))
653-
or value == Union
653+
or value is Union
654654
)
655655

656656
@staticmethod
@@ -671,11 +671,11 @@ def _type_to_str(type_: Any) -> str:
671671

672672
# If its a Generic type
673673
elif get_origin(type_) is not None:
674-
if get_origin(type_) == list and len(get_args(type_)) > 0:
674+
if get_origin(type_) is list and len(get_args(type_)) > 0:
675675
return Base._type_to_str(get_args(type_)[0])
676-
elif get_origin(type_) == dict and len(get_args(type_)) > 0:
676+
elif get_origin(type_) is dict and len(get_args(type_)) > 0:
677677
return Base._type_to_str(get_args(type_)[1])
678-
elif get_origin(type_) == Union and len(get_args(type_)) > 0:
678+
elif get_origin(type_) is Union and len(get_args(type_)) > 0:
679679
return (
680680
"Union["
681681
+ ", ".join([Base._type_to_str(arg) for arg in get_args(type_)])
@@ -916,9 +916,9 @@ def insert_links(text, format=MARKDOWN_FORMAT):
916916
table_info.append([n, t, d])
917917

918918
# Get the contained type
919-
if get_origin(type_) == list and len(get_args(type_)) > 0:
919+
if get_origin(type_) is list and len(get_args(type_)) > 0:
920920
referenced.append(get_args(type_)[0])
921-
elif get_origin(type_) == dict and len(get_args(type_)) > 1:
921+
elif get_origin(type_) is dict and len(get_args(type_)) > 1:
922922
referenced.append(get_args(type_)[1])
923923
else:
924924
referenced.append(type_)
@@ -1080,7 +1080,7 @@ def _is_list_base(cl):
10801080
Check if a class is a list of Base objects. These will be serialized as dicts if the underlying class has an id
10811081
attribute.
10821082
"""
1083-
return get_origin(cl) == list and issubclass(get_args(cl)[0], Base)
1083+
return get_origin(cl) is list and issubclass(get_args(cl)[0], Base)
10841084

10851085

10861086
converter.register_unstructure_hook_factory(_is_list_base, _unstructure_list_base)

src/modelspec/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,13 @@ def evaluate(
486486
expr = tf.constant(int(expr))
487487
else:
488488
expr = int(expr)
489-
except:
489+
except Exception:
490490
try:
491491
if array_format == FORMAT_TENSORFLOW:
492492
expr = tf.constant(float(expr))
493493
else:
494494
expr = float(expr)
495-
except:
495+
except Exception:
496496
pass
497497

498498
if type(expr) is list:
@@ -525,7 +525,7 @@ def evaluate(
525525
else: # will have failed if not number
526526
print_(" Returning {}: {}".format(type(expr), expr), verbose)
527527
return expr
528-
except:
528+
except Exception:
529529
try:
530530
if rng:
531531
expr = expr.replace("random()", "rng.random()")
@@ -582,12 +582,12 @@ def parse_list_like(list_str):
582582
try:
583583
expr = int(list_str)
584584
return [expr]
585-
except:
585+
except Exception:
586586
pass
587587
try:
588588
expr = float(list_str)
589589
return [expr]
590-
except:
590+
except Exception:
591591
pass
592592
if "[" in list_str:
593593
return eval(list_str)

tests/test_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def test_evaluate(self):
1919
assert evaluate("p+p", params, verbose=True) == 66
2020

2121
print("======")
22-
assert type(evaluate("33")) == int
23-
assert type(evaluate("33", cast_to_int=True)) == int
24-
assert type(evaluate("33.0")) == float
25-
assert type(evaluate("33.0", cast_to_int=True)) == int
22+
assert type(evaluate("33")) is int
23+
assert type(evaluate("33", cast_to_int=True)) is int
24+
assert type(evaluate("33.0")) is float
25+
assert type(evaluate("33.0", cast_to_int=True)) is int
2626

27-
assert type(evaluate("33.1")) == float
28-
assert type(evaluate("33.1a", verbose=True)) == str
27+
assert type(evaluate("33.1")) is float
28+
assert type(evaluate("33.1a", verbose=True)) is str
2929

30-
assert type(evaluate("a")) == str
30+
assert type(evaluate("a")) is str
3131

3232
import random
3333

0 commit comments

Comments
 (0)