Skip to content

Commit d46258f

Browse files
committed
Merge branch 'experimental' into test_py313
2 parents 7f831d3 + e7a1ce8 commit d46258f

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
pip list
6262
6363
- name: Run simple examples
64+
shell: bash
6465
run: |
6566
cd examples
6667
python document.py
@@ -70,6 +71,7 @@ jobs:
7071
python test.py
7172
7273
- name: Test NeuroML examples
74+
shell: bash
7375
run: |
7476
7577
cd examples/neuroml2
@@ -78,6 +80,7 @@ jobs:
7880
# Note: NeuroML files will be validated with OMV below
7981
8082
- name: Test SBML examples
83+
shell: bash
8184
run: |
8285
8386
cd examples/sbml

.github/workflows/static.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Checkout
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3434

3535
- name: Set up Python
36-
uses: actions/setup-python@v4
36+
uses: actions/setup-python@v5
3737
with:
3838
python-version: 3.9
3939

@@ -61,11 +61,11 @@ jobs:
6161
uses: actions/configure-pages@v3
6262

6363
- name: Upload artifact
64-
uses: actions/upload-pages-artifact@v2
64+
uses: actions/upload-pages-artifact@v3
6565
with:
6666
# Upload just docs
6767
path: 'docs/sphinx/build/html'
6868

6969
- name: Deploy to GitHub Pages
7070
id: deployment
71-
uses: actions/deploy-pages@v2
71+
uses: actions/deploy-pages@v4

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))

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)