<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2017 <NAME> <<EMAIL>>
#
# Distributed under terms of the MIT license.

"""Create functions to colourize figures."""

import logging

import numpy as np
from hsluv import hpluv_to_hex

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

HEX_VALUES_DARK = np.array([hpluv_to_hex((value, 85, 65)) for value in range(360)])
HEX_VALUES_LIGHT = np.array([hpluv_to_hex((value, 85, 85)) for value in range(360)])


def colour_orientation(orientations, light_colours=False):
    """Get a colour from an orientation."""
    orientations = orientations % 2 * np.pi
    if light_colours:
        return HEX_VALUES_LIGHT[np.floor(orientations / np.pi * 180).astype(int)]
    return HEX_VALUES_DARK[np.floor(orientations / np.pi * 180).astype(int)]<commit_msg>Revert deletion of clean_orientation function<commit_after>#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2017 <NAME> <<EMAIL>>
#
# Distributed under terms of the MIT license.

"""Create functions to colourize figures."""

import logging

import numpy as np
from hsluv import hpluv_to_hex

from ..analysis.order import get_z_orientation

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

HEX_VALUES_DARK = np.array([hpluv_to_hex((value, 85, 65)) for value in range(360)])
HEX_VALUES_LIGHT = np.array([hpluv_to_hex((value, 85, 85)) for value in range(360)])


def clean_orientation(snapshot):
    """Convert an orientation to a sensible format."""
    orientations = get_z_orientation(snapshot.particles.orientation)
    nmol = max(snapshot.particles.body)+1
    o_dict = {body: orient for body, orient in zip(
        snapshot.particles.body[:nmol],
        orientations
    )}
    orientation = np.array([o_dict[body] for body in snapshot.particles.body])
    return orientation


def colour_orientation(orientations, light_colours=False):
    """Get a colour from an orientation."""
    orientations = orientations % 2 * np.pi
    if light_colours:
        return HEX_VALUES_LIGHT[np.floor(orientations / np.pi * 180).astype(int)]
    return HEX_VALUES_DARK[np.floor(orientations / np.pi * 180).astype(int)]
{'fraction_non_alphanumeric': 0.12483100495718792, 'fraction_numerical': 0.024785939612438034, 'mean_word_length': 4.508684863523573, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4521864', 'n_tokens_mistral': 798, 'n_tokens_neox': 738, 'n_words': 188}