def test_get_figure_invalid_2(self): un = 'PlotlyImageTest' ak = '786r5mecv0' url = "https://plot.ly/~PlotlyImageTest/-1/" py.sign_in(un, ak) with self.assertRaises(exceptions.PlotlyError): py.get_figure(url)
def display_cumulative_variance_dataset(X, scaler_method=None): n_components = X.shape[1] pca = PCA(n_components=n_components) # pca = PCA(n_components=2) #X_pca = pca.fit_transform(X) pca = pca.fit(X) _ = pca.transform(X) fig = show_cum_variance_vs_components(pca, n_components) py.sign_in('franec94', 'QbLNKpC0EZB0kol0aL2Z') if scaler_method is None: py.iplot(fig, filename='selecting-principal-components') # py.plot(fig, filename='selecting-principal-components') else: py.iplot(fig, filename='selecting-principal-components {}'.format(scaler_method)) # py.plot(fig, filename='selecting-principal-components {}'.format(scaler_method)) principal_components = [pc for pc in '2,5,6,7,8,9,10'.split(',')] for _, pc in enumerate(principal_components): n_components = int(pc) cum_var_exp_up_to_n_pcs = np.cumsum(pca.explained_variance_ratio_)[n_components-1] print(f"Cumulative varation explained up to {n_components} pcs = {cum_var_exp_up_to_n_pcs}") pass
def test_get_figure_does_not_exist(self): un = 'PlotlyImageTest' ak = '786r5mecv0' url = "https://plot.ly/~PlotlyImageTest/1000000000/" py.sign_in(un, ak) with self.assertRaises(_plotly_utils.exceptions.PlotlyError): py.get_figure(url)
def test_get_figure_invalid_2(self): un = "PlotlyImageTest" ak = "786r5mecv0" url = "https://plot.ly/~PlotlyImageTest/-1/" py.sign_in(un, ak) with self.assertRaises(exceptions.PlotlyError): py.get_figure(url)
def test_get_figure_invalid_3(self): un = "PlotlyImageTest" ak = "786r5mecv0" url = "https://plot.ly/~PlotlyImageTest/2/" py.sign_in(un, ak) with self.assertRaises(ValueError): py.get_figure(url)
def test_get_figure_does_not_exist(self): un = "PlotlyImageTest" ak = "786r5mecv0" url = "https://plot.ly/~PlotlyImageTest/1000000000/" py.sign_in(un, ak) with self.assertRaises(_plotly_utils.exceptions.PlotlyError): py.get_figure(url)
def test_get_figure_invalid_3(self): un = 'PlotlyImageTest' ak = '786r5mecv0' url = "https://plot.ly/~PlotlyImageTest/2/" py.sign_in(un, ak) with self.assertRaises(ValueError): py.get_figure(url)
def test_get_figure_invalid_1(self): un = 'PlotlyImageTest' ak = '786r5mecv0' url = "https://plot.ly/~PlotlyImageTest/a/" py.sign_in(un, ak) with self.assertRaises(exceptions.PlotlyError): py.get_figure(url)
def makeHoroplethMap(df): API='Vn3DdeYNzJ9f44m9ykeb' USER_NAME='irisdrei' fig = px.choropleth(df, locations="country", color="Clustering", hover_name="country", color_continuous_scale=px.colors.sequential.Plasma, locationmode="country names") # fig.show() py.sign_in(USER_NAME, API) py.image.save_as(fig, filename='countries.png') # choromap = px.choropleth(df,color="Bergeron",locations='country', projection="mercator") # choromap = px.choropleth(df, locations="country", color="Clustering", hover_name="country",color_continuous_scale=px.colors.sequential.Plasma, locationmode="country names") # choromap.update_geos(fitbounds="locations", visible=False) # choromap.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0}) # choromap.show() # df_new = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv') # fig = go.Figure(data=go.Choropleth(locations=df_new['CODE'], z=df['Clustering'], text=df['country'], colorscale='Blues', autocolorscale=False, reversescale=True)) # fig.update_layout(geo=dict(showframe=False,showcoastlines=False,projection_type='equirectangular'),annotations=[dict()]) # fig.show() # py.sign_in(USER_NAME, API) # py.image.save_as(choromap, filename='name.png') # df = preProcessing.preProcess("C:\\Users\\Chen\\Desktop\\Dataset.xlsx") # runModel(df,3,2)
def test(self): py.sign_in('username', 'key', **plot_options['parent']) options = py._plot_option_logic(plot_options['child']) for option, value in plot_options['expected_output'].items(): self.assertEqual(options[option], value)
def setUp(self): super(TestPlot, self).setUp() py.sign_in('PlotlyImageTest', '786r5mecv0') self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
def test_get_figure_with_url(self): un = "PlotlyImageTest" ak = "786r5mecv0" url = "https://plot.ly/~PlotlyImageTest/13183/" py.sign_in(un, ak) py.get_figure(url)
def test_proper_escaping(self): un = 'PlotlyImageTest' ak = '786r5mecv0' url = "https://plot.ly/~PlotlyImageTest/13185/" py.sign_in(un, ak) py.get_figure(url)
def setUp(self): super(TestImage, self).setUp() py.sign_in("PlotlyImageTest", "786r5mecv0") self.data = [{"x": [1, 2, 3], "y": [3, 1, 6]}]
def test_get_figure(self): un = "PlotlyImageTest" ak = "786r5mecv0" file_id = 13183 py.sign_in(un, ak) py.get_figure("PlotlyImageTest", str(file_id))
def setUp(self): super(TestPlot, self).setUp() py.sign_in("PlotlyImageTest", "786r5mecv0") self.simple_figure = {"data": [{"x": [1, 2, 3], "y": [2, 1, 2]}]}
def test_get_figure_raw(self): un = 'PlotlyImageTest' ak = '786r5mecv0' file_id = 2 py.sign_in(un, ak) py.get_figure('PlotlyImageTest', str(file_id), raw=True)
def test(self): py.sign_in('username', 'key', **plot_options) self.assertRaises(PlotlyError, py._plot_option_logic, {})
def test_get_figure(self): un = 'PlotlyImageTest' ak = '786r5mecv0' file_id = 13183 py.sign_in(un, ak) py.get_figure('PlotlyImageTest', str(file_id))
def setUp(self): super(TestImage, self).setUp() py.sign_in('PlotlyImageTest', '786r5mecv0') self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
def test_get_figure_raw(self): un = "PlotlyImageTest" ak = "786r5mecv0" file_id = 2 py.sign_in(un, ak) py.get_figure("PlotlyImageTest", str(file_id), raw=True)
def test_proper_escaping(self): un = "PlotlyImageTest" ak = "786r5mecv0" url = "https://plot.ly/~PlotlyImageTest/13185/" py.sign_in(un, ak) py.get_figure(url)
def test_get_figure_with_url(self): un = 'PlotlyImageTest' ak = '786r5mecv0' url = "https://plot.ly/~PlotlyImageTest/13183/" py.sign_in(un, ak) py.get_figure(url)
def setup_image(): py.sign_in("PlotlyImageTest", "786r5mecv0") data = [{"x": [1, 2, 3], "y": [3, 1, 6]}] return data
def test(self): py.sign_in("username", "key", **plot_options) self.assertRaises(PlotlyError, py._plot_option_logic, {})
def setUp(self): py.sign_in("PlotlyImageTest", "786r5mecv0", plotly_domain="https://plot.ly")
def test(self): py.sign_in("username", "key", **plot_options["parent"]) options = py._plot_option_logic(plot_options["child"]) for option, value in plot_options["expected_output"].items(): self.assertEqual(options[option], value)
def setUp(self): py.sign_in('PlotlyImageTest', '786r5mecv0', plotly_domain='https://plot.ly')