From 2f7b49b9566e05e9414cb24d87c9fcd002ceb55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Sat, 4 Mar 2023 19:33:48 +0100 Subject: [PATCH 1/8] Return xmap with correct phase list when sparse one is given MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- orix/crystal_map/crystal_map.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/orix/crystal_map/crystal_map.py b/orix/crystal_map/crystal_map.py index 87fdee5a..07f60c92 100644 --- a/orix/crystal_map/crystal_map.py +++ b/orix/crystal_map/crystal_map.py @@ -23,7 +23,7 @@ import numpy as np from orix.crystal_map.crystal_map_properties import CrystalMapProperties -from orix.crystal_map.phase_list import Phase, PhaseList +from orix.crystal_map.phase_list import ALL_COLORS, Phase, PhaseList from orix.quaternion import Orientation, Rotation @@ -251,7 +251,7 @@ def __init__( if phase_list is None: self._phases = PhaseList(ids=unique_phase_ids) else: - phase_list = copy.deepcopy(phase_list) + phase_list = phase_list.deepcopy() phase_ids = phase_list.ids n_different = len(phase_ids) - len(unique_phase_ids) if n_different > 0: @@ -265,15 +265,20 @@ def __init__( break elif n_different < 0: # Create new phase list adding the missing phases with - # default initial values - phase_list = PhaseList( - names=phase_list.names, - space_groups=phase_list.space_groups, - point_groups=phase_list.point_groups, - colors=phase_list.colors, - structures=phase_list.structures, - ids=unique_phase_ids, + # default initial values (but unique colors) + phase_dict = {} + all_colors = list(ALL_COLORS.keys()) + all_unique_colors = np.delete( + all_colors, np.isin(all_colors, phase_list.colors) ) + ci = 0 + for i in unique_phase_ids: + if i in phase_ids: + phase_dict[i] = phase_list[i] + else: + phase_dict[i] = Phase(color=all_unique_colors[ci]) + ci += 1 + phase_list = PhaseList(phase_dict) # Ensure phase list IDs correspond to IDs in phase_id array new_ids = list(unique_phase_ids.astype(int)) phase_list._dict = dict(zip(new_ids, phase_list._dict.values())) From 3ed10cd41acbe14d0d7a9dbcfe4a2a13574a385d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Sat, 4 Mar 2023 19:34:23 +0100 Subject: [PATCH 2/8] Test xmap init with phase list with fewer phases than in phase IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- orix/tests/test_crystal_map.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/orix/tests/test_crystal_map.py b/orix/tests/test_crystal_map.py index 6a5dbf9a..b3764424 100644 --- a/orix/tests/test_crystal_map.py +++ b/orix/tests/test_crystal_map.py @@ -166,6 +166,31 @@ def test_init_with_phase_list(self, crystal_map_input, expected_presence): unique_phase_ids = list(np.unique(crystal_map_input["phase_id"]).astype(int)) assert xmap.phases.ids == unique_phase_ids + def test_init_with_sparse_phase_list(self): + """Initialize a map with a sparse phase list only containing one + of the phase IDs passed in the phase list. + """ + pl = PhaseList(ids=[1], names=["b"], space_groups=[225]) + phase_id = np.array([0, 0, 1, 1, 1, 3]) + xmap = CrystalMap( + rotations=Rotation.identity(phase_id.size), + is_in_data=phase_id == 1, + phase_list=pl, + phase_id=phase_id, + ) + for i, name, color, sg_name in zip( + [0, 1, 3], + ["", "b", ""], + ["tab:orange", "tab:blue", "tab:green"], + [None, "Fm-3m", None], + ): + assert xmap.phases[i].name == name + assert xmap.phases[i].color == color + if sg_name is None: + assert xmap.phases[i].space_group is None + else: + assert xmap.phases[i].space_group.short_name == sg_name + def test_init_with_single_point_group(self, crystal_map_input): point_group = O phase_list = PhaseList(point_groups=point_group) From c72e1ff8d7c7415549d69f52ad867694403d3e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Sat, 4 Mar 2023 19:35:10 +0100 Subject: [PATCH 3/8] Bump version to 0.11.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- orix/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orix/__init__.py b/orix/__init__.py index 6794c8ab..c915050c 100644 --- a/orix/__init__.py +++ b/orix/__init__.py @@ -1,5 +1,5 @@ __name__ = "orix" -__version__ = "0.11.0" +__version__ = "0.11.1" __author__ = "orix developers" __author_email__ = "pyxem.team@gmail.com" __description__ = "orix is an open-source Python library for handling crystal orientation mapping data." From 16fb7929030f1fd6832e2354fe4b69ab195db2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Sat, 4 Mar 2023 19:35:23 +0100 Subject: [PATCH 4/8] Add 0.11.1 section to changelog, mention phase list fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- CHANGELOG.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 80e5129f..c175fb4e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,14 @@ All user facing changes to this project are documented in this file. The format on `Keep a Changelog `__, and this project tries its best to adhere to `Semantic Versioning `__. +2023-03-14 - version 0.11.1 +=========================== + +Fixed +----- +- Initialization of a crystal map with a phase list with fewer phases than in the phase + ID array given returns a map with a new phase list with correct phase IDs. + 2023-02-09 - version 0.11.0 =========================== From 5507c46299424de407ad6a6a33307d6bd3d67c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Sat, 4 Mar 2023 20:07:53 +0100 Subject: [PATCH 5/8] Add icon_links to PyData HTML theme options to work around error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index c1ed70de..a58ccd63 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -86,6 +86,7 @@ html_theme_options = { "github_url": "https://github.com/pyxem/orix", "header_links_before_dropdown": 6, + "icon_links": [], # Workaround for pydata/pydata-sphinx-theme#1220 "logo": {"alt_text": project, "text": project}, "navigation_with_keys": False, "show_toc_level": 2, From 110a8a767d4aa4866d3721180d72381faddf69fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Tue, 7 Mar 2023 08:49:17 +0100 Subject: [PATCH 6/8] Restrict PyData Sphinx Theme to >= 0.13.1 to avoid workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- doc/conf.py | 1 - setup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a58ccd63..c1ed70de 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -86,7 +86,6 @@ html_theme_options = { "github_url": "https://github.com/pyxem/orix", "header_links_before_dropdown": 6, - "icon_links": [], # Workaround for pydata/pydata-sphinx-theme#1220 "logo": {"alt_text": project, "text": project}, "navigation_with_keys": False, "show_toc_level": 2, diff --git a/setup.py b/setup.py index c28128aa..68b0ac95 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ "sphinx-design", "sphinx-gallery < 0.11", "sphinx-last-updated-by-git", - "pydata-sphinx-theme", + "pydata-sphinx-theme >= 0.13.1", "sphinxcontrib-bibtex >= 1.0", "scikit-image", "scikit-learn", From 09fabf9973b2a6a3d307c606d2fac9ce83d16121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Tue, 14 Mar 2023 10:21:55 +0100 Subject: [PATCH 7/8] Revert release version to 0.12.dev0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- orix/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orix/__init__.py b/orix/__init__.py index c915050c..c18f0941 100644 --- a/orix/__init__.py +++ b/orix/__init__.py @@ -1,5 +1,5 @@ __name__ = "orix" -__version__ = "0.11.1" +__version__ = "0.12.dev0" __author__ = "orix developers" __author_email__ = "pyxem.team@gmail.com" __description__ = "orix is an open-source Python library for handling crystal orientation mapping data." From bd6109806567692872e44dad50e005c0deff7eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Tue, 14 Mar 2023 10:22:09 +0100 Subject: [PATCH 8/8] Add Unreleased section to changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- CHANGELOG.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c175fb4e..422001df 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,24 @@ All user facing changes to this project are documented in this file. The format on `Keep a Changelog `__, and this project tries its best to adhere to `Semantic Versioning `__. +Unreleased +========== + +Added +----- + +Changed +------- + +Deprecated +---------- + +Removed +------- + +Fixed +----- + 2023-03-14 - version 0.11.1 ===========================