Skip to content

Commit

Permalink
test / dev env: upgrade black
Browse files Browse the repository at this point in the history
  • Loading branch information
fphammerle committed Apr 8, 2022
1 parent d5b246b commit 07bd93b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Expand Up @@ -15,7 +15,7 @@ cc1101 = {editable = true,path = "."}
spidev = "==3.4"

[dev-packages]
black = "==20.8b1"
black = "*"
# >=0.1.1 for https://github.com/blu3r4y/blinkcheck/pull/2
blinkcheck = {version = ">=0.1.1", markers = "python_version >= '3.8'"}
mypy = "*"
Expand Down
35 changes: 28 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions cc1101/__init__.py
Expand Up @@ -147,7 +147,7 @@ class CC1101:
_CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ = 26e6
# see "21 Frequency Programming"
# > f_carrier = f_XOSC / 2**16 * (FREQ + CHAN * ((256 + CHANSPC_M) * 2**CHANSPC_E-2))
_FREQUENCY_CONTROL_WORD_HERTZ_FACTOR = _CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ / 2 ** 16
_FREQUENCY_CONTROL_WORD_HERTZ_FACTOR = _CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ / 2**16

# roughly estimated / tested with SDR receiver, docs specify:
# > can [...] be programmed for operation at other frequencies
Expand Down Expand Up @@ -277,7 +277,7 @@ def _filter_bandwidth_floating_point_to_real(
See "13 Receiver Channel Filter Bandwidth"
"""
return cls._CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ / (
8 * (4 + mantissa) * (2 ** exponent)
8 * (4 + mantissa) * (2**exponent)
)

def _get_filter_bandwidth_hertz(self) -> float:
Expand Down Expand Up @@ -341,9 +341,9 @@ def _symbol_rate_floating_point_to_real(
# see "12 Data Rate Programming"
return (
(256 + mantissa)
* (2 ** exponent)
* (2**exponent)
* cls._CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ
/ (2 ** 28)
/ (2**28)
)

@classmethod
Expand All @@ -354,14 +354,14 @@ def _symbol_rate_real_to_floating_point(cls, real: float) -> typing.Tuple[int, i
math.log2(real / cls._CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ) + 20
)
mantissa = round(
real * 2 ** 28 / cls._CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ / 2 ** exponent
real * 2**28 / cls._CRYSTAL_OSCILLATOR_FREQUENCY_HERTZ / 2**exponent
- 256
)
if mantissa == 256:
exponent += 1
mantissa = 0
assert 0 < exponent <= 2 ** 4, exponent
assert mantissa <= 2 ** 8, mantissa
assert 0 < exponent <= 2**4, exponent
assert mantissa <= 2**8, mantissa
return mantissa, exponent

def get_symbol_rate_baud(self) -> float:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gpio.py
Expand Up @@ -102,7 +102,7 @@ def test_line_wait_for_rising_edge(
wait_args, wait_kwargs = libgpiod_mock.gpiod_line_event_wait.call_args
assert wait_args[0] == pointer
assert (
wait_args[1].contents.tv_sec + wait_args[1].contents.tv_nsec / 10 ** 9
wait_args[1].contents.tv_sec + wait_args[1].contents.tv_nsec / 10**9
) == pytest.approx(timeout_seconds, abs=1e-10)
assert not wait_args[2:]
assert not wait_kwargs
Expand Down

0 comments on commit 07bd93b

Please sign in to comment.