Skip to content

Commit 8a5a53f

Browse files
committed
black formated
1 parent 7558576 commit 8a5a53f

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ classifiers =
3434
packages = find:
3535
install_requires =
3636
pyyaml
37+
pymongo
3738
numpy
3839
tabulate
3940
attrs

src/modelspec/base_types.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ def to_bson_file(self, filename: str, include_metadata: bool = True) -> str:
183183
filename = f"{self.id}.bson"
184184

185185
with open(filename, "wb") as outfile:
186-
bson_data = bson.encode(
187-
bson_converter.unstructure(self.to_dict()),
188-
)
186+
bson_data = bson.encode(bson_converter.unstructure(self.to_dict()),)
189187
outfile.write(bson_data)
190188

191189
return filename
@@ -280,7 +278,7 @@ def from_bson_file(cls, filename: str) -> "Base":
280278
Returns:
281279
An modelspec :class:`.Base` for this BSON
282280
"""
283-
with open("document.bson",'rb') as infile:
281+
with open("document.bson", "rb") as infile:
284282
data_encoded = infile.read()
285283
d = bson.decode(data_encoded)
286284
return cls.from_dict(d)
@@ -668,13 +666,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
668666
doc_dict[name]["allowed_parameters"][f]["description"] = description
669667

670668
elif format == MARKDOWN_FORMAT:
671-
doc_string += (
672-
"\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
673-
f,
674-
f'<a href="#{type_str.lower()}">{type_str}</a>'
675-
if referencable
676-
else type_str,
677-
)
669+
doc_string += "\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
670+
f,
671+
f'<a href="#{type_str.lower()}">{type_str}</a>'
672+
if referencable
673+
else type_str,
678674
)
679675
doc_string += "\n <td><i>%s</i></td>\n </tr>\n\n" % (
680676
insert_links(description)
@@ -729,13 +725,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
729725
][0]
730726

731727
elif format == MARKDOWN_FORMAT:
732-
doc_string += (
733-
"\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
734-
c,
735-
f'<a href="#{type_str.lower()}">{type_str}</a>'
736-
if referencable
737-
else type_str,
738-
)
728+
doc_string += "\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
729+
c,
730+
f'<a href="#{type_str.lower()}">{type_str}</a>'
731+
if referencable
732+
else type_str,
739733
)
740734
doc_string += "\n <td><i>%s</i></td>\n </tr>\n\n" % (
741735
insert_links(description)
@@ -921,8 +915,7 @@ def _is_list_base(cl):
921915

922916
converter.register_unstructure_hook_factory(_is_list_base, _unstructure_list_base)
923917
converter.register_unstructure_hook_factory(
924-
lambda cl: issubclass(cl, Base),
925-
_base_unstruct_hook_factory,
918+
lambda cl: issubclass(cl, Base), _base_unstruct_hook_factory,
926919
)
927920

928921
converter.register_structure_hook_factory(_is_list_base, _structure_list_base)

src/modelspec/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def load_bson(filename):
3737
"""
3838
Load a generic BSON file
3939
"""
40-
with open(filename,'rb') as infile:
40+
with open(filename, "rb") as infile:
4141
data_encoded = infile.read()
4242
data = bson.decode(data_encoded)
4343

tests/test_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ class Node(Base):
313313
model = Node(id="a", metadata={"b": np.array([0])})
314314
model.to_json()
315315

316+
316317
def test_ndarray_bson_metadata():
317318
import numpy as np
318319

@@ -323,9 +324,12 @@ class Node(Base):
323324
kw_only=True, default=None, validator=optional(instance_of(dict))
324325
)
325326

326-
model = Node(id="a", metadata={"b": np.random.randint(10,10000,1000)}) #creates an array of 1000 integers ranging from 1 to 10000
327+
model = Node(
328+
id="a", metadata={"b": np.random.randint(10, 10000, 1000)}
329+
) # creates an array of 1000 integers ranging from 1 to 10000
327330
model.to_bson_file("sample.bson")
328-
model.to_json_file("sample.json") #to compare the size
331+
model.to_json_file("sample.json") # to compare the size
329332
model.from_bson_file("sample.bson")
330333

334+
331335
test_ndarray_bson_metadata()

0 commit comments

Comments
 (0)