Skip to content

Commit

Permalink
fix: tests workflow and force b-file encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Etienne de Montalivet committed Jan 3, 2024
1 parent 5b7dd0f commit 5d0376e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
CONDA_ENV: 'environment.yml'
strategy:
matrix:
python-version: ["3.9", "3.11"]
os: [ubuntu-latest, windows-latest]
python-version: ["3.9"]
os: [ubuntu-latest, windows-latest]

name: tests_python-${{ matrix.python-version }}
name: tests_python-${{ matrix.python-version }}-${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
Expand All @@ -28,7 +28,7 @@ jobs:
environment-file: ${{ env.CONDA_ENV }}
- name: Install extra dependencies
shell: bash -el {0}
run: poetry install --with dev
run: poetry install --with dev && conda install -c conda-forge liblsl
- name: Test with pytest
shell: bash -el {0}
run: |
Expand Down
7 changes: 4 additions & 3 deletions micromed_io/scripts/emulate_online_trc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
"""
import logging
import socket
import numpy as np
import time
from datetime import datetime
from pathlib import Path

import click
import numpy as np

from micromed_io.in_out import MicromedIO
import micromed_io.tcp as mmio_tcp
from micromed_io.in_out import ENCODING, MicromedIO


@click.command(context_settings=dict(max_content_width=120))
Expand Down Expand Up @@ -77,7 +78,7 @@ def run(
raise FileNotFoundError(f"{file} does not exist")

# open trc file
with open(str(Path(file)), "rb") as f:
with open(str(Path(file)), "rb", encoding=ENCODING) as f:
b_data_trc = f.read()
if verbosity >= 1:
logging.info("TRC file read done.")
Expand Down
8 changes: 4 additions & 4 deletions micromed_io/trc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import numpy as np

from micromed_io.in_out import MicromedIO
from micromed_io.in_out import ENCODING, MicromedIO


class MicromedTRC(MicromedIO):
Expand All @@ -34,15 +34,15 @@ def __init__(
):
MicromedIO.__init__(self, None)
self.filename = filename
with open(self.filename, "rb") as f:
with open(self.filename, "rb", encoding=ENCODING) as f:
b_data = f.read(
self._get_data_address()
) # trick to not open the whole file
self.decode_data_header_packet(b_data)

def _get_data_address(self):
"""Read and return data address"""
with open(self.filename, "rb") as f:
with open(self.filename, "rb", encoding=ENCODING) as f:
packet = f.read(142)
data_address = int.from_bytes(packet[138:142], "little")
return data_address
Expand Down Expand Up @@ -103,7 +103,7 @@ def get_data(
* self.micromed_header.nb_of_channels
)

with open(self.filename, "rb") as f:
with open(self.filename, "rb", encoding=ENCODING) as f:
f.seek(self._get_data_address() + start_address)
b_data = f.read(packet_size)
self.decode_data_eeg_packet(b_data, picks, keep_raw, use_volt)
Expand Down

0 comments on commit 5d0376e

Please sign in to comment.