<commit_before>#!/usr/bin/env python3.5
import pandas as pd
import sqlalchemy

import unittest
import pdb
from collections import OrderedDict
from decimal import Decimal

from features import compute_bursts, FeatureStorage


def db_helper(db, table_name, feature_names):
    """Helper function for testing a table in the database. Takes
    some column(s) in a table and generates a dict.

    Args:
        db [FeatureStorage object]: database object
        table_name [string]: name of the table to test
        feature_names [list of strings]: names of the columns to test

    Returns:
        actual_output [dict]: Contains the actual output in a dict that can be
            easily compared with the expected output dict defined in the test
    """

    select_query = "SELECT * FROM {} ORDER BY exampleid; ".format(table_name)
    result = db.engine.execute(select_query)

    # Ensure we preserve the order of the columns with an OrderedDict
    actual_output = OrderedDict({'exampleid': []})
    for feature_name in feature_names:
        actual_output.update({feature_name: []})

    column_names = ['exampleid'] + feature_names<commit_msg>Fix docstring wrap in tests<commit_after>#!/usr/bin/env python3.5
import pandas as pd
import sqlalchemy

import unittest
import pdb
from collections import OrderedDict
from decimal import Decimal

from features import compute_bursts, FeatureStorage


def db_helper(db, table_name, feature_names):
    """Helper function for testing a table in the database. Takes some
    column(s) in a table and generates a dict.

    Args:
        db [FeatureStorage object]: database object
        table_name [string]: name of the table to test
        feature_names [list of strings]: names of the columns to test

    Returns:
        actual_output [dict]: Contains the actual output in a dict that 
            can be easily compared with the expected output dict defined
            in the test
    """

    select_query = "SELECT * FROM {} ORDER BY exampleid; ".format(table_name)
    result = db.engine.execute(select_query)

    # Ensure we preserve the order of the columns with an OrderedDict
    actual_output = OrderedDict({'exampleid': []})
    for feature_name in feature_names:
        actual_output.update({feature_name: []})

    column_names = ['exampleid'] + feature_names
{'fraction_non_alphanumeric': 0.068699012451696, 'fraction_numerical': 0.0017174753112924003, 'mean_word_length': 3.480769230769231, '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': '1973847', 'n_tokens_mistral': 631, 'n_tokens_neox': 612, 'n_words': 255}