files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  """Backend interface.
  
  To be used as a modeling and inference backend in a :class:`bayeslite.BayesDB`
  handle, a backends must first be registered with
  :func:`bayesdb_register_backend`.
  
  The CGPM backend is registered by default, but we can suppress
  that for illustration::
  
     import bayeslite
     from bayeslite.backends.cgpm_backend import CGPM_Backend
  
     bdb = bayeslite.bayesdb_open(pathname='
  
  [... the rest is omitted ...]
files: src/backend.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  """Backend interface.
  
  To be used as a modeling and inference backend in a :class:`bayeslite.BayesDB`
  handle, a backends must first be registered with
  :func:`bayesdb_register_backend`.
  
  The CGPM backend is registered by default, but we can suppress
  that for illustration::
  
     import bayeslite
     from bayeslite.backends.cgpm_backend import CGPM_Backend
  
     bdb = bayeslite.bayesdb_open(pathname='
  
  [... the rest is omitted ...]
files: src/backend.py
files: /*
   *  Copyright (c) 2010-2016, MIT Probabilistic Computing Project
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  bql(start)              ::= phrases(phrases).
  
  phrases(none)           ::= .
  phrases(some)           ::= phrases(phrases) phrase_opt(phrase) T_SEMI.
  phrase_opt(none)        ::= .
  phrase_opt(some)        ::= phrase(phrase).
  phrase(command)         ::= command(c).
  phrase(query)           ::= query(q).
  
  /*
   * Transactions
   */
  command(begin)          ::= K_BEGIN.
  command(rollback)       ::= K_ROLLBACK.
  
  
  [... the rest is omitted ...]
files: src/grammar.y
files: /*
   *  Copyright (c) 2010-2016, MIT Probabilistic Computing Project
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  bql(start)              ::= phrases(phrases).
  
  phrases(none)           ::= .
  phrases(some)           ::= phrases(phrases) phrase_opt(phrase) T_SEMI.
  phrase_opt(none)        ::= .
  phrase_opt(some)        ::= phrase(phrase).
  phrase(command)         ::= command(c).
  phrase(query)           ::= query(q).
  
  /*
   * Transactions
   */
  command(begin)          ::= K_BEGIN.
  command(rollback)       ::= K_ROLLBACK.
  
  
  [... the rest is omitted ...]
files: src/grammar.y
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  """BQL parser front end."""
  
  import StringIO
  
  import bayeslite.ast as ast
  import bayeslite.grammar as grammar
  import bayeslite.scan as scan
  from bayeslite.exception import BQLParseError
  
  def parse_bql_phrases(scanner):
      semantics = BQLSemantics()
      parser = grammar.Parser(semantics)
      while not semantics.failed:
          token = scanner.read()
          semantics.context.append(token)
          if token[0] == -1:
  
  [... the rest is omitted ...]
files: src/parse.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  """BQL parser front end."""
  
  import StringIO
  
  import bayeslite.ast as ast
  import bayeslite.grammar as grammar
  import bayeslite.scan as scan
  from bayeslite.exception import BQLParseError
  
  def parse_bql_phrases(scanner):
      semantics = BQLSemantics()
      parser = grammar.Parser(semantics)
      while not semantics.failed:
          token = scanner.read()
          semantics.context.append(token)
          if token[0] == -1:
  
  [... the rest is omitted ...]
files: src/parse.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import StringIO
  import apsw
  import pytest
  import struct
  
  import bayeslite
  import bayeslite.ast as ast
  import bayeslite.compiler as compiler
  import bayeslite.core as core
  import bayeslite.guess as guess
  import bayeslite.backends.troll_rng as troll
  import bayeslite.parse as parse
  
  from bayeslite.exception import BQLError
  from bayeslite.math_util import relerr
  from bayeslite.backends.cgpm
  
  [... the rest is omitted ...]
files: tests/test_bql.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import StringIO
  import apsw
  import pytest
  import struct
  
  import bayeslite
  import bayeslite.ast as ast
  import bayeslite.compiler as compiler
  import bayeslite.core as core
  import bayeslite.guess as guess
  import bayeslite.backends.troll_rng as troll
  import bayeslite.parse as parse
  
  from bayeslite.exception import BQLError
  from bayeslite.math_util import relerr
  from bayeslite.backends.cgpm
  
  [... the rest is omitted ...]
files: tests/test_bql.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  from __future__ import division
  
  import StringIO
  import contextlib
  import math
  import time
  
  import numpy as np
  import pytest
  
  from cgpm.cgpm import CGpm
  from cgpm.dummy.barebones import BareBonesCGpm
  from cgpm.dummy.piecewise import PieceWise
  from cgpm.dummy.trollnormal import TrollNormal
  from cgpm.factor.factor import FactorAnalysis
  from cgpm.regressions.linreg import LinearRegression
  
  [... the rest is omitted ...]
files: tests/test_cgpm.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  from __future__ import division
  
  import StringIO
  import contextlib
  import math
  import time
  
  import numpy as np
  import pytest
  
  from cgpm.cgpm import CGpm
  from cgpm.dummy.barebones import BareBonesCGpm
  from cgpm.dummy.piecewise import PieceWise
  from cgpm.dummy.trollnormal import TrollNormal
  from cgpm.factor.factor import FactorAnalysis
  from cgpm.regressions.linreg import LinearRegression
  
  [... the rest is omitted ...]
files: tests/test_cgpm.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import contextlib
  import pytest
  
  import bayeslite.core
  
  from bayeslite import bayesdb_register_backend
  from bayeslite.exception import BQLError
  from bayeslite.math_util import abserr
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from test_cgpm import cgpm_dummy_satellites_bdb
  
  
  @contextlib.contextmanager
  def cgpm_dummy_satellites_pop_bdb():
      with c
  
  [... the rest is omitted ...]
files: tests/test_cgpm_alter.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import contextlib
  import pytest
  
  import bayeslite.core
  
  from bayeslite import bayesdb_register_backend
  from bayeslite.exception import BQLError
  from bayeslite.math_util import abserr
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from test_cgpm import cgpm_dummy_satellites_bdb
  
  
  @contextlib.contextmanager
  def cgpm_dummy_satellites_pop_bdb():
      with c
  
  [... the rest is omitted ...]
files: tests/test_cgpm_alter.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import pytest
  
  import bayeslite.core
  
  from bayeslite import bayesdb_register_backend
  from bayeslite.exception import BQLError
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from test_cgpm import cgpm_dummy_satellites_bdb
  
  # This test suite needs expanding to confirm the subproblems are compiled to the
  # right inference kernels in cgpm_backend, but the information is quite nested
  # so it is not
  
  [... the rest is omitted ...]
files: tests/test_cgpm_analysis.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import pytest
  
  import bayeslite.core
  
  from bayeslite import bayesdb_register_backend
  from bayeslite.exception import BQLError
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from test_cgpm import cgpm_dummy_satellites_bdb
  
  # This test suite needs expanding to confirm the subproblems are compiled to the
  # right inference kernels in cgpm_backend, but the information is quite nested
  # so it is not
  
  [... the rest is omitted ...]
files: tests/test_cgpm_analysis.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import contextlib
  import itertools
  import pytest
  
  from bayeslite import bayesdb_open
  from bayeslite.exception import BQLError
  from bayeslite.exception import BQLParseError
  
  
  '''This test provides coverage for ESTIMATE and SIMULATE of conditional mutual
  information queries for univariate and multivariate targets and conditioning
  statements.'''
  
  
  @contextlib.contextmanager
  def smoke_bdb():
      with bayesdb_open(':memory:') as bdb:
          bdb.sql_execute('CREATE
  
  [... the rest is omitted ...]
files: tests/test_cmi.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import contextlib
  import itertools
  import pytest
  
  from bayeslite import bayesdb_open
  from bayeslite.exception import BQLError
  from bayeslite.exception import BQLParseError
  
  
  '''This test provides coverage for ESTIMATE and SIMULATE of conditional mutual
  information queries for univariate and multivariate targets and conditioning
  statements.'''
  
  
  @contextlib.contextmanager
  def smoke_bdb():
      with bayesdb_open(':memory:') as bdb:
          bdb.sql_execute('CREATE
  
  [... the rest is omitted ...]
files: tests/test_cmi.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import bayeslite
  
  def test_conditional_probability_simple_inferences():
      data = [
          ['x', 'a'], ['x', 'a'], ['x', 'a'],
          ['y', 'b'], ['y', 'b'], ['y', 'b'],
      ]
      with bayeslite.bayesdb_open() as bdb:
          bdb.sql_execute('create table t(foo, bar)')
          for row in data:
              bdb.sql_execute('insert into t values
  
  [... the rest is omitted ...]
files: tests/test_condprob.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import bayeslite
  
  def test_conditional_probability_simple_inferences():
      data = [
          ['x', 'a'], ['x', 'a'], ['x', 'a'],
          ['y', 'b'], ['y', 'b'], ['y', 'b'],
      ]
      with bayeslite.bayesdb_open() as bdb:
          bdb.sql_execute('create table t(foo, bar)')
          for row in data:
              bdb.sql_execute('insert into t values
  
  [... the rest is omitted ...]
files: tests/test_condprob.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import apsw
  import contextlib
  import itertools
  import json
  import pytest
  import tempfile
  
  import bayeslite
  import bayeslite.backend
  import bayeslite.bqlfn as bqlfn
  import bayeslite.core as core
  
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from bayeslite import bql_quote_name
  from bayeslite.sqlite3_util import sqlite3_connection
  from bayeslite.util import cursor_value
  
  
  
  [... the rest is omitted ...]
files: tests/test_core.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import apsw
  import contextlib
  import itertools
  import json
  import pytest
  import tempfile
  
  import bayeslite
  import bayeslite.backend
  import bayeslite.bqlfn as bqlfn
  import bayeslite.core as core
  
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from bayeslite import bql_quote_name
  from bayeslite.sqlite3_util import sqlite3_connection
  from bayeslite.util import cursor_value
  
  
  
  [... the rest is omitted ...]
files: tests/test_core.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  '''Ensures that INFER EXPLICIT PREDICT col for a _rowid_ which exists in the
  base table, but not incorporated into the generator (i.e. did not exist in the
  table during INITIALIZE) correctly retrieves all other values in the row. The
  test cases creates a population of (0,1) and (1,0) -- the complement function --
  and ensures its recovery on a held-out test set.'''
  
  import pytest
  
  from bayeslite import bayesdb_open
  
  
  
  [... the rest is omitted ...]
files: tests/test_infer_hypothetical.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  '''Ensures that INFER EXPLICIT PREDICT col for a _rowid_ which exists in the
  base table, but not incorporated into the generator (i.e. did not exist in the
  table during INITIALIZE) correctly retrieves all other values in the row. The
  test cases creates a population of (0,1) and (1,0) -- the complement function --
  and ensures its recovery on a held-out test set.'''
  
  import pytest
  
  from bayeslite import bayesdb_open
  
  
  
  [... the rest is omitted ...]
files: tests/test_infer_hypothetical.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import pytest
  
  import bayeslite.core as core
  
  from bayeslite import BQLError
  from bayeslite import bayesdb_open
  from bayeslite import bayesdb_register_backend
  from bayeslite.backends.nig_normal import NIGNormalBackend
  
  def test_nig_normal_smoke():
      with bayesdb_open(':memory:') as bdb:
          bayesdb_register_backend(bdb, NIGNormalBackend())
          bdb.sql_execute('create
  
  [... the rest is omitted ...]
files: tests/test_nig_normal.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import pytest
  
  import bayeslite.core as core
  
  from bayeslite import BQLError
  from bayeslite import bayesdb_open
  from bayeslite import bayesdb_register_backend
  from bayeslite.backends.nig_normal import NIGNormalBackend
  
  def test_nig_normal_smoke():
      with bayesdb_open(':memory:') as bdb:
          bayesdb_register_backend(bdb, NIGNormalBackend())
          bdb.sql_execute('create
  
  [... the rest is omitted ...]
files: tests/test_nig_normal.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import contextlib
  import itertools
  import pytest
  
  import bayeslite
  import bayeslite.ast as ast
  import bayeslite.parse as parse
  
  def parse_bql_string(string):
      phrases = list(parse.parse_bql_string(string))
      phrase_pos = list(parse.parse_bql_string_pos(string))
      assert len(phrases) == len(phrase_pos)
      start = 0
      for i in range(len(phrase_pos)):
          phrase, pos = phrase_pos[i]
          assert phrases[i]
  
  [... the rest is omitted ...]
files: tests/test_parse.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import contextlib
  import itertools
  import pytest
  
  import bayeslite
  import bayeslite.ast as ast
  import bayeslite.parse as parse
  
  def parse_bql_string(string):
      phrases = list(parse.parse_bql_string(string))
      phrase_pos = list(parse.parse_bql_string_pos(string))
      assert len(phrases) == len(phrase_pos)
      start = 0
      for i in range(len(phrase_pos)):
          phrase, pos = phrase_pos[i]
          assert phrases[i]
  
  [... the rest is omitted ...]
files: tests/test_parse.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import pytest
  
  from bayeslite import BQLError
  from bayeslite import bayesdb_register_backend
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from test_cgpm import cgpm_dummy_satellites_bdb
  
  
  def test_regress_bonanza__ci_integration():
      with cgpm_dummy_satellites_bdb() as bdb:
          bayesdb_register_backend(
              bdb, CGPM
  
  [... the rest is omitted ...]
files: tests/test_regress.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import pytest
  
  from bayeslite import BQLError
  from bayeslite import bayesdb_register_backend
  from bayeslite.backends.cgpm_backend import CGPM_Backend
  
  from test_cgpm import cgpm_dummy_satellites_bdb
  
  
  def test_regress_bonanza__ci_integration():
      with cgpm_dummy_satellites_bdb() as bdb:
          bayesdb_register_backend(
              bdb, CGPM
  
  [... the rest is omitted ...]
files: tests/test_regress.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import os
  
  import pytest
  
  import bayeslite
  import bayeslite.read_csv as read_csv
  
  from bayeslite.guess import bayesdb_guess_population
  
  
  root = os.path.dirname(os.path.abspath(__file__))
  dha_csv = os.path.join(root, 'dha.csv')
  
  
  # Test that simulating a column constrained to have a specific value
  # returns an error.
  #
  # XXX This should be a backend-independent test.
  def test_simulate_drawconstraint_error__ci_s
  
  [... the rest is omitted ...]
files: tests/test_simulate.py
files: # -*- coding: utf-8 -*-
  
  #   Copyright (c) 2010-2016, MIT Probabilistic Computing Project
  #
  #   Licensed under the Apache License, Version 2.0 (the "License");
  #   you may not use this file except in compliance with the License.
  #   You may obtain a copy of the License at
  #
  #       http://www.apache.org/licenses/LICENSE-2.0
  #
  #   Unless required by applicable law or agreed to in writing, software
  #   distributed under the License is distributed on an "AS IS" BASIS,
  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #   See the License for the specific language governing permissions and
  #   limitations under the License.
  
  import os
  
  import pytest
  
  import bayeslite
  import bayeslite.read_csv as read_csv
  
  from bayeslite.guess import bayesdb_guess_population
  
  
  root = os.path.dirname(os.path.abspath(__file__))
  dha_csv = os.path.join(root, 'dha.csv')
  
  
  # Test that simulating a column constrained to have a specific value
  # returns an error.
  #
  # XXX This should be a backend-independent test.
  def test_simulate_drawconstraint_error__ci_s
  
  [... the rest is omitted ...]
files: tests/test_simulate.py