Skip to content

Commit 1a00618

Browse files
committedJun 10, 2024·
Try fix black
1 parent 7957eb7 commit 1a00618

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed
 

‎mantra/lex_to_json.py

+7-16
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def process_triangulation(triangulation):
3737
representing the top-level simplices of the triangulation.
3838
"""
3939
simplices = np.asarray(
40-
[np.fromstring(line, sep=",", dtype=int)
41-
for line in triangulation.split("\n")]
40+
[np.fromstring(line, sep=",", dtype=int) for line in triangulation.split("\n")]
4241
)
4342

4443
dimensions = [len(simplex) - 1 for simplex in simplices]
@@ -247,9 +246,7 @@ def process_triangulations(filename):
247246
type=str,
248247
help="Type information for triangulations (optional)",
249248
)
250-
parser.add_argument(
251-
"-o", "--output", type=str, help="Output file (optional)"
252-
)
249+
parser.add_argument("-o", "--output", type=str, help="Output file (optional)")
253250

254251
args = parser.parse_args()
255252
triangulations = process_triangulations(args.INPUT)
@@ -263,9 +260,7 @@ def process_triangulations(filename):
263260
triangulations[manifold].update(homology_groups[manifold])
264261

265262
if args.type is not None:
266-
types = process_homology_groups_or_types(
267-
args.type, parse_topological_type
268-
)
263+
types = process_homology_groups_or_types(args.type, parse_topological_type)
269264

270265
for manifold in triangulations:
271266
triangulations[manifold].update(types[manifold])
@@ -274,18 +269,15 @@ def process_triangulations(filename):
274269
# whole data set into a list of triangulations, making it easier
275270
# to add new triangulations later on.
276271
triangulations = [
277-
{"id": manifold, **triangulations[manifold]}
278-
for manifold in triangulations
272+
{"id": manifold, **triangulations[manifold]} for manifold in triangulations
279273
]
280274

281275
with (
282-
open(args.output, "w") if args.output is not
283-
None else nullcontext(sys.stdout)
276+
open(args.output, "w") if args.output is not None else nullcontext(sys.stdout)
284277
) as f:
285278
result = json.dumps(triangulations, indent=2)
286279

287-
regex = re.compile(r"^(\s+)\[(.*?)\]([,]\s+?)",
288-
re.MULTILINE | re.DOTALL)
280+
regex = re.compile(r"^(\s+)\[(.*?)\]([,]\s+?)", re.MULTILINE | re.DOTALL)
289281

290282
def prettify_triangulation(match):
291283
"""Auxiliary function for pretty-printing a triangulation.
@@ -313,8 +305,7 @@ def prettify_triangulation(match):
313305
# Fix indent of "triangulation" fields afterwards. This ensures
314306
# that the closing bracket of the triangulation key aligns with
315307
# the start.
316-
regex = re.compile(r"^(\s+)\"triangulation\":.*?\]\]",
317-
re.MULTILINE | re.DOTALL)
308+
regex = re.compile(r"^(\s+)\"triangulation\":.*?\]\]", re.MULTILINE | re.DOTALL)
318309

319310
indents = [len(match.group(1)) for match in regex.finditer(result)]
320311

0 commit comments

Comments
 (0)
Please sign in to comment.