Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 2 additions & 10 deletions _updateversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ def updateversion(path=_HERE):
# Also, when git is not available (PyPi package), use stored version.py
version_py = os.path.join(path,"version.py")
try:
if sys.version[0]=='2':
version_git = subprocess.check_output(["git","describe"]).rstrip()
elif sys.version[0]=='3':
version_git = subprocess.check_output(["git","describe"]).rstrip().decode()
else:
raise Exception("Wrong python version !")
version_git = subprocess.check_output(["git",
"describe"]).rstrip().decode()
except:
with open(version_py,'r') as fh:
version_git = fh.read().strip().split("=")[-1].replace("'",'')
Expand All @@ -28,7 +24,3 @@ def updateversion(path=_HERE):
msg = "{0}__version__ = '{1}'{0}".format(os.linesep, version_git)
fh.write(version_msg + msg)
return version_git




5 changes: 1 addition & 4 deletions tofu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@
"""
import sys
import warnings
if sys.version[0] == '2':
from .version import __version__
elif sys.version[0] == '3':
from .version import __version__
from .version import __version__

# For tests without display with nosetests
if not 'matplotlib.pyplot' in sys.modules:
Expand Down
27 changes: 10 additions & 17 deletions tofu/geom/_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import numpy as np
import scipy.interpolate as scpinterp
import scipy.integrate as scpintg

if sys.version[0] == "3":
from inspect import signature as insp
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is suppressed too, where is insp defined ?

elif sys.version[0] == "2":
from inspect import getargspec as insp
from inspect import signature as insp
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected !


# ToFu-specific
try:
Expand Down Expand Up @@ -1027,18 +1023,15 @@ def LOS_calc_signal(
D, u, dL, DL=DL, dLMode=dLMode, method=method, Test=Test
)
out = insp(ff)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insp is called here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry ! you are right ! fixed

if sys.version[0] == "3":
N = np.sum(
[
(
pp.kind == pp.POSITIONAL_OR_KEYWORD
and pp.default is pp.empty
)
for pp in out.parameters.values()
]
)
else:
N = len(out.args)
N = np.sum(
[
(
pp.kind == pp.POSITIONAL_OR_KEYWORD
and pp.default is pp.empty
)
for pp in out.parameters.values()
]
)

if N == 1:
Vals = ff(Pts)
Expand Down
57 changes: 0 additions & 57 deletions tofu/tests/tests01_geom/tests01_GG.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,6 @@ def test10_Ves_Smesh_Tor_PhiMinMax(VPoly=VPoly, plot=True):
[[3.*np.pi/4.,5.*np.pi/4.], [np.pi/2.,np.pi]],
[[3.*np.pi/4.,5.*np.pi/4.], [7.*np.pi/6.,5.*np.pi/6.]]]

if plot and sys.version[0]=='2':
f = plt.figure(figsize=(11.7,8.3),facecolor="w")
axarr = mplgrid.GridSpec(2,len(LPhi)/2)
axarr.update(left=0.05, right=0.95, top=0.95, bottom=0.05,
wspace=0.05, hspace=0.05)
Lax = []

for ii in range(0,len(LPhi)):
Pts, dS, ind,\
NL, dLr, Rref,\
Expand All @@ -476,20 +469,6 @@ def test10_Ves_Smesh_Tor_PhiMinMax(VPoly=VPoly, plot=True):
Out='(R,Z,Phi)',
margin=1.e-9)

if plot and sys.version[0]=='2':
Lax.append( f.add_subplot(axarr[ii], facecolor='w',
projection='3d') )
pts = GG.CoordShift(Pts, In='(R,Z,Phi)', Out='(X,Y,Z)',
CrossRef=None)
Lax[-1].plot(pts[0,:],pts[1,:],pts[2,:], '.k', ms=3.)
rad180 = 180./np.pi
Lax[-1].set_title(
"Phi = [{0:02.0f},{1:02.0f}]\n"
"DPhi = [{2:02.0f},{3:02.0f}] ".format(LPhi[ii][0][0]*rad180,
LPhi[ii][0][1]*rad180,
LPhi[ii][1][0]*rad180,
LPhi[ii][1][1]*rad180))

#try:
assert Pts.ndim==2 and Pts.shape[0]==3
LPhi[ii][0][0] = np.arctan2(np.sin(LPhi[ii][0][0]),
Expand Down Expand Up @@ -549,12 +528,6 @@ def test10_Ves_Smesh_Tor_PhiMinMax(VPoly=VPoly, plot=True):
# range(0,len(ind)) if ind[jj]==lii[ii]]])


if plot and sys.version[0]=='2':
f.canvas.draw()
f.savefig('./test_GG_test07_Ves_Smesh_Tor_PhiMinMax.png', format='png')
plt.close(f)



def test11_Ves_Smesh_TorStruct(VPoly=VPoly, plot=True):

Expand All @@ -573,14 +546,6 @@ def test11_Ves_Smesh_TorStruct(VPoly=VPoly, plot=True):
[[3.*np.pi/4.,5.*np.pi/4.], [np.pi/2.,np.pi]],
[[3.*np.pi/4.,5.*np.pi/4.], [7.*np.pi/6.,5.*np.pi/6.]]]


if plot and sys.version[0]=='2':
f = plt.figure(figsize=(11.7,8.3),facecolor="w")
axarr = mplgrid.GridSpec(2,len(LPhi)/2)
axarr.update(left=0.05, right=0.95, top=0.95, bottom=0.05, wspace=0.05,
hspace=0.05)
Lax = []

for ii in range(0,len(LPhi)):
Pts, dS, ind, NL, \
dLr, Rref, \
Expand All @@ -595,19 +560,6 @@ def test11_Ves_Smesh_TorStruct(VPoly=VPoly, plot=True):
Out='(R,Z,Phi)',
margin=1.e-9)

if plot and sys.version[0]=='2':
Lax.append(f.add_subplot(axarr[ii], facecolor='w', projection='3d'))
pts = GG.CoordShift(Pts, In='(R,Z,Phi)', Out='(X,Y,Z)',
CrossRef=None)
Lax[-1].plot(pts[0,:],pts[1,:],pts[2,:], '.k', ms=3.)
rad180 = 180./np.pi
Lax[-1].set_title(
"Phi = [{0:02.0f},{1:02.0f}]\n"
"DPhi = [{2:02.0f},{3:02.0f}] ".format(LPhi[ii][0][0]*rad180,
LPhi[ii][0][1]*rad180,
LPhi[ii][1][0]*rad180,
LPhi[ii][1][1]*rad180))

#try:
assert Pts.ndim==2 and Pts.shape[0]==3
LPhi[ii][0][0] = np.arctan2(np.sin(LPhi[ii][0][0]),
Expand Down Expand Up @@ -678,15 +630,6 @@ def test11_Ves_Smesh_TorStruct(VPoly=VPoly, plot=True):
for hh in [jj for jj in range(0,len(ind)) if ind[jj]==lii[ii]]])
"""

if plot and sys.version[0]=='2':
f.canvas.draw()
f.savefig('./test_GG_test08_Ves_Smesh_TorStruct.png', format='png')
plt.close(f)





def test12_Ves_Smesh_Lin(VPoly=VPoly):

XMinMax = np.array([0.,10.])
Expand Down
17 changes: 3 additions & 14 deletions tofu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

_sep = '_'
_dict_lexcept_key = []
_pyv = int(sys.version[0])

_SAVETYP = '__type__'
_NSAVETYP = len(_SAVETYP)
Expand Down Expand Up @@ -1847,10 +1846,8 @@ def save(self, path=None, name=None,
strip=strip, compressed=compressed,
return_pfe=return_pfe, verb=verb)

if sys.version[0]=='2':
ToFuObject.save.__func__.__doc__ = save.__doc__
else:
ToFuObject.save.__doc__ = save.__doc__

ToFuObject.save.__doc__ = save.__doc__


#############################################
Expand Down Expand Up @@ -1910,11 +1907,6 @@ def __init__(self, Cls=None, Name=None, Type=None, Deg=None,
SavePath=None, usr=None, dUSR=None, lObj=None,
fromdict=None, include=None):

# To replace __init_subclass__ for Python 2
if sys.version[0]=='2':
self._dstrip = ToFuObjectBase._dstrip.copy()
self.__class__._strip_init()

kwdargs = locals()
del kwdargs['self']
#super()
Expand Down Expand Up @@ -2038,10 +2030,7 @@ def _strip_init(cls):
nMax = max(cls._dstrip['allowed'])
doc = ""
doc = ToFuObjectBase.strip.__doc__.format(doc,nMax)
if sys.version[0]=='2':
cls.strip.__func__.__doc__ = doc
else:
cls.strip.__doc__ = doc
cls.strip.__doc__ = doc

def strip(self, strip=0):
#super()
Expand Down