def test_override_kde_grid(self): c = ChainConsumer() x, y = np.linspace(0, 10, 10), np.linspace(0, 10, 10) z = np.ones((10, 10)) c.add_chain([x, y], weights=z, grid=True, kde=2.0) c.configure() assert not c.chains[0].config["kde"]
def test_pass_in_dataframe1(self): df = pd.DataFrame(self.d2, columns=self.p) c = ChainConsumer() c.add_chain(df) summary1 = c.analysis.get_summary() assert np.isclose(summary1["a"][0], -1, atol=0.03) assert np.isclose(summary1["a"][1], 0, atol=0.05) assert np.isclose(summary1["a"][2], 1, atol=0.03) assert np.isclose(summary1["b"][0], -1, atol=0.03) assert np.isclose(summary1["c"][0], -1, atol=0.03)
def test_pass_in_dataframe3(self): data = np.random.uniform(-4, 6, size=(1000000, 1)) weight = norm.pdf(data) df = pd.DataFrame(data, columns=["a"]) df["weight"] = weight c = ChainConsumer() c.add_chain(df) summary1 = c.analysis.get_summary() assert np.isclose(summary1["a"][0], -1, atol=0.03) assert np.isclose(summary1["a"][1], 0, atol=0.05) assert np.isclose(summary1["a"][2], 1, atol=0.03)
def test_cache_invalidation(self): c = ChainConsumer() c.add_chain(normal(size=(1000000, 1)), parameters=["a"]) c.configure(summary_area=0.68) summary1 = c.analysis.get_summary() c.configure(summary_area=0.95) summary2 = c.analysis.get_summary() assert np.isclose(summary1["a"][0], -1, atol=0.03) assert np.isclose(summary2["a"][0], -2, atol=0.03) assert np.isclose(summary1["a"][2], 1, atol=0.03) assert np.isclose(summary2["a"][2], 2, atol=0.03)
def test_override_kde_grid(self): c = ChainConsumer() x, y = np.linspace(0, 10, 10), np.linspace(0, 10, 10) z = np.ones((10, 10)) c.add_chain([x, y], weights=z, grid=True, kde=2.0) c.configure() assert not c.chains[0].config["kde"]
def test_cache_invalidation(self): c = ChainConsumer() c.add_chain(normal(size=(1000000, 1)), parameters=["a"]) c.configure(summary_area=0.68) summary1 = c.analysis.get_summary() c.configure(summary_area=0.95) summary2 = c.analysis.get_summary() assert np.isclose(summary1["a"][0], -1, atol=1e-2) assert np.isclose(summary2["a"][0], -2, atol=1e-2) assert np.isclose(summary1["a"][1], summary2["a"][1], atol=1e-2) assert np.isclose(summary1["a"][2], 1, atol=1e-2) assert np.isclose(summary2["a"][2], 2, atol=1e-2)
def test_color_data_posterior(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, name=self.n, weights=self.w, posterior=np.ones(100)) c.configure(color_params="posterior") chain = c.chains[0] assert np.all(chain.get_color_data() == np.ones(100))
def test_color_data_none(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, name=self.n, weights=self.w, posterior=np.ones(100)) c.configure(color_params=None) chain = c.chains[0] assert chain.get_color_data() is None
def test_color_data_none(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, name=self.n, weights=self.w, posterior=np.ones(100)) c.configure(color_params=None) chain = c.chains[0] assert chain.get_color_data() is None
def test_override_kde(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, kde=2.0) c.configure() assert c.chains[0].config["kde"] == 2.0
def test_override_shade_alpha(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, shade_alpha=0.8) c.configure() assert c.chains[0].config["shade_alpha"] == 0.8
def test_override_linestyle(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, linestyle="--") c.configure() assert c.chains[0].config["linestyle"] == "--"
def test_override_linewidth(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, linewidth=2.0) c.configure(linewidths=[100]) assert c.chains[0].config["linewidth"] == 100
def test_override_color(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, color="#4286f4") c.configure() assert c.chains[0].config["color"] == "#4286f4"
def test_override_color(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, color="#4286f4") c.configure() assert c.chains[0].config["color"] == "#4286f4"
def test_color_data_posterior(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, name=self.n, weights=self.w, posterior=np.ones(100)) c.configure(color_params="posterior") chain = c.chains[0] assert np.all(chain.get_color_data() == np.ones(100))
def test_override_linewidth(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, linewidth=2.0) c.configure(linewidths=[100]) assert c.chains[0].config["linewidth"] == 100
def test_override_linestyle(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, linestyle="--") c.configure() assert c.chains[0].config["linestyle"] == "--"
def test_override_kde(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, kde=2.0) c.configure() assert c.chains[0].config["kde"] == 2.0
def test_override_shade_alpha(self): c = ChainConsumer() c.add_chain(self.d, parameters=self.p, shade_alpha=0.8) c.configure() assert c.chains[0].config["shade_alpha"] == 0.8