34
34
'WHERE chain = ?' ),
35
35
'draw_count' : ('SELECT COUNT(*) FROM [{table}] '
36
36
'WHERE chain = ?' ),
37
- ## Named placeholders are used in the selection templates because
38
- ## some values occur more than once in the same template.
37
+ # Named placeholders are used in the selection templates because
38
+ # some values occur more than once in the same template.
39
39
'select' : ('SELECT * FROM [{table}] '
40
40
'WHERE (chain = :chain)' ),
41
41
'select_burn' : ('SELECT * FROM [{table}] '
@@ -71,6 +71,7 @@ class SQLite(base.BaseTrace):
71
71
Sampling values will be stored for these variables. If None,
72
72
`model.unobserved_RVs` is used.
73
73
"""
74
+
74
75
def __init__ (self , name , model = None , vars = None ):
75
76
super (SQLite , self ).__init__ (name , model , vars )
76
77
self ._var_cols = {}
@@ -80,13 +81,13 @@ def __init__(self, name, model=None, vars=None):
80
81
self ._len = None
81
82
82
83
self .db = _SQLiteDB (name )
83
- ## Inserting sampling information is queued to avoid locks
84
- ## caused by hitting the database with transactions each
85
- ## iteration.
84
+ # Inserting sampling information is queued to avoid locks
85
+ # caused by hitting the database with transactions each
86
+ # iteration.
86
87
self ._queue = {varname : [] for varname in self .varnames }
87
88
self ._queue_limit = 5000
88
89
89
- ## Sampling methods
90
+ # Sampling methods
90
91
91
92
def setup (self , draws , chain ):
92
93
"""Perform chain-specific setup.
@@ -127,7 +128,7 @@ def _create_table(self):
127
128
def _create_insert_queries (self , chain ):
128
129
template = TEMPLATES ['insert' ]
129
130
for varname , var_cols in self ._var_cols .items ():
130
- ## Create insert statement for each variable.
131
+ # Create insert statement for each variable.
131
132
var_str = ', ' .join (var_cols )
132
133
placeholders = ', ' .join (['?' ] * len (var_cols ))
133
134
statement = template .format (table = varname ,
@@ -164,7 +165,7 @@ def close(self):
164
165
self ._execute_queue ()
165
166
self .db .close ()
166
167
167
- ## Selection methods
168
+ # Selection methods
168
169
169
170
def __len__ (self ):
170
171
if not self ._is_setup :
@@ -252,6 +253,7 @@ def point(self, idx):
252
253
253
254
254
255
class _SQLiteDB (object ):
256
+
255
257
def __init__ (self , name ):
256
258
self .name = name
257
259
self .con = None
@@ -306,8 +308,8 @@ def load(name, model=None):
306
308
307
309
def _get_table_list (cursor ):
308
310
"""Return a list of table names in the current database."""
309
- ## Modified from Django. Skips the sqlite_sequence system table used
310
- ## for autoincrement key generation.
311
+ # Modified from Django. Skips the sqlite_sequence system table used
312
+ # for autoincrement key generation.
311
313
cursor .execute ("SELECT name FROM sqlite_master "
312
314
"WHERE type='table' AND NOT name='sqlite_sequence' "
313
315
"ORDER BY name" )
0 commit comments