How to use the orix.scalar.Scalar function in orix

To help you get started, we’ve selected a few orix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyxem / orix / tests / test_scalar.py View on Github external
    ([5], Scalar([6]), 0),
    pytest.param([3], 'larry', None, marks=pytest.mark.xfail),
], indirect=['scalar'])
def test_equality(scalar, other, expected):
    eq = scalar == other
    assert np.allclose(eq, expected)
github pyxem / orix / tests / test_vector3d.py View on Github external
def scalar(request):
    return Scalar(request.param)
github pyxem / orix / orix / plot / crystal_map_plot.py View on Github external
phase_id = crystal_map.get_map_data("phase_id")
            phase_id = phase_id[self._data_slices]
            unique_phase_ids = np.unique(phase_id[~np.isnan(phase_id)])
            data = np.ones(phase_id.shape + (3,))
            for i, color in zip(
                unique_phase_ids, crystal_map.phases_in_data.colors_rgb
            ):
                mask = phase_id == int(i)
                data[mask] = data[mask] * color

            # Add legend patches to plot
            patches = []
            for _, p in crystal_map.phases_in_data:
                patches.append(mpatches.Patch(color=p.color_rgb, label=p.name))
        else:  # Create masked array of correct shape
            if isinstance(value, Scalar) or isinstance(value, Vector3d):
                value = value.data
            data = crystal_map.get_map_data(value)
            data = data[self._data_slices]

        # Squeeze 1-dimensions
        data = np.squeeze(data)

        # Legend
        if legend and isinstance(patches, list):
            if legend_properties is None:
                legend_properties = {}
            self._add_legend(patches, **legend_properties)

        # Scalebar
        if scalebar:
            if scalebar_properties is None:
github pyxem / orix / orix / vector / __init__.py View on Github external
def __add__(self, other):
        if isinstance(other, Vector3d):
            return self.__class__(self.data + other.data)
        elif isinstance(other, Scalar):
            return self.__class__(self.data + other.data[..., np.newaxis])
        elif isinstance(other, (int, float)):
            return self.__class__(self.data + other)
        elif isinstance(other, (list, tuple)):
            other = np.array(other)
        if isinstance(other, np.ndarray):
            return self.__class__(self.data + other[..., np.newaxis])
        return NotImplemented
github pyxem / orix / orix / quaternion / rotation.py View on Github external
def angle_with(self, other):
        """The angle of rotation transforming this rotation to the other.

        Returns
        -------
        Scalar

        """
        other = Rotation(other)
        angles = Scalar(
            np.nan_to_num(np.arccos(2 * self.unit.dot(other.unit).data ** 2 - 1))
        )
        return angles
github pyxem / orix / orix / vector / __init__.py View on Github external
def z(self):
        """Scalar : This vector's z data."""
        return Scalar(self.data[..., 2])
github pyxem / orix / orix / quaternion / __init__.py View on Github external
def dot_outer(self, other):
        """Scalar : the outer dot product of this quaternion and the other."""
        dots = np.tensordot(self.data, other.data, axes=(-1, -1))
        return Scalar(dots)
github pyxem / orix / orix / vector / __init__.py View on Github external
def y(self):
        """Scalar : This vector's y data."""
        return Scalar(self.data[..., 1])
github pyxem / orix / orix / quaternion / __init__.py View on Github external
def b(self):
        return Scalar(self.data[..., 1])
github pyxem / orix / orix / vector / neo_euler.py View on Github external
def angle(self):
        return Scalar(np.arctan(self.norm.data) * 2)