Skip to content

Commit 9ed6bb9

Browse files
authored
Merge branch 'main' into recording_entity
2 parents f306315 + 3f59b0e commit 9ed6bb9

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

doc/whats_new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The following authors had contributed before. Thank you for sticking around!
2323

2424
* `Stefan Appelhoff`_
2525
* `Daniel McCloy`_
26+
* `Scott Huberty`_
2627

2728
Detailed list of changes
2829
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -48,6 +49,7 @@ Detailed list of changes
4849

4950
- :func:`mne_bids.read_raw_bids` can optionally return an ``event_id`` dictionary suitable for use with :func:`mne.events_from_annotations`, and if a ``values`` column is present in ``events.tsv`` it will be used as the source of the integer event ID codes, by `Daniel McCloy`_ (:gh:`1349`)
5051
- BIDS dictates that the recording entity should be displayed as "_recording-" in the filename. This PR makes :class:`mne_bids.BIDSPath` correctly display "_recording-" (instead of "_rec-") in BIDSPath.fpath. By `Scott Huberty`_ (:gh:`1348`)
52+
- :func:`mne_bids.make_dataset_description` now correctly encodes the dataset description as UTF-8 on disk, by `Scott Huberty`_ (:gh:`1357`)
5153

5254
⚕️ Code health
5355
^^^^^^^^^^^^^^

mne_bids/tests/test_write.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def test_make_dataset_description(tmp_path, monkeypatch):
376376
make_dataset_description(
377377
path=tmp_path,
378378
name="tst2",
379-
authors="MNE B., MNE P.",
379+
authors="MNE B., MNE P., MNE Ł.",
380380
funding="GSOC2019, GSOC2021",
381381
references_and_links="https://doi.org/10.21105/joss.01896",
382382
dataset_type="derivative",
@@ -386,7 +386,14 @@ def test_make_dataset_description(tmp_path, monkeypatch):
386386

387387
with open(op.join(tmp_path, "dataset_description.json"), encoding="utf-8") as fid:
388388
dataset_description_json = json.load(fid)
389-
assert dataset_description_json["Authors"] == ["MNE B.", "MNE P."]
389+
assert dataset_description_json["Authors"] == ["MNE B.", "MNE P.", "MNE Ł."]
390+
# If the text on disk is unicode, json.load will convert it. So let's test that
391+
# the text was encoded correctly on disk.
392+
fid.seek(0)
393+
# don't use json.load here, as it will convert unicode to str
394+
dataset_description_string = fid.read()
395+
# Check that U+0141 was correctly encoded as Ł on disk
396+
assert "MNE Ł." in dataset_description_string
390397

391398
# Check we raise warnings and errors where appropriate
392399
with pytest.raises(

mne_bids/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _write_json(fname, dictionary, overwrite=False):
233233
f'"{fname}" already exists. Please set overwrite to True.'
234234
)
235235

236-
json_output = json.dumps(dictionary, indent=4)
236+
json_output = json.dumps(dictionary, indent=4, ensure_ascii=False)
237237
with open(fname, "w", encoding="utf-8") as fid:
238238
fid.write(json_output)
239239
fid.write("\n")

0 commit comments

Comments
 (0)