All Samples(94233) | Call(93831) | Derive(399) | Import(3)
float(x) -> floating point number Convert a string or number to a floating point number, if possible.
src/p/y/python-ogre-HEAD/python-ogre/demos/samples/Sample_Terrain.py python-ogre(Download)
endy = min(endy, long(terrainSize))
for y in range (starty, endy+1):
for x in range (startx, endx + 1):
tsXdist = (float(x) / float(terrainSize)) - tsPos.x
tsYdist = (float(y) / float(terrainSize)) - tsPos.y
weight = float(Math.sqrt(tsYdist * tsYdist + tsXdist * tsXdist)) / float((0.5 * self.mBrushSizeTerrainSpace))
weight = min (1.0, weight)
endy = min(endy, long(imgSize))
for y in range(starty,endy+1):
for x in range(startx,endx+1) :
tsXdist = (float(x) / float(imgSize)) - tsPos.x
tsYdist = (float(y) / float(imgSize)) - tsPos.y
weight = float(Math.sqrt(tsYdist * tsYdist + tsXdist * tsXdist)) / float(0.5 * self.mBrushSizeTerrainSpace)
src/p/y/PyProp-HEAD/examples/combined/h2_ionization/non-bo/grid-generation.py PyProp(Download)
if not conf.include_right_boundary: count += 1 dx = (xmax - xmin) / float(count-1) if not conf.include_left_boundary: start += dx if conf.include_right_boundary:
def GetBidirectionalGridExponential(conf): xmax = float(conf.xmax) count = conf.count gamma = float(conf.gamma) xmin = - log(xmax+1) / gamma xmax = log(xmax+1) / gamma
def GetBidirectionalGridExponentialLinear(conf): innerBoundary = float(conf.inner_boundary) outerBoundary = float(conf.outer_boundary) count = conf.inner_count gamma = conf.gamma i = array(r_[0:count], dtype=double) n = float(count)
src/q/u/quickflash-HEAD/examples/flame_struct/plot_flame_dist.py quickflash(Download)
+ "scale factor and (optional) unit name\n\n")
exit(-1)
position_scale = float(words[0])
if (num_words > 1) :
title_unit_suffix = " (" + words[1] + ")"
keyword_value, table = read_file(filename)
sim_time = float(keyword_value.get_first_value("SimTime"))
raw_flame_center_mass \
= float(keyword_value.get_first_value("FlameCenterMass"))
flame_center_mass \
= raw_flame_center_mass * position_scale
raw_flame_center_mass_fraction \
= float(keyword_value.get_first_value("FlameCenterMassFract"))
= raw_flame_center_mass_fraction * position_scale
raw_local_flame_min_pos \
= float(keyword_value.get_first_value("MinFlamePos"))
local_flame_min_pos \
= raw_local_flame_min_pos * position_scale
raw_local_flame_max_pos \
= float(keyword_value.get_first_value("MaxFlamePos"))
flame_max_pos = local_flame_max_pos
local_bin_array_min_pos \
= float(keyword_value.get_first_value("BinArrayMinPos")) \
* position_scale
local_bin_array_max_pos \
= float(keyword_value.get_first_value("BinArrayMaxPos")) \
if (rms_diff_index is not None) :
local_ref_value = float(keyword_value[rms_diff_index].get_value())
if (rms_ref_value is None) :
rms_ref_value = local_ref_value
max_flame_values = list()
for value_string in max_flame_values_str_list :
max_flame_values.append(float(value_string))
area_min_flame_value_list.append(float(min_flame_value_str))
area_min_flame_value_str_list.append(min_flame_value_str)
src/m/a/matplotlib-HEAD/py4science/examples/scrape_key_stats.py matplotlib(Download)
fails, just return the string
"""
if x=='N/A': return None
elif x.endswith('%'): return float(x[:-1])
elif x.endswith('B'): return float(x[:-1])*1e9
elif x.endswith('M'): return float(x[:-1])*1e6
elif x.endswith('K'): return float(x[:-1])*1e3
else:
# try to convert to float
try: return float(x)
src/o/p/openev-HEAD/src/pymod/toolexample.py openev(Download)
disp_text = disp_text + '\n\n<Not a raster layer>\n'
return disp_text
[long,lat]=clayer.get_data().pixel_to_georef(float(pix),float(line))
disp_text = disp_text + ' Latitude: ' + str(lat)
disp_text = disp_text + ' Longitude: ' + str(long) + '\n'
try:
value = gdal_dataset.ReadAsArray(int(float(pix)),int(float(line)),1,1)
def update_roi_view(self,*args):
# Shouldn't get here if inactive anyway, but just in case...
if (self.RP_ToolDlg.is_active() == False):
return
# Update view based on new frame values
line = int(float(self.RP_ToolDlg.entry_dict['start_line'].get_text()))
pix = int(float(self.RP_ToolDlg.entry_dict['start_pix'].get_text()))
sl = int(float(self.RP_ToolDlg.entry_dict['num_lines'].get_text()))
sp = int(float(self.RP_ToolDlg.entry_dict['num_pix'].get_text()))
disp_text = 'Region Attributes: \n'
fname = clayer.get_parent().get_dataset().GetDescription()
disp_text = disp_text + '\tFilename: ' + fname + '\n'
disp_text = disp_text + '\tLines: ' + str(int(float(line))) + ' to '
disp_text = disp_text + str(int(float(line))+int(float(sl))-1) + '\n'
disp_text = disp_text + '\tPixels: ' + str(int(float(pix))) + ' to '
disp_text = disp_text + str(int(float(pix))+int(float(sp))-1)+'\n'
src/q/u/quickflash-HEAD/examples/demo/graphbins.py quickflash(Download)
words = current_line.split()
current_time = float(words[1])
block_lines = list()
for words in data_block :
center_list.append(float(words[center_index]))
entries_list.append(int(words[entries_index]))
weight_list.append(float(words[weight_index]))
mean_list.append(float(words[mean_index]))
stddev_list.append(float(words[stddev_index]))
min_list.append(float(words[min_index]))
max_list.append(float(words[max_index]))
src/x/g/xgcode-HEAD/PathSampler.py xgcode(Download)
expected_fraction = RateMatrix.get_jukes_cantor_transition_matrix(path_length)[(initial_state, terminal_state)]
print 'testing the rejection sampling:'
print 'expected fraction:', expected_fraction
print 'observed fraction:', rejection_path_count / float(n)
print 'comparing rejection sampling and nielsen sampling:'
rejection_method_fraction = rejection_event_count / float(rejection_path_count)
nielsen_method_fraction = nielsen_event_count / float(nielsen_path_count)
print 'rejection method fraction:', rejection_method_fraction
print 'nielsen method fraction:', nielsen_method_fraction
print 'comparing time of first event:'
print 'rejection method first event time mean:', rejection_first_time_sum / float(rejection_path_count)
print 'nielsen method first event time mean:', nielsen_first_time_sum / float(nielsen_path_count)
print 'comparing the duration spent in each state:'
print 'rejection:'
for state, t in rejection_dwell.items():
print '\t%s: %f' % (state, t/float(rejection_path_count))
print 'nielsen:'
for state, t in nielsen_dwell.items():
print '\t%s: %f' % (state, t/float(nielsen_path_count))
src/b/r/brian-HEAD/examples/frompapers/Diesmann_et_al_1999_longer.py brian(Download)
net.reinit(params)
net.run()
(newa,newsigma) = estimate_params(net.mon[-1],params.initial_burst_t)
newa = float(newa)/float(neuron_multiply)
col = (float(ai)/float(grid),float(sigmai)/float(grid),0.5)
plot([sigma/ms,newsigma/ms],[a,newa],color=col)
plot([sigma/ms],[a],marker='.',color=col,markersize=15)
i+=1
if verbose:
print str(int(100.*float(i)/float((grid+1)**2)))+"%",
src/s/y/sympy-0.6.6/examples/intermediate/sample.py sympy(Download)
except:
raise ValueError("x_args must be a tuple of the form (var, min, max, n)")
x_l = float(x_max - x_min)
x_d = x_l/float(x_n)
X = arange(float(x_min), float(x_max)+x_d, x_d)
Y = empty(len(X))
for i in range(len(X)):
try:
Y[i] = float(f.subs(x, X[i]))
except:
raise ValueError("x_args and y_args must be tuples of the form (var, min, max, intervals)")
x_l = float(x_max - x_min)
x_d = x_l/float(x_n)
x_a = arange(float(x_min), float(x_max)+x_d, x_d)
y_l = float(y_max - y_min)
y_d = y_l/float(y_n)
y_a = arange(float(y_min), float(y_max)+y_d, y_d)
for j in range(len(X)):
for k in range(len(X[0])):
try:
Z[j][k] = float( f.subs(x, X[j][k]).subs(y, Y[j][k]) )
except:
Z[j][k] = 0
return X, Y, Z
src/b/o/bot2d-HEAD/examples/navlib/wheelchair.py bot2d(Download)
def init(config, userData=None):
try: x = float(config.x)
except: x = 0.0
try: y = float(config.y)
except: y = 0.0
try: theta = radians(config.theta)
except: theta = 0.0
wheelbase = float(config.wheelbase)
k1 = float(config.k1)
k2 = float(config.k2)
kw = float(config.kw)
try: density = float(config.density)
casters = []
if dir(config).count('caster') > 0:
for casterCfg in config.caster:
x = float(casterCfg.x)
y = float(casterCfg.y)
try: theta = float(casterCfg.theta)
except: theta = 0.0
radius = float(casterCfg.radius)
Previous 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 Next