text
stringlengths
0
828
""""""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
""""""
engine = engine_from_config(
winchester_config['database'],
prefix='',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()"
4679,"def follow_cf(save, Uspan, target_cf, nup, n_tot=5.0, slsp=None):
""""""Calculates the quasiparticle weight in single
site spin hamiltonian under with N degenerate half-filled orbitals """"""
if slsp == None:
slsp = Spinon(slaves=6, orbitals=3, avg_particles=n_tot,
hopping=[0.5]*6, populations = np.asarray([n_tot]*6)/6)
zet, lam, mu, mean_f = [], [], [], []
for co in Uspan:
print('U=', co, 'del=', target_cf)
res=root(targetpop, nup[-1],(co,target_cf,slsp, n_tot))
print(res.x)
if res.x>nup[-1]: break
nup.append(res.x)
slsp.param['populations']=population_distri(nup[-1])
mean_f.append(slsp.mean_field())
zet.append(slsp.quasiparticle_weight())
lam.append(slsp.param['lambda'])
mu.append(orbital_energies(slsp.param, zet[-1]))
# plt.plot(np.asarray(zet)[:,0], label='d={}, zl'.format(str(target_cf)))
# plt.plot(np.asarray(zet)[:,5], label='d={}, zh'.format(str(target_cf)))
case = save.createGroup('cf={}'.format(target_cf))
varis = st.setgroup(case)
st.storegroup(varis, Uspan[:len(zet)], zet, lam, mu, nup[1:],target_cf,mean_f)"
4680,"def targetpop(upper_density, coul, target_cf, slsp, n_tot):
""""""restriction on finding the right populations that leave the crystal
field same""""""
if upper_density < 0.503: return 0.
trypops=population_distri(upper_density, n_tot)
slsp.set_filling(trypops)
slsp.selfconsistency(coul,0)
efm_free = dos_bethe_find_crystalfield(trypops, slsp.param['hopping'])
orb_ener = slsp.param['lambda']+ slsp.quasiparticle_weight()*efm_free
obtained_cf = orb_ener[5] - orb_ener[0]
return target_cf - obtained_cf"
4681,"def produce_pdf(rst_content=None, doctree_content=None, filename=None):
""""""produce a pdf content based of a given rst content
If filename is given, it will store the result using the given filename
if no filename is given, it will generate a pdf in /tmp/ with a random
name
""""""
if filename is None:
filename = os.path.join(
""/tmp"", ''.join([random.choice(string.ascii_letters +
string.digits) for n in range(15)]) + '.pdf')
r2p = RstToPdf(stylesheets=['pdf.style'],
style_path=[os.path.join(os.path.dirname(__file__),
'styles')],
breaklevel=0,
splittables=True,
footer=""""""###Title### - ###Page###/###Total###"""""")
r2p.createPdf(text=rst_content,
doctree=doctree_content,
output=filename)
return filename"
4682,"def load(self, filename=None):
""""""Method was overriden to set spectrum.filename as well""""""
DataFile.load(self, filename)
self.spectrum.filename = filename"
4683,"def _do_save_as(self, filename):
""""""Saves spectrum back to FITS file.""""""
if len(self.spectrum.x) < 2:
raise RuntimeError(""Spectrum must have at least two points"")
if os.path.isfile(filename):
os.unlink(filename) # PyFITS does not overwrite file
hdu = self.spectrum.to_hdu()
overwrite_fits(hdu, filename)"
4684,"def alternator(*pipes):
''' a lot like zip, just instead of:
(a,b),(a,b),(a,b)