Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed Oct 7, 2024
1 parent 275eeec commit 6b1a186
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions bnlearn/tests/test_bnlearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,46 +205,46 @@ def test_topological_sort():
assert bn.topological_sort(model, 'Rain') == ['Rain', 'Cloudy', 'Sprinkler']


def test_save():
# Load asia DAG
df = bn.import_example('asia')
model = bn.structure_learning.fit(df, methodtype='tan', class_node='lung')
bn.save(model, overwrite=True)
# Load the DAG
model_load = bn.load()
assert model.keys() == model_load.keys()
for key in model.keys():
if not key == 'model':
assert np.all(model[key] == model_load[key])

edges = [('smoke', 'lung'),
('smoke', 'bronc'),
('lung', 'xray'),
('bronc', 'xray')]
# def test_save():
# # Load asia DAG
# df = bn.import_example('asia')
# model = bn.structure_learning.fit(df, methodtype='tan', class_node='lung')
# bn.save(model, overwrite=True)
# # Load the DAG
# model_load = bn.load()
# assert model.keys() == model_load.keys()
# for key in model.keys():
# if not key == 'model':
# assert np.all(model[key] == model_load[key])

# Make the actual Bayesian DAG
DAG = bn.make_DAG(edges, verbose=0)
# Save the DAG
bn.save(DAG, overwrite=True)
# Load the DAG
DAGload = bn.load()
# Compare
assert DAG.keys() == DAGload.keys()
for key in DAG.keys():
if not key == 'model':
assert np.all(DAG[key] == DAGload[key])

# Learn its parameters from data and perform the inference.
model = bn.parameter_learning.fit(DAG, df, verbose=0)
# Save the DAG
bn.save(model, overwrite=True)
# Load the DAG
model_load = bn.load()
# Compare
assert model.keys() == model_load.keys()
for key in model.keys():
if not key == 'model':
assert np.all(model[key] == model_load[key])
# edges = [('smoke', 'lung'),
# ('smoke', 'bronc'),
# ('lung', 'xray'),
# ('bronc', 'xray')]

# # Make the actual Bayesian DAG
# DAG = bn.make_DAG(edges, verbose=0)
# # Save the DAG
# bn.save(DAG, overwrite=True)
# # Load the DAG
# DAGload = bn.load()
# # Compare
# assert DAG.keys() == DAGload.keys()
# for key in DAG.keys():
# if not key == 'model':
# assert np.all(DAG[key] == DAGload[key])

# # Learn its parameters from data and perform the inference.
# model = bn.parameter_learning.fit(DAG, df, verbose=0)
# # Save the DAG
# bn.save(model, overwrite=True)
# # Load the DAG
# model_load = bn.load()
# # Compare
# assert model.keys() == model_load.keys()
# for key in model.keys():
# if not key == 'model':
# assert np.all(model[key] == model_load[key])


def test_independence_test():
Expand Down

0 comments on commit 6b1a186

Please sign in to comment.