<commit_before>from __future__ import absolute_import, division, print_function

import datashape
from datashape import (dshape, DataShape, Record, isdimension, Option,
        discover, Tuple)

from .dispatch import dispatch
from .expr import Expr
from .compatibility import _strtypes

__all__ = []

try:
    import pyspark
    from pyspark import sql, RDD
    from pyspark.sql import (IntegerType, FloatType, StringType, TimestampType,
            StructType, StructField, ArrayType, SchemaRDD, SQLContext,
            ShortType, DoubleType, BooleanType, LongType)
    from pyspark import SparkContext
except ImportError:
    pyspark = None


if not issubclass(SQLContext, object):
    raise ImportError("This version of SparkSQL uses old-style classes. "
            "Please update to newer version of Spark")


def deoption(ds):
    """

    >>> deoption('int32')
    ctype("int32")

    >>> deoption('?int32')
    ctype("int32")
    """
    if isinstance(ds, str):
        ds = dshape(ds)
    if isinstance(ds, DataShape) and not isdimension(ds[0]):
        return deoption(ds[0])
    if isinstance(ds, Option):
        return ds.ty
    else:
        return ds


if pyspark:

    types = {datashape.int16: ShortType(),
             datashape.int32: IntegerType(),
             datashape.int64: IntegerType(),
             datashape.float32: FloatType(),
             datashape.float64: DoubleType(),
             datashape.real: DoubleType(),
             datashape.time_: TimestampType(),
             datashape.date_: TimestampType(),
             datashape.datetime_: TimestampType(),
             datashape.bool_: BooleanType(),
             datashape.string: StringType()}
<commit_msg>move sqlcontext old-style-class check in if pyspark check<commit_after>from __future__ import absolute_import, division, print_function

import datashape
from datashape import (dshape, DataShape, Record, isdimension, Option,
        discover, Tuple)

from .dispatch import dispatch
from .expr import Expr
from .compatibility import _strtypes

__all__ = []

try:
    import pyspark
    from pyspark import sql, RDD
    from pyspark.sql import (IntegerType, FloatType, StringType, TimestampType,
            StructType, StructField, ArrayType, SchemaRDD, SQLContext,
            ShortType, DoubleType, BooleanType, LongType)
    from pyspark import SparkContext
except ImportError:
    pyspark = None



def deoption(ds):
    """

    >>> deoption('int32')
    ctype("int32")

    >>> deoption('?int32')
    ctype("int32")
    """
    if isinstance(ds, str):
        ds = dshape(ds)
    if isinstance(ds, DataShape) and not isdimension(ds[0]):
        return deoption(ds[0])
    if isinstance(ds, Option):
        return ds.ty
    else:
        return ds


if pyspark:
    if not issubclass(SQLContext, object):
        raise ImportError("This version of SparkSQL uses old-style classes. "
                "Please update to newer version of Spark")


    types = {datashape.int16: ShortType(),
             datashape.int32: IntegerType(),
             datashape.int64: IntegerType(),
             datashape.float32: FloatType(),
             datashape.float64: DoubleType(),
             datashape.real: DoubleType(),
             datashape.time_: TimestampType(),
             datashape.date_: TimestampType(),
             datashape.datetime_: TimestampType(),
             datashape.bool_: BooleanType(),
             datashape.string: StringType()}

{'fraction_non_alphanumeric': 0.0963435867672664, 'fraction_numerical': 0.011607661056297156, 'mean_word_length': 2.746739130434783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7511249', 'n_tokens_mistral': 1033, 'n_tokens_neox': 980, 'n_words': 275}