<commit_before>from openmdao.main.api import Component, Container, Assembly
from openmdao.lib.datatypes.api import *
from numpy import array
from requests import get, post
import json
from flask import Flask, request
from flask_wtf import Form, RecaptchaField
from flask.ext.mail import Message, Mail
from wtforms import TextField, HiddenField, FloatField, ValidationError, RadioField,\
    BooleanField, SubmitField, IntegerField, FormField, validators, PasswordField, TextAreaField,\
    SelectField
from wtforms.validators import Required
from flask import Flask, request, render_template, flash
import yaml
from werkzeug.datastructures import MultiDict


json2omdao = {
    'Float': Float,
    'Int': Int,
    'Array': Array,
    'Str': Str,
    'Enum': Enum
    }

json2type = {
    'Float': float,
    'Int': int,
    'Array': array,
    'Str': str,
    'Enum': str
    }


def prep_field(dic):
    """Helpful function that translate the FUSED I/O definition into something
    consumable by the wtform field classes
    """
    out = {}
    if 'desc' in dic:
        out['description'] = dic['desc']
    if 'default' in dic:
        out['default'] = dic['default']
    if 'values' in dic:
        out['choices'] = [(val, val) for val in dic['values']]
    return out

# A rosetta dictionary to transform between FUSED types into WTForm field types
type_fields = {
    'Float':FloatField,
    'Int':IntegerField,
    'Str':TextField,
    'Array':TextField,
    'Enum': SelectField
}

def traits2json(cpnt):<commit_msg>added Bool type<commit_after>from openmdao.main.api import Component, Container, Assembly
from openmdao.lib.datatypes.api import *
from numpy import array
from requests import get, post
import json
from flask import Flask, request
from flask_wtf import Form, RecaptchaField
from flask.ext.mail import Message, Mail
from wtforms import TextField, HiddenField, FloatField, ValidationError, RadioField,\
    BooleanField, SubmitField, IntegerField, FormField, validators, PasswordField, TextAreaField,\
    SelectField
from wtforms.validators import Required
from flask import Flask, request, render_template, flash
import yaml
from werkzeug.datastructures import MultiDict


json2omdao = {
    'Float': Float,
    'Int': Int,
    'Array': Array,
    'Str': Str,
    'Enum': Enum,
    'Bool': Bool
    }

json2type = {
    'Float': float,
    'Int': int,
    'Array': array,
    'Str': str,
    'Enum': str,
    'Bool': bool
    }


def prep_field(dic):
    """Helpful function that translate the FUSED I/O definition into something
    consumable by the wtform field classes
    """
    out = {}
    if 'desc' in dic:
        out['description'] = dic['desc']
    if 'default' in dic:
        out['default'] = dic['default']
    if 'values' in dic:
        out['choices'] = [(val, val) for val in dic['values']]
    return out

# A rosetta dictionary to transform between FUSED types into WTForm field types
type_fields = {
    'Float':FloatField,
    'Int':IntegerField,
    'Str':TextField,
    'Array':TextField,
    'Enum': SelectField,
    'Bool': BooleanField
}

def traits2json(cpnt):
{'fraction_non_alphanumeric': 0.10668380462724936, 'fraction_numerical': 0.0019280205655526992, 'mean_word_length': 3.681203007518797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3589105', 'n_tokens_mistral': 965, 'n_tokens_neox': 940, 'n_words': 317}