Skip to content

Commit 5f947f8

Browse files
author
Jorge Núñez Santiago
authored
Merge pull request #187 from gachiemchiep/master
Json files will be written using utf-8 encoding
2 parents c830c0c + bc76fb2 commit 5f947f8

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

pyodi/apps/coco/coco_merge.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def coco_merge(
9292
)
9393
)
9494

95-
with open(output_file, "w") as f:
96-
json.dump(output, f, indent=indent)
95+
with open(output_file, "w", encoding="utf-8") as f:
96+
json.dump(output, f, indent=indent, ensure_ascii=False)
9797

9898
return output_file

pyodi/apps/coco/coco_split.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ def property_split(
149149
output_files = []
150150
for split_type, split in zip(["train", "val"], [train_split, val_split]):
151151
output_files.append(output_filename + f"_{split_type}.json")
152-
with open(output_files[-1], "w") as f:
153-
json.dump(split, f, indent=2)
152+
with open(output_files[-1], "w", encoding="utf-8") as f:
153+
json.dump(split, f, indent=2, ensure_ascii=False)
154154

155155
return output_files
156156

@@ -217,7 +217,7 @@ def random_split(
217217
output_files = []
218218
for split_type, split in zip(["train", "val"], [train_split, val_split]):
219219
output_files.append(output_filename + f"_{split_type}.json")
220-
with open(output_files[-1], "w") as f:
221-
json.dump(split, f, indent=2)
220+
with open(output_files[-1], "w", encoding="utf-8") as f:
221+
json.dump(split, f, indent=2, ensure_ascii=False)
222222

223223
return output_files

pyodi/apps/crops/crops_merge.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def crops_merge(
9191
"annotations": annotations,
9292
}
9393

94-
with open(output_file, "w") as f:
95-
json.dump(new_ground_truth, f, indent=2)
94+
with open(output_file, "w", encoding="utf-8") as f:
95+
json.dump(new_ground_truth, f, indent=2, ensure_ascii=False)
9696

9797
return output_file

tests/apps/test_coco_merge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ def test_coco_merge_with_json_indent(tmp_path, indent):
8484
output_file=tmp_path / "result.json",
8585
indent=indent,
8686
)
87-
mock.assert_called_once_with(ANY, ANY, indent=indent)
87+
mock.assert_called_once_with(ANY, ANY, indent=indent, ensure_ascii=False)

0 commit comments

Comments
 (0)