Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sunset py2 #2577

Merged
merged 34 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0b6223b
sunset py2: remove Py2 from setup.py and CI
megies Mar 9, 2020
d394e84
sunset py2: remove __future__/future import header from all files
megies Mar 9, 2020
8d2bbcc
sunset py2: remove test for future/__future__ import headers
megies Mar 9, 2020
32568a5
sunset py2: remove usage of future's native_str() to convert strings
megies Mar 9, 2020
bc9435e
sunset py2: remove future's native_str in isinstance checks
megies Mar 9, 2020
4d1318a
sunset py2: mark a test for later checking
megies Mar 9, 2020
6fe3f31
sunset py2: remove some last future native_str imports
megies Mar 9, 2020
ee6be4a
sunset py2: remove native_bytes usage
megies Mar 9, 2020
ab6e901
sunset py2: remove loads of Py2/3 if/else and compat
megies Mar 9, 2020
0cb8c04
sunset py2: remove mock compatibility layer
megies Mar 9, 2020
256ac8a
sunset py2: remove most content from core.compatibility and its usages
megies Mar 9, 2020
9a3dc91
sunset py2: switch Circle CI to Py3
megies Mar 9, 2020
b82474c
sunset py2: replace raise_from with Py3 builtin syntax
megies Mar 9, 2020
943c51b
sunset py2: remove unused imports and no-op left overs from future
megies Mar 9, 2020
b32c84c
sunset py2: fix CircleCI switch to Py3
megies Mar 9, 2020
add4a08
sunset py2: replace with_metaclass
megies Mar 9, 2020
68447f6
sunset py2: remove some left over future thingies
megies Mar 9, 2020
fb55b0d
remove official support for Python 3.4 and remove it from CI
megies Mar 11, 2020
c40cc96
setup.py: add "python_requires" >=3.5
megies Mar 11, 2020
5ebcbb2
bugfix dependency check in runtests' report
ThomasLecocq Mar 13, 2020
0f5b821
replace matplotlib rc text.hinting to reduce verbosity (deprecation)
ThomasLecocq Mar 13, 2020
2de6cfb
bye bye Python <3.7
megies Mar 16, 2020
3376090
CI: pyshp, pyimgur, geographiclib should be installable via conda
megies Mar 16, 2020
83b05e6
only test pickle with bytesio, remove saved pickles
d-chambers Mar 19, 2020
be87fa6
fix UTCDateTime.strftime format issue
d-chambers Mar 19, 2020
e8604d6
allow bytes/str of test_stats to run
d-chambers Mar 19, 2020
2e82def
remove deprecated scipy.fix
d-chambers Mar 19, 2020
bc55063
bump numpy, scipy, mpl versions
d-chambers Mar 19, 2020
4c17ec1
block setup.py for older versions of python
d-chambers Mar 19, 2020
f51043c
add import error for ObsPy >2.0 running on python 2
d-chambers Mar 19, 2020
e6867d1
loosen strfmt test for trailing 0
d-chambers Mar 19, 2020
b0ed739
deprecate arclink and remove all arclink tests
megies Mar 20, 2020
2d4acf8
add linux specific strftime
d-chambers Mar 20, 2020
9bfa573
strftime: introspective approach to get rid of %Y problems < year 1000
megies Mar 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed obspy/core/tests/data/example_py2.pickle
Binary file not shown.
Binary file removed obspy/core/tests/data/example_py3.pickle
Binary file not shown.
4 changes: 0 additions & 4 deletions obspy/core/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ def test_different_string_types(self):
Test the various types of strings found in the wild get converted to
native_str type.
"""
# XXX check what to do here, if still needed after Py2 removal
raise Exception(
'test needs to be looked at more closely after Py2 sunset')
# get native bytes
nbytes = bytes('HHZ', 'utf8')
the_strs = ['HHZ', nbytes, u'HHZ']

Expand Down
70 changes: 22 additions & 48 deletions obspy/core/tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,54 +1435,28 @@ def test_read_pickle(self):
"""
Testing _read_pickle function.

Example pickles were written using obspy 1.0.3 on Py2 and Py3
respectively.
"""
for filename in ('example_py2.pickle', 'example_py3.pickle'):
pickle_file = os.path.join(self.data_path, filename)
st = read(pickle_file, format='PICKLE')
self.assertEqual(len(st), 3)
self.assertEqual(len(st[0]), 114)
self.assertEqual(len(st[1]), 110)
self.assertEqual(len(st[2]), 105)
for tr, comp in zip(st, 'ZNE'):
self.assertEqual(tr.stats.network, 'BW')
self.assertEqual(tr.stats.station, 'RJOB')
self.assertEqual(tr.stats.location, '')
self.assertEqual(tr.stats.channel, 'EH' + comp)
self.assertEqual(tr.stats.sampling_rate, 100.0)
self.assertEqual(st[0].stats.starttime,
UTCDateTime('2009-08-24T00:20:03.000000Z'))
self.assertEqual(st[1].stats.starttime,
UTCDateTime('2009-08-24T00:20:03.040000Z'))
self.assertEqual(st[2].stats.starttime,
UTCDateTime('2009-08-24T00:20:03.090000Z'))
self.assertEqual(st[0].stats.endtime,
UTCDateTime('2009-08-24T00:20:04.130000Z'))
self.assertEqual(st[1].stats.endtime,
UTCDateTime('2009-08-24T00:20:04.130000Z'))
self.assertEqual(st[2].stats.endtime,
UTCDateTime('2009-08-24T00:20:04.130000Z'))
np.testing.assert_array_equal(
st[0].data[:10], [0, 6, 75, 262, 549, 943, 1442, 1785, 2147,
3029])
np.testing.assert_array_equal(
st[1].data[:10], [624, 1125, 1647, 2607, 3320, 4389, 5764,
7078, 8063, 9458])
np.testing.assert_array_equal(
st[2].data[:10], [-9573, -11576, -14450, -16754, -20348,
-23220, -28837, -30811, -36024, -40052])
np.testing.assert_array_equal(
st[0].data[-10:], [-283742, -305558, -302737, -317144, -310056,
-308462, -302752, -304243, -296202,
-313968])
np.testing.assert_array_equal(
st[1].data[-10:], [90493, 105062, 100721, 98631, 100355,
106287, 115356, 117989, 97907, 113225])
np.testing.assert_array_equal(
st[2].data[-10:], [-144765, -149205, -123622, -139548, -137160,
-154283, -103584, -138578, -128339,
-125707])
Pickle support is only provided for pickles created with the same
versions of ObsPy/python.
"""
def _remove_format(st):
"""Remove '_format' from stats so streams """
for tr in st:
tr.stats.pop("_format", None)
return st

# Save stream to bio.
bio = io.BytesIO()
st = read()
st.write(bio, "pickle")
# Read pickle without specifying format.
bio.seek(0)
st_no_format = read(bio)
# Read pickle with specifying format.
bio.seek(0)
st_with_format = read(bio, format="pickle")
# Test equalities.
self.assertEqual(st, _remove_format(st_no_format))
self.assertEqual(st_no_format, _remove_format(st_with_format))

def test_get_gaps_2(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion obspy/core/tests/test_utcdatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ def test_strftime_with_years_less_than_1900(self):
t = UTCDateTime(1888, 1, 2, 1, 39, 37)
self.assertEqual(t.strftime('%Y-%m-%d'), '1888-01-02')
t = UTCDateTime(998, 11, 9, 1, 39, 37)
self.assertEqual(t.strftime('%Y-%m-%d'), '0998-11-09')
self.assertEqual(t.strftime('%Y-%m-%d'), '998-11-09')
d-chambers marked this conversation as resolved.
Show resolved Hide resolved

def test_strftime_replacement(self):
"""
Expand Down
20 changes: 1 addition & 19 deletions obspy/core/utcdatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,25 +1279,7 @@ def strftime(self, format):
See methods :meth:`~datetime.datetime.strftime()` and
:meth:`~datetime.datetime.strptime()` for more information.
"""
try:
ret = self.datetime.strftime(format)
# this is trying to work around strftime refusing to work with years
# <1900
# XXX this problem seems to be specific to Python < 3.2
# XXX so this can be removed after dropping Python 2 support
except ValueError as e:
# some other error? just raise it..
if 'the datetime strftime() methods require year' not in str(e):
raise
# otherwise, try to do replace all strftime '%' commands with
# simple string formatting
format_ = self._strftime_replacement(format)
# if there's still some strftime commands in there, we have a
# problem still ('%%' is a %-sign literal)
if '%' in format_.replace('%%', ''):
raise
ret = format_
return ret
return self.datetime.strftime(format)

def _strftime_replacement(self, strftime_string):
"""
Expand Down
4 changes: 2 additions & 2 deletions obspy/signal/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import math

import numpy as np
from scipy import fftpack, fix, signal
from scipy import fftpack, signal

from obspy.core.util.misc import factorize_int
from obspy.signal.headers import clibsignal
Expand Down Expand Up @@ -138,7 +138,7 @@ def enframe(x, win, inc):
else:
# length = next_pow_2(nwin)
length = nwin
nf = int(fix((nx - length + inc) // inc))
nf = int(np.fix((nx - length + inc) // inc))
# f = np.zeros((nf, length))
indf = inc * np.arange(nf)
inds = np.arange(length) + 1
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
# when bumping to numpy 1.7.0: get rid of if/else when loading npz file to PPSD
# and get rid of helper function _np_copy_astype() in obspy/io/mseed/core.py
INSTALL_REQUIRES = [
'numpy>=1.6.1',
'scipy>=0.9.0',
'matplotlib>=1.1.0',
'numpy>=1.15.0',
'scipy>=1.0.0',
'matplotlib>=3.2.0',
'lxml',
'setuptools',
'sqlalchemy',
Expand Down