Add isort, rename Nox session to 'format'

This commit is contained in:
Seth Michael Larson 2020-10-15 16:46:21 -05:00 committed by Seth Michael Larson
parent 18fb4af731
commit 05a24cbe0b
75 changed files with 252 additions and 243 deletions

View File

@ -160,7 +160,7 @@ currently using a minimum version of PyCharm 2019.2.4.
- Run `pytest --nbval` to validate install
- To test specific versions of Python use `nox -s test-3.8`
- To run the automatic formatter and check for lint issues
run `nox -s blacken`
run `nox -s format`
### Documentation

View File

@ -23,13 +23,13 @@
# -- Path setup --------------------------------------------------------------
import datetime
import os
import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import datetime
sys.path.insert(0, os.path.abspath("../sphinxext"))
sys.path.extend(

View File

@ -15,22 +15,22 @@
# specific language governing permissions and limitations
# under the License.
from eland._version import ( # noqa: F401
__title__,
__description__,
__url__,
__version__,
from ._version import ( # noqa: F401
__author__,
__author_email__,
__description__,
__maintainer__,
__maintainer_email__,
__title__,
__url__,
__version__,
)
from eland.common import SortOrder
from eland.index import Index
from eland.ndframe import NDFrame
from eland.series import Series
from eland.dataframe import DataFrame
from eland.etl import pandas_to_eland, eland_to_pandas, read_es, read_csv, csv_to_eland
from .common import SortOrder
from .dataframe import DataFrame
from .etl import csv_to_eland, eland_to_pandas, pandas_to_eland, read_csv, read_es
from .index import Index
from .ndframe import NDFrame
from .series import Series
__all__ = [
"DataFrame",

View File

@ -16,9 +16,9 @@
# under the License.
from abc import ABC, abstractmethod
from typing import List, Optional, TYPE_CHECKING, Union
from eland import SortOrder
from typing import TYPE_CHECKING, List, Optional, Union
from eland import SortOrder
if TYPE_CHECKING:
import pandas as pd # type: ignore

View File

@ -17,7 +17,7 @@
from abc import ABC, abstractmethod
from io import StringIO
from typing import Union, List, TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, List, Union
import numpy as np # type: ignore

View File

@ -18,7 +18,7 @@
import re
import warnings
from enum import Enum
from typing import Union, List, Tuple, cast, Callable, Any, Optional, Dict
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
import numpy as np # type: ignore
import pandas as pd # type: ignore

View File

@ -15,11 +15,11 @@
# specific language governing permissions and limitations
# under the License.
import re
import sys
import warnings
from io import StringIO
import re
from typing import List, Optional, Sequence, Union, Tuple
from typing import List, Optional, Sequence, Tuple, Union
import numpy as np
import pandas as pd
@ -34,12 +34,12 @@ from pandas.io.formats.printing import pprint_thing
from pandas.util._validators import validate_bool_kwarg
import eland.plotting as gfx
from eland.ndframe import NDFrame
from eland.series import Series
from eland.common import DEFAULT_NUM_ROWS_DISPLAYED, docstring_parameter
from eland.filter import BooleanFilter
from eland.utils import deprecated_api, is_valid_attr_name
from eland.groupby import GroupByDataFrame
from eland.ndframe import NDFrame
from eland.series import Series
from eland.utils import deprecated_api, is_valid_attr_name
class DataFrame(NDFrame):

View File

@ -16,17 +16,18 @@
# under the License.
import csv
from typing import Generator, Union, List, Tuple, Optional, Mapping, Dict, Any
from collections import deque
from typing import Any, Dict, Generator, List, Mapping, Optional, Tuple, Union
import pandas as pd # type: ignore
from elasticsearch import Elasticsearch # type: ignore
from elasticsearch.helpers import parallel_bulk # type: ignore
from pandas.io.parsers import _c_parser_defaults # type: ignore
from eland import DataFrame
from eland.common import DEFAULT_CHUNK_SIZE, ensure_es_client
from eland.field_mappings import FieldMappings, verify_mapping_compatibility
from eland.common import ensure_es_client, DEFAULT_CHUNK_SIZE
from eland.utils import deprecated_api
from elasticsearch import Elasticsearch # type: ignore
from elasticsearch.helpers import parallel_bulk # type: ignore
@deprecated_api("eland.DataFrame()")

View File

@ -16,31 +16,32 @@
# under the License.
import warnings
from typing import (
TYPE_CHECKING,
Any,
Dict,
List,
Mapping,
NamedTuple,
Optional,
Set,
Tuple,
)
import numpy as np
import pandas as pd
from pandas.core.dtypes.common import (
is_float_dtype,
is_bool_dtype,
is_integer_dtype,
is_datetime_or_timedelta_dtype,
is_float_dtype,
is_integer_dtype,
is_string_dtype,
)
from pandas.core.dtypes.inference import is_list_like
from typing import (
NamedTuple,
Optional,
Mapping,
Dict,
Any,
Tuple,
TYPE_CHECKING,
List,
Set,
)
if TYPE_CHECKING:
from elasticsearch import Elasticsearch
from eland import DataFrame

View File

@ -17,7 +17,7 @@
# Originally based on code in MIT-licensed pandasticsearch filters
from typing import Dict, Any, List, Optional, Union, cast
from typing import Any, Dict, List, Optional, Union, cast
class BooleanFilter:

View File

@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
from typing import List, TYPE_CHECKING
from typing import TYPE_CHECKING, List
from eland.query_compiler import QueryCompiler
if TYPE_CHECKING:

View File

@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
from typing import Optional, TextIO, TYPE_CHECKING
from typing import TYPE_CHECKING, Optional, TextIO
from eland.utils import deprecated_api
if TYPE_CHECKING:

View File

@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
from eland.ml.ml_model import MLModel, ImportedMLModel
from eland.ml.ml_model import ImportedMLModel, MLModel
__all__ = [
"MLModel",

View File

@ -19,7 +19,7 @@ import base64
import gzip
import json
from abc import ABC
from typing import Sequence, Dict, Any, Optional, List
from typing import Any, Dict, List, Optional, Sequence
def add_if_exists(d: Dict[str, Any], k: str, v: Any) -> None:

View File

@ -15,31 +15,40 @@
# specific language governing permissions and limitations
# under the License.
from typing import List, Union, cast, Optional, Dict, TYPE_CHECKING, Any, Tuple
import warnings
import numpy as np # type: ignore
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast
import elasticsearch # type: ignore
from .common import TYPE_REGRESSION, TYPE_CLASSIFICATION
from .transformers import get_model_transformer
import numpy as np # type: ignore
from eland.common import ensure_es_client, es_version
from eland.utils import deprecated_api
from .common import TYPE_CLASSIFICATION, TYPE_REGRESSION
from .transformers import get_model_transformer
if TYPE_CHECKING:
from elasticsearch import Elasticsearch # noqa: F401
# Try importing each ML lib separately so mypy users don't have to
# have both installed to use type-checking.
try:
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor # type: ignore # noqa: F401
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor # type: ignore # noqa: F401
from sklearn.ensemble import ( # type: ignore # noqa: F401
RandomForestClassifier,
RandomForestRegressor,
)
from sklearn.tree import ( # type: ignore # noqa: F401
DecisionTreeClassifier,
DecisionTreeRegressor,
)
except ImportError:
pass
try:
from xgboost import XGBRegressor, XGBClassifier # type: ignore # noqa: F401
from xgboost import XGBClassifier, XGBRegressor # type: ignore # noqa: F401
except ImportError:
pass
try:
from lightgbm import LGBMRegressor, LGBMClassifier # type: ignore # noqa: F401
from lightgbm import LGBMClassifier, LGBMRegressor # type: ignore # noqa: F401
except ImportError:
pass

View File

@ -17,8 +17,8 @@
import inspect
from typing import Any, Dict, Type
from .base import ModelTransformer
from .base import ModelTransformer
__all__ = ["get_model_transformer"]
_MODEL_TRANSFORMERS: Dict[type, Type[ModelTransformer]] = {}
@ -42,13 +42,13 @@ def get_model_transformer(model: Any, **kwargs: Any) -> ModelTransformer:
try:
from .sklearn import _MODEL_TRANSFORMERS as _SKLEARN_MODEL_TRANSFORMERS
from .sklearn import (
SKLearnDecisionTreeTransformer,
SKLearnForestClassifierTransformer,
SKLearnForestRegressorTransformer,
SKLearnForestTransformer,
SKLearnTransformer,
_MODEL_TRANSFORMERS as _SKLEARN_MODEL_TRANSFORMERS,
)
__all__ += [
@ -63,13 +63,13 @@ except ImportError:
pass
try:
from .xgboost import _MODEL_TRANSFORMERS as _XGBOOST_MODEL_TRANSFORMERS
from .xgboost import (
XGBoostClassifierTransformer,
XGBClassifier,
XGBoostClassifierTransformer,
XGBoostForestTransformer,
XGBoostRegressorTransformer,
XGBRegressor,
_MODEL_TRANSFORMERS as _XGBOOST_MODEL_TRANSFORMERS,
)
__all__ += [
@ -84,13 +84,13 @@ except ImportError:
pass
try:
from .lightgbm import _MODEL_TRANSFORMERS as _LIGHTGBM_MODEL_TRANSFORMERS
from .lightgbm import (
LGBMRegressor,
LGBMClassifier,
LGBMForestTransformer,
LGBMRegressorTransformer,
LGBMClassifierTransformer,
_MODEL_TRANSFORMERS as _LIGHTGBM_MODEL_TRANSFORMERS,
LGBMForestTransformer,
LGBMRegressor,
LGBMRegressorTransformer,
)
__all__ += [

View File

@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
from typing import Sequence, Optional, Any
from typing import Any, Optional, Sequence
from .._model_serializer import ModelSerializer

View File

@ -15,15 +15,16 @@
# specific language governing permissions and limitations
# under the License.
from typing import Optional, List, Dict, Any, Type
from .base import ModelTransformer
from typing import Any, Dict, List, Optional, Type
from .._model_serializer import Ensemble, Tree, TreeNode
from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION
from .._optional import import_optional_dependency
from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION
from .base import ModelTransformer
import_optional_dependency("lightgbm", on_version="warn")
from lightgbm import Booster, LGBMRegressor, LGBMClassifier # type: ignore
from lightgbm import Booster, LGBMClassifier, LGBMRegressor # type: ignore
def transform_decider(decider: str) -> str:

View File

@ -15,16 +15,21 @@
# specific language governing permissions and limitations
# under the License.
from typing import Any, Dict, Optional, Sequence, Tuple, Type, Union
import numpy as np # type: ignore
from typing import Optional, Sequence, Union, Dict, Any, Type, Tuple
from .base import ModelTransformer
from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION
from .._optional import import_optional_dependency
from .._model_serializer import Ensemble, Tree, TreeNode
from .._optional import import_optional_dependency
from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION
from .base import ModelTransformer
import_optional_dependency("sklearn", on_version="warn")
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor # type: ignore
from sklearn.ensemble import ( # type: ignore
RandomForestClassifier,
RandomForestRegressor,
)
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor # type: ignore
from sklearn.utils.validation import check_is_fitted # type: ignore

View File

@ -16,16 +16,18 @@
# under the License.
import re
from typing import Optional, List, Dict, Any, Type
from .base import ModelTransformer
from typing import Any, Dict, List, Optional, Type
import pandas as pd # type: ignore
from .._model_serializer import Ensemble, Tree, TreeNode
from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION
from .._optional import import_optional_dependency
from ..common import TYPE_CLASSIFICATION, TYPE_REGRESSION
from .base import ModelTransformer
import_optional_dependency("xgboost", on_version="warn")
from xgboost import Booster, XGBRegressor, XGBClassifier # type: ignore
from xgboost import Booster, XGBClassifier, XGBRegressor # type: ignore
class XGBoostForestTransformer(ModelTransformer):

View File

@ -17,10 +17,11 @@
import sys
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Tuple, Optional
import pandas as pd
from eland.query_compiler import QueryCompiler
from typing import TYPE_CHECKING, Optional, Tuple
import pandas as pd
from eland.query_compiler import QueryCompiler
if TYPE_CHECKING:
from eland.index import Index

View File

@ -17,49 +17,49 @@
import copy
import warnings
from collections import defaultdict
from typing import (
TYPE_CHECKING,
Any,
Dict,
Generator,
List,
Optional,
Sequence,
Tuple,
List,
Dict,
Any,
TYPE_CHECKING,
Union,
)
import numpy as np
import pandas as pd
from collections import defaultdict
from elasticsearch.helpers import scan
from eland.index import Index
from eland.actions import PostProcessingAction, SortFieldAction
from eland.common import (
SortOrder,
DEFAULT_CSV_BATCH_OUTPUT_SIZE,
DEFAULT_ES_MAX_RESULT_WINDOW,
elasticsearch_date_to_pandas_date,
build_pd_series,
DEFAULT_PAGINATION_SIZE,
SortOrder,
build_pd_series,
elasticsearch_date_to_pandas_date,
)
from eland.index import Index
from eland.query import Query
from eland.actions import PostProcessingAction, SortFieldAction
from eland.tasks import (
HeadTask,
RESOLVED_TASK_TYPE,
TailTask,
SampleTask,
BooleanFilterTask,
ArithmeticOpFieldsTask,
QueryTermsTask,
BooleanFilterTask,
HeadTask,
QueryIdsTask,
QueryTermsTask,
SampleTask,
SizeTask,
TailTask,
)
if TYPE_CHECKING:
from eland.query_compiler import QueryCompiler
from eland.field_mappings import Field
from eland.query_compiler import QueryCompiler
class QueryParams:

View File

@ -22,10 +22,7 @@ Based from https://github.com/pandas-dev/pandas/blob/v0.25.3/pandas/plotting/__i
but only supporting a subset of plotting methods (for now).
"""
from eland.plotting._core import (
ed_hist_frame,
ed_hist_series,
)
from eland.plotting._core import ed_hist_frame, ed_hist_series
__all__ = [
"ed_hist_frame",

View File

@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
from eland.plotting._matplotlib.hist import hist_series, hist_frame
from eland.plotting._matplotlib.hist import hist_frame, hist_series
def ed_hist_series(

View File

@ -22,10 +22,7 @@ Based from https://github.com/pandas-dev/pandas/blob/v0.25.3/pandas/plotting/__i
but only supporting a subset of plotting methods (for now).
"""
from eland.plotting._matplotlib.hist import (
hist_frame,
hist_series,
)
from eland.plotting._matplotlib.hist import hist_frame, hist_series
__all__ = [
"hist_frame",

View File

@ -19,6 +19,7 @@ import numpy as np
from pandas.core.dtypes.generic import ABCIndexClass
from pandas.plotting._matplotlib import converter
from pandas.plotting._matplotlib.tools import _flatten, _set_ticks_props, _subplots
from eland.utils import try_sort

View File

@ -17,16 +17,9 @@
import warnings
from copy import deepcopy
from typing import Optional, Dict, List, Any
from typing import Any, Dict, List, Optional
from eland.filter import (
RandomScoreFilter,
BooleanFilter,
NotNull,
IsNull,
IsIn,
Rlike,
)
from eland.filter import BooleanFilter, IsIn, IsNull, NotNull, RandomScoreFilter, Rlike
class Query:

View File

@ -17,20 +17,20 @@
import copy
from datetime import datetime
from typing import Optional, Sequence, TYPE_CHECKING, List
from typing import TYPE_CHECKING, List, Optional, Sequence
import numpy as np # type: ignore
import pandas as pd # type: ignore
from eland.field_mappings import FieldMappings
from eland.filter import QueryFilter
from eland.operations import Operations
from eland.index import Index
from eland.common import (
ensure_es_client,
DEFAULT_PROGRESS_REPORTING_NUM_ROWS,
elasticsearch_date_to_pandas_date,
ensure_es_client,
)
from eland.field_mappings import FieldMappings
from eland.filter import QueryFilter
from eland.index import Index
from eland.operations import Operations
if TYPE_CHECKING:
from .tasks import ArithmeticOpFieldsTask # noqa: F401

View File

@ -35,33 +35,34 @@ import sys
import warnings
from collections.abc import Collection
from io import StringIO
from typing import Optional, Union, Sequence, Any, Tuple, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, Union
import numpy as np
import pandas as pd
from pandas.io.common import _expand_user, stringify_path
import eland.plotting
from eland import NDFrame
from eland.arithmetics import ArithmeticSeries, ArithmeticString, ArithmeticNumber
from eland.arithmetics import ArithmeticNumber, ArithmeticSeries, ArithmeticString
from eland.common import DEFAULT_NUM_ROWS_DISPLAYED, docstring_parameter
from eland.filter import (
BooleanFilter,
NotFilter,
Equal,
Greater,
Less,
GreaterEqual,
LessEqual,
ScriptFilter,
IsIn,
IsNull,
Less,
LessEqual,
NotFilter,
NotNull,
ScriptFilter,
)
from eland.ndframe import NDFrame
from eland.utils import deprecated_api, to_list
if TYPE_CHECKING: # type: ignore
from elasticsearch import Elasticsearch # noqa: F401
from eland.query_compiler import QueryCompiler # noqa: F401

View File

@ -16,18 +16,18 @@
# under the License.
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, List, Any, Tuple
from typing import TYPE_CHECKING, Any, List, Tuple
from eland import SortOrder
from eland.actions import HeadAction, TailAction, SortIndexAction
from eland.actions import HeadAction, SortIndexAction, TailAction
from eland.arithmetics import ArithmeticSeries
if TYPE_CHECKING:
from .actions import PostProcessingAction # noqa: F401
from .filter import BooleanFilter # noqa: F401
from .query_compiler import QueryCompiler # noqa: F401
from .operations import QueryParams # noqa: F401
from .index import Index # noqa: F401
from .operations import QueryParams # noqa: F401
from .query_compiler import QueryCompiler # noqa: F401
RESOLVED_TASK_TYPE = Tuple["QueryParams", List["PostProcessingAction"]]

View File

@ -19,6 +19,7 @@ import os
import pandas as pd
from elasticsearch import Elasticsearch
from eland.common import es_version
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

View File

@ -26,12 +26,12 @@ ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
# Create pandas and eland data frames
from eland.tests import (
ECOMMERCE_DF_FILE_NAME,
ECOMMERCE_INDEX_NAME,
ES_TEST_CLIENT,
FLIGHTS_DF_FILE_NAME,
FLIGHTS_INDEX_NAME,
FLIGHTS_SMALL_INDEX_NAME,
ECOMMERCE_DF_FILE_NAME,
ECOMMERCE_INDEX_NAME,
)
_pd_flights = pd.read_json(FLIGHTS_DF_FILE_NAME).sort_index()

View File

@ -16,22 +16,25 @@
# under the License.
import inspect
import pytest
import pandas as pd
import pytest
import eland as ed
from .common import (
TestData,
_ed_ecommerce,
_ed_flights,
_ed_flights_small,
_pd_ecommerce,
_pd_flights,
_pd_flights_small,
assert_frame_equal,
assert_pandas_eland_frame_equal,
assert_pandas_eland_series_equal,
assert_frame_equal,
assert_series_equal,
_ed_flights,
_pd_flights,
_ed_ecommerce,
_pd_ecommerce,
_ed_flights_small,
_pd_flights_small,
TestData,
)
import eland as ed
class SymmetricAPIChecker:

View File

@ -18,8 +18,9 @@
# File called _pytest for PyCharm compatability
import numpy as np
from pandas.testing import assert_frame_equal, assert_series_equal
import pytest
from pandas.testing import assert_frame_equal, assert_series_equal
from eland.tests.common import TestData

View File

@ -18,8 +18,7 @@
# File called _pytest for PyCharm compatability
import eland as ed
from eland.tests.common import ES_TEST_CLIENT
from eland.tests.common import TestData
from eland.tests.common import ES_TEST_CLIENT, TestData
class TestDataFrameBigMapping(TestData):

View File

@ -24,10 +24,12 @@ from pandas.testing import assert_series_equal
import eland as ed
from eland.field_mappings import FieldMappings
from eland.tests.common import ES_TEST_CLIENT
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_frame_equal
from eland.tests.common import assert_pandas_eland_series_equal
from eland.tests.common import (
ES_TEST_CLIENT,
TestData,
assert_pandas_eland_frame_equal,
assert_pandas_eland_series_equal,
)
class TestDataFrameDateTime(TestData):

View File

@ -19,6 +19,7 @@
import numpy as np
import pandas as pd
from eland.tests.common import assert_series_equal

View File

@ -18,8 +18,8 @@
# File called _pytest for PyCharm compatability
import pytest
from eland.tests.common import TestData
from eland.tests.common import assert_eland_frame_equal
from eland.tests.common import TestData, assert_eland_frame_equal
class TestDataEsQuery(TestData):

View File

@ -18,6 +18,7 @@
# File called _pytest for PyCharm compatability
import pytest
from eland.tests.common import TestData

View File

@ -17,10 +17,11 @@
# File called _pytest for PyCharm compatability
import pandas as pd
import pytest
from pandas.testing import assert_frame_equal, assert_series_equal
from eland.tests.common import TestData
import pandas as pd
class TestGroupbyDataFrame(TestData):

View File

@ -17,8 +17,7 @@
# File called _pytest for PyCharm compatability
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_frame_equal
from eland.tests.common import TestData, assert_pandas_eland_frame_equal
class TestDataFrameHeadTail(TestData):

View File

@ -19,9 +19,7 @@
from io import StringIO
import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests.common import TestData

View File

@ -21,8 +21,7 @@ import pytest
import eland as ed
from eland.query_compiler import QueryCompiler
from eland.tests import ES_TEST_CLIENT
from eland.tests import FLIGHTS_INDEX_NAME
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
class TestDataFrameInit:

View File

@ -15,11 +15,13 @@
# specific language governing permissions and limitations
# under the License.
# File called _pytest for PyCharm compatibility
import pytest
import numpy as np
import pandas as pd
# File called _pytest for PyCharm compatibility
import pytest
from pandas.testing import assert_series_equal
from eland.tests.common import TestData

View File

@ -20,9 +20,7 @@
import pandas as pd
import eland as ed
from eland.tests.common import ES_TEST_CLIENT
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_frame_equal
from eland.tests.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal
class TestDataFrameQuery(TestData):

View File

@ -19,8 +19,8 @@
import pytest
from pandas.testing import assert_frame_equal
from eland.tests.common import TestData
from eland import eland_to_pandas
from eland.tests.common import TestData
class TestDataFrameSample(TestData):

View File

@ -18,8 +18,7 @@
# File called _pytest for PyCharm compatability
import numpy as np
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_frame_equal
from eland.tests.common import TestData, assert_pandas_eland_frame_equal
class TestDataFrameSelectDTypes(TestData):

View File

@ -24,10 +24,8 @@ import pandas as pd
from pandas.testing import assert_frame_equal
import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests import FLIGHTS_INDEX_NAME
from eland.tests.common import ROOT_DIR
from eland.tests.common import TestData
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import ROOT_DIR, TestData
class TestDataFrameToCSV(TestData):

View File

@ -22,8 +22,7 @@ import pandas as pd
import eland as ed
from eland.field_mappings import FieldMappings
from eland.tests.common import ES_TEST_CLIENT, assert_pandas_eland_frame_equal
from eland.tests.common import TestData
from eland.tests.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal
class TestDataFrameUtils(TestData):

View File

@ -16,10 +16,12 @@
# under the License.
from datetime import datetime, timedelta
import pytest
import pandas as pd
import pytest
from elasticsearch.helpers import BulkIndexError
from eland import pandas_to_eland, DataFrame
from eland import DataFrame, pandas_to_eland
from eland.tests.common import (
ES_TEST_CLIENT,
assert_frame_equal,

View File

@ -19,7 +19,7 @@
import pytest
from eland.field_mappings import FieldMappings
from eland.tests import ES_TEST_CLIENT, ECOMMERCE_INDEX_NAME
from eland.tests import ECOMMERCE_INDEX_NAME, ES_TEST_CLIENT
from eland.tests.common import TestData

View File

@ -19,8 +19,7 @@
from datetime import datetime
from eland.field_mappings import FieldMappings
from eland.tests.common import ES_TEST_CLIENT
from eland.tests.common import TestData
from eland.tests.common import ES_TEST_CLIENT, TestData
class TestDateTime(TestData):

View File

@ -21,8 +21,7 @@ from pandas.testing import assert_series_equal
from eland.field_mappings import FieldMappings
from eland.tests import FLIGHTS_INDEX_NAME, FLIGHTS_MAPPING
from eland.tests.common import ES_TEST_CLIENT
from eland.tests.common import TestData
from eland.tests.common import ES_TEST_CLIENT, TestData
class TestFieldNamePDDType(TestData):

View File

@ -21,7 +21,7 @@ from pandas.testing import assert_index_equal
# File called _pytest for PyCharm compatability
from eland.field_mappings import FieldMappings
from eland.tests import FLIGHTS_INDEX_NAME, ES_TEST_CLIENT
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData

View File

@ -20,7 +20,7 @@
import numpy as np
from eland.field_mappings import FieldMappings
from eland.tests import ES_TEST_CLIENT, ECOMMERCE_INDEX_NAME, FLIGHTS_INDEX_NAME
from eland.tests import ECOMMERCE_INDEX_NAME, ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData

View File

@ -21,7 +21,7 @@ from io import StringIO
import numpy as np
from eland.field_mappings import FieldMappings
from eland.tests import FLIGHTS_INDEX_NAME, ES_TEST_CLIENT
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData

View File

@ -15,16 +15,15 @@
# specific language governing permissions and limitations
# under the License.
import pytest
import numpy as np
import pytest
from eland.ml import MLModel
from eland.tests import ES_TEST_CLIENT, ES_VERSION
try:
from sklearn import datasets
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
HAS_SKLEARN = True
@ -32,14 +31,14 @@ except ImportError:
HAS_SKLEARN = False
try:
from xgboost import XGBRegressor, XGBClassifier
from xgboost import XGBClassifier, XGBRegressor
HAS_XGBOOST = True
except ImportError:
HAS_XGBOOST = False
try:
from lightgbm import LGBMRegressor, LGBMClassifier
from lightgbm import LGBMClassifier, LGBMRegressor
HAS_LIGHTGBM = True
except ImportError:

View File

@ -16,18 +16,18 @@
# under the License.
from eland.filter import (
Equal,
Greater,
GreaterEqual,
Less,
LessEqual,
Equal,
IsIn,
IsNull,
Less,
LessEqual,
Like,
Rlike,
Startswith,
NotNull,
Rlike,
ScriptFilter,
Startswith,
)

View File

@ -16,6 +16,7 @@
# under the License.
import pandas as pd
from eland.tests.common import TestData, assert_series_equal

View File

@ -15,10 +15,12 @@
# specific language governing permissions and limitations
# under the License.
import warnings
import numpy as np
import pandas as pd
import warnings
from eland.common import build_pd_series, EMPTY_SERIES_DTYPE
from eland.common import EMPTY_SERIES_DTYPE, build_pd_series
from eland.tests.common import assert_series_equal

View File

@ -18,8 +18,8 @@
# File called _pytest for PyCharm compatability
import pytest
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_series_equal
from eland.tests.common import TestData, assert_pandas_eland_series_equal
class TestSeriesFilter(TestData):

View File

@ -17,10 +17,8 @@
# File called _pytest for PyCharm compatability
import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests import FLIGHTS_INDEX_NAME
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_series_equal
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData, assert_pandas_eland_series_equal
class TestSeriesHeadTail(TestData):

View File

@ -17,11 +17,12 @@
# File called _pytest for PyCharm compatability
import pytest
import pandas as pd
import numpy as np
from datetime import timedelta
import numpy as np
import pandas as pd
import pytest
from eland.tests.common import TestData

View File

@ -16,8 +16,7 @@
# under the License.
from eland import eland_to_pandas
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_frame_equal
from eland.tests.common import TestData, assert_pandas_eland_frame_equal
class TestSeriesNA(TestData):

View File

@ -17,10 +17,8 @@
# File called _pytest for PyCharm compatability
import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests import FLIGHTS_INDEX_NAME
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_series_equal
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData, assert_pandas_eland_series_equal
class TestSeriesName(TestData):

View File

@ -17,10 +17,8 @@
# File called _pytest for PyCharm compatability
import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests import FLIGHTS_INDEX_NAME
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_series_equal
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData, assert_pandas_eland_series_equal
class TestSeriesRename(TestData):

View File

@ -17,8 +17,7 @@
# File called _pytest for PyCharm compatability
import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests import FLIGHTS_INDEX_NAME
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData

View File

@ -17,10 +17,8 @@
# File called _pytest for PyCharm compatibility
import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests import FLIGHTS_INDEX_NAME
from eland.tests.common import TestData
from eland.tests.common import assert_pandas_eland_series_equal
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import TestData, assert_pandas_eland_series_equal
class TestSeriesSample(TestData):

View File

@ -18,25 +18,24 @@
import pandas as pd
from elasticsearch import helpers
from eland.common import es_version
from eland.tests import (
FLIGHTS_FILE_NAME,
FLIGHTS_INDEX_NAME,
FLIGHTS_SMALL_FILE_NAME,
FLIGHTS_SMALL_INDEX_NAME,
FLIGHTS_MAPPING,
ECOMMERCE_FILE_NAME,
ECOMMERCE_INDEX_NAME,
ECOMMERCE_MAPPING,
ELASTICSEARCH_HOST,
ES_TEST_CLIENT,
FLIGHTS_FILE_NAME,
FLIGHTS_INDEX_NAME,
FLIGHTS_MAPPING,
FLIGHTS_SMALL_FILE_NAME,
FLIGHTS_SMALL_INDEX_NAME,
TEST_MAPPING1,
TEST_MAPPING1_INDEX_NAME,
TEST_NESTED_USER_GROUP_DOCS,
TEST_NESTED_USER_GROUP_INDEX_NAME,
TEST_NESTED_USER_GROUP_MAPPING,
ES_TEST_CLIENT,
ELASTICSEARCH_HOST,
)
from eland.common import es_version
DATA_LIST = [
(FLIGHTS_FILE_NAME, FLIGHTS_INDEX_NAME, FLIGHTS_MAPPING),

View File

@ -15,13 +15,13 @@
# specific language governing permissions and limitations
# under the License.
import re
import functools
import re
import warnings
from typing import Callable, TypeVar, Any, Union, List, cast, Collection, Iterable
from collections.abc import Collection as ABCCollection
import pandas as pd # type: ignore
from typing import Any, Callable, Collection, Iterable, List, TypeVar, Union, cast
import pandas as pd # type: ignore
RT = TypeVar("RT")

View File

@ -18,9 +18,9 @@
import os
import subprocess
from pathlib import Path
import nox
import elasticsearch
import elasticsearch
import nox
BASE_DIR = Path(__file__).parent
SOURCE_FILES = (
@ -57,18 +57,20 @@ TYPED_FILES = (
@nox.session(reuse_venv=True)
def blacken(session):
session.install("black")
def format(session):
session.install("black", "isort")
session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES)
session.run("black", "--target-version=py36", *SOURCE_FILES)
session.run("isort", *SOURCE_FILES)
lint(session)
@nox.session(reuse_venv=True)
def lint(session):
session.install("black", "flake8", "mypy")
session.install("black", "flake8", "mypy", "isort")
session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES)
session.run("black", "--check", "--target-version=py36", *SOURCE_FILES)
session.run("isort", "--check", *SOURCE_FILES)
session.run("flake8", "--ignore=E501,W503,E402,E712,E203", *SOURCE_FILES)
# TODO: When all files are typed we can change this to .run("mypy", "--strict", "eland/")

2
setup.cfg Normal file
View File

@ -0,0 +1,2 @@
[isort]
profile = black

View File

@ -20,7 +20,7 @@
from codecs import open
from os import path
from setuptools import setup, find_packages
from setuptools import find_packages, setup
here = path.abspath(path.dirname(__file__))
about = {}

View File

@ -17,12 +17,13 @@
"""Script that is used to create the compatibility matrix in the documentation"""
import re
import eland
import pandas
import inspect
import re
from pathlib import Path
import pandas
import eland
api_docs_dir = Path(__file__).absolute().parent.parent / "docs/source/reference/api"
is_supported = []

View File

@ -23,9 +23,8 @@ error out if 'fix' would have changed the file.
import os
import sys
from typing import List, Iterator
from itertools import chain
from typing import Iterator, List
lines_to_keep = ["# -*- coding: utf-8 -*-\n", "#!/usr/bin/env python\n"]
license_header_lines = [