本文整理汇总了Python中pychron.core.helpers.formatting.floatfmt函数的典型用法代码示例。如果您正苦于以下问题:Python floatfmt函数的具体用法?Python floatfmt怎么用?Python floatfmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了floatfmt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _build_label_text
def _build_label_text(self, x, we, n, total_n=None, mswd_args=None, percent_error=False, sig_figs=3):
display_n = True
display_mswd = n >= 2
if display_n:
if total_n and n != total_n:
n = "n= {}/{}".format(n, total_n)
else:
n = "n= {}".format(n)
else:
n = ""
if mswd_args and display_mswd:
mswd, valid_mswd, _ = mswd_args
vd = "" if valid_mswd else "*"
mswd = "{}mswd= {:0.2f}".format(vd, mswd)
else:
mswd = ""
sx = floatfmt(x, sig_figs)
swe = floatfmt(we, sig_figs)
if self.options.index_attr in ("uF", "Ar40/Ar36"):
me = u"{} {}{}".format(sx, PLUSMINUS, swe)
else:
age_units = self._get_age_units()
pe = ""
if percent_error:
pe = "({})".format(format_percent_error(x, we, include_percent_sign=True))
me = u"{} {}{}{} {}".format(sx, PLUSMINUS, swe, pe, age_units)
return u"{} {} {}".format(me, mswd, n)
开发者ID:OSUPychron,项目名称:pychron,代码行数:34,代码来源:arar_figure.py
示例2: _build_label_text
def _build_label_text(self, x, we, mswd, valid_mswd, n,
percent_error=False,
sig_figs=3):
display_n = True
display_mswd = n >= 2
if display_n:
n = 'n= {}'.format(n)
else:
n = ''
if display_mswd:
vd = '' if valid_mswd else '*'
mswd = '{}mswd= {:0.2f}'.format(vd, mswd)
else:
mswd = ''
sx = floatfmt(x, sig_figs)
swe = floatfmt(we, sig_figs)
if self.options.index_attr in ('uF', 'Ar40/Ar36'):
me = '{} +/-{}'.format(sx, swe)
else:
age_units = self._get_age_units()
pe = ''
if percent_error:
pe = '({})'.format(format_percent_error(x, we, include_percent_sign=True))
me = '{} +/-{}{} {}'.format(sx, swe, pe, age_units)
return u'{} {} {}'.format(me, mswd, n)
开发者ID:UManPychron,项目名称:pychron,代码行数:30,代码来源:arar_figure.py
示例3: _get_discrimination_text
def _get_discrimination_text(self):
ic = self.item.discrimination
if ic is None:
v, e = 1.0, 0
else:
v, e = nominal_value(ic), std_dev(ic)
return '{}+/-{}'.format(floatfmt(v, n=4), floatfmt(e, n=4))
开发者ID:NMGRL,项目名称:pychron,代码行数:8,代码来源:adapters.py
示例4: _load_unknown_computed
def _load_unknown_computed(self, an, new_list):
attrs = (('Age', 'uage_w_j_err'),
# ('Age', 'age', None, None, 'age_err'),
('w/o J', 'wo_j', '', 'uage', 'age_err_wo_j'),
('K/Ca', 'kca'),
('K/Cl', 'kcl'),
('40Ar*', 'rad40_percent'),
('F', 'uF'),
('w/o Irrad', 'wo_irrad', '', 'uF', 'F_err_wo_irrad'))
if new_list:
def comp_factory(n, a, value=None, value_tag=None, error_tag=None):
if value is None:
value = getattr(an, a)
display_value = True
if value_tag:
value = getattr(an, value_tag)
display_value = False
if error_tag:
e = getattr(an, error_tag)
else:
e = std_dev(value)
return ComputedValue(name=n,
tag=a,
value=nominal_value(value) or 0,
value_tag=value_tag or '',
display_value=display_value,
error=e or 0)
cv = [comp_factory(*args)
for args in attrs]
self.computed_values = cv
else:
age = an.uage
nage, sage = nominal_value(age), std_dev(age)
try:
self.summary_str = u'Age={} {}{}({}%)'.format(floatfmt(nage), PLUSMINUS,
floatfmt(sage), format_percent_error(nage, sage))
except:
pass
for ci in self.computed_values:
attr = ci.tag
if attr == 'wo_j':
ci.error = an.age_err_wo_j or 0
ci.value = nominal_value(getattr(an, ci.value_tag))
elif attr == 'wo_irrad':
ci.error = an.F_err_wo_irrad or 0
ci.value = nominal_value(getattr(an, ci.value_tag))
else:
v = getattr(an, attr)
if v is not None:
ci.value = nominal_value(v)
ci.error = std_dev(v)
开发者ID:NMGRL,项目名称:pychron,代码行数:58,代码来源:main_view.py
示例5: _make_flux_row
def _make_flux_row(self, ans):
mR = sum(ai.R for ai in ans) / len(ans)
j, e = calculate_flux(mR, 1, self.monitor_age)
r = Row(fontsize=8)
r.add_item(value='<b>J</b>', span=5)
r.add_item(value='<b>{}</b>'.format(floatfmt(j)))
r.add_item(value='<b>{}</b>'.format(floatfmt(e)))
return r
开发者ID:UManPychron,项目名称:pychron,代码行数:10,代码来源:flux_pdf_writer.py
示例6: calculate_width
def calculate_width(self, txt):
if self.calculated_width is None:
self.calculated_width = self._calculate_label_width()
if isinstance(txt, float):
if self.nsigfigs:
txt = floatfmt(txt, self.nsigfigs, use_scientific=self.use_scientific)
else:
txt = floatfmt(txt)
self.calculated_width = max(self.calculated_width, len(str(txt))+5)
开发者ID:NMGRL,项目名称:pychron,代码行数:11,代码来源:column.py
示例7: _update_ratios
def _update_ratios(self, an):
for ci in self.computed_values:
nd = ci.detectors
r = self._get_non_corrected_ratio(nd)
rr, ic = self._get_corrected_ratio(nd)
ci.trait_set(value=floatfmt(rr.nominal_value),
error=floatfmt(rr.std_dev),
noncorrected_value=r.nominal_value,
noncorrected_error=r.std_dev,
ic_factor=nominal_value(ic))
开发者ID:jirhiker,项目名称:pychron,代码行数:11,代码来源:main_view.py
示例8: test_convert_to_scientific
def test_convert_to_scientific(self):
x = 0.001
fx = floatfmt(x, n=2)
self.assertEqual(fx, '1.00E-03')
fx = floatfmt(x, n=2, s=1)
self.assertEqual(fx, '1.0E-03')
x = 0.001
fx = floatfmt(x)
self.assertEqual(fx, '0.0010')
开发者ID:UManPychron,项目名称:pychron,代码行数:11,代码来源:floatfmt.py
示例9: _permutate
def _permutate(self, ai, record_id, e, ici, prog, i, n):
if prog:
prog.change_message("Setting ic_factor to {}, {}".format(ici, e))
ai.set_ic_factor("CDD", ici, e)
ai.calculate_age(force=True)
r = PermutationRecord()
r.age = ai.uage
r.info_str = "{} (ic={},{})".format(record_id, floatfmt(ici), floatfmt(e))
r.identifier = ai.identifier
return r
开发者ID:OSUPychron,项目名称:pychron,代码行数:12,代码来源:permutator.py
示例10: comp_factory
def comp_factory(n, a, value=None, error_tag=None):
if value is None:
aa = getattr(an, a)
value = floatfmt(nominal_value(aa))
if error_tag:
e = getattr(an, error_tag)
else:
e = std_dev(aa)
return ComputedValue(name=n,
tag=a,
value=value,
error=floatfmt(e))
开发者ID:jirhiker,项目名称:pychron,代码行数:13,代码来源:main_view.py
示例11: _get_value
def _get_value(self, attr, n=3, **kw):
v = ""
item = self.item
if hasattr(item, attr):
v = getattr(self.item, attr)
if v:
v = floatfmt(nominal_value(v), n=n, **kw)
elif hasattr(item, "isotopes"):
if attr in item.isotopes:
v = item.isotopes[attr].get_intensity()
v = floatfmt(nominal_value(v), n=n, **kw)
return v
开发者ID:jirhiker,项目名称:pychron,代码行数:13,代码来源:base_adapter.py
示例12: _air_ratio
def _air_ratio(self):
a4038 = self.isotope_group.get_ratio('Ar40/Ar38', non_ic_corr=True)
a4036 = self.isotope_group.get_ratio('Ar40/Ar36', non_ic_corr=True)
# e4038 = uformat_percent_error(a4038, include_percent_sign=True)
# e4036 = uformat_percent_error(a4036, include_percent_sign=True)
lines = [self._make_header('Ratios'),
'Ar40/Ar36= {} {}'.format(floatfmt(nominal_value(a4036)), errorfmt(nominal_value(a4036),
std_dev(a4036))),
'Ar40/Ar38= {} {}'.format(floatfmt(nominal_value(a4038)), errorfmt(nominal_value(a4038),
std_dev(a4038)))]
return self._make_lines(lines)
开发者ID:NMGRL,项目名称:pychron,代码行数:13,代码来源:result.py
示例13: _make_weighted_mean_row
def _make_weighted_mean_row(self, ans):
r = Row(fontsize=8)
ages, errors = zip(*[(ai.age.nominal_value, ai.age.std_dev)
for ai in ans])
wm, we = calculate_weighted_mean(ages, errors)
r.add_item(value='<b>weighted mean</b>', span=2)
r.add_blank_item(3)
r.add_item(value='<b>{}</b>'.format(floatfmt(wm)))
r.add_item(value=u'<b>\u00b1{}</b>'.format(floatfmt(we)))
return r
开发者ID:UManPychron,项目名称:pychron,代码行数:13,代码来源:flux_pdf_writer.py
示例14: _update_ratios
def _update_ratios(self, an):
for ci in self.computed_values:
nd = ci.detectors
n, d = nd.split('/')
niso, diso = self._get_isotope(n), self._get_isotope(d)
noncorrected = self._get_non_corrected_ratio(niso, diso)
corrected, ic = self._get_corrected_ratio(niso, diso)
ci.trait_set(value=floatfmt(nominal_value(corrected)),
error=floatfmt(std_dev(corrected)),
noncorrected_value=nominal_value(noncorrected),
noncorrected_error=std_dev(noncorrected),
ic_factor=nominal_value(ic))
开发者ID:OSUPychron,项目名称:pychron,代码行数:14,代码来源:main_view.py
示例15: load_measurement
def load_measurement(self, an, ar):
# j = self._get_j(an)
j = ar.j
jf = 'NaN'
if j is not None:
jj = floatfmt(nominal_value(j), n=7, s=5)
pe = format_percent_error(nominal_value(j), std_dev(j), include_percent_sign=True)
jf = u'{} \u00b1{:0.2e}({})'.format(jj, std_dev(j), pe)
a39 = ar.ar39decayfactor
a37 = ar.ar37decayfactor
ms = [MeasurementValue(name='Branch',
value=an.branch),
MeasurementValue(name='DAQ Version',
value=an.collection_version),
MeasurementValue(name='UUID',
value=an.uuid),
MeasurementValue(name='RepositoryID',
value=an.repository_identifier),
MeasurementValue(name='Spectrometer',
value=an.mass_spectrometer),
MeasurementValue(name='Run Date',
value=an.rundate.strftime('%Y-%m-%d %H:%M:%S')),
MeasurementValue(name='Irradiation',
value=self._get_irradiation(an)),
MeasurementValue(name='J',
value=jf),
MeasurementValue(name='Position Error',
value=floatfmt(an.position_jerr, use_scientific=True)),
MeasurementValue(name='Lambda K',
value=nominal_value(ar.arar_constants.lambda_k),
units='1/a'),
MeasurementValue(name='Project',
value=an.project),
MeasurementValue(name='Sample',
value=an.sample),
MeasurementValue(name='Material',
value=an.material),
MeasurementValue(name='Comment',
value=an.comment),
MeasurementValue(name='Ar39Decay',
value=floatfmt(a39)),
MeasurementValue(name='Ar37Decay',
value=floatfmt(a37)),
MeasurementValue(name='Sens.',
value=floatfmt(an.sensitivity, use_scientific=True),
units=an.sensitivity_units)]
self.measurement_values = ms
开发者ID:NMGRL,项目名称:pychron,代码行数:50,代码来源:main_view.py
示例16: _irradiation_changed
def _irradiation_changed(self):
super(LabnumberEntry, self)._irradiation_changed()
if self.irradiation:
db = self.db
with db.session_ctx():
irrad = db.get_irradiation(self.irradiation)
j = irrad.chronology.duration
j *= self.j_multiplier
self.estimated_j_value = u'{} {}{}'.format(floatfmt(j),
PLUSMINUS,
floatfmt(j*0.001))
items = [NeutronDose(*args) for args in irrad.chronology.get_doses()]
self.chronology_items = items
开发者ID:OSUPychron,项目名称:pychron,代码行数:14,代码来源:labnumber_entry.py
示例17: assemble_lines
def assemble_lines(self):
pt = self.current_position
if pt:
# x, y = self.component.map_data(pt)
comp = self.component
inds = self.get_selected_index()
lines = []
convert_index = self.convert_index
if inds is not None and len(inds):
he = hasattr(self.component, 'yerror')
ys = comp.value.get_data()[inds]
xs = comp.index.get_data()[inds]
for i, x, y in zip(inds, xs, ys):
if he:
ye = comp.yerror.get_data()[i]
pe = self.percent_error(y, ye)
ye = floatfmt(ye, n=6, s=3)
sy = u'{} {}{} ({})'.format(y, PLUSMINUS, ye, pe)
else:
sy = floatfmt(y, n=6, s=3)
if convert_index:
x = convert_index(x)
else:
x = '{:0.5f}'.format(x)
lines.extend([u'pt={:03d}, x= {}, y= {}'.format(i + 1, x, sy)])
if hasattr(comp, 'display_index'):
x = comp.display_index.get_data()[i]
lines.append('{}'.format(x))
if self.additional_info is not None:
try:
ad = self.additional_info(i, self.id)
except BaseException:
ad = self.additional_info(i)
if isinstance(ad, (list, tuple)):
lines.extend(ad)
else:
lines.append(ad)
return lines
# delim_n = max([len(li) for li in lines])
# return intersperse(lines, '-' * delim_n)
else:
return []
开发者ID:NMGRL,项目名称:pychron,代码行数:49,代码来源:point_inspector.py
示例18: traits_view
def traits_view(self):
return View(HGroup(Item('age_kind',
style='readonly', show_label=False),
Item('display_age', format_func=lambda x: floatfmt(x, 3),
label='Age',
style='readonly'),
Item('display_age_err',
label=u'\u00b11\u03c3',
format_func=lambda x: floatfmt(x, 4),
style='readonly'),
Item('display_age_units',
style='readonly', show_label=False),
Item('mswd',
format_func=lambda x: floatfmt(x, 2),
style='readonly', label='MSWD')))
开发者ID:OSUPychron,项目名称:pychron,代码行数:15,代码来源:interpreted_age.py
示例19: make_items
def make_items(isotopes):
items = []
for det in DETECTOR_ORDER:
ai = next((ai for ai in isotopes.values() if ai.detector.upper() == det), None)
if ai:
rv = ai.get_non_detector_corrected_value()
r = RatioItem(name=ai.detector,
refvalue=rv,
intensity=floatfmt(nominal_value(rv)),
intensity_err=floatfmt(std_dev(rv)))
r.add_ratio(ai)
for bi in isotopes.values():
r.add_ratio(bi)
items.append(r)
return items
开发者ID:OSUPychron,项目名称:pychron,代码行数:16,代码来源:detector_ic.py
示例20: assemble_lines
def assemble_lines(self):
idx = self.current_position
comp = self.component
e = comp.errors[idx]
ys = comp.value.get_data()[::2]
v = ys[idx]
low_c = 0 if idx == 0 else self.cumulative39s[idx - 1]
return ['Step={}'.format(ALPHAS[idx]),
'{}={} +/- {} (1s)'.format(comp.container.y_axis.title, floatfmt(v),
floatfmt(e)
),
'Cumulative. Ar39={}-{}'.format(floatfmt(low_c),
floatfmt(self.cumulative39s[idx]))]
开发者ID:UManPychron,项目名称:pychron,代码行数:16,代码来源:tools.py
注:本文中的pychron.core.helpers.formatting.floatfmt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论