diff --git a/.isort.cfg b/.isort.cfg index 369065e..9cf6d92 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,7 +1,2 @@ [settings] -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -use_parentheses=True -line_length=88 known_third_party = django,environs,numpy,pytest,scos_actions,setuptools diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..035730e --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,3 @@ +default: true +MD013: + line_length: 88 diff --git a/.ml_style.rb b/.ml_style.rb deleted file mode 100644 index 750d9e8..0000000 --- a/.ml_style.rb +++ /dev/null @@ -1,6 +0,0 @@ -# markdownlint style -# https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md -# Enable all rules by default -all - -rule 'MD013', :line_length => 88 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8c4bb51..67568c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,31 +1,41 @@ +default_language_version: + python: python3.7 repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer + - id: check-ast + types: [file, python] + - id: check-case-conflict - id: check-docstring-first + types: [file, python] + - id: check-merge-conflict - id: check-yaml + types: [file, yaml] - id: debug-statements - - repo: https://github.com/asottile/seed-isort-config - rev: v2.2.0 + types: [file, python] + - id: detect-private-key + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/asottile/pyupgrade + rev: v2.34.0 hooks: - - id: seed-isort-config - language_version: python3.7 - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 + - id: pyupgrade + - repo: https://github.com/pycqa/isort + rev: 5.10.1 hooks: - id: isort - language_version: python3.7 - - repo: https://github.com/ambv/black - rev: 22.1.0 + name: isort (python) + types: [file, python] + args: ["--profile", "black", "--filter-files", "--gitignore"] + - repo: https://github.com/psf/black + rev: 22.6.0 hooks: - id: black - language_version: python3.7 - # TODO markdownlint broken - # - repo: https://github.com/markdownlint/markdownlint - # rev: v0.9.0 - # hooks: - # - id: markdownlint - # args: [-s, .ml_style.rb, README.md] - # exclude: GitHubRepoPublicReleaseApproval.md|LICENSE.md + types: [file, python] + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.31.1 + hooks: + - id: markdownlint + types: [file, markdown] + exclude: GitHubRepoPublicReleaseApproval.md|LICENSE.md diff --git a/scos_usrp/hardware/tests/test_usrp.py b/scos_usrp/hardware/tests/test_usrp.py index c105ede..df2db6b 100644 --- a/scos_usrp/hardware/tests/test_usrp.py +++ b/scos_usrp/hardware/tests/test_usrp.py @@ -94,7 +94,6 @@ def test_tune_result(self): self.rx.tune_frequency(f_lo, f_dsp) assert f_lo == self.rx.lo_freq and f_dsp == self.rx.dsp_freq - def test_set_sample_rate_also_sets_clock_rate(self): """Setting sample_rate should adjust clock_rate""" @@ -108,7 +107,3 @@ def test_set_sample_rate_also_sets_clock_rate(self): observed_clock_rate = self.rx.clock_rate assert expected_clock_rate == observed_clock_rate - - - - diff --git a/scos_usrp/hardware/usrp_sigan.py b/scos_usrp/hardware/usrp_sigan.py index 287985b..ec2c688 100644 --- a/scos_usrp/hardware/usrp_sigan.py +++ b/scos_usrp/hardware/usrp_sigan.py @@ -17,13 +17,11 @@ import numpy as np from scos_actions import utils from scos_actions.hardware.sigan_iface import SignalAnalyzerInterface -from scos_actions.settings import sensor_calibration -from scos_actions.settings import sigan_calibration +from scos_actions.settings import sensor_calibration, sigan_calibration from scos_usrp import settings from scos_usrp.hardware.mocks.usrp_block import MockUsrp - logger = logging.getLogger(__name__) logger.debug(f"USRP_CONNECTION_ARGS = {settings.USRP_CONNECTION_ARGS}") @@ -33,15 +31,13 @@ class USRPSignalAnalyzer(SignalAnalyzerInterface): - @property def last_calibration_time(self): """Returns the last calibration time from calibration data.""" return utils.convert_string_to_millisecond_iso_format( - sensor_calibration.calibration_datetime + sensor_calibration.calibration_datetime ) - @property def overload(self): """Returns True if overload occurred, otherwise returns False.""" @@ -66,7 +62,6 @@ def __init__(self): self.requested_sample_rate = 0 self.connect() - def connect(self): if self._is_available: return True @@ -228,7 +223,9 @@ def check_sensor_overload(self, data): > self.sensor_calibration_data["1db_compression_sensor"] ) - def acquire_time_domain_samples(self, num_samples, num_samples_skip=0, retries=5,gain_adjust=True): + def acquire_time_domain_samples( + self, num_samples, num_samples_skip=0, retries=5, gain_adjust=True + ): """Acquire num_samples_skip+num_samples samples and return the last num_samples :type num_samples: int @@ -251,16 +248,19 @@ def acquire_time_domain_samples(self, num_samples, num_samples_skip=0, retries=5 """ self._sigan_overload = False self._capture_time = None - # Get the calibration data for the acquisition - logger.debug('Using requested sample rate of ' + str(self.requested_sample_rate)) - calibration_args = [self.requested_sample_rate, self.frequency, self.gain] - self.recompute_calibration_data(calibration_args) + logger.debug( + "Using requested sample rate of " + str(self.requested_sample_rate) + ) + nsamps = int(num_samples) nskip = int(num_samples_skip) - # Compute the linear gain - db_gain = self.sensor_calibration_data["gain_sensor"] if gain_adjust: + # Get the calibration data for the acquisition + calibration_args = [self.requested_sample_rate, self.frequency, self.gain] + self.recompute_calibration_data(calibration_args) + # Compute the linear gain + db_gain = self.sensor_calibration_data["gain_sensor"] linear_gain = 10 ** (db_gain / 20.0) else: linear_gain = 1