<commit_before>import pandas as pd

from .dataframe_dataset import DataFrameDataset
from .query_dataset import QueryDataset
from .table_dataset import TableDataset
from .dataset_info import DatasetInfo
from ..geojson import load_geojson
from .utils import GEOM_TYPE_POINT, GEOM_TYPE_LINE, GEOM_TYPE_POLYGON, is_sql_query, is_geojson, is_table_name, \
    _save_index_as_column

DOWNLOAD_RETRY_TIMES = 3


class Dataset(object):
    FAIL = TableDataset.FAIL
    REPLACE = TableDataset.REPLACE
    APPEND = TableDataset.APPEND

    PRIVATE = DatasetInfo.PRIVATE
    PUBLIC = DatasetInfo.PUBLIC
    LINK = DatasetInfo.LINK

    GEOM_TYPE_POINT = GEOM_TYPE_POINT
    GEOM_TYPE_LINE = GEOM_TYPE_LINE
    GEOM_TYPE_POLYGON = GEOM_TYPE_POLYGON

    def __init__(self, data, credentials=None, schema=None):
        self._strategy = self._init_strategy(data, credentials, schema)
        self._is_saved_in_carto = self._init_saved_in_carto()

    def _init_strategy(self, data, credentials=None, schema=None):
        credentials = credentials or _get_default_credentials()

        if isinstance(data, pd.DataFrame):
            return self._getDataFrameDataset(data)
        elif is_geojson(data):
            return self._getDataFrameDataset(load_geojson(data))
        elif is_sql_query(data):
            return self._getQueryDataset(data, credentials)
        elif is_table_name(data):
            return self._getTableDataset(data, credentials, schema)

        raise ValueError('We can not detect the Dataset type for data={}'.format(data))<commit_msg>honor CR<commit_after>import pandas as pd

from .dataframe_dataset import DataFrameDataset
from .query_dataset import QueryDataset
from .table_dataset import TableDataset
from .dataset_info import DatasetInfo
from ..geojson import load_geojson
from .utils import GEOM_TYPE_POINT, GEOM_TYPE_LINE, GEOM_TYPE_POLYGON, is_sql_query, is_geojson, is_table_name, \
    _save_index_as_column

DOWNLOAD_RETRY_TIMES = 3


class Dataset(object):
    FAIL = TableDataset.FAIL
    REPLACE = TableDataset.REPLACE
    APPEND = TableDataset.APPEND

    PRIVATE = DatasetInfo.PRIVATE
    PUBLIC = DatasetInfo.PUBLIC
    LINK = DatasetInfo.LINK

    GEOM_TYPE_POINT = GEOM_TYPE_POINT
    GEOM_TYPE_LINE = GEOM_TYPE_LINE
    GEOM_TYPE_POLYGON = GEOM_TYPE_POLYGON

    def __init__(self, data, credentials=None, schema=None):
        self._strategy = self._init_strategy(data, credentials, schema)
        self._is_saved_in_carto = self._init_saved_in_carto()

    def _init_strategy(self, data, credentials=None, schema=None):
        credentials = credentials or _get_default_credentials()

        if isinstance(data, pd.DataFrame):
            return self._getDataFrameDataset(data)
        elif is_geojson(data):
            return self._getDataFrameDataset(load_geojson(data))
        elif is_sql_query(data):
            return self._getQueryDataset(data, credentials)
        elif is_table_name(data):
            return self._getTableDataset(data, credentials, schema)

        raise ValueError('We can not detect the Dataset type')
{'fraction_non_alphanumeric': 0.068359375, 'fraction_numerical': 0.0006510416666666666, 'mean_word_length': 3.9168, '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': '3279264', 'n_tokens_mistral': 981, 'n_tokens_neox': 960, 'n_words': 210}