本文整理匯總了Python中add.Add類的典型用法代碼示例。如果您正苦於以下問題:Python Add類的具體用法?Python Add怎麽用?Python Add使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Add類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add
def add(self):
adder = Add()
if self.args['one_sample'] is not None:
new_sample = [tuple(entry.strip('}').strip('{').strip(',').split(':')) for entry in self.args['one_sample']]
new_sample = dict(new_sample)
adder.add_one_sample(new_sample)
if len(self.args['email']) > 0:
if not sampleinfo_mongo.is_fully_annotated(new_sample['SAMPLE']):
annotate = Annotate()
annotate.annotate_sample(new_sample['SAMPLE'], 'orig')
output_files = Output()
final_file = output_files.sample_variants_csv(new_sample['SAMPLE'], 'orig')
message = "Here are all the variants for the sample %s with their QC status." % new_sample['SAMPLE']
for address in self.args['email']:
self.__log_sending_email(address)
output_bash.email_file(message, final_file, address)
elif self.args['sample_info'] is not None:
adder.add_sample_info(self.args['sample_info'])
示例2: as_real_imag
def as_real_imag(self, deep=True, **hints):
from sympy.core.symbol import symbols
from sympy.polys.polytools import poly
from sympy.core.function import expand_multinomial
if self.exp.is_Integer:
exp = self.exp
re, im = self.base.as_real_imag(deep=deep)
if re.func == C.re or im.func == C.im:
return self, S.Zero
a, b = symbols('a b', cls=Dummy)
if exp >= 0:
if re.is_Number and im.is_Number:
# We can be more efficient in this case
expr = expand_multinomial(self.base**exp)
return expr.as_real_imag()
expr = poly((a + b)**exp) # a = re, b = im; expr = (a + b*I)**exp
else:
mag = re**2 + im**2
re, im = re/mag, -im/mag
if re.is_Number and im.is_Number:
# We can be more efficient in this case
expr = expand_multinomial((re + im*S.ImaginaryUnit)**-exp)
return expr.as_real_imag()
expr = poly((a + b)**-exp)
# Terms with even b powers will be real
r = [i for i in expr.terms() if not i[0][1] % 2]
re_part = Add(*[cc*a**aa*b**bb for (aa, bb), cc in r])
# Terms with odd b powers will be imaginary
r = [i for i in expr.terms() if i[0][1] % 4 == 1]
im_part1 = Add(*[cc*a**aa*b**bb for (aa, bb), cc in r])
r = [i for i in expr.terms() if i[0][1] % 4 == 3]
im_part3 = Add(*[cc*a**aa*b**bb for (aa, bb), cc in r])
return (re_part.subs({a: re, b: S.ImaginaryUnit*im}),
im_part1.subs({a: re, b: im}) + im_part3.subs({a: re, b: -im}))
elif self.exp.is_Rational:
# NOTE: This is not totally correct since for x**(p/q) with
# x being imaginary there are actually q roots, but
# only a single one is returned from here.
re, im = self.base.as_real_imag(deep=deep)
if re.func == C.re or im.func == C.im:
return self, S.Zero
r = Pow(Pow(re, 2) + Pow(im, 2), S.Half)
t = C.atan2(im, re)
rp, tp = Pow(r, self.exp), t*self.exp
return (rp*C.cos(tp), rp*C.sin(tp))
else:
if deep:
hints['complex'] = False
return (C.re(self.expand(deep, **hints)),
C.im(self.expand(deep, **hints)))
else:
return (C.re(self), C.im(self))
示例3: HandInserting
from handinserting import *
hi = HandInserting()
hi.insert_terms()
elif ec == "4":
from handinserting import *
tables = []
hi = HandInserting()
hi.insert_phrases()
elif ec == "5":
from testing import *
tph = TestPhrases()
tph.start(["all_phrases"])
elif ec == "6":
from add import Add
ad = Add()
ad.add_term()
elif ec == "7":
from delete import Delete
delete = Delete()
delete.del_term()
elif ec == "8":
from change import Change
ch = Change()
ch.change_term()
示例4: init
def init(argv):
opts, methods = getopt(argv, 'hl:r:vm:s:a:fi:NP:ducS', ['help', 'lang=', 'reference=', 'version' ,'main=', 'skeleton=', 'add=', 'cout', 'force', 'include=', 'prefix=', 'downcase', 'uppercase', 'camel', 'snake'])
xunit = load()
includes = []
prefix = 1
force = 0
cout = 0
add = None
skeleton = None
main = None
lang = None
downcase = None
snake = None
for opt, value in opts:
if '-h' == opt or '--help' == opt:
usage()
sys.exit(0)
elif '-v' == opt or '--version' == opt:
version()
for lang in xunit.lang.items():
print ' ' + lang[1].version + '(--lang ' + lang[0] + ')'
sys.exit(0)
elif '-r' == opt or '--reference' == opt:
try:
print xunit.lang[value].reference
except KeyError:
sys.stderr.write('Un Support Language:%s' % value)
sys.exit(1)
elif '-l' == opt or '--lang' == opt:
try:
lang = xunit.lang[value]
except KeyError:
sys.stderr.write('Un Support Language:%s' % value)
sys.exit(1)
elif '-m' == opt or '--main' == opt:
main = value
elif '-s' == opt or '--skeleton' == opt:
skeleton = value
elif '-a' == opt or '--add' == opt:
add = value
force = 1
elif '-P' == opt or '--prefix' == opt:
if value == '+':
prefix = 1
elif value == '-':
prefix = 0
else:
raise ValueError, "prefix option can accept only '+' or '-'"
elif '-f' == opt or '--force' == opt:
force = 1
elif '-d' == opt or '--downcase' == opt:
downcase = 1
elif '-u' == opt or '--uppercase' == opt:
downcase = 0
elif '-S' == opt or '--snake' == opt:
snake = 1
elif '-c' == opt or '--camel' == opt:
snake = 0
elif '--cout' == opt:
cout = 1
elif '-i' == opt or '--include' == opt:
includes.append(value)
if add is not None:
add = Add(add, language(xunit, lang, add), methods, includes)
add.create()
output(add.filename, add.result, force, cout)
else:
if skeleton is not None:
skeleton = Skeleton(skeleton, methods, includes, prefix,
language(xunit, lang, skeleton))
skeleton.create()
output(skeleton.filename, skeleton.result, force, cout)
if main is not None:
main = Main(main, language(xunit, lang, main))
main.create()
output(main.filename, main.result, force, cout)