BQLError when simulating MI of variable not in population throws NameError
Closed this issue · 5 comments
curlette commented
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-97-8b1168ac0f59> in <module>()
----> 1 get_ipython().magic(u'bql .density SIMULATE MUTUAL INFORMATION OF spending_health_per1 WITH predicted_gdp GIVEN (gdp = 0) USING 10 SAMPLES FROM MODELS OF gapminder_monitor_p;')
/scratch/curlette/.pyenv/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2144 magic_name, _, magic_arg_s = arg_s.partition(' ')
2145 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2146 return self.run_line_magic(magic_name, magic_arg_s)
2147
2148 #-------------------------------------------------------------------------
/scratch/curlette/.pyenv/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2065 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2066 with self.builtin_trap:
-> 2067 result = fn(*args,**kwargs)
2068 return result
2069
/scratch/curlette/iventure/build/lib.linux-x86_64-2.7/iventure/magics.py in logged_cell_wrapper(self, line, cell)
136 raw = self._retrieve_raw(line, cell)
137 try:
--> 138 output = func(self, line, cell)
139 except:
140 exception = traceback.format_exc()
<decorator-gen-129> in bql(self, line, cell)
/scratch/curlette/.pyenv/local/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
/scratch/curlette/iventure/build/lib.linux-x86_64-2.7/iventure/magics.py in bql(self, line, cell)
299 continue
300 if cmd.startswith('.'):
--> 301 result = self._cmd(cmd)
302 else:
303 result = self._bql([cmd])
/scratch/curlette/iventure/build/lib.linux-x86_64-2.7/iventure/magics.py in _cmd(self, cmd, sql)
340 args = str.replace(args, m, '')
341 args = str.strip(args)
--> 342 return self._PLTS[dot_command](self, args, sql=sql, **kwargs)
343 else:
344 sys.stderr.write('Unknown command: %s\n' % (dot_command,))
/scratch/curlette/iventure/build/lib.linux-x86_64-2.7/iventure/magics.py in _cmd_density(self, query, sql, **kwargs)
422
423 def _cmd_density(self, query, sql=None, **kwargs):
--> 424 c = self._bdb.sql_execute(query) if sql else self._bdb.execute(query)
425 df = utils_bql.cursor_to_df(c)
426 utils_plot.density(df, **kwargs)
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/bayesdb.py in execute(self, string, bindings)
226 bindings = ()
227 return self._maybe_trace(
--> 228 self.tracer, self._do_execute, string, bindings)
229
230 def _maybe_trace(self, tracer, meth, string, bindings):
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/bayesdb.py in _maybe_trace(self, tracer, meth, string, bindings)
234 if tracer:
235 tracer(string, bindings)
--> 236 return meth(string, bindings)
237
238 def _qid(self):
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/bayesdb.py in _do_execute(self, string, bindings)
275 else:
276 raise ValueError('>1 phrase in string')
--> 277 cursor = bql.execute_phrase(self, phrase, bindings)
278 return self._empty_cursor if cursor is None else cursor
279
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/bql.py in execute_phrase(bdb, phrase, bindings)
63 out = compiler.Output(n_numpar, nampar_map, bindings)
64 with bdb.savepoint():
---> 65 compiler.compile_query(bdb, phrase, out)
66 winders, unwinders = out.getwindings()
67 return execute_wound(bdb, winders, unwinders, out.getvalue(),
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/compiler.py in compile_query(bdb, query, out)
213 :param Output out: output accumulator
214 """
--> 215 _compile_query(bdb, query, BQLCompiler_None(), out)
216
217 def _compile_query(bdb, query, bql_compiler, out):
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/compiler.py in _compile_query(bdb, query, bql_compiler, out)
255 compile_simulate(bdb, query, out)
256 elif isinstance(query, ast.SimulateModels):
--> 257 compile_simulate_models(bdb, query, bql_compiler, out)
258 elif isinstance(query, ast.EstCols):
259 compile_estcols(bdb, query, out)
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/compiler.py in compile_simulate_models(bdb, simmodels, bql_compiler, out)
750 compile_simulate_models_1(
751 bdb, simmodels.columns[0], population_id, generator_id, False,
--> 752 bql_compiler, out)
753 else:
754 # XXX For now, each of these will be independent estimates.
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/compiler.py in compile_simulate_models_1(bdb, selcol, population_id, generator_id, rowid_p, bql_compiler, out)
820 out.write(' AND conditions = ')
821 compile_simulate_constraints(
--> 822 bdb, exp.constraints, population_id, generator_id, out)
823 if exp.nsamples is not None:
824 out.write(' AND nsamples = ')
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/compiler.py in compile_simulate_constraints(bdb, constraints, population_id, generator_id, out)
840 return lit.value
841 assert all(isinstance(exp, ast.ExpLit) for _var, exp in constraints)
--> 842 mapped = {map_var(var): map_lit(exp.value) for var, exp in constraints}
843 compile_string(bdb, json_dumps(mapped), out)
844
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/compiler.py in <dictcomp>((var, exp))
840 return lit.value
841 assert all(isinstance(exp, ast.ExpLit) for _var, exp in constraints)
--> 842 mapped = {map_var(var): map_lit(exp.value) for var, exp in constraints}
843 compile_string(bdb, json_dumps(mapped), out)
844
/scratch/curlette/bayeslite/build/lib.linux-x86_64-2.7/bayeslite/compiler.py in map_var(var)
831 bdb, population_id, generator_id, var):
832 raise BQLError(bdb, 'No such variable in population %r: %r' %
--> 833 (simmodels.population, var))
834 return core.bayesdb_variable_number(
835 bdb, population_id, generator_id, var)
NameError: global name 'simmodels' is not defined
fsaad commented
Which branch/SHA? Does not seem this source is from master.
curlette commented
20170207-riastradh-estprob
fsaad commented
curlette commented
riastradh-probcomp commented