From be9d9c404d0f6c182d848114cdd981c25507df35 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:35:23 +0100 Subject: [PATCH] Apply isort --- demo/plotEDFFile.py | 5 +--- demo/readEDFFile.py | 2 +- demo/stacklineplot.py | 2 +- demo/streamingEDFFile.py | 11 ++++--- demo/writeEDFFile.py | 2 ++ doc/source/conf.py | 5 ++-- pyedflib/data/__init__.py | 2 +- pyedflib/data/_readers.py | 1 + pyedflib/edfreader.py | 3 +- pyedflib/edfwriter.py | 51 ++++++++++++++++++++++++++------ pyedflib/highlevel.py | 7 +++-- pyedflib/tests/test_doc.py | 1 - pyedflib/tests/test_edfreader.py | 11 ++++--- pyedflib/tests/test_edfwriter.py | 13 ++++---- pyedflib/tests/test_highlevel.py | 11 ++++--- setup.py | 10 ++++--- util/authors.py | 8 ++--- util/gh_lists.py | 7 ++--- util/refguide_check.py | 22 +++++++------- 19 files changed, 113 insertions(+), 61 deletions(-) diff --git a/demo/plotEDFFile.py b/demo/plotEDFFile.py index 7cfae39..2cc06db 100644 --- a/demo/plotEDFFile.py +++ b/demo/plotEDFFile.py @@ -1,12 +1,9 @@ #!/usr/bin/env python import numpy as np - -import pyedflib - - from stacklineplot import stackplot +import pyedflib if __name__ == '__main__': f = pyedflib.data.test_generator() diff --git a/demo/readEDFFile.py b/demo/readEDFFile.py index e770b8c..37415fe 100644 --- a/demo/readEDFFile.py +++ b/demo/readEDFFile.py @@ -1,11 +1,11 @@ #!/usr/bin/env python import os + import numpy as np import pyedflib - if __name__ == '__main__': f = pyedflib.data.test_generator() print("\nlibrary version: %s" % pyedflib.version.version) diff --git a/demo/stacklineplot.py b/demo/stacklineplot.py index d6626f9..4df7706 100644 --- a/demo/stacklineplot.py +++ b/demo/stacklineplot.py @@ -2,8 +2,8 @@ # uses line collections (might actually be from pbrain example) # clm -import numpy as np import matplotlib.pyplot as plt +import numpy as np from matplotlib.collections import LineCollection diff --git a/demo/streamingEDFFile.py b/demo/streamingEDFFile.py index d709161..e4845bc 100644 --- a/demo/streamingEDFFile.py +++ b/demo/streamingEDFFile.py @@ -1,12 +1,15 @@ #!/usr/bin/env python -import numpy as np -import matplotlib.pyplot as plt -import matplotlib.animation as animation import time -import pyedflib + +import matplotlib.animation as animation +import matplotlib.pyplot as plt +import numpy as np from stacklineplot import stackplot_t +import pyedflib + + def animate(frame): global offset for i in np.arange(n): diff --git a/demo/writeEDFFile.py b/demo/writeEDFFile.py index 2fbcd9f..1f21425 100644 --- a/demo/writeEDFFile.py +++ b/demo/writeEDFFile.py @@ -1,8 +1,10 @@ # Copyright (c) 2016 Holger Nahrstaedt import os + import numpy as np from scipy import signal + import pyedflib # signal label/waveform amplitude f sf diff --git a/doc/source/conf.py b/doc/source/conf.py index f09445e..b478635 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -9,10 +9,10 @@ # # All configuration values have a default; values that are commented out # serve to show the default. -import re import datetime -import jinja2.filters +import re +import jinja2.filters import numpy as np # FIXME: doctests need the str/repr formatting used in Numpy < 1.14. @@ -64,6 +64,7 @@ # # The short X.Y version. import pyedflib + version = re.sub(r'\.dev0+.*$', r'.dev', pyedflib.__version__) release = pyedflib.__version__ diff --git a/pyedflib/data/__init__.py b/pyedflib/data/__init__.py index ee10415..f52b313 100644 --- a/pyedflib/data/__init__.py +++ b/pyedflib/data/__init__.py @@ -1 +1 @@ -from ._readers import test_generator, get_generator_filename +from ._readers import get_generator_filename, test_generator diff --git a/pyedflib/data/_readers.py b/pyedflib/data/_readers.py index 7cb48a5..e38fcd1 100644 --- a/pyedflib/data/_readers.py +++ b/pyedflib/data/_readers.py @@ -1,6 +1,7 @@ import os import numpy as np + import pyedflib diff --git a/pyedflib/edfreader.py b/pyedflib/edfreader.py index 6b4cacc..b04c737 100644 --- a/pyedflib/edfreader.py +++ b/pyedflib/edfreader.py @@ -5,9 +5,10 @@ # # See LICENSE for license details. +import warnings from datetime import datetime + import numpy as np -import warnings from ._extensions._pyedflib import CyEdfReader diff --git a/pyedflib/edfwriter.py b/pyedflib/edfwriter.py index 5d6080b..e650ca1 100644 --- a/pyedflib/edfwriter.py +++ b/pyedflib/edfwriter.py @@ -5,18 +5,51 @@ # # See LICENSE for license details. -import numpy as np import sys import warnings -from datetime import datetime, date -from ._extensions._pyedflib import FILETYPE_EDFPLUS, FILETYPE_BDFPLUS, FILETYPE_BDF, FILETYPE_EDF -from ._extensions._pyedflib import open_file_writeonly, set_physical_maximum, set_patient_additional, set_digital_maximum -from ._extensions._pyedflib import set_birthdate, set_digital_minimum, set_technician, set_recording_additional, set_patientname -from ._extensions._pyedflib import set_patientcode, set_equipment, set_admincode, set_sex, set_datarecord_duration, set_number_of_annotation_signals -from ._extensions._pyedflib import set_startdatetime, set_starttime_subsecond, set_samples_per_record, set_physical_minimum, set_label, set_physical_dimension -from ._extensions._pyedflib import set_transducer, set_prefilter, write_physical_samples, close_file, write_annotation_latin1, write_annotation_utf8 -from ._extensions._pyedflib import blockwrite_physical_samples, write_errors, blockwrite_digital_samples, write_digital_short_samples, write_digital_samples, blockwrite_digital_short_samples +from datetime import date, datetime + +import numpy as np +from ._extensions._pyedflib import ( + FILETYPE_BDF, + FILETYPE_BDFPLUS, + FILETYPE_EDF, + FILETYPE_EDFPLUS, + blockwrite_digital_samples, + blockwrite_digital_short_samples, + blockwrite_physical_samples, + close_file, + open_file_writeonly, + set_admincode, + set_birthdate, + set_datarecord_duration, + set_digital_maximum, + set_digital_minimum, + set_equipment, + set_label, + set_number_of_annotation_signals, + set_patient_additional, + set_patientcode, + set_patientname, + set_physical_dimension, + set_physical_maximum, + set_physical_minimum, + set_prefilter, + set_recording_additional, + set_samples_per_record, + set_sex, + set_startdatetime, + set_starttime_subsecond, + set_technician, + set_transducer, + write_annotation_latin1, + write_annotation_utf8, + write_digital_samples, + write_digital_short_samples, + write_errors, + write_physical_samples, +) __all__ = ['EdfWriter'] diff --git a/pyedflib/highlevel.py b/pyedflib/highlevel.py index b28ccaf..ac2759b 100644 --- a/pyedflib/highlevel.py +++ b/pyedflib/highlevel.py @@ -21,11 +21,14 @@ """ import os -import numpy as np import warnings -import pyedflib from copy import deepcopy from datetime import datetime, timedelta + +import numpy as np + +import pyedflib + # from . import EdfWriter # from . import EdfReader diff --git a/pyedflib/tests/test_doc.py b/pyedflib/tests/test_doc.py index 29b2e53..449104c 100644 --- a/pyedflib/tests/test_doc.py +++ b/pyedflib/tests/test_doc.py @@ -3,7 +3,6 @@ import os import unittest - pdir = os.path.pardir docs_base = os.path.abspath(os.path.join(os.path.dirname(__file__), pdir, pdir, "doc", "source")) diff --git a/pyedflib/tests/test_edfreader.py b/pyedflib/tests/test_edfreader.py index 015ffb9..648e5c2 100644 --- a/pyedflib/tests/test_edfreader.py +++ b/pyedflib/tests/test_edfreader.py @@ -1,16 +1,19 @@ # Copyright (c) 2019 - 2020 Simon Kern # Copyright (c) 2015 Holger Nahrstaedt -import os import gc -import numpy as np -from datetime import datetime +import os + # from numpy.testing import (assert_raises, run_module_suite, # assert_equal, assert_allclose, assert_almost_equal) import unittest +from datetime import datetime + +import numpy as np + import pyedflib -from pyedflib.edfwriter import EdfWriter from pyedflib.edfreader import EdfReader +from pyedflib.edfwriter import EdfWriter class TestEdfReader(unittest.TestCase): diff --git a/pyedflib/tests/test_edfwriter.py b/pyedflib/tests/test_edfwriter.py index 4446872..af14b52 100644 --- a/pyedflib/tests/test_edfwriter.py +++ b/pyedflib/tests/test_edfwriter.py @@ -1,17 +1,20 @@ # Copyright (c) 2019 - 2023 Simon Kern # Copyright (c) 2015 Holger Nahrstaedt -import os import gc -import warnings -import numpy as np +import os + # from numpy.testing import (assert_raises, run_module_suite, # assert_equal, assert_allclose, assert_almost_equal) import unittest +import warnings +from datetime import date, datetime + +import numpy as np + import pyedflib -from pyedflib.edfwriter import EdfWriter, ChannelDoesNotExist, WrongInputSize from pyedflib.edfreader import EdfReader -from datetime import datetime, date +from pyedflib.edfwriter import ChannelDoesNotExist, EdfWriter, WrongInputSize class TestEdfWriter(unittest.TestCase): diff --git a/pyedflib/tests/test_highlevel.py b/pyedflib/tests/test_highlevel.py index e2985a5..bada086 100644 --- a/pyedflib/tests/test_highlevel.py +++ b/pyedflib/tests/test_highlevel.py @@ -1,17 +1,20 @@ # Copyright (c) 2019 - 2020 Simon Kern # Copyright (c) 2015 Holger Nahrstaedt +import gc import os import shutil -import gc -import numpy as np + # from numpy.testing import (assert_raises, run_module_suite, # assert_equal, assert_allclose, assert_almost_equal) import unittest +from datetime import datetime, timedelta + +import numpy as np + from pyedflib import highlevel -from pyedflib.edfwriter import EdfWriter from pyedflib.edfreader import EdfReader -from datetime import datetime, timedelta +from pyedflib.edfwriter import EdfWriter def _compare_cropped_edf(path_orig_edf, path_cropped_edf): diff --git a/setup.py b/setup.py index 53d2a2e..e9765af 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,13 @@ #!/usr/bin/env python import os -import sys import subprocess -import setuptools +import sys +from distutils.sysconfig import get_python_inc from functools import partial -from setuptools import setup, Extension -from distutils.sysconfig import get_python_inc +import setuptools +from setuptools import Extension, setup try: from Cython.Build import cythonize @@ -213,6 +213,8 @@ def write_version_py(filename='pyedflib/version.py'): ] from setuptools.command.develop import develop + + class develop_build_clib(develop): """Ugly monkeypatching to get clib to build for development installs See coverage comment above for why we don't just let libraries be built diff --git a/util/authors.py b/util/authors.py index 90451ae..b0595fc 100644 --- a/util/authors.py +++ b/util/authors.py @@ -13,13 +13,13 @@ """ # Author: Pauli Virtanen . This script is in the public domain. +import collections +import io import optparse -import re -import sys import os -import io +import re import subprocess -import collections +import sys stdout_b = sys.stdout.buffer MAILMAP_FILE = os.path.join(os.path.dirname(__file__), "..", ".mailmap") diff --git a/util/gh_lists.py b/util/gh_lists.py index 786ef8f..e483ea5 100644 --- a/util/gh_lists.py +++ b/util/gh_lists.py @@ -4,16 +4,15 @@ Functions for Github API requests. """ +import argparse +import collections +import json import os import re import sys -import json -import collections -import argparse from urllib2 import urlopen - Issue = collections.namedtuple('Issue', ('id', 'title', 'url')) diff --git a/util/refguide_check.py b/util/refguide_check.py index fc932cc..536fb15 100644 --- a/util/refguide_check.py +++ b/util/refguide_check.py @@ -22,26 +22,28 @@ $ python refguide_check.py --check_docs optimize """ -import sys -import os -import re import copy -import inspect -import warnings import doctest -import tempfile +import glob +import inspect import io -import docutils.core -from docutils.parsers.rst import directives +import os +import re import shutil -import glob -from doctest import NORMALIZE_WHITESPACE, ELLIPSIS, IGNORE_EXCEPTION_DETAIL +import sys +import tempfile +import warnings from argparse import ArgumentParser +from doctest import ELLIPSIS, IGNORE_EXCEPTION_DETAIL, NORMALIZE_WHITESPACE + +import docutils.core import numpy as np +from docutils.parsers.rst import directives # sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'doc', # 'sphinxext')) from numpydoc.docscrape_sphinx import get_doc_object + # Remove sphinx directives that don't run without Sphinx environment directives._directives.pop('versionadded', None) directives._directives.pop('versionchanged', None)