Skip to content

Commit 67c91f5

Browse files
author
F Saad
committed
Eliminate usage of Engine.transition_foreign.
1 parent e9569e7 commit 67c91f5

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

src/metamodels/cgpm_metamodel.py

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -283,40 +283,16 @@ def retrieve_analyze_variables(ast):
283283
raise ValueError('1 clause permitted in ANALYZE: %s.' % ast)
284284
return variables
285285

286-
def foreign(varname):
287-
schema = self._schema(bdb, generator_id)
288-
return all(v[0]!=varname for v in schema['variables'])
289-
290286
# Retrieve target variables.
291287
analyze_ast = cgpm_analyze.parse.parse(program)
292288
variables = retrieve_analyze_variables(analyze_ast)
293-
varnames_gpmcc = [v for v in variables if not foreign(v)]
294-
varnames_foreign = [v for v in variables if foreign(v)]
289+
varnos = [core.bayesdb_variable_number(bdb, population_id, v)
290+
for v in variables]
295291

296-
# Get the engine.
292+
# Run transition.
297293
engine = self._engine(bdb, generator_id)
298-
299-
# Transition gpmcc variables.
300-
if varnames_gpmcc:
301-
print varnames_gpmcc
302-
varnos_gpmcc = [
303-
core.bayesdb_variable_number(bdb, population_id, v)
304-
for v in varnames_gpmcc
305-
]
306-
engine.transition(
307-
N=iterations, S=max_seconds, cols=varnos_gpmcc,
308-
multithread=self._ncpu)
309-
310-
# Transition foreign variables.
311-
if varnames_foreign:
312-
print varnames_foreign
313-
varnos_foreign = [
314-
core.bayesdb_variable_number(bdb, population_id, v)
315-
for v in varnames_foreign
316-
]
317-
engine.transition_foreign(
318-
N=iterations, S=max_seconds, cols=varnos_foreign,
319-
multithread=self._ncpu)
294+
engine.transition(
295+
N=iterations, S=max_seconds, cols=varnos, multithread=self._ncpu)
320296

321297
# Serialize the engine.
322298
engine_json = json_dumps(engine.to_metadata())

0 commit comments

Comments
 (0)