Skip to content

BUG: EDF export failing on latest edfio #12521

Closed

Description

@larsoner

Our use of private edfio._utils is problematic, @cbrnr see failed CI run :

mne\export\tests\test_export.py:305: in test_channel_label_too_long_for_edf_raises_error
    raw.export(tmp_path / "test.edf")
<decorator-gen-346>:12: in export
    ???
mne\io\base.py:1792: in export
    export_raw(
<decorator-gen-599>:12: in export_raw
    ???
mne\export\_export.py:74: in export_raw
    from ._edf import _export_raw
mne\export\_edf.py:14: in <module>
    from edfio._utils import round_float_to_8_characters  # noqa: E402
E   ModuleNotFoundError: No module named 'edfio._utils'

Activity

  1. hofaflo commented on Mar 29, 2024

    @hofaflo
    Contributor

    Sorry for breaking this in the-siesta-group/edfio#37! We can think about making this a part of edfio's public API, or, for a quicker fix, I could open a PR to copy the function to mne/export/_edf.py... which option do you prefer?

  2. larsoner commented on Mar 29, 2024

    @larsoner
    MemberAuthor

    Either way is fine with me but a fix that would work for all edfio versions would be to copy the function over here (especially if it's only a couple of lines). I was about to add a skip in #12520 but instead I'll try that!

  3. hofaflo commented on Mar 29, 2024

    @hofaflo
    Contributor

    👍
    It's rather short and can be simplified a bit as mne only uses one way of rounding:

    def _round_float_to_8_characters(value):
        if isinstance(value, int) or value.is_integer():
            return value
        length = 8
        integer_part_length = str(value).find(".")
        if integer_part_length == length:
            return round(value)
        factor = 10 ** (length - 1 - integer_part_length)
        return round(value * factor) / factor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions