Skip to content

DirectionColorKeyTSL.direction2color throws an error when passed a Miller #638

@argerlt

Description

@argerlt

@alpkulaksizoglu brought up an error in a recent disussion thread.

Namely, if you do the following:

import orix.crystal_map as ocm
import orix.vector as ove
import orix.plot as opl
import orix.quaternion.symmetry as osm # <-- side note, should we start doing this?

phase = ocm.Phase(point_group=osm.D6h)
rgbkey=opl.DirectionColorKeyTSL(osm.D6h)

m = ove.Miller(uvw=[1,2,3],phase=phase)
rgb = rgbkey.direction2color(m)

you get the following error:

AttributeError: 'Vector3d' object has no attribute 'phase'

Which seems to happen here because laue_group.fundamental_sector is a FundamentalSector and 'h' is a Miller, and when later on a cross product is attempted, laue_group.fundamental_sector doesn't have the phase attributed needed by Miller.cross

If we think users should be allowed to pass Miller objects into direction2color (I think that makes sense?) we just need to add the following if/then/else to DirectionColorKeyTSL.direction2color

if isinstance(direction, ove.Miller):
    if direction.phase.point_group.laue == self.symmetry
         direction = Vector3d(direction)
    else:
        "Input Error message here"

Otherwise, if there is a reason this should not be allowed, we should add a relevant error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions