def test(): patns = mockdb.get_mock().patns def test_func(doc): return {'$set': {'dummy_field': 'yay!'}} n_right = parallelMap(test_func, patns, 'pno') print "num for which alleged successfull: {}".format(n_right) print "num with dummy_field: {}".format(patns.find({'dummy_field': 'yay!'}).count()) return patns
def test(): db = get_mock() in_deg_counts, out_deg_counts = in_and_out_counts(db, 100) f, (ax1, ax2) = plt.subplots(1, 2, sharey=True) f.set_size_inches(18.5, 10.5) ax1.hist(in_deg_counts.keys(), weights=in_deg_counts.values(), bins=20) ax1.set_xlabel('In-Degree') ax1.set_ylabel('Count') ax2.hist(out_deg_counts.keys(), weights=out_deg_counts.values(), bins=20) ax2.set_xlabel('Out-Degree') ax2.set_ylabel('Count') plt.suptitle('Degree Distributions') plt.savefig('degree_distributions_test.png')
def test(): db = get_mock() in_deg_counts, out_deg_counts = in_and_out_counts(db, 100) f,(ax1, ax2) = plt.subplots(1,2,sharey=True) f.set_size_inches(18.5, 10.5) ax1.hist(in_deg_counts.keys(), weights=in_deg_counts.values(), bins=20) ax1.set_xlabel('In-Degree') ax1.set_ylabel('Count') ax2.hist(out_deg_counts.keys(), weights=out_deg_counts.values(), bins=20) ax2.set_xlabel('Out-Degree') ax2.set_ylabel('Count') plt.suptitle('Degree Distributions') plt.savefig('degree_distributions_test.png')
def test(): db = get_mock() inctr, outctr = cites_over_time(db,limit=100) in_dates, in_cites = zip(*inctr.items()) out_dates, out_cites = zip(*outctr.items()) f,(ax1, ax2) = plt.subplots(1,2,sharey=True) f.set_size_inches(18.5, 10.5) ax1.scatter(in_dates, in_cites) ax1.set_xlabel('Date') ax1.set_title('In-degrees over Time.') ax2.scatter(out_dates, out_cites) ax2.set_xlabel('Date') ax2.set_title('Out-Degrees over Time.') plt.show() return inctr, outctr
def setUp(self): self.db = get_mock() self.pat_coll = self.db.pat_text self.K = 5 self.n_docs = 50 data_dir = '/'.join([_this_dir, 'data']) self.out_dir = '/'.join([_this_dir, 'test_output']) self.stored_vocab_fn = '/'.join([data_dir, 'test_vocab.dict']) self.stored_corpus_fn = '/'.join([data_dir, 'test_corpus.svmlight']) self.visualize_fn = '/'.join([data_dir, 'test_vis.png']) fields = ['_id', 'patText'] nulls = [None, ''] self.pnos, self.texts = get_fields_unordered(self.pat_coll, fields, nulls, self.n_docs) self.model = lda.MyLda(self.K, 'tester')
def test(): enforce_func = lambda x: len(x.get('citedby', [])) > 100 realdb = MongoClient().patents patent_family = [4061724, 4064521, 4340563, 4405829, 4655771, 4683202, 4723129, 5103459, 5143854, 5572643] print "Getting docs from real db..." patent_family_docs = [realdb.traits.find_one({'_id': pno}) for pno in patent_family] # pprint(patent_family_docs) mockdb = get_mock() print "computing 2 generation tf-idf reach..." compute_reach(trait='tf-idf', n_gens=2, db=mockdb, family=patent_family_docs, enforce_func = enforce_func) print "computing 2 generation w2v reach..." compute_reach(trait='w2v', n_gens=2, db=mockdb, family=patent_family_docs, enforce_func = enforce_func) print "computing 2 generation w2v trait variance..." compute_trait_variance(trait='w2v', n_gens=2, db=mockdb, family=patent_family_docs, enforce_func = enforce_func) print "computing 5 generation tf-idf reach..." compute_reach(trait='tf-idf', n_gens=5, db=mockdb, family=patent_family_docs, enforce_func = enforce_func) print "computing 5 generation w2v reach..." compute_reach(trait='w2v', n_gens=5, db=mockdb, family=patent_family_docs, enforce_func = enforce_func) print "computing 5 generation w2v trait variance..." compute_trait_variance(trait='w2v', n_gens=5, db=mockdb, family=patent_family_docs, enforce_func = enforce_func) print "Done testing."
def setUp(self): self.db = get_mock() self.n_test = 10
def setUp(self): self.db = get_mock() self.n_test = 2 self.pnos_test = dbutil.get_fields_unordered(self.db.patns, ['pno'], [0], self.n_test)[0]
def setUp(self): self.db = get_mock()
def setUp(self): self.db = get_mock() self.n_test = 10 self.family_docs = self.db.traits.find().limit(self.n_test)
def setUp(self): self.enforcer = lambda x: len(x.get('citedby', [])) > 100 self.db = get_mock() self.n_test = 5 self.family_docs = self.db.traits.find().limit(self.n_test)
def setUp(self): self.enforcer = lambda x: len(x.get("citedby", [])) > 100 self.db = get_mock() self.n_test = 5 self.family_docs = self.db.traits.find().limit(self.n_test)