<commit_before># ##### BEGIN GPL LICENSE BLOCK #####
#
#  JewelCraft jewelry design toolkit for Blender.
#  Copyright (C) 2015-2020  <NAME>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
# ##### END GPL LICENSE BLOCK #####


from math import pi, modf

from .. import var
from ..lib import unit, asset, gettext


def _ct_calc(stone, cut, size):
    try:
        dens = var.STONES[stone].density
        corr = var.CUTS[cut].vol_correction
    except KeyError:
        return 0

    dens = unit.convert_cm3_mm3(dens)
    l = size[1]
    w = size[0]
    h = size[2]

    if cut in {"ROUND", "OVAL", "PEAR", "MARQUISE", "OCTAGON", "HEART"}:
        vol = pi * (l / 2) * (w / 2) * (h / 3)  # Cone

    elif cut in {"SQUARE", "ASSCHER", "PRINCESS", "CUSHION", "RADIANT", "FLANDERS"}:
        vol = l * w * h / 3  # Pyramid

    elif cut in {"BAGUETTE", "EMERALD"}:
        vol = l * w * (h / 2)  # Prism

    elif cut in {"TRILLION", "TRILLIANT", "TRIANGLE"}:
        vol = l * w * h / 6  # Tetrahedron

    g = vol * corr * dens
    ct = unit.convert_g_ct(g)

    return round(ct, 3)


def _to_ring_size(cir, size_format):
    if size_format in {"US", "JP"}:
        size = round((cir - var.CIR_BASE_US) / var.CIR_STEP_US, 2)

        if size >= 0.0:

            if size_format == "US":
                return asset.to_int(size)

            for i, s in enumerate(var.MAP_SIZE_JP_TO_US):
                if s - 0.2 < size < s + 0.2:
                    return i + 1<commit_msg>Cleanup: make use of enumerate start argument<commit_after># ##### BEGIN GPL LICENSE BLOCK #####
#
#  JewelCraft jewelry design toolkit for Blender.
#  Copyright (C) 2015-2020  <NAME>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
# ##### END GPL LICENSE BLOCK #####


from math import pi, modf

from .. import var
from ..lib import unit, asset, gettext


def _ct_calc(stone, cut, size):
    try:
        dens = var.STONES[stone].density
        corr = var.CUTS[cut].vol_correction
    except KeyError:
        return 0

    dens = unit.convert_cm3_mm3(dens)
    l = size[1]
    w = size[0]
    h = size[2]

    if cut in {"ROUND", "OVAL", "PEAR", "MARQUISE", "OCTAGON", "HEART"}:
        vol = pi * (l / 2) * (w / 2) * (h / 3)  # Cone

    elif cut in {"SQUARE", "ASSCHER", "PRINCESS", "CUSHION", "RADIANT", "FLANDERS"}:
        vol = l * w * h / 3  # Pyramid

    elif cut in {"BAGUETTE", "EMERALD"}:
        vol = l * w * (h / 2)  # Prism

    elif cut in {"TRILLION", "TRILLIANT", "TRIANGLE"}:
        vol = l * w * h / 6  # Tetrahedron

    g = vol * corr * dens
    ct = unit.convert_g_ct(g)

    return round(ct, 3)


def _to_ring_size(cir, size_format):
    if size_format in {"US", "JP"}:
        size = round((cir - var.CIR_BASE_US) / var.CIR_STEP_US, 2)

        if size >= 0.0:

            if size_format == "US":
                return asset.to_int(size)

            for size_jp, size_us in enumerate(var.MAP_SIZE_JP_TO_US, start=1):
                if size_us - 0.2 < size < size_us + 0.2:
                    return size_jp
{'fraction_non_alphanumeric': 0.12141332700972256, 'fraction_numerical': 0.014228124258951862, 'mean_word_length': 2.509151414309484, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2246013', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1406, 'n_words': 511}