Skip to content

Commit

Permalink
Remove compat for Python 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Mar 24, 2020
1 parent 2e74a56 commit c91bdd8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 67 deletions.
2 changes: 0 additions & 2 deletions .ci/test-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ PYTHON_VERSION:
- 3.8
- 3.7
- 3.6
- 3.5.3


exclude: ~
17 changes: 0 additions & 17 deletions eland/compat.py

This file was deleted.

65 changes: 20 additions & 45 deletions eland/tests/dataframe/test_repr_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import pandas as pd
import pytest

from eland.compat import PY36
from eland.dataframe import DEFAULT_NUM_ROWS_DISPLAYED
from eland.tests.common import TestData, assert_pandas_eland_series_equal

Expand All @@ -29,19 +28,6 @@ def setup_class(cls):
# conftest.py changes this default - restore to original setting
pd.set_option('display.max_rows', 60)

# Override these methods as:
# {'lat': '-33.94609833', 'lon': '151.177002'} order is not consistent in python 3.5 (dict's not ordered)
# remove from test for now
def ed_flights(self):
if not PY36:
return super().ed_flights().drop(columns=['OriginLocation', 'DestLocation'])
return super().ed_flights()

def pd_flights(self):
if not PY36:
return super().pd_flights().drop(columns=['OriginLocation', 'DestLocation'])
return super().pd_flights()

"""
to_string
"""
Expand Down Expand Up @@ -81,36 +67,28 @@ def test_simple_lat_lon(self):
Hence we store the pandas df source json as 'lon', 'lat'
"""
if PY36:
pd_dest_location = self.pd_flights()['DestLocation'].head(1)
ed_dest_location = self.ed_flights()['DestLocation'].head(1)
pd_dest_location = self.pd_flights()['DestLocation'].head(1)
ed_dest_location = self.ed_flights()['DestLocation'].head(1)

assert_pandas_eland_series_equal(pd_dest_location, ed_dest_location)
else:
# NOOP
assert True
assert_pandas_eland_series_equal(pd_dest_location, ed_dest_location)

def test_num_rows_to_string(self):
if PY36:
# check setup works
assert pd.get_option('display.max_rows') == 60

# Test eland.DataFrame.to_string vs pandas.DataFrame.to_string
# In pandas calling 'to_string' without max_rows set, will dump ALL rows

# Test n-1, n, n+1 for edge cases
self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED - 1)
self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED)
with pytest.warns(UserWarning):
# UserWarning displayed by eland here (compare to pandas with max_rows set)
self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED + 1, None, DEFAULT_NUM_ROWS_DISPLAYED)

# Test for where max_rows lt or gt num_rows
self.num_rows_to_string(10, 5, 5)
self.num_rows_to_string(100, 200, 200)
else:
# NOOP
assert True
# check setup works
assert pd.get_option('display.max_rows') == 60

# Test eland.DataFrame.to_string vs pandas.DataFrame.to_string
# In pandas calling 'to_string' without max_rows set, will dump ALL rows

# Test n-1, n, n+1 for edge cases
self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED - 1)
self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED)
with pytest.warns(UserWarning):
# UserWarning displayed by eland here (compare to pandas with max_rows set)
self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED + 1, None, DEFAULT_NUM_ROWS_DISPLAYED)

# Test for where max_rows lt or gt num_rows
self.num_rows_to_string(10, 5, 5)
self.num_rows_to_string(100, 200, 200)

def num_rows_to_string(self, rows, max_rows_eland=None, max_rows_pandas=None):
ed_flights = self.ed_flights()[['DestLocation', 'OriginLocation']]
Expand Down Expand Up @@ -257,10 +235,7 @@ def num_rows_repr_html(self, rows, max_rows=None):
# print(ed_head_str)
# print(pd_head_str)

# Currently pandas display bold_rows=True with >=PY36 and bold_rows=False with 3.5
# TODO - fix this test for 3.5
if PY36:
assert pd_head_str == ed_head_str
assert pd_head_str == ed_head_str

def test_empty_dataframe_repr_html(self):
# TODO - there is a bug in 'show_dimensions' as it gets added after the last </div>
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand Down Expand Up @@ -185,9 +184,9 @@
keywords='elastic eland pandas python',
packages=find_packages(include=["eland", "eland.*"]),
install_requires=[
'elasticsearch>=7.0.5',
'elasticsearch>=7.0.5, <8',
'pandas==0.25.3',
'matplotlib'
],
python_requires=">=3.5",
python_requires=">=3.6",
)

0 comments on commit c91bdd8

Please sign in to comment.