Skip to content

Commit

Permalink
Fix formatting and such in notebooks following ruff
Browse files Browse the repository at this point in the history
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
  • Loading branch information
hakonanes committed Jan 1, 2025
1 parent 33d9229 commit b0c5536
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 224 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
## You should have received a copy of the GNU General Public License
## along with kikuchipy. If not, see <http://www.gnu.org/licenses/>.##
repos:
# # https://docs.astral.sh/ruff/configuration
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.6.8
# hooks:
# - id: ruff
# args: [ --fix ]
# - id: ruff-format
# https://black.readthedocs.io/en/stable/index.html
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
Expand Down
156 changes: 80 additions & 76 deletions doc/tutorials/esteem2022_diffraction_workshop.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions doc/tutorials/geometrical_ebsd_simulations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"import hyperspy.api as hs\n",
"import kikuchipy as kp\n",
"from orix.crystal_map import Phase\n",
"from orix.quaternion import Rotation\n",
"\n",
"\n",
"# Plotting parameters\n",
Expand Down Expand Up @@ -479,7 +478,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions doc/tutorials/hough_indexing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@
"%matplotlib inline\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"from diffpy.structure import Atom, Lattice, Structure\n",
"from diffsims.crystallography import ReciprocalLatticeVector\n",
"import kikuchipy as kp\n",
"from orix import io, plot\n",
"from orix import plot\n",
"from orix.crystal_map import Phase, PhaseList\n",
"from orix.vector import Vector3d\n",
"\n",
Expand Down Expand Up @@ -526,6 +525,7 @@
"metadata": {},
"outputs": [],
"source": [
"# from orix import io\n",
"# io.save(\"xmap_ni.h5\", xmap)\n",
"# io.save(\n",
"# \"xmap_ni.ang\",\n",
Expand Down Expand Up @@ -584,7 +584,7 @@
"fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(10, 5), layout=\"tight\")\n",
"for ax, to_plot in zip(axes.ravel(), [\"pq\", \"cm\", \"fit\", \"nmatch\"]):\n",
" ax.hist(xmap.prop[to_plot], bins=100)\n",
" ax.set(xlabel=to_plot, ylabel=\"Frequency\");"
" _ = ax.set(xlabel=to_plot, ylabel=\"Frequency\")"
]
},
{
Expand Down Expand Up @@ -806,7 +806,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
197 changes: 106 additions & 91 deletions doc/tutorials/hybrid_indexing.ipynb

Large diffs are not rendered by default.

44 changes: 26 additions & 18 deletions doc/tutorials/mandm2021_sunday_short_course.ipynb

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions doc/tutorials/pattern_matching.ipynb

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions doc/tutorials/reference_frames.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@
"outputs": [],
"source": [
"R = Rotation.random(10)\n",
"O = Orientation(R, mp.phase.point_group)"
"Or = Orientation(R, mp.phase.point_group)"
]
},
{
Expand All @@ -547,7 +547,7 @@
"metadata": {},
"outputs": [],
"source": [
"s2 = mp.get_patterns(O, det2, energy=20, compute=True)"
"s2 = mp.get_patterns(Or, det2, energy=20, compute=True)"
]
},
{
Expand Down Expand Up @@ -586,7 +586,7 @@
"metadata": {},
"outputs": [],
"source": [
"from pyebsdindex import ebsd_index, pcopt"
"from pyebsdindex import ebsd_index"
]
},
{
Expand Down Expand Up @@ -662,19 +662,19 @@
" )\n",
" data, *_ = indexer.index_pats(s2.data)\n",
" R_hi = Rotation(data[0][\"quat\"]) * R_sample[vendor]\n",
" O_hi = Orientation(R_hi, mp.phase.point_group)\n",
" Or_hi = Orientation(R_hi, mp.phase.point_group)\n",
"\n",
" print(\n",
" f\"Average misorientation angle to ground truth: {O_hi.angle_with(O, degrees=True).mean():.4f}\"\n",
" f\"Average misorientation angle to ground truth: {Or_hi.angle_with(Or, degrees=True).mean():.4f}\"\n",
" )\n",
" fig = O.scatter(\n",
" fig = Or.scatter(\n",
" \"ipf\",\n",
" direction=v_sample,\n",
" c=\"C0\",\n",
" s=200,\n",
" return_figure=True,\n",
" )\n",
" O_hi.scatter(\"ipf\", figure=fig, c=\"C1\", s=100)\n",
" Or_hi.scatter(\"ipf\", figure=fig, c=\"C1\", s=100)\n",
" plt.pause(0.5) # Show IPFs before continuing with next vendor"
]
},
Expand Down Expand Up @@ -703,7 +703,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
6 changes: 1 addition & 5 deletions doc/tutorials/visualizing_patterns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@
"%matplotlib inline\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pyvista as pv\n",
"import skimage.exposure as ske\n",
"import skimage.transform as skt\n",
"\n",
"import hyperspy.api as hs\n",
"import kikuchipy as kp\n",
"from orix import io, plot, quaternion, vector\n",
"\n",
"\n",
"# See https://docs.pyvista.org/user-guide/jupyter/index.html\n",
Expand Down Expand Up @@ -337,7 +333,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.7"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,15 @@ filterwarnings = [
profile = "black"
filter_files = true
force_sort_within_sections = true

[tool.ruff.lint]
select = [
# Pyflakes
"F",
# Pycodestyle
"E",
"W",
# isort
"I"
]
extend-ignore = ["E501"]

0 comments on commit b0c5536

Please sign in to comment.