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
4 changes: 4 additions & 0 deletions .github/workflows/ci_test_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
brew install hdf5

- name: Install & test package
shell: bash
env:
PYTHONUTF8: "1"
PYTHONIOENCODING: "utf-8"
run: |
python -m pip install --upgrade pip
# pip install 'numpy<2.0.0' # due to lingering issues with other modules & numpy...
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
# - id: black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ['--maxkb=800']
Expand Down Expand Up @@ -46,6 +46,6 @@ repos:
# files: src

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.10.0
hooks:
- id: black
6 changes: 3 additions & 3 deletions examples/test/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ A model....
<tr>
<td><b>float_like_req</b></td>
<td>float</td>
<td><i>name says it all...</i></td>
<td><i>Anything (float, str, int) which can be converted to a float with float(x)</i></td>
</tr>


<tr>
<td><b>float_like_optional</b></td>
<td>float</td>
<td><i>name also says it all...</i></td>
<td><i>Same as float<a href="#like">like</a>req, but optional</i></td>
</tr>


<tr>
<td><b>int_like_optional</b></td>
<td>int</td>
<td><i>name also says it all...</i></td>
<td><i>Same as float<a href="#like">like</a>req, but optional int</i></td>
</tr>


Expand Down
8 changes: 4 additions & 4 deletions examples/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class TopClass(Base):

Args:
id: The unique id of the thing
float_like_req: name says it all...
float_like_optional: name also says it all...
int_like_optional: name also says it all...
float_like_req: Anything (float, str, int) which can be converted to a float with float(x)
float_like_optional: Same as float_like_req, but optional
int_like_optional: Same as float_like_req, but optional int
"""

id: str = field(validator=instance_of(str))
Expand All @@ -74,7 +74,7 @@ class TopClass(Base):
) # a string which can be converted to a float...

# tc.float_like_req = 2.01
tc.float_like_optional = 44
tc.float_like_optional = "42"
# tc.float_like_optional2 = 66
tc.mid = MidClassNoId(int_val=4, str_val="three")

Expand Down
7 changes: 4 additions & 3 deletions examples/test/test.specification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ TopClass:
description: The unique id of the thing
float_like_req:
type: float
description: name says it all...
description: Anything (float, str, int) which can be converted to a float
with float(x)
float_like_optional:
type: float
description: name also says it all...
description: Same as float_like_req, but optional
int_like_optional:
type: int
description: name also says it all...
description: Same as float_like_req, but optional int
mid:
type: MidClassNoId
description: ''
Expand Down
2 changes: 1 addition & 1 deletion examples/test/test_instance.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"MyTest": {
"float_like_req": 4.0,
"float_like_optional": 44.0,
"float_like_optional": 42.0,
"mid": {
"int_val": 4,
"str_val": "three"
Expand Down
2 changes: 1 addition & 1 deletion examples/test/test_instance.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<TopClass id="MyTest" float_like_req="4.0" float_like_optional="44.0">
<TopClass id="MyTest" float_like_req="4.0" float_like_optional="42.0">
<mid int_val="4" str_val="three"/>
</TopClass>
2 changes: 1 addition & 1 deletion examples/test/test_instance.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MyTest:
float_like_req: 4.0
float_like_optional: 44.0
float_like_optional: 42.0
mid:
int_val: 4
str_val: three
32 changes: 20 additions & 12 deletions src/modelspec/base_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
doc_string += (
"\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
f,
f'<a href="#{type_str.lower()}">{type_str}</a>'
if referencable
else type_str,
(
f'<a href="#{type_str.lower()}">{type_str}</a>'
if referencable
else type_str
),
)
)
doc_string += "\n <td><i>%s</i></td>\n </tr>\n\n" % (
Expand All @@ -849,9 +851,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
elif format == RST_FORMAT:
n = "**%s**" % f
t = "{}".format(
rst_url_format % (type_, "#" + type_str.lower())
if referencable
else type_str,
(
rst_url_format % (type_, "#" + type_str.lower())
if referencable
else type_str
),
)
d = "%s" % (insert_links(description, format=RST_FORMAT))
table_info.append([n, t, d])
Expand Down Expand Up @@ -898,9 +902,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
doc_string += (
"\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
c,
f'<a href="#{type_str.lower()}">{type_str}</a>'
if referencable
else type_str,
(
f'<a href="#{type_str.lower()}">{type_str}</a>'
if referencable
else type_str
),
)
)
doc_string += "\n <td><i>%s</i></td>\n </tr>\n\n" % (
Expand All @@ -910,9 +916,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
elif format == RST_FORMAT:
n = "**%s**" % c
t = "{}".format(
rst_url_format % (type_str, "#" + type_str.lower())
if referencable
else type_str,
(
rst_url_format % (type_str, "#" + type_str.lower())
if referencable
else type_str
),
)
d = "%s" % (insert_links(description, format=RST_FORMAT))
table_info.append([n, t, d])
Expand Down
4 changes: 2 additions & 2 deletions src/modelspec/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def build_xml_element(data, parent=None):


def ascii_encode_dict(data):
ascii_encode = (
lambda x: x.encode("ascii")
ascii_encode = lambda x: (
x.encode("ascii")
if (sys.version_info[0] == 2 and isinstance(x, unicode))
else x
)
Expand Down
Loading