pyxem / kikuchipy

Toolbox for analysis of electron backscatter diffraction (EBSD) patterns
https://kikuchipy.org
GNU General Public License v3.0
79 stars 30 forks source link

Add option to return new (possibly lazy) signal instead of operating inplace #605

Closed hakonanes closed 1 year ago

hakonanes commented 1 year ago

Description of the change

This PR adds the option to pass inplace=False to many methods, like EBSD.remove_static_background() or EBSDMasterPattern.rescale_intensity(). Most methods also support to return a lazy signal instead of one in memory via lazy_output=True.

A LazyVirtualBSEImage class is added for use with mostly VirtualBSEImage.rescale_intensity(inplace=False, lazy_output=True).

Progress of the PR

Minimal example of the bug fix or new feature

>>> import kikuchipy as kp
>>> s = kp.data.nickel_ebsd_small()

# Before

>>> s2 = s.deepcopy()
>>> s2.remove_static_background()

# Now

>>> s2 = s.remove_static_background(inplace=False)

For reviewers