Skip to content

Commit

Permalink
Merge pull request #432 from hakonanes/main-into-develop-post-0.11-re…
Browse files Browse the repository at this point in the history
…lease

Main into develop post 0.11 release
  • Loading branch information
hakonanes authored Feb 27, 2023
2 parents 4eb6151 + c7af446 commit e3e10a4
Show file tree
Hide file tree
Showing 23 changed files with 308 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Check code style of Jupyter notebooks
run: |
black doc/**/*.ipynb --check
black --diff --line-length 77 doc/tutorials/*.ipynb
# Make sure all necessary files will be included in a release
manifest:
Expand Down
14 changes: 6 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
- id: black-jupyter
files: \.ipynb
args: [--line-length=77]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args:
[
"--profile",
"black",
"--filter-files",
"--force-sort-within-sections",
]
[--profile=black, --filter-files, --force-sort-within-sections]
17 changes: 5 additions & 12 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
Changelog
=========

All notable changes to the ``orix`` project are documented in this file.
All user facing changes to this project are documented in this file. The format is based
on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`__, and this project tries
its best to adhere to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`__.

The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`__, and
this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`__.

Unreleased
==========
2023-02-09 - version 0.11.0
===========================

Added
-----
Expand Down Expand Up @@ -46,9 +45,6 @@ Changed
- Bumped minimal version of ``diffpy.structure >= 3.0.2``.
- Only ASTAR .ang files return crystal maps with ``"nm"`` as scan unit.

Deprecated
----------

Removed
-------
- Parameter ``z`` when creating a ``CrystalMap`` and the ``z`` and ``dz`` attributes of
Expand All @@ -64,9 +60,6 @@ Fixed
-----
- Reading of EDAX TSL .ang files with ten columns should now work.

Security
--------

2022-10-25 - version 0.10.2
===========================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@
"\n",
"# Cluster 2\n",
"centre2 = Rotation.from_axes_angles((1, 0, 0), np.pi / 4)\n",
"cluster2 = Rotation.random_vonmises(n_orientations, alpha=alpha, reference=centre2)\n",
"cluster2 = Rotation.random_vonmises(\n",
" n_orientations, alpha=alpha, reference=centre2\n",
")\n",
"\n",
"# Cluster 3\n",
"centre3 = Rotation.from_axes_angles((1, 1, 0), np.pi / 3)\n",
"cluster3 = Rotation.random_vonmises(n_orientations, alpha=alpha, reference=centre3)\n",
"cluster3 = Rotation.random_vonmises(\n",
" n_orientations, alpha=alpha, reference=centre3\n",
")\n",
"\n",
"# Stack and map into the Oh fundamental zone\n",
"ori = Orientation.stack([cluster1, cluster2, cluster3]).flatten()\n",
Expand Down Expand Up @@ -172,9 +176,9 @@
"metadata": {},
"outputs": [],
"source": [
"dbscan = DBSCAN(eps=np.deg2rad(17), min_samples=20, metric=\"precomputed\").fit(\n",
" D2.astype(np.float32)\n",
")\n",
"dbscan = DBSCAN(\n",
" eps=np.deg2rad(17), min_samples=20, metric=\"precomputed\"\n",
").fit(D2.astype(np.float32))\n",
"print(\"Labels:\", np.unique(dbscan.labels_))"
]
},
Expand Down Expand Up @@ -202,7 +206,9 @@
"source": [
"color_names = [to_rgb(f\"C{i}\") for i in range(6)] # ['C0', 'C1', ...]\n",
"\n",
"colors_naive = label2rgb(dbscan_naive.labels_, colors=color_names, bg_label=-1)\n",
"colors_naive = label2rgb(\n",
" dbscan_naive.labels_, colors=color_names, bg_label=-1\n",
")\n",
"colors = label2rgb(dbscan.labels_, colors=color_names, bg_label=-1)"
]
},
Expand Down Expand Up @@ -256,7 +262,9 @@
" plt.draw()\n",
"\n",
"\n",
"ani = animation.FuncAnimation(fig, animate, np.linspace(75, 360 + 74, 720), interval=25)"
"ani = animation.FuncAnimation(\n",
" fig, animate, np.linspace(75, 360 + 74, 720), interval=25\n",
")"
]
}
],
Expand All @@ -276,7 +284,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
60 changes: 38 additions & 22 deletions doc/tutorials/clustering_misorientations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,27 @@
"outputs": [],
"source": [
"ckey = plot.IPFColorKeyTSL(D6)\n",
"ckey.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(ncols=2, figsize=(15, 10))\n",
"\n",
"directions = [(1, 0, 0), (0, 1, 0)]\n",
"titles = [\"X\", \"Y\"]\n",
"for i in range(len(ax)):\n",
"\n",
"fig, axes = plt.subplots(ncols=2, figsize=(15, 10))\n",
"for i, ax in enumerate(axes):\n",
" ckey.direction = Vector3d(directions[i])\n",
" # Invert because orix assumes lab2crystal when coloring orientations\n",
" ax[i].imshow(ckey.orientation2color(~ori))\n",
" ax[i].set_title(f\"IPF-{titles[i]}\")\n",
" ax[i].axis(\"off\")\n",
"fig.tight_layout()"
" ax.imshow(ckey.orientation2color(~ori))\n",
" ax.set_title(f\"IPF-{titles[i]}\")\n",
" ax.axis(\"off\")\n",
"\n",
"# Add color key\n",
"ax_ipfkey = fig.add_axes(\n",
" [0.932, 0.37, 0.1, 0.1], # (Left, bottom, width, height)\n",
" projection=\"ipf\",\n",
" symmetry=ori.symmetry.laue,\n",
")\n",
"ax_ipfkey.plot_ipf_color_key()\n",
"ax_ipfkey.set_title(\"\")\n",
"fig.subplots_adjust(wspace=0.01)"
]
},
{
Expand Down Expand Up @@ -267,7 +269,9 @@
"# Compute clusters\n",
"dbscan = DBSCAN(eps=0.05, min_samples=10, metric=\"precomputed\").fit(D)\n",
"\n",
"unique_labels, all_cluster_sizes = np.unique(dbscan.labels_, return_counts=True)\n",
"unique_labels, all_cluster_sizes = np.unique(\n",
" dbscan.labels_, return_counts=True\n",
")\n",
"print(\"Labels:\", unique_labels)\n",
"\n",
"n_clusters = unique_labels.size - 1\n",
Expand All @@ -287,7 +291,9 @@
"metadata": {},
"outputs": [],
"source": [
"unique_cluster_labels = unique_labels[1:] # Without the \"no-cluster\" label -1\n",
"unique_cluster_labels = unique_labels[\n",
" 1:\n",
"] # Without the \"no-cluster\" label -1\n",
"cluster_sizes = all_cluster_sizes[1:]\n",
"\n",
"rc = Rotation.from_axes_angles((0, 0, 1), 15, degrees=True)\n",
Expand Down Expand Up @@ -383,7 +389,9 @@
"source": [
"mori2 = (~twin_theory).outer(cluster_means)\n",
"sym_op = D6.outer(D6).unique()\n",
"mori2_equiv = D6.outer(~twin_theory).outer(sym_op).outer(cluster_means).outer(D6)\n",
"mori2_equiv = (\n",
" D6.outer(~twin_theory).outer(sym_op).outer(cluster_means).outer(D6)\n",
")\n",
"D2 = mori2_equiv.angle.min(axis=(0, 2, 4))"
]
},
Expand Down Expand Up @@ -438,8 +446,12 @@
"cluster_sizes = all_cluster_sizes[1:]\n",
"cluster_sizes_scaled = 1000 * cluster_sizes / cluster_sizes.max()\n",
"\n",
"fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(projection=\"ipf\", symmetry=D6))\n",
"ax.scatter(cluster_means.axis, c=colors, s=cluster_sizes_scaled, alpha=0.5, ec=\"k\")"
"fig, ax = plt.subplots(\n",
" figsize=(5, 5), subplot_kw=dict(projection=\"ipf\", symmetry=D6)\n",
")\n",
"ax.scatter(\n",
" cluster_means.axis, c=colors, s=cluster_sizes_scaled, alpha=0.5, ec=\"k\"\n",
")"
]
},
{
Expand All @@ -462,7 +474,9 @@
},
"outputs": [],
"source": [
"wireframe_kwargs = dict(color=\"black\", linewidth=0.5, alpha=0.1, rcount=361, ccount=361)\n",
"wireframe_kwargs = dict(\n",
" color=\"black\", linewidth=0.5, alpha=0.1, rcount=361, ccount=361\n",
")\n",
"fig = mori.scatter(\n",
" projection=\"axangle\",\n",
" wireframe_kwargs=wireframe_kwargs,\n",
Expand All @@ -477,7 +491,9 @@
"handle_kwds = dict(marker=\"o\", color=\"none\", markersize=10)\n",
"handles = []\n",
"for i in range(n_clusters):\n",
" line = Line2D([0], [0], label=i + 1, markerfacecolor=colors[i], **handle_kwds)\n",
" line = Line2D(\n",
" [0], [0], label=i + 1, markerfacecolor=colors[i], **handle_kwds\n",
" )\n",
" handles.append(line)\n",
"ax.legend(\n",
" handles=handles,\n",
Expand Down
134 changes: 70 additions & 64 deletions doc/tutorials/clustering_orientations.ipynb

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions doc/tutorials/crystal_directions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"outputs": [],
"source": [
"tetragonal = Phase(\n",
" point_group=\"4\", structure=Structure(lattice=Lattice(0.5, 0.5, 1, 90, 90, 90))\n",
" point_group=\"4\",\n",
" structure=Structure(lattice=Lattice(0.5, 0.5, 1, 90, 90, 90)),\n",
")\n",
"print(tetragonal)\n",
"print(tetragonal.structure.lattice)"
Expand Down Expand Up @@ -383,7 +384,8 @@
"outputs": [],
"source": [
"trigonal = Phase(\n",
" point_group=\"321\", structure=Structure(lattice=Lattice(4.9, 4.9, 5.4, 90, 90, 120))\n",
" point_group=\"321\",\n",
" structure=Structure(lattice=Lattice(4.9, 4.9, 5.4, 90, 90, 120)),\n",
")\n",
"trigonal"
]
Expand Down Expand Up @@ -733,7 +735,9 @@
"metadata": {},
"outputs": [],
"source": [
"o2 = Orientation.from_euler([10, 20, 30], symmetry=trigonal.point_group, degrees=True)\n",
"o2 = Orientation.from_euler(\n",
" [10, 20, 30], symmetry=trigonal.point_group, degrees=True\n",
")\n",
"o2"
]
},
Expand Down
Loading

0 comments on commit e3e10a4

Please sign in to comment.