Skip to content

Commit c928fb6

Browse files
authored
Merge pull request #73 from ModECI/experimental
Fixes for macos-latest
2 parents ce5a73a + 73b5761 commit c928fb6

File tree

11 files changed

+26
-46
lines changed

11 files changed

+26
-46
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ jobs:
2929
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
3030
runs-on: [ubuntu-latest, macos-latest, windows-latest]
3131
exclude:
32-
- runs-on: macos-14
32+
- runs-on: macos-latest
3333
python-version: "3.8"
34-
- runs-on: macos-14
34+
- runs-on: macos-latest
3535
python-version: "3.9"
3636

3737
steps:
@@ -112,7 +112,7 @@ jobs:
112112
python contributors.py
113113
cd sphinx
114114
make clean
115-
make html
115+
make html
116116
117117
- name: Install and test with OMV
118118
if: ${{ matrix.runs-on != 'windows-latest' }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,4 @@ cython_debug/
164164
/examples/document.specification.bson
165165
/examples/neuroml2/hello_world.v.dat
166166
/examples/sbml/example_sbml_test.xml
167+
/updatelibs.sh

docs/contributors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import requests
22
import pandas as pd
3-
import json
43
import textwrap
54
from datetime import date
65

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 2024-04-12.
6+
This page is generated periodically, most recently on 2024-04-25.
77

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

examples/neuroml2/neuroml2_spec.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class neuroml(Base):
128128

129129

130130
if __name__ == "__main__":
131-
132131
nml_doc = neuroml(id="TestNeuroML")
133132

134133
izh = izhikevich2007Cell(

examples/sbml/sbml32spec.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class SBase(Base):
8282

8383
@modelspec.define
8484
class SBaseWithId(SBase):
85-
8685
id: str = field(default=None, validator=optional([instance_of(str), valid_sid]))
8786

8887

examples/sbml/sbml_validators.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def valid_kind(instance, attribute, value):
22-
if not value in sbml_si_units:
22+
if value not in sbml_si_units:
2323
raise ValueError(
2424
f"kind {value} must be one of the standard SI units: {sbml_si_units}"
2525
)
@@ -168,7 +168,6 @@ def validate_sbml(doc, units_consistency: bool = False) -> None:
168168

169169

170170
if __name__ == "__main__":
171-
172171
import libsbml
173172

174173
sbml_file = sys.argv[1]

examples/sbml/test_sbml3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import json
99
import yaml
10-
import os
1110

1211
from sbml32spec import *
1312

src/modelspec/base_types.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def from_dict(cls, d: Dict[str, Any]) -> "Base":
147147
# If this object has an id attribute, it may have been serialized within a dict with the id as the key, even if
148148
# it is a single object.
149149
if "id" in [f.name for f in attr.fields(cls)] and "id" not in d.keys():
150-
151150
keys = list(d.keys())
152151
if len(keys) == 0:
153152
raise ValueError(
@@ -166,11 +165,6 @@ def from_yaml(cls, yaml_str: str) -> "Base":
166165
"""Instantiate an modelspec object from a YAML string"""
167166
return cls.from_dict(yaml.load(yaml_str, Loader=yaml.SafeLoader))
168167

169-
@classmethod
170-
def from_yaml_file(cls, yaml_file: str) -> "Base":
171-
"""Instantiate an modelspec object from a file containing YAML"""
172-
return cls.from_dict(yaml.load(yaml_file, Loader=yaml.SafeLoader))
173-
174168
@classmethod
175169
def from_json(cls, json_str: str) -> "Base":
176170
"""Instantiate an modelspec object from a JSON string"""
@@ -297,7 +291,6 @@ def to_yaml_file(
297291
filename = f"{self.id}.yaml"
298292

299293
with open(filename, "w") as outfile:
300-
301294
# We need to setup another
302295
yaml.dump(
303296
yaml_converter.unstructure(self.to_dict()),
@@ -313,7 +306,6 @@ def to_xml_file(
313306
filename: Optional[str] = None,
314307
include_metadata: bool = True,
315308
) -> str:
316-
317309
if filename is None:
318310
filename = f"{self.id}.xml"
319311

@@ -636,7 +628,6 @@ def _is_base_type(
636628
can_be_none=False,
637629
can_be_eval_expr=False,
638630
):
639-
640631
import numpy
641632

642633
if verbose:
@@ -730,7 +721,6 @@ def _cls_generate_documentation(cls, format: str = MARKDOWN_FORMAT):
730721
rst_url_format = "`%s <%s>`__"
731722

732723
def insert_links(text, format=MARKDOWN_FORMAT):
733-
734724
code_ref = ":code:`"
735725
# print(" > Converting: %s" % text)
736726
text2 = text

src/modelspec/utils.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,12 @@ def convert_xml_dict_values(value):
192192

193193

194194
def save_to_json_file(info_dict, filename, indent=4):
195-
196195
strj = json.dumps(info_dict, indent=indent)
197196
with open(filename, "w") as fp:
198197
fp.write(strj)
199198

200199

201200
def save_to_yaml_file(info_dict, filename, indent=4):
202-
203201
if sys.version_info[0] == 2:
204202
stry = yaml.dump(info_dict, indent=indent, default_flow_style=False)
205203
else:
@@ -251,7 +249,6 @@ def build_xml_element(data, parent=None):
251249

252250
attrs = attr.fields(data.__class__)
253251
for aattr in attrs:
254-
255252
print_(" == Looking at: {} ({})".format(aattr, type(aattr)), verbose)
256253
if isinstance(aattr.default, attr.Factory):
257254
children = data.__getattribute__(aattr.name)
@@ -272,15 +269,14 @@ def build_xml_element(data, parent=None):
272269
)
273270
if attribute_value is not None:
274271
if (
275-
type(attribute_value) is int
276-
or type(attribute_value) is float
277-
or type(attribute_value) is str
278-
or type(attribute_value) is bool
279-
or type(attribute_value) is list
272+
isinstance(attribute_value, int)
273+
or isinstance(attribute_value, float)
274+
or isinstance(attribute_value, str)
275+
or isinstance(attribute_value, bool)
276+
or isinstance(attribute_value, list)
280277
):
281278
parent.set(attribute_name, str(attribute_value))
282-
elif type(attribute_value) == dict:
283-
279+
elif isinstance(attribute_value, dict):
284280
"""for k, v in attribute_value.items():
285281
child_element = build_xml_element(v)"""
286282
else:
@@ -309,7 +305,6 @@ def ascii_encode_dict(data):
309305

310306

311307
def _parse_element(dict_format, to_build):
312-
313308
print_("Parse for element: [%s]" % dict_format, verbose)
314309
for k in dict_format.keys():
315310
print_(
@@ -323,7 +318,6 @@ def _parse_element(dict_format, to_build):
323318

324319

325320
def _parse_attributes(dict_format, to_build):
326-
327321
for key in dict_format:
328322
value = dict_format[key]
329323
new_format = True
@@ -333,7 +327,7 @@ def _parse_attributes(dict_format, to_build):
333327
)
334328

335329
if new_format:
336-
if type(to_build) == dict:
330+
if isinstance(to_build, dict):
337331
to_build[key] = value
338332

339333
elif key in to_build.allowed_children:
@@ -345,11 +339,11 @@ def _parse_attributes(dict_format, to_build):
345339
exec("to_build.%s.append(ff)" % key)
346340
else:
347341
if (
348-
type(value) == str
349-
or type(value) == int
350-
or type(value) == float
351-
or type(value) == bool
352-
or type(value) == list
342+
isinstance(value, str)
343+
or isinstance(value, int)
344+
or isinstance(value, float)
345+
or isinstance(value, bool)
346+
or isinstance(value, list)
353347
or value is None
354348
):
355349
to_build.__setattr__(key, value)
@@ -370,11 +364,15 @@ def _parse_attributes(dict_format, to_build):
370364
exec("to_build.%s = ff" % key)
371365

372366
else:
373-
if type(to_build) == dict:
367+
if isinstance(to_build, dict):
374368
to_build[key] = value
375-
elif type(value) == str or type(value) == int or type(value) == float:
369+
elif (
370+
isinstance(value, str)
371+
or isinstance(value, int)
372+
or isinstance(value, float)
373+
):
376374
to_build.__setattr__(key, value)
377-
elif type(value) == list:
375+
elif isinstance(value, list):
378376
type_to_use = to_build.allowed_children[key][1]
379377

380378
for vl in value:
@@ -403,7 +401,7 @@ def locate_file(f, base_dir):
403401

404402

405403
def _val_info(param_val):
406-
if type(param_val) == np.ndarray:
404+
if isinstance(param_val, np.ndarray):
407405
pp = "%s" % (np.array2string(param_val, threshold=4, edgeitems=1))
408406
pp = pp.replace("\n", "")
409407
pp += f" (NP {param_val.shape} {param_val.dtype})"
@@ -489,7 +487,6 @@ def evaluate(
489487
else:
490488
expr = int(expr)
491489
except:
492-
493490
try:
494491
if array_format == FORMAT_TENSORFLOW:
495492
expr = tf.constant(float(expr))
@@ -557,7 +554,6 @@ def evaluate(
557554
)
558555

559556
if (type(v) is float or type(v) is str) and int(v) == v:
560-
561557
print_(" Returning int: %s" % int(v), verbose)
562558

563559
if array_format == FORMAT_TENSORFLOW:
@@ -576,7 +572,6 @@ def evaluate(
576572

577573

578574
def parse_list_like(list_str):
579-
580575
if isinstance(list_str, int):
581576
return [list_str]
582577
elif isinstance(list_str, float):

0 commit comments

Comments
 (0)