Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def dbsubset(dbin, expr, name = None):
"""Subset a database view"""
dbout = Dbptr(dbin)
dbout.subset(expr, name)
return dbout
def dbsort(dbin, keys, unique = False, reverse = False, name = None):
"""Sort a database view"""
dbout = Dbptr(dbin)
dbout.sort(keys, unique, reverse, name)
return dbout
def test_method_group(self):
db = Dbptr(self.dbname)
db.lookup(table = 'arrival')
db.sort('sta')
db.group('sta')
self.assertTrue(db.database >= 0)
self.assertTrue(db.table >= 0)
self.assertEqual(db.field, dbALL)
self.assertEqual(db.record, dbALL)
db.close()
def test_method_free(self):
db = Dbptr(self.dbname)
db.lookup(table = 'origin')
db.sort('time')
db.free()
db.close()
def test_method_find(self):
db = Dbptr(self.dbname)
db.lookup(table = 'origin')
rc = db.find('orid == 645')
self.assertTrue(rc > 0)
db.close()
def test_method_loadchan(self):
db = Dbptr(self.dbname)
tr = db.loadchan(706139719.05000, 706139855.95000, "TKM", "BHZ")
self.assert_(isinstance(db, Dbptr))
self.assertTrue(tr.database >= 0)
self.assertNotEqual(tr.table, dbINVALID)
self.assertNotEqual(tr.field, dbINVALID)
self.assertNotEqual(tr.record, dbINVALID)
tr = db.loadchan("1992-05-17 21:55:19.05", "1992-05-17 21:57:35.95", "TKM", "BHZ")
self.assert_(isinstance(db, Dbptr))
self.assertTrue(tr.database >= 0)
self.assertNotEqual(tr.table, dbINVALID)
def dbgroup(db, groupfields, name = None, type = 1):
"""Group a sorted table"""
dbout = Dbptr(db)
dbout.group(groupfields, name, type)
return dbout
def dbtheta(db1, db2, ex_str, outer = False, name = None):
"""Theta-join two database views"""
dbout = Dbptr(db1)
dbout.theta(db2, ex_str, outer, name)
return dbout
def test_method_ungroup(self):
db = Dbptr(self.dbname)
db.lookup(table = 'arrival')
db.sort('sta')
db.group('sta')
db.ungroup()
self.assertTrue(db.database >= 0)
self.assertTrue(db.table >= 0)
self.assertEqual(db.field, dbALL)
db.close()
def test_procedure_dbclose(self):
db = Dbptr(self.dbname)
dbclose(db)