示例#1
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     np.random.seed(TEST_SEED)
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000', multi=True)
     self.single_trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000_0.csv')
     self.size_known = json.load(open(FULL_PATH + '/data/effective_size.json', 'r'))
示例#2
0
    def setUp(self):

        self.a = {chr(i+97):list(range(10)) for i in range(5)}

        self.t = Trace(**self.a)
        self.mt = Trace(self.a,self.a,self.a)
        self.real_mt = Trace.from_csv(FULL_PATH + r'/data/south_mvcm_5000', multi=True)
        self.real_singles = [Trace.from_csv(FULL_PATH + r'/data/south_mvcm_5000_{}.csv'
                             .format(i)) for i in range(4)]
示例#3
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     np.random.seed(TEST_SEED)
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000',
                                 multi=True)
     self.single_trace = Trace.from_csv(FULL_PATH +
                                        '/data/south_mvcm_5000_0.csv')
     self.geweke_known = json.load(open(FULL_PATH + '/data/geweke.json'))
示例#4
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     np.random.seed(TEST_SEED)
     test_methods = ['obm', 'bm', 'bartlett', 'hanning', 'tukey']
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000', multi=True)
     self.single_trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000_0.csv')
     self.bm = json.load(open(FULL_PATH + '/data/mcse_bm.json', 'r'))
     self.obm = json.load(open(FULL_PATH + '/data/mcse_obm.json', 'r'))
     self.tukey = json.load(open(FULL_PATH + '/data/mcse_hanning.json', 'r'))
     self.bartlett = json.load(open(FULL_PATH + '/data/mcse_bartlett.json', 'r'))
     self.hanning = self.tukey
示例#5
0
 def setUp(self):
     super(Test_Lower_SMA, self).build_self()
     self.cls = lower.Lower_SMA
     del self.inputs["M"]
     self.inputs['n_samples'] = 0
     instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/lower_sma.csv')
示例#6
0
 def setUp(self):
     super(Test_Lower_SE, self).build_self()
     self.cls = lower.Lower_SE
     del self.inputs["M"]
     self.inputs['n_samples'] = 0
     instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/lower_se.csv')
示例#7
0
 def setUp(self):
     super(Test_Upper_SE, self).build_self()
     self.cls = upper.Upper_SE
     del self.inputs["W"]
     self.inputs['n_samples'] = 0
     instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/upper_se.csv')
示例#8
0
 def setUp(self):
     super(Test_Upper_SMA, self).build_self()
     self.cls = upper.Upper_SMA
     del self.inputs["W"]
     self.inputs['n_samples'] = 0
     instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/upper_sma.csv')
示例#9
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     np.random.seed(TEST_SEED)
     test_methods = ['obm', 'bm', 'bartlett', 'hanning', 'tukey']
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000',
                                 multi=True)
     self.single_trace = Trace.from_csv(FULL_PATH +
                                        '/data/south_mvcm_5000_0.csv')
     self.bm = json.load(open(FULL_PATH + '/data/mcse_bm.json', 'r'))
     self.obm = json.load(open(FULL_PATH + '/data/mcse_obm.json', 'r'))
     self.tukey = json.load(open(FULL_PATH + '/data/mcse_hanning.json',
                                 'r'))
     self.bartlett = json.load(
         open(FULL_PATH + '/data/mcse_bartlett.json', 'r'))
     self.hanning = self.tukey
示例#10
0
 def setUp(self):
     super(Test_MVCM, self).build_self()
     self.cls = M.MVCM
     del self.inputs['M']
     del self.inputs['W']
     self.inputs['n_samples'] = 0
     self.instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/mvcm.csv')
示例#11
0
 def setUp(self):
     super(Test_MVCM, self).build_self()
     self.cls = M.MVCM
     del self.inputs['M']
     del self.inputs['W']
     self.inputs['n_samples'] = 0
     self.instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/mvcm.csv')
示例#12
0
 def test_mvcm(self):
     instance = self.cls(**self.inputs)
     np.random.seed(TEST_SEED)
     instance.draw()
     other_answers = Trace.from_csv(FULL_PATH + '/data/mvcm.csv')
     strip_out = [col for col in instance.trace.varnames if col not in other_answers.varnames]
     other_answers._assert_allclose(instance.trace.drop(
                                    *strip_out, inplace=False),
                                    rtol=RTOL, atol=ATOL)
示例#13
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     with open(FULL_PATH + '/data/psrf_noburn.json', 'r') as noburn:
         self.noburn = json.load(noburn)
     with open(FULL_PATH + '/data/psrf_brooks.json', 'r') as brooks:
         self.known_brooks = json.load(brooks)
     with open(FULL_PATH + '/data/psrf_gr.json', 'r') as gr:
         self.known_gr = json.load(gr)
     np.random.seed(TEST_SEED)
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000', multi=True)
     self.mockmodel = Hashmap(trace=self.trace)
示例#14
0
 def test_mvcm(self):
     instance = self.cls(**self.inputs)
     np.random.seed(TEST_SEED)
     instance.draw()
     other_answers = Trace.from_csv(FULL_PATH + '/data/mvcm.csv')
     strip_out = [
         col for col in instance.trace.varnames
         if col not in other_answers.varnames
     ]
     other_answers._assert_allclose(instance.trace.drop(*strip_out,
                                                        inplace=False),
                                    rtol=RTOL,
                                    atol=ATOL)
示例#15
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     with open(FULL_PATH + '/data/psrf_noburn.json', 'r') as noburn:
         self.noburn = json.load(noburn)
     with open(FULL_PATH + '/data/psrf_brooks.json', 'r') as brooks:
         self.known_brooks = json.load(brooks)
     with open(FULL_PATH + '/data/psrf_gr.json', 'r') as gr:
         self.known_gr = json.load(gr)
     np.random.seed(TEST_SEED)
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000',
                                 multi=True)
     self.mockmodel = Hashmap(trace=self.trace)
示例#16
0
    def setUp(self):

        self.a = {chr(i + 97): list(range(10)) for i in range(5)}

        self.t = Trace(**self.a)
        self.mt = Trace(self.a, self.a, self.a)
        self.real_mt = Trace.from_csv(FULL_PATH + r'/data/south_mvcm_5000',
                                      multi=True)
        self.real_singles = [
            Trace.from_csv(FULL_PATH +
                           r'/data/south_mvcm_5000_{}.csv'.format(i))
            for i in range(4)
        ]
示例#17
0
 def test_from_df(self):
     df = self.t.to_df()
     new_trace = Trace.from_df(df)
     assert new_trace == self.t
     new_mt = Trace.from_df((df, df, df))
     assert new_mt == self.t
示例#18
0
 def setUp(self):
     super(Test_SMASE, self).build_self()
     self.cls = M.SMASE
     self.inputs['n_samples'] = 0
     self.instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/smase.csv')
示例#19
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     np.random.seed(TEST_SEED)
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000', multi=True)
示例#20
0
 def test_from_csv(self):
     self.t.to_csv('./test_from_csv.csv')
     new_t = Trace.from_csv('./test_from_csv.csv')
     assert self.t == new_t
     os.remove('./test_from_csv.csv')
示例#21
0
 def test_validate_names(self):
     b = self.a.copy()
     try:
         bad_names = Trace(self.a, b, self.a, self.a)
     except KeyError:
         pass
示例#22
0
 def test_multi_roundtrips(self):
     dfs = self.real_mt.to_df()
     new = Trace.from_df(dfs)
     new._assert_allclose(self.real_mt)
示例#23
0
 def test_ordering(self):
     for ch, alone in zip(self.real_mt.chains, self.real_singles):
         Trace(ch)._assert_allclose(alone)
示例#24
0
 def test_from_df(self):
     df = self.t.to_df()
     new_trace = Trace.from_df(df)
     assert new_trace == self.t
     new_mt = Trace.from_df((df, df, df))
     assert new_mt == self.t
示例#25
0
 def setUp(self):
     data = south()
     data['n_samples'] = 0
     np.random.seed(TEST_SEED)
     self.trace = Trace.from_csv(FULL_PATH + '/data/south_mvcm_5000',
                                 multi=True)
示例#26
0
 def setUp(self):
     super(Test_Generic, self).build_self()
     self.cls = M.Generic
     self.inputs['n_samples'] = 0
     instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/generic.csv')
示例#27
0
 def test_single_roundtrips(self):
     source_from_file = self.real_singles[0]
     from_df = Trace.from_df(source_from_file.to_df())
     source_from_file._assert_allclose(from_df)
示例#28
0
 def test_multi_roundtrips(self):
     dfs = self.real_mt.to_df()
     new = Trace.from_df(dfs)
     new._assert_allclose(self.real_mt)
示例#29
0
 def setUp(self):
     super(Test_Generic, self).build_self()
     self.cls = M.Generic
     self.inputs['n_samples'] = 0
     instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/generic.csv')
示例#30
0
 def test_from_csv(self):
     self.t.to_csv('./test_from_csv.csv')
     new_t = Trace.from_csv('./test_from_csv.csv')
     assert self.t == new_t
     os.remove('./test_from_csv.csv')
示例#31
0
 def test_single_roundtrips(self):
     source_from_file = self.real_singles[0]
     from_df = Trace.from_df(source_from_file.to_df())
     source_from_file._assert_allclose(from_df)
示例#32
0
    def __init__(
            self,
            #data parameters
            Y,
            X,
            coordinates,
            n_samples=1000,
            n_jobs=1,
            priors=None,
            configs=None,
            starting_values=None,
            extra_traced_params=None,
            dmetric='euclidean',
            correlation_function=nexp,
            verbose=False,
            center=True,
            rescale_dists=True):
        if center:
            X = verify_center(X)
        X = verify_covariates(X)

        N, p = X.shape
        Xs = X

        X = explode(X)
        self.state = Hashmap(X=X, Y=Y, coordinates=coordinates)
        self.traced_params = ['Betas', 'Mus', 'T', 'Phi', 'Tau2']
        if extra_traced_params is not None:
            self.traced_params.extend(extra_traced_params)
        self.trace = Trace(**{param: [] for param in self.traced_params})
        st = self.state
        self.state.correlation_function = correlation_function
        self.verbose = verbose

        st.Y = Y
        st.X = X
        st.Xs = Xs
        st.N = N
        st.p = p

        st._dmetric = dmetric
        if isinstance(st._dmetric, str):
            st.pwds = d.squareform(d.pdist(st.coordinates, metric=st._dmetric))
        elif callable(st._dmetric):
            st.pwds = st._dmetric(st.coordinates)

        st.max_dist = st.pwds.max()
        if rescale_dists:
            st.pwds = st.pwds / st.max_dist
            st._old_max = st.max_dist
            st.max_dist = 1.

        if configs is None:
            configs = dict()
        if priors is None:
            priors = dict()
        if starting_values is None:
            starting_values = dict()

        self._setup_priors(**priors)
        self._setup_starting_values(**starting_values)
        self._setup_configs(**configs)

        self._verbose = verbose
        self.cycles = 0

        if n_samples > 0:
            try:
                self.sample(n_samples, n_jobs=n_jobs)
            except (np.linalg.LinAlgError, ValueError) as e:
                Warn('Encountered the following LinAlgError. '
                     'Model will return for debugging. \n {}'.format(e))
示例#33
0
class Test_Trace(ut.TestCase):
    def setUp(self):

        self.a = {chr(i+97):list(range(10)) for i in range(5)}

        self.t = Trace(**self.a)
        self.mt = Trace(self.a,self.a,self.a)
        self.real_mt = Trace.from_csv(FULL_PATH + r'/data/south_mvcm_5000', multi=True)
        self.real_singles = [Trace.from_csv(FULL_PATH + r'/data/south_mvcm_5000_{}.csv'
                             .format(i)) for i in range(4)]

    def test_validate_names(self):
        b = self.a.copy()
        try:
            bad_names = Trace(self.a,b,self.a,self.a)
        except KeyError:
            pass

    # tests
    def test_slicing(self):
        t = self.t
        mt = self.mt
        #1index
        assert t[1] == {'a':1, 'b':1, 'c':1, 'd':1, 'e':1}
        assert mt[6] == [{k:6 for k in ['a','b', 'c', 'd', 'e']}]*3
        assert t[-1] =={k:9 for k in  ['a','b', 'c', 'd', 'e']}
        assert mt[-1] == [{k:9 for k in ['a','b', 'c', 'd', 'e']}]*3

        assert t[2:5] == {k:list(range(2,5)) for k in  ['a','b', 'c', 'd', 'e']}
        assert mt[8:] == [ {k:list(range(8,10)) for k in  ['a','b', 'c', 'd', 'e'] }] * 3
        assert t[-4::2] ==  {k:[6,8] for k in  ['a','b', 'c', 'd', 'e']}

        assert (t['a'] == list(range(10))).all()
        assert (mt['a'] == [list(range(10))]*3).all()
        assert t[['a','b']] == {'a':list(range(10)), 'b':list(range(10))}
        assert mt[['a','b']] == [{'a':list(range(10)), 'b':list(range(10))}]*3

        #2index
        assert t['a', 1] == 1
        assert t[['a', 'b'], 1] == {'a':1, 'b':1}
        assert (mt['e', 5] == [5]*3).all()
        assert mt[['d', 'e'], 8:] == [{'d':[8,9], 'e':[8,9]}]*3

        assert (t[0, 'a'] == list(range(10))).all()
        assert t[0, ['a', 'b']] == {'a':list(range(10)), 'b':list(range(10))}
        try:
            t[1, ['a','c']]
            raise Exception('This did not raise an exception within the slicer!')
        except IndexError:
            pass
        assert mt[1:, ['a','c']] == [{'a':list(range(10)), 'c':list(range(10))}] * 2
        assert (mt[2, 'a'] == list(range(10))).all()
        assert t[0,-1] == {k:9 for k in ['a', 'b', 'c', 'd', 'e']}
        assert t[0,:] ==  {k:list(range(10)) for k in  ['a', 'b', 'c', 'd', 'e']}
        assert mt[:, -1:-4:-1] ==  [{k:[9,8,7] for k in ['a', 'b', 'c', 'd', 'e']}]*3

        #3index
        assert t[0, 'a', -1] == 9
        assert t[0, ['a','b'],-3::2] == {'a':[7,9], 'b':[7,9]}
        assert t[0, : ,-1] == {k:9 for k in ['a','b','c','d','e']}
        try:
            t[1, 'a', -1]
            raise Exception('this did not raise an exception when it should have')
        except IndexError:
            pass
        assert (mt[1:, 'a', -1] == [9]*2).all()
        assert mt[1:, ['a','b'], -2:] == [{'a':[8,9], 'b':[8,9]}]*2
        assert (mt[2, 'a', 5::2] == [5,7,9]).all()
        assert (mt[1:, 'a', -5::2] == [[5,7,9]]*2).all()
        assert (mt[:, 'a', -5::2] == [[5,7,9]]*3).all()
        assert mt[2, :, :] == {k:list(range(10)) for k in ['a','b','c','d','e']}
        assert mt[:,:,:] == mt.chains
        assert mt[:,:,:] is not mt.chains

    def test_to_df(self):
        df = self.t.to_df()
        df2 = pd.DataFrame.from_dict(self.t.chains[0])
        np.testing.assert_array_equal(df.values, df2.values)
        mtdf = self.mt.to_df()
        mtdf2 = [pd.DataFrame.from_dict(chain) for chain in self.mt.chains]
        for i in range(len(mtdf2)):
            np.testing.assert_array_equal(mtdf[i].values, mtdf2[i].values)

    def test_from_df(self):
        df = self.t.to_df()
        new_trace = Trace.from_df(df)
        assert new_trace == self.t
        new_mt = Trace.from_df((df, df, df))
        assert new_mt == self.t

    def test_to_csv(self):
        df = self.t.to_df()
        self.t.to_csv('./test_to_csv.csv')
        new_df = pd.read_csv('./test_to_csv.csv')
        np.testing.assert_allclose(df.values, new_df.values,
                                    rtol=RTOL, atol=ATOL)
        os.remove('./test_to_csv.csv')

    def test_from_csv(self):
        self.t.to_csv('./test_from_csv.csv')
        new_t = Trace.from_csv('./test_from_csv.csv')
        assert self.t == new_t
        os.remove('./test_from_csv.csv')

    def test_single_roundtrips(self):
        source_from_file = self.real_singles[0]
        from_df = Trace.from_df(source_from_file.to_df())
        source_from_file._assert_allclose(from_df)

    def test_ordering(self):
        for ch, alone in zip(self.real_mt.chains, self.real_singles):
            Trace(ch)._assert_allclose(alone)

    def test_multi_roundtrips(self):
        dfs = self.real_mt.to_df()
        new = Trace.from_df(dfs)
        new._assert_allclose(self.real_mt)


    @ut.skip
    def test_from_pymc3(self):
        raise NotImplementedError

    @ut.skip
    def test_plot(self):
        try:
            import matplotlib as mpl
            mpl.use('Agg')
            self.t.plot()
        except:
            raise Exception('Single trace plotting failed!')

        try:
            import matplotlib as mpl
            mpl.use('Agg')
            self.mt.plot()
        except:
            raise Exception('Multi-chain trace plotting failed!')
示例#34
0
 def setUp(self):
     super(Test_SESE, self).build_self()
     self.cls = M.SESE
     self.inputs['n_samples'] = 0
     self.instance = self.cls(**self.inputs)
     self.answer_trace = Trace.from_csv(FULL_PATH + '/data/sese.csv')
示例#35
0
class Test_Trace(ut.TestCase):
    def setUp(self):

        self.a = {chr(i + 97): list(range(10)) for i in range(5)}

        self.t = Trace(**self.a)
        self.mt = Trace(self.a, self.a, self.a)
        self.real_mt = Trace.from_csv(FULL_PATH + r'/data/south_mvcm_5000',
                                      multi=True)
        self.real_singles = [
            Trace.from_csv(FULL_PATH +
                           r'/data/south_mvcm_5000_{}.csv'.format(i))
            for i in range(4)
        ]

    def test_validate_names(self):
        b = self.a.copy()
        try:
            bad_names = Trace(self.a, b, self.a, self.a)
        except KeyError:
            pass

    # tests
    def test_slicing(self):
        t = self.t
        mt = self.mt
        #1index
        assert t[1] == {'a': 1, 'b': 1, 'c': 1, 'd': 1, 'e': 1}
        assert mt[6] == [{k: 6 for k in ['a', 'b', 'c', 'd', 'e']}] * 3
        assert t[-1] == {k: 9 for k in ['a', 'b', 'c', 'd', 'e']}
        assert mt[-1] == [{k: 9 for k in ['a', 'b', 'c', 'd', 'e']}] * 3

        assert t[2:5] == {
            k: list(range(2, 5))
            for k in ['a', 'b', 'c', 'd', 'e']
        }
        assert mt[8:] == [{
            k: list(range(8, 10))
            for k in ['a', 'b', 'c', 'd', 'e']
        }] * 3
        assert t[-4::2] == {k: [6, 8] for k in ['a', 'b', 'c', 'd', 'e']}

        assert (t['a'] == list(range(10))).all()
        assert (mt['a'] == [list(range(10))] * 3).all()
        assert t[['a', 'b']] == {'a': list(range(10)), 'b': list(range(10))}
        assert mt[['a', 'b']] == [{
            'a': list(range(10)),
            'b': list(range(10))
        }] * 3

        #2index
        assert t['a', 1] == 1
        assert t[['a', 'b'], 1] == {'a': 1, 'b': 1}
        assert (mt['e', 5] == [5] * 3).all()
        assert mt[['d', 'e'], 8:] == [{'d': [8, 9], 'e': [8, 9]}] * 3

        assert (t[0, 'a'] == list(range(10))).all()
        assert t[0, ['a', 'b']] == {'a': list(range(10)), 'b': list(range(10))}
        try:
            t[1, ['a', 'c']]
            raise Exception(
                'This did not raise an exception within the slicer!')
        except IndexError:
            pass
        assert mt[1:, ['a', 'c']] == [{
            'a': list(range(10)),
            'c': list(range(10))
        }] * 2
        assert (mt[2, 'a'] == list(range(10))).all()
        assert t[0, -1] == {k: 9 for k in ['a', 'b', 'c', 'd', 'e']}
        assert t[0, :] == {
            k: list(range(10))
            for k in ['a', 'b', 'c', 'd', 'e']
        }
        assert mt[:, -1:-4:-1] == [{
            k: [9, 8, 7]
            for k in ['a', 'b', 'c', 'd', 'e']
        }] * 3

        #3index
        assert t[0, 'a', -1] == 9
        assert t[0, ['a', 'b'], -3::2] == {'a': [7, 9], 'b': [7, 9]}
        assert t[0, :, -1] == {k: 9 for k in ['a', 'b', 'c', 'd', 'e']}
        try:
            t[1, 'a', -1]
            raise Exception(
                'this did not raise an exception when it should have')
        except IndexError:
            pass
        assert (mt[1:, 'a', -1] == [9] * 2).all()
        assert mt[1:, ['a', 'b'], -2:] == [{'a': [8, 9], 'b': [8, 9]}] * 2
        assert (mt[2, 'a', 5::2] == [5, 7, 9]).all()
        assert (mt[1:, 'a', -5::2] == [[5, 7, 9]] * 2).all()
        assert (mt[:, 'a', -5::2] == [[5, 7, 9]] * 3).all()
        assert mt[2, :, :] == {
            k: list(range(10))
            for k in ['a', 'b', 'c', 'd', 'e']
        }
        assert mt[:, :, :] == mt.chains
        assert mt[:, :, :] is not mt.chains

    def test_to_df(self):
        df = self.t.to_df()
        df2 = pd.DataFrame.from_dict(self.t.chains[0])
        np.testing.assert_array_equal(df.values, df2.values)
        mtdf = self.mt.to_df()
        mtdf2 = [pd.DataFrame.from_dict(chain) for chain in self.mt.chains]
        for i in range(len(mtdf2)):
            np.testing.assert_array_equal(mtdf[i].values, mtdf2[i].values)

    def test_from_df(self):
        df = self.t.to_df()
        new_trace = Trace.from_df(df)
        assert new_trace == self.t
        new_mt = Trace.from_df((df, df, df))
        assert new_mt == self.t

    def test_to_csv(self):
        df = self.t.to_df()
        self.t.to_csv('./test_to_csv.csv')
        new_df = pd.read_csv('./test_to_csv.csv')
        np.testing.assert_allclose(df.values,
                                   new_df.values,
                                   rtol=RTOL,
                                   atol=ATOL)
        os.remove('./test_to_csv.csv')

    def test_from_csv(self):
        self.t.to_csv('./test_from_csv.csv')
        new_t = Trace.from_csv('./test_from_csv.csv')
        assert self.t == new_t
        os.remove('./test_from_csv.csv')

    def test_single_roundtrips(self):
        source_from_file = self.real_singles[0]
        from_df = Trace.from_df(source_from_file.to_df())
        source_from_file._assert_allclose(from_df)

    def test_ordering(self):
        for ch, alone in zip(self.real_mt.chains, self.real_singles):
            Trace(ch)._assert_allclose(alone)

    def test_multi_roundtrips(self):
        dfs = self.real_mt.to_df()
        new = Trace.from_df(dfs)
        new._assert_allclose(self.real_mt)

    @ut.skip
    def test_from_pymc3(self):
        raise NotImplementedError

    @ut.skip
    def test_plot(self):
        try:
            import matplotlib as mpl
            mpl.use('Agg')
            self.t.plot()
        except:
            raise Exception('Single trace plotting failed!')

        try:
            import matplotlib as mpl
            mpl.use('Agg')
            self.mt.plot()
        except:
            raise Exception('Multi-chain trace plotting failed!')