def fulltext(self): """Compute the new and deleted bibcodes for each type of error from most recent list of bibcodes compared with previous most recent list. Results stored in variables that are then used in report.py.""" for err in conf['FULLTEXT_ERRORS']: err_msg = "_".join(err.split('"')[1].split()).replace( '-', '_').replace(']', '').replace('[', '') dir = conf['AIR_DATA_DIRECTORY'] + "ft/" + err_msg + '/' # get 2 most recent files files = sorted(glob.glob(dir + '*.txt'), key=sorter, reverse=True) sort(files[0]) sort(files[1]) remove_duplicates(files[0]) remove_duplicates(files[1]) ft_start = files[1] ft_end = files[0] ft_new = dir + "new.tsv" self.values['new_ft_' + err_msg] = comm(ft_end, ft_start, ft_new) ft_fixed = dir + "fixed.tsv" self.values['fixed_ft_' + err_msg] = comm(ft_start, ft_end, ft_fixed)
def canonical(self): """compute new, deleted""" canonical_start = Filename.get(self.start, FileType.CANONICAL) canonical_end = Filename.get(self.end, FileType.CANONICAL) canonical_new = Filename.get(self.end, FileType.CANONICAL, FileAdjective.NEW) self.values['new_canonical'] = comm(canonical_end, canonical_start, canonical_new) canonical_deleted = Filename.get(self.end, FileType.CANONICAL, FileAdjective.DELETED) self.values['deleted_canonical'] = comm(canonical_start, canonical_end, canonical_deleted) self.values['canonical'] = lines_in_file(canonical_end)
def test(): """Testing script for the harmonic oscillator module.""" from numpy.random import randn from utils import assert_o def randc(): """Random complex number.""" return randn() + 1j*randn() a = mat(boson_ladder(default_n)) alpha = randc() s = coherent_state(alpha) s0 = state(0, default_n) D = displace(alpha) assert_o((s - s0.u_propagate(D)).norm(), 0, tol) # displacement z = randc() S = squeeze(z) Q = position(); P = momentum() q = randn(); p = randn() sq = position_state(q) sp = momentum_state(p) temp = 1e-1 # the truncation accuracy is not amazing here assert_o(sq.ev(Q), q, temp) # Q, P eigenstates assert_o(sp.ev(P), p, temp) temp = ones(default_n); temp[-1] = -default_n+1 # truncation... assert_o(norm(comm(Q,P) - 1j * diag(temp)), 0, tol) # [Q, P] = i assert_o(norm(mat(P)**2 +mat(Q)**2 - 2 * a.H * a -diag(temp)), 0, tol) # P^2 +Q^2 = 2a^\dagger * a + 1
def fulltext(self): """Compute the new and deleted bibcodes for each type of error from todays list of bibcodes compared with yesterdays list. Results stored in variables that are then used in report.py.""" for e in conf['FULLTEXT_ERRORS'].keys(): err_msg = "_" + ("_".join(e.split())).replace('-', '_') ft_start = Filename.get(self.start, FileType.FULLTEXT, adjective=None, msg=err_msg + "_") ft_end = Filename.get(self.end, FileType.FULLTEXT, adjective=None, msg=err_msg + "_") ft_new = Filename.get(self.end, FileType.FULLTEXT, adjective=FileAdjective.NEW, msg=err_msg + "_") self.values['new_ft' + err_msg] = comm(ft_end, ft_start, ft_new) ft_deleted = Filename.get(self.end, FileType.FULLTEXT, FileAdjective.DELETED, msg=err_msg + "_") self.values['deleted_ft' + err_msg] = comm(ft_start, ft_end, ft_deleted) self.values['ft' + err_msg] = lines_in_file(ft_end)
def solr(self): """compute missing, deleted, new, extra""" solr_end = Filename.get(self.end, FileType.SOLR) canonical_end = Filename.get(self.end, FileType.CANONICAL) solr_missing = Filename.get(self.end, FileType.SOLR, FileAdjective.MISSING) self.values['missing_solr'] = comm(canonical_end, solr_end, solr_missing) solr_start = Filename.get(self.start, FileType.SOLR) solr_new = Filename.get(self.end, FileType.SOLR, FileAdjective.NEW) self.values['new_solr'] = comm(solr_end, solr_start, solr_new) solr_deleted = Filename.get(self.end, FileType.SOLR, FileAdjective.DELETED) self.values['deleted_solr'] = comm(solr_start, solr_end, solr_deleted) solr_extra = Filename.get(self.end, FileType.SOLR, FileAdjective.EXTRA) self.values['extra_solr'] = comm(solr_end, canonical_end, solr_extra) self.values['solr'] = lines_in_file(solr_end)