Made code python 3 compatible:

Replaced round with numpy.round
replaced map with list-comprehension
master
Per A Brodtkorb 9 years ago
parent cef998d962
commit 8b4e4dae57

@ -1802,7 +1802,7 @@ def common_shape(*args, ** kwds):
--------
broadcast, broadcast_arrays
'''
args = map(asarray, args)
args = [asarray(x) for x in args]
shapes = [x.shape for x in args]
shape = kwds.get('shape')
if shape is not None:
@ -1947,7 +1947,7 @@ def stirlerr(n):
def getshipchar(value=None, property="max_deadweight", # @ReservedAssignment
** kwds): # @IgnorePep8
**kwds): # @IgnorePep8
'''
Return ship characteristics from value of one ship-property
@ -2026,23 +2026,23 @@ def getshipchar(value=None, property="max_deadweight", # @ReservedAssignment
max_deadweight = prop2max_dw.get(prop, lambda x: x)(value)
propertySTD = prop + 'STD'
length = round(3.45 * max_deadweight ** 0.40)
length = np.round(3.45 * max_deadweight ** 0.40)
length_err = length ** 0.13
beam = round(1.78 * max_deadweight ** 0.27 * 10) / 10
beam = np.round(1.78 * max_deadweight ** 0.27 * 10) / 10
beam_err = beam * 0.10
draught = round(0.80 * max_deadweight ** 0.24 * 10) / 10
draught = np.round(0.80 * max_deadweight ** 0.24 * 10) / 10
draught_err = draught * 0.22
# S = round(2/3*(L)**0.525)
speed = round(1.14 * max_deadweight ** 0.21 * 10) / 10
speed = np.round(1.14 * max_deadweight ** 0.21 * 10) / 10
speed_err = speed * 0.10
p_diam = 0.12 * length ** (3.0 / 4.0)
p_diam_err = 0.12 * length_err ** (3.0 / 4.0)
max_deadweight = round(max_deadweight)
max_deadweight = np.round(max_deadweight)
max_deadweightSTD = 0.1 * max_deadweight
shipchar = OrderedDict(beam=beam, beamSTD=beam_err,

@ -1055,7 +1055,7 @@ class SpecData1D(PlotData):
maxS = max(S.data)
# Fs = 2*freq(end)+eps # sampling frequency
for ix in xrange(max_sim):
for ix in range(max_sim):
x2, x1 = self.sim_nl(ns=np, cases=cases, dt=None, iseed=iseed,
method=method, fnlimit=fn_limit,
output='timeseries')
@ -1371,7 +1371,7 @@ class SpecData1D(PlotData):
rind = Rind(**opts)
# h11 = fwaitbar(0,[],sprintf('Please wait ...(start at: %s)',
# datestr(now)))
for pt in xrange(Nstart, Ntime):
for pt in range(Nstart, Ntime):
Nt = pt - Nd + 1
Ntd = Nt + Nd
Ntdc = Ntd + Nc
@ -3545,8 +3545,7 @@ class SpecData1D(PlotData):
m, unused_mtxt = self.moment(nr=4, even=False)
fact_dict = dict(alpha=0, eps2=1, eps4=3, qp=3, Qp=3)
fact = atleast_1d(map(lambda fact: fact_dict.get(fact, fact),
list(factors)))
fact = atleast_1d(fact_dict.get(fact, fact) for fact in list(factors))
# fact = atleast_1d(fact)
alpha = m[2] / sqrt(m[0] * m[4])

@ -147,10 +147,10 @@ class Profile(object):
self.xlabel = ''
self.ylabel = 'Profile log'
(self.i_fixed, self.N, self.alpha, self.pmin, self.pmax, self.x,
self.logSF, self.link) = map(
kwds.get,
self.logSF, self.link) = [kwds.get(name, val)
for name, val in zip(
['i', 'N', 'alpha', 'pmin', 'pmax', 'x', 'logSF', 'link'],
[i0, 100, 0.05, None, None, None, None, None])
[i0, 100, 0.05, None, None, None, None, None])]
self.title = '%g%s CI' % (100 * (1.0 - self.alpha), '%')
if fit_dist.method.startswith('ml'):

Loading…
Cancel
Save