@@ -1800,58 +1800,83 @@ def setup_class(self):
1800
1800
Y_obs = Normal ("Y_obs" , mu = mu , sigma = sigma , observed = Y )
1801
1801
1802
1802
self .distributions = [alpha , sigma , mu , b , Z , Y_obs , bound_var ]
1803
- self .expected_latex = (
1804
- r"$\text{alpha} \sim \text{Normal}(\mathit{mu}=0.0,~\mathit{sigma}=10.0)$" ,
1805
- r"$\text{sigma} \sim \text{HalfNormal}(\mathit{sigma}=1.0)$" ,
1806
- r"$\text{mu} \sim \text{Deterministic}(\text{alpha},~\text{Constant},~\text{beta})$" ,
1807
- r"$\text{beta} \sim \text{Normal}(\mathit{mu}=0.0,~\mathit{sigma}=10.0)$" ,
1808
- r"$\text{Z} \sim \text{MvNormal}(\mathit{mu}=array,~\mathit{chol_cov}=array)$" ,
1809
- r"$\text{Y_obs} \sim \text{Normal}(\mathit{mu}=\text{mu},~\mathit{sigma}=f(\text{sigma}))$" ,
1810
- r"$\text{bound_var} \sim \text{Bound}(\mathit{lower}=1.0,~\mathit{upper}=\text{None})$ -- \text{Normal}(\mathit{mu}=0.0,~\mathit{sigma}=10.0)$" ,
1811
- r"$\text{kron_normal} \sim \text{KroneckerNormal}(\mathit{mu}=array)$" ,
1812
- r"$\text{mat_normal} \sim \text{MatrixNormal}(\mathit{mu}=array,~\mathit{rowcov}=array,~\mathit{colchol_cov}=array)$" ,
1813
- )
1814
- self .expected_str = (
1815
- r"alpha ~ Normal(mu=0.0, sigma=10.0)" ,
1816
- r"sigma ~ HalfNormal(sigma=1.0)" ,
1817
- r"mu ~ Deterministic(alpha, Constant, beta)" ,
1818
- r"beta ~ Normal(mu=0.0, sigma=10.0)" ,
1819
- r"Z ~ MvNormal(mu=array, chol_cov=array)" ,
1820
- r"Y_obs ~ Normal(mu=mu, sigma=f(sigma))" ,
1821
- r"bound_var ~ Bound(lower=1.0, upper=None)-Normal(mu=0.0, sigma=10.0)" ,
1822
- r"kron_normal ~ KroneckerNormal(mu=array)" ,
1823
- r"mat_normal ~ MatrixNormal(mu=array, rowcov=array, colchol_cov=array)" ,
1824
- )
1803
+ self .expected = {
1804
+ "latex" : (
1805
+ r"$\text{alpha} \sim \text{Normal}$" ,
1806
+ r"$\text{sigma} \sim \text{HalfNormal}$" ,
1807
+ r"$\text{mu} \sim \text{Deterministic}$" ,
1808
+ r"$\text{beta} \sim \text{Normal}$" ,
1809
+ r"$\text{Z} \sim \text{MvNormal}$" ,
1810
+ r"$\text{Y_obs} \sim \text{Normal}$" ,
1811
+ r"$\text{bound_var} \sim \text{Bound}$ -- \text{Normal}$" ,
1812
+ r"$\text{kron_normal} \sim \text{KroneckerNormal}$" ,
1813
+ r"$\text{mat_normal} \sim \text{MatrixNormal}$" ,
1814
+ ),
1815
+ "plain" : (
1816
+ r"alpha ~ Normal" ,
1817
+ r"sigma ~ HalfNormal" ,
1818
+ r"mu ~ Deterministic" ,
1819
+ r"beta ~ Normal" ,
1820
+ r"Z ~ MvNormal" ,
1821
+ r"Y_obs ~ Normal" ,
1822
+ r"bound_var ~ Bound-Normal" ,
1823
+ r"kron_normal ~ KroneckerNormal" ,
1824
+ r"mat_normal ~ MatrixNormal" ,
1825
+ ),
1826
+ "latex_with_params" : (
1827
+ r"$\text{alpha} \sim \text{Normal}(\mathit{mu}=0.0,~\mathit{sigma}=10.0)$" ,
1828
+ r"$\text{sigma} \sim \text{HalfNormal}(\mathit{sigma}=1.0)$" ,
1829
+ r"$\text{mu} \sim \text{Deterministic}(\text{alpha},~\text{Constant},~\text{beta})$" ,
1830
+ r"$\text{beta} \sim \text{Normal}(\mathit{mu}=0.0,~\mathit{sigma}=10.0)$" ,
1831
+ r"$\text{Z} \sim \text{MvNormal}(\mathit{mu}=array,~\mathit{chol_cov}=array)$" ,
1832
+ r"$\text{Y_obs} \sim \text{Normal}(\mathit{mu}=\text{mu},~\mathit{sigma}=f(\text{sigma}))$" ,
1833
+ r"$\text{bound_var} \sim \text{Bound}(\mathit{lower}=1.0,~\mathit{upper}=\text{None})$ -- \text{Normal}(\mathit{mu}=0.0,~\mathit{sigma}=10.0)$" ,
1834
+ r"$\text{kron_normal} \sim \text{KroneckerNormal}(\mathit{mu}=array)$" ,
1835
+ r"$\text{mat_normal} \sim \text{MatrixNormal}(\mathit{mu}=array,~\mathit{rowcov}=array,~\mathit{colchol_cov}=array)$" ,
1836
+ ),
1837
+ "plain_with_params" : (
1838
+ r"alpha ~ Normal(mu=0.0, sigma=10.0)" ,
1839
+ r"sigma ~ HalfNormal(sigma=1.0)" ,
1840
+ r"mu ~ Deterministic(alpha, Constant, beta)" ,
1841
+ r"beta ~ Normal(mu=0.0, sigma=10.0)" ,
1842
+ r"Z ~ MvNormal(mu=array, chol_cov=array)" ,
1843
+ r"Y_obs ~ Normal(mu=mu, sigma=f(sigma))" ,
1844
+ r"bound_var ~ Bound(lower=1.0, upper=None)-Normal(mu=0.0, sigma=10.0)" ,
1845
+ r"kron_normal ~ KroneckerNormal(mu=array)" ,
1846
+ r"mat_normal ~ MatrixNormal(mu=array, rowcov=array, colchol_cov=array)" ,
1847
+ ),
1848
+ }
1825
1849
1826
1850
def test__repr_latex_ (self ):
1827
- for distribution , tex in zip (self .distributions , self .expected_latex ):
1851
+ for distribution , tex in zip (self .distributions , self .expected [ "latex_with_params" ] ):
1828
1852
assert distribution ._repr_latex_ () == tex
1829
1853
1830
1854
model_tex = self .model ._repr_latex_ ()
1831
1855
1832
- for tex in self .expected_latex : # make sure each variable is in the model
1856
+ # make sure each variable is in the model
1857
+ for tex in self .expected ["latex" ]:
1833
1858
for segment in tex .strip ("$" ).split (r"\sim" ):
1834
1859
assert segment in model_tex
1835
1860
1836
1861
def test___latex__ (self ):
1837
- for distribution , tex in zip (self .distributions , self .expected_latex ):
1862
+ for distribution , tex in zip (self .distributions , self .expected [ "latex_with_params" ] ):
1838
1863
assert distribution ._repr_latex_ () == distribution .__latex__ ()
1839
1864
assert self .model ._repr_latex_ () == self .model .__latex__ ()
1840
1865
1841
1866
def test___str__ (self ):
1842
- for distribution , str_repr in zip (self .distributions , self .expected_str ):
1867
+ for distribution , str_repr in zip (self .distributions , self .expected [ "plain" ] ):
1843
1868
assert distribution .__str__ () == str_repr
1844
1869
1845
1870
model_str = self .model .__str__ ()
1846
- for str_repr in self .expected_str :
1871
+ for str_repr in self .expected [ "plain" ] :
1847
1872
assert str_repr in model_str
1848
1873
1849
1874
def test_str (self ):
1850
- for distribution , str_repr in zip (self .distributions , self .expected_str ):
1875
+ for distribution , str_repr in zip (self .distributions , self .expected [ "plain" ] ):
1851
1876
assert str (distribution ) == str_repr
1852
1877
1853
1878
model_str = str (self .model )
1854
- for str_repr in self .expected_str :
1879
+ for str_repr in self .expected [ "plain" ] :
1855
1880
assert str_repr in model_str
1856
1881
1857
1882
0 commit comments