MechMicroMan / DefDAP

A python library for correlating EBSD and HRDIC data
Apache License 2.0
35 stars 16 forks source link

Error with findGrains #125

Closed rhysgt closed 4 months ago

rhysgt commented 5 months ago

An error has emerged in the findGrains function in the latest release of defdap.

Even though nothing has changed in the code, the following error occurs in the docs (which were recently recompiled).

I guess the behaviour of script.stats.mode might have changed?


IndexError Traceback (most recent call last) Cell In[33], line 1 ----> 1 dicMap.findGrains(minGrainSize=10)

File ~/checkouts/readthedocs.org/user_builds/defdap/envs/latest/lib/python3.10/site-packages/defdap/utils.py:47, in reportProgress..decorator..wrapper(*args, **kwargs) 45 try: 46 while True: ---> 47 prog = next(generator) 48 if type(prog) is str: 49 printFinal = False

File ~/checkouts/readthedocs.org/userbuilds/defdap/envs/latest/lib/python3.10/site-packages/defdap/hrdic.py:942, in Map.findGrains(self, algorithm, minGrainSize) 937 for i in range(len(self)): 938 # Find grain by masking the native ebsd grain image with 939 # selected grain from the warped dic grain image. The modal 940 # value is the EBSD grain label. 941 modeId, = mode(self.ebsdMap.grains[warpedDicGrains == i + 1]) --> 942 ebsd_grain_idx = modeId[0] - 1 943 self.ebsdGrainIds.append(ebsd_grain_idx) 944 self[i].ebsdGrainId = ebsd_grain_idx

IndexError: invalid index to scalar variable.

rhysgt commented 5 months ago

Occurs in scipy version >1.11.4 and possibly earlier.

Could be related to this:

Unlike other reduction functions (e.g. skew, kurtosis), the default behavior of mode usually retains the the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of keepdims will become False, the axis over which the statistic is taken will be eliminated, and the value None will no longer be accepted.