Skip to content

remove python 2 lines #757

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

Merged
merged 20 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c51a4d6
Resolve merge conflicts.
alexandermorgan Jul 12, 2019
0e9a985
Merge remote-tracking branch 'upstream/master'
alexandermorgan Jul 16, 2019
52e1a50
Merge remote-tracking branch 'upstream/master'
alexandermorgan Jul 21, 2019
a762fc3
Remove py2 and Windows checks.
alexandermorgan Jul 21, 2019
0508b33
Remove from __future__ import print_function.
alexandermorgan Jul 21, 2019
d063a39
Remove from __future__ import division.
alexandermorgan Jul 21, 2019
84fb23e
Revert "Remove py2 and Windows checks."
alexandermorgan Jul 21, 2019
f960ea0
Remove has_python2 checks.
alexandermorgan Jul 21, 2019
be1c868
Remove duplicate line in what's new file.
alexandermorgan Jul 22, 2019
e1ffc45
Remove python2-sensitive imports.
alexandermorgan Jul 22, 2019
a5c3212
Remove out-of-date python2 comment.
alexandermorgan Jul 22, 2019
900ed15
Import JSONDecodeError directly in py3 way.
alexandermorgan Jul 22, 2019
22f20d4
Change Tkinter import (py2) to tkinter (py3).
alexandermorgan Jul 22, 2019
de15a93
Update import configparser to only py3 version.
alexandermorgan Jul 22, 2019
505dec1
Update documentation comment.
alexandermorgan Jul 22, 2019
7c36148
Remove strict arguments.
alexandermorgan Jul 23, 2019
ab9d67d
Remove platform_is_windows import.
alexandermorgan Jul 23, 2019
16d7de9
Set strict arg to True for two tests.
alexandermorgan Jul 23, 2019
6f2e105
Fix indentation mistake.
alexandermorgan Jul 23, 2019
69ba049
Revert "Remove from __future__ import print_function."
alexandermorgan Jul 24, 2019
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
5 changes: 1 addition & 4 deletions pvlib/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
absolute airmass and to determine pressure from altitude or vice versa.
"""

from __future__ import division

from warnings import warn

import numpy as np
Expand Down Expand Up @@ -211,8 +209,7 @@ def get_relative_airmass(zenith, model='kastenyoung1989'):
Sandia Report, (2012).
'''

# need to filter first because python 2.7 does not support raising a
# negative number to a negative power.
# set zenith values greater than 90 to nans
z = np.where(zenith > 90, np.nan, zenith)
zenith_rad = np.radians(z)

Expand Down
2 changes: 0 additions & 2 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
to calculate clear sky GHI, DNI, and DHI.
"""

from __future__ import division

import os
from collections import OrderedDict
import calendar
Expand Down
1 change: 0 additions & 1 deletion pvlib/iotools/ecmwf_macc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Read data from ECMWF MACC Reanalysis.
"""

from __future__ import division
import threading
import pandas as pd

Expand Down
8 changes: 1 addition & 7 deletions pvlib/iotools/epw.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
"""

import io

try:
# python 2 compatibility
from urllib2 import urlopen, Request
except ImportError:
from urllib.request import urlopen, Request

from urllib.request import urlopen, Request
import pandas as pd


Expand Down
6 changes: 1 addition & 5 deletions pvlib/iotools/psm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
import io
import requests
import pandas as pd
# Python-2 compatible JSONDecodeError
try:
from json import JSONDecodeError
except ImportError:
JSONDecodeError = ValueError
from json import JSONDecodeError

URL = "http://developer.nrel.gov/api/solar/nsrdb_psm3_download.csv"

Expand Down
8 changes: 1 addition & 7 deletions pvlib/iotools/surfrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
Import functions for NOAA SURFRAD Data.
"""
import io

try:
# python 2 compatibility
from urllib2 import urlopen, Request
except ImportError:
from urllib.request import urlopen, Request

from urllib.request import urlopen, Request
import pandas as pd
import numpy as np

Expand Down
18 changes: 6 additions & 12 deletions pvlib/iotools/tmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
import datetime
import io
import re

try:
# python 2 compatibility
from urllib2 import urlopen, Request
except ImportError:
from urllib.request import urlopen, Request

from urllib.request import urlopen, Request
import dateutil
import pandas as pd

Expand Down Expand Up @@ -160,7 +154,7 @@ def read_tmy3(filename=None, coerce_year=None, recolumn=True):
try:
filename = _interactive_load()
except ImportError:
raise ImportError('Interactive load failed. Tkinter not supported '
raise ImportError('Interactive load failed. tkinter not supported '
'on this system. Try installing X-Quartz and '
'reloading')

Expand Down Expand Up @@ -210,9 +204,9 @@ def read_tmy3(filename=None, coerce_year=None, recolumn=True):


def _interactive_load():
import Tkinter
from tkFileDialog import askopenfilename
Tkinter.Tk().withdraw() # Start interactive file input
import tkinter
from tkinter.filedialog import askopenfilename
tkinter.Tk().withdraw() # Start interactive file input
return askopenfilename()


Expand Down Expand Up @@ -406,7 +400,7 @@ def read_tmy2(filename):
try:
filename = _interactive_load()
except ImportError:
raise ImportError('Interactive load failed. Tkinter not supported '
raise ImportError('Interactive load failed. tkinter not supported '
'on this system. Try installing X-Quartz and '
'reloading')

Expand Down
2 changes: 0 additions & 2 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
irradiance, and total irradiance under various conditions.
"""

from __future__ import division

import datetime
from collections import OrderedDict
from functools import partial
Expand Down
18 changes: 3 additions & 15 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
performance of PV modules and inverters.
"""

from __future__ import division

from collections import OrderedDict
import io
import os
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen

from urllib.request import urlopen
import numpy as np
import pandas as pd

Expand Down Expand Up @@ -1632,14 +1626,8 @@ def retrieve_sam(name=None, path=None):
else:
csvdata = path
elif name is None and path is None:
try:
# python 2
import Tkinter as tkinter
from tkFileDialog import askopenfilename
except ImportError:
# python 3
import tkinter
from tkinter.filedialog import askopenfilename
import tkinter
from tkinter.filedialog import askopenfilename

tkinter.Tk().withdraw()
csvdata = askopenfilename()
Expand Down
1 change: 0 additions & 1 deletion pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Tony Lorenzo (@alorenzo175), University of Arizona, 2015
# Cliff hansen (@cwhanse), Sandia National Laboratories, 2018

from __future__ import division
import os
import datetime as dt
try:
Expand Down
1 change: 0 additions & 1 deletion pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Contributors:
# Created by Tony Lorenzo (@alorenzo175), Univ. of Arizona, 2015

from __future__ import division
import os
import threading
import warnings
Expand Down
2 changes: 0 additions & 2 deletions pvlib/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def inner():
data_dir = os.path.join(test_dir, os.pardir, 'data')


has_python2 = parse_version(platform.python_version()) < parse_version('3')

platform_is_windows = platform.system() == 'Windows'
skip_windows = pytest.mark.skipif(platform_is_windows,
reason='does not run on windows')
Expand Down
8 changes: 3 additions & 5 deletions pvlib/test/test_conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import pytest

from conftest import fail_on_pvlib_version, platform_is_windows, has_python2
from conftest import fail_on_pvlib_version


# allow xpass for python 2 on windows
@pytest.mark.xfail(strict=(not (platform_is_windows and has_python2)),
@pytest.mark.xfail(strict=True,
reason='fail_on_pvlib_version should cause test to fail')
@fail_on_pvlib_version('0.0')
def test_fail_on_pvlib_version():
Expand All @@ -16,8 +15,7 @@ def test_fail_on_pvlib_version_pass():
pass


@pytest.mark.xfail(strict=(not (platform_is_windows and has_python2)),
reason='ensure that the test is called')
@pytest.mark.xfail(strict=True, reason='ensure that the test is called')
@fail_on_pvlib_version('100000.0')
def test_fail_on_pvlib_version_fail_in_test():
raise Exception
1 change: 0 additions & 1 deletion pvlib/test/test_ecmwf_macc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
tests for :mod:`pvlib.iotools.ecmwf_macc`
"""

from __future__ import division
import os
import datetime
import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions pvlib/tracking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import division

import numpy as np
import pandas as pd

Expand Down