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

New patch release 0.8.7 fixing passing a PC array > 1D to HI PC optimization #647

Merged
merged 3 commits into from Jul 24, 2023

Conversation

hakonanes
Copy link
Member

@hakonanes hakonanes commented Jul 23, 2023

Description of the change

We cannot pass a 3-component projection center (PC) array with more than one dimension to EBSD.hough_indexing_optimize_pc(). This PR fixes this. Since it's a bug, I'll release the fix as a patch release 0.8.7 tomorrow Monday 24 July.

The previousy failing behavior is now tested.

The error raised is:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[10], line 1
----> 1 det_ref = s_in.hough_indexing_optimize_pc(pc0=det.pc, indexer=indexer)
      3 print(det.pc - det_ref.pc)

File ~/checkouts/readthedocs.org/user_builds/kikuchipy/envs/646/lib/python3.11/site-packages/kikuchipy/signals/ebsd.py:1803, in EBSD.hough_indexing_optimize_pc(self, pc0, indexer, batch, method)
   1800 if self._lazy:  # pragma: no cover
   1801     patterns = patterns.rechunk({0: "auto", 1: -1, 2: -1})
-> 1803 pc = _optimize_pc(
   1804     pc0=pc0, patterns=patterns, indexer=indexer, batch=batch, method=method
   1805 )
   1807 if batch:
   1808     pc = pc.reshape(nav_shape + (3,))

File ~/checkouts/readthedocs.org/user_builds/kikuchipy/envs/646/lib/python3.11/site-packages/kikuchipy/indexing/_hough_indexing.py:411, in _optimize_pc(pc0, patterns, indexer, batch, method)
    409 else:
    410     from pyebsdindex.pcopt import optimize as optimize_func
--> 411 return optimize_func(pats=patterns, indexer=indexer, PC0=pc0, batch=batch)

File ~/checkouts/readthedocs.org/user_builds/kikuchipy/envs/646/lib/python3.11/site-packages/pyebsdindex/pcopt.py:119, in optimize(pats, indexer, PC0, batch)
    116     PC0 = PCtemp
    118 if not batch:
--> 119     PCopt = opt.minimize(
    120         _optfunction,
    121         PC0,
    122         args=(indexer, banddat),
    123         method="Nelder-Mead",
    124         options={"fatol": 0.00001}
    125     )
    126     PCoutRet = PCopt['x']
    127 else:

File ~/checkouts/readthedocs.org/user_builds/kikuchipy/envs/646/lib/python3.11/site-packages/scipy/optimize/_minimize.py:533, in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
    530 x0 = np.atleast_1d(np.asarray(x0))
    532 if x0.ndim != 1:
--> 533     raise ValueError("'x0' must only have one dimension.")
    535 if x0.dtype.kind in np.typecodes["AllInteger"]:
    536     x0 = np.asarray(x0, dtype=float)

ValueError: 'x0' must only have one dimension.

It is seen in the docs built from #646: https://kikuchipy--646.org.readthedocs.build/en/646/tutorials/pc_calibration_moving_screen_technique.html.

Progress of the PR

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • New contributors are added to release.py, .zenodo.json and
    .all-contributorsrc with the table regenerated.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes added the bug Something isn't working label Jul 23, 2023
@hakonanes hakonanes added this to the v0.8.7 milestone Jul 23, 2023
@hakonanes hakonanes mentioned this pull request Jul 23, 2023
5 tasks
@hakonanes
Copy link
Member Author

In the interest of time, I'll release this now.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes merged commit 3ccece9 into pyxem:main Jul 24, 2023
12 checks passed
@hakonanes hakonanes deleted the fix-pc-shape-hi-optimize branch July 24, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant