Skip to content

Commit

Permalink
Remove odict and fix test (#259)
Browse files Browse the repository at this point in the history
* input observed data as dictionary

* add tests for log_likelihood and observed_data

* remove odict and fix test
  • Loading branch information
ahartikainen authored and ColCarroll committed Sep 20, 2018
1 parent 36c8104 commit 5d70084
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions arviz/plots/plot_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Utilities for plotting."""
from itertools import product
from collections import OrderedDict as odict

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -204,7 +203,7 @@ def xarray_var_iter(data, var_names=None, combined=False, skip_dims=None, revers
if var_name in data:
new_dims = [dim for dim in data[var_name].dims if dim not in skip_dims]
vals = [data[var_name][dim].values for dim in new_dims]
dims = [odict((k, v) for k, v in zip(new_dims, prod)) for prod in product(*vals)]
dims = [{k : v for k, v in zip(new_dims, prod)} for prod in product(*vals)]
if reverse_selections:
dims = reversed(dims)

Expand Down
8 changes: 7 additions & 1 deletion arviz/tests/test_plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ def test_dataset_to_numpy_not_combined(sample_dataset): # pylint: disable=inval

# 2 vars x 2 chains
assert len(var_names) == 4
assert (data == np.concatenate((mu, tau), axis=0)).all()
mu_tau = np.concatenate((mu, tau), axis=0)
tau_mu = np.concatenate((tau, mu), axis=0)
deqmt = data == mu_tau
deqtm = data == tau_mu
assert deqmt.all() or deqtm.all()


def test_dataset_to_numpy_combined(sample_dataset):
mu, tau, data = sample_dataset
var_names, data = xarray_to_ndarray(data, combined=True)

assert len(var_names) == 2
if var_names[0] == 'tau':
data = data[::-1]
assert (data[0] == mu.reshape(1, 6)).all()
assert (data[1] == tau.reshape(1, 6)).all()

Expand Down

0 comments on commit 5d70084

Please sign in to comment.