Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port precommits to ruff #801

Merged
merged 6 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.2.2'
hooks:
- id: ruff
types_or: [python, pyi, jupyter, toml]
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand All @@ -11,14 +18,7 @@ repos:
- id: debug-statements
- id: mixed-line-ending
args: ['--fix=no']
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ['--py39-plus', '--keep-runtime-typing']
- repo: https://github.com/akaihola/darker
rev: 1.7.2
hooks:
- id: darker
args: [-i]
additional_dependencies: [isort]
13 changes: 5 additions & 8 deletions docs/examples/Example_Write_Read_JSON.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
"# IMPORTS\n",
"#\n",
"%matplotlib nbagg\n",
"import matplotlib as mpl\n",
"\n",
"import broadbean as bb\n",
"from broadbean.plotting import plotter\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
"\n",
"mpl.rcParams['figure.figsize'] = (8, 3)\n",
"mpl.rcParams['figure.subplot.bottom'] = 0.15 \n",
"import yaml\n",
"import re\n",
"import json"
"mpl.rcParams['figure.subplot.bottom'] = 0.15 "
]
},
{
Expand Down Expand Up @@ -6079,7 +6076,7 @@
"outputs": [],
"source": [
"def writeblueprint(blueprint, path:str,SR:float = 1e9,SeqAmp:float = 10e-3,SeqOffset:float = 0):# -> None\n",
" if blueprint.SR == None:\n",
" if blueprint.SR is None:\n",
" blueprint.setSR(SR)\n",
" elemtmp = bb.Element()\n",
" seqtmp = bb.Sequence()\n",
Expand Down
8 changes: 6 additions & 2 deletions docs/examples/Filter_compensation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@
"%matplotlib notebook\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import sys\n",
"from broadbean.ripasso import applyRCFilter, applyInverseRCFilter, applyCustomTransferFunction"
"\n",
"from broadbean.ripasso import (\n",
" applyCustomTransferFunction,\n",
" applyInverseRCFilter,\n",
" applyRCFilter,\n",
")"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/Making_output_for_Tektronix_AWG70000A.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
"# a wait time, a ramp up, a sine, a ramp down, and more wait time\n",
"# And then we vary the sine frequency\n",
"%matplotlib notebook\n",
"import numpy as np\n",
"\n",
"import broadbean as bb\n",
"from broadbean.plotting import plotter\n",
"import numpy as np\n",
"\n",
"sine = bb.PulseAtoms.sine\n",
"ramp = bb.PulseAtoms.ramp\n",
Expand Down
19 changes: 10 additions & 9 deletions docs/examples/Pulse_Building_Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@
"# IMPORTS\n",
"#\n",
"%matplotlib inline\n",
"import matplotlib as mpl\n",
"import numpy as np\n",
"\n",
"import broadbean as bb\n",
"from broadbean.plotting import plotter\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
"\n",
"mpl.rcParams['figure.figsize'] = (8, 3)\n",
"mpl.rcParams['figure.subplot.bottom'] = 0.15 "
]
Expand Down Expand Up @@ -224,9 +225,9 @@
],
"source": [
"# A blueprint has a handful of different lengths one may check\n",
"print('Number of points in blueprint: {}'.format(bp1.points))\n",
"print('Length of blueprint in seconds: {}'.format(bp1.duration))\n",
"print('Number of segments in blueprint: {}'.format(bp1.length_segments))\n"
"print(f'Number of points in blueprint: {bp1.points}')\n",
"print(f'Length of blueprint in seconds: {bp1.duration}')\n",
"print(f'Number of segments in blueprint: {bp1.length_segments}')\n"
]
},
{
Expand Down Expand Up @@ -630,9 +631,9 @@
],
"source": [
"# An element has several features\n",
"print('Designated channels: {}'.format(elem1.channels))\n",
"print('Total duration: {} s'.format(elem1.duration))\n",
"print('Sample rate: {} (Sa/S)'.format(elem1.SR))"
"print(f'Designated channels: {elem1.channels}')\n",
"print(f'Total duration: {elem1.duration} s')\n",
"print(f'Sample rate: {elem1.SR} (Sa/S)')"
]
},
{
Expand Down
21 changes: 17 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ module = [
]
ignore_missing_imports = true

[tool.ruff]

extend-include = ["*.ipynb"]

[tool.ruff.lint]
extend-select = ["UP", "ISC", "I"]

[tool.ruff.lint.per-file-ignores]
"*.ipynb" = ["E402"]

[tool.ruff.lint.isort]
known-first-party = ["broadbean"]

[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true

[tool.versioningit]
default-version = "0.0"

Expand All @@ -90,7 +106,4 @@ source-file = "src/broadbean/_version.py"
build-file = "broadbean/_version.py"

[tool.darker]
isort = true

[tool.isort]
profile = "black"
isort = false
2 changes: 1 addition & 1 deletion src/broadbean/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa (ignore unused imports)
# ruff: noqa: F401

# Version 1.0
from . import ripasso
Expand Down
2 changes: 2 additions & 0 deletions src/broadbean/_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
def _get_version() -> str:
from pathlib import Path

import versioningit

import broadbean

project_dir = Path(broadbean.__file__).parent.parent
Expand Down
Loading
Loading