Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix units in sizeof_fmt #12962

Merged
merged 8 commits into from
Nov 14, 2024
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
1 change: 1 addition & 0 deletions doc/changes/devel/12962.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix displayed units in representations of classes such as :class:`mne.io.Raw` to correctly use KiB, MiB, GiB, and so on, by `Clemens Brunner`_.
4 changes: 2 additions & 2 deletions mne/source_space/tests/test_source_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def test_discrete_source_space(tmp_path):
with pytest.raises(ValueError, match="Cannot create interpolation"):
setup_volume_source_space("sample", pos=pos_dict, mri=fname_mri)
assert repr(src_new).split("~")[0] == repr(src_c).split("~")[0]
assert " kB" in repr(src_new)
assert " KiB" in repr(src_new)
assert src_new.kind == "discrete"
assert _get_src_type(src_new, None) == "discrete"

Expand Down Expand Up @@ -359,7 +359,7 @@ def test_volume_source_space(tmp_path):
)
del bem
assert repr(src) == repr(src_new)
assert " MB" in repr(src)
assert " MiB" in repr(src)
assert src.kind == "volume"
# Spheres
sphere = make_sphere_model(
Expand Down
2 changes: 1 addition & 1 deletion mne/tests/test_source_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_volume_stc(tmp_path):
assert isinstance(stc, VolSourceEstimate)

assert "sample" in repr(stc)
assert " kB" in repr(stc)
assert " KiB" in repr(stc)

stc_new = stc
fname_temp = tmp_path / ("temp-vl.stc")
Expand Down
2 changes: 1 addition & 1 deletion mne/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def sizeof_fmt(num):
size : str
The size in human-readable format.
"""
units = ["bytes", "kB", "MB", "GB", "TB", "PB"]
units = ["bytes", "KiB", "MiB", "GiB", "TiB", "PiB"]
decimals = [0, 0, 1, 2, 2, 2]
if num > 1:
exponent = min(int(log(num, 1024)), len(units) - 1)
Expand Down
Loading