예제 #1
0
 def setUp(self):
     super(GetHeadersTest, self).setUp()
     self.domain = 'https://foo.bar'
     self.username = '******'
     self.api_key = 'secret'
     sign_in(self.username, self.api_key, proxy_username='******',
             proxy_password='******', plotly_proxy_authorization=False)
예제 #2
0
 def test_proxy_auth(self):
     sign_in(self.username, self.api_key, plotly_proxy_authorization=True)
     headers = utils.get_headers()
     expected_headers = {
         'authorization': 'Basic a2xlZW4ta2FudGVlbjpoeWRyYXRlZA=='
     }
     self.assertEqual(headers, expected_headers)
예제 #3
0
 def test_proxy_auth(self):
     sign_in(self.username, self.api_key, plotly_proxy_authorization=True)
     headers = utils.get_headers()
     expected_headers = {
         'authorization': 'Basic a2xlZW4ta2FudGVlbjpoeWRyYXRlZA=='
     }
     self.assertEqual(headers, expected_headers)
예제 #4
0
 def setUp(self):
     super(GetHeadersTest, self).setUp()
     self.domain = 'https://foo.bar'
     self.username = '******'
     self.api_key = 'secret'
     sign_in(self.username, self.api_key, proxy_username='******',
             proxy_password='******', plotly_proxy_authorization=False)
예제 #5
0
    def setUp(self):

        super(PlotlyApiTestCase, self).setUp()

        self.username = '******'
        self.api_key = 'bar'

        self.proxy_username = '******'
        self.proxy_password = '******'
        self.stream_ids = ['heyThere']

        self.plotly_api_domain = 'https://api.do.not.exist'
        self.plotly_domain = 'https://who.am.i'
        self.plotly_proxy_authorization = False
        self.plotly_streaming_domain = 'stream.does.not.exist'
        self.plotly_ssl_verification = True

        sign_in(username=self.username,
                api_key=self.api_key,
                proxy_username=self.proxy_username,
                proxy_password=self.proxy_password,
                stream_ids=self.stream_ids,
                plotly_domain=self.plotly_domain,
                plotly_api_domain=self.plotly_api_domain,
                plotly_streaming_domain=self.plotly_streaming_domain,
                plotly_proxy_authorization=self.plotly_proxy_authorization,
                plotly_ssl_verification=self.plotly_ssl_verification)
예제 #6
0
    def setUp(self):

        super(PlotlyApiTestCase, self).setUp()

        self.username = '******'
        self.api_key = 'bar'

        self.proxy_username = '******'
        self.proxy_password = '******'
        self.stream_ids = ['heyThere']

        self.plotly_api_domain = 'https://api.do.not.exist'
        self.plotly_domain = 'https://who.am.i'
        self.plotly_proxy_authorization = False
        self.plotly_streaming_domain = 'stream.does.not.exist'
        self.plotly_ssl_verification = True

        sign_in(
            username=self.username,
            api_key=self.api_key,
            proxy_username=self.proxy_username,
            proxy_password=self.proxy_password,
            stream_ids = self.stream_ids,
            plotly_domain=self.plotly_domain,
            plotly_api_domain=self.plotly_api_domain,
            plotly_streaming_domain=self.plotly_streaming_domain,
            plotly_proxy_authorization=self.plotly_proxy_authorization,
            plotly_ssl_verification=self.plotly_ssl_verification
        )
예제 #7
0
 def test_proxy_auth(self):
     sign_in(self.username, self.api_key, plotly_proxy_authorization=True)
     headers = utils.get_headers()
     expected_headers = {
         'plotly-client-platform': 'python {}'.format(version.__version__),
         'authorization': 'Basic Y25ldDpob29wbGE=',
         'plotly-authorization': 'Basic Zm9vOmJhcg==',
         'content-type': 'application/json'
     }
     self.assertEqual(headers, expected_headers)
예제 #8
0
 def test_proxy_auth(self):
     sign_in(self.username, self.api_key, plotly_proxy_authorization=True)
     headers = utils.get_headers()
     expected_headers = {
         'plotly-client-platform': 'python {}'.format(version.__version__),
         'authorization': 'Basic Y25ldDpob29wbGE=',
         'plotly-authorization': 'Basic Zm9vOmJhcg==',
         'content-type': 'application/json'
     }
     self.assertEqual(headers, expected_headers)
예제 #9
0
    def setUp(self):
        super(RequestTest, self).setUp()
        self.domain = 'https://foo.bar'
        self.username = '******'
        self.api_key = 'secret'
        sign_in(self.username, self.api_key, proxy_username='******',
                proxy_password='******', plotly_proxy_authorization=False)

        # Mock the actual api call, we don't want to do network tests here.
        patcher = patch('plotly.api.v1.utils.requests.request')
        self.request_mock = patcher.start()
        self.addCleanup(patcher.stop)
        self.request_mock.return_value = MagicMock(Response)

        # Mock the validation function since we test that elsewhere.
        patcher = patch('plotly.api.v1.utils.validate_response')
        self.validate_response_mock = patcher.start()
        self.addCleanup(patcher.stop)

        self.method = 'get'
        self.url = 'https://foo.bar.does.not.exist.anywhere'
예제 #10
0
    def setUp(self):
        super(RequestTest, self).setUp()
        self.domain = 'https://foo.bar'
        self.username = '******'
        self.api_key = 'secret'
        sign_in(self.username, self.api_key, proxy_username='******',
                proxy_password='******', plotly_proxy_authorization=False)

        # Mock the actual api call, we don't want to do network tests here.
        patcher = patch('plotly.api.v1.utils.requests.request')
        self.request_mock = patcher.start()
        self.addCleanup(patcher.stop)
        self.request_mock.return_value = MagicMock(Response)

        # Mock the validation function since we test that elsewhere.
        patcher = patch('plotly.api.v1.utils.validate_response')
        self.validate_response_mock = patcher.start()
        self.addCleanup(patcher.stop)

        self.method = 'get'
        self.url = 'https://foo.bar.does.not.exist.anywhere'
예제 #11
0
 def setUp(self):
     self.stash_session()
     self.stash_files()
     defaults = dict(files.FILE_CONTENT[files.CREDENTIALS_FILE],
                     **files.FILE_CONTENT[files.CONFIG_FILE])
     session.sign_in(**defaults)
예제 #12
0
def plot(x_data, y_data, colors, other_lables, labels, nodes, segment, title):
    se.sign_in("scottt1987", "T7ztp3BTkd0kFqeqilZX")   # Do Not Share It
    mode_size = [8, 8, 12, 8]
    line_size = [2, 2, 4, 2]

    traces = []
    for i in range(0, segment):
        #print(y_data[i],  y_data[i])


        traces.append(go.Scatter(
            x=x_data[i],
            y=y_data[i],
            mode='lines',
            name=other_lables[i],
            line=dict(color=colors[i], width=2),
            connectgaps=True,
        ))

        traces.append(go.Scatter(
            x=[x_data[i][0], x_data[i][nodes]],
            y=[y_data[i][0], y_data[i][nodes]],
            name = "",
            mode='markers',
            marker=dict(color=colors[i], size=1)
        ))


    layout = go.Layout(
        xaxis=dict(
            showline=True,
            showgrid=False,
            showticklabels=True,
            linecolor='rgb(204, 204, 204)',
            linewidth=2,
            autotick=False,
            ticks='outside',
            tickcolor='rgb(204, 204, 204)',
            tickwidth=2,
            ticklen=5,
            tickfont=dict(
                family='Arial',
                size=12,
                color='rgb(82, 82, 82)',
            ),
        ),
        yaxis=dict(
            showgrid=False,
            zeroline=False,
            showline=False,
            showticklabels=False,
        ),
        autosize=False,
        margin=dict(
            autoexpand=False,
            l=100,
            r=20,
            t=110,
        ),
        showlegend=True,
    )

    annotations = []

    # Adding labels
    for y_trace, label, color in zip(y_data, labels, colors):
        # labeling the left_side of the plot
        annotations.append(dict(xref='paper', x=0.05, y=y_trace[0],
                                      xanchor='right', yanchor='middle',
                                      text=label + ' {}%'.format(y_trace[0]),
                                      font=dict(family='Arial',
                                                size=16,
                                                color=colors,),
                                      showarrow=False))
        # labeling the right_side of the plot
        annotations.append(dict(xref='paper', x=0.95, y=y_trace[nodes],
                                      xanchor='left', yanchor='middle',
                                      text='{}%'.format(y_trace[nodes]),
                                      font=dict(family='Arial',
                                                size=16,
                                                color=colors,),
                                      showarrow=False))
    # Title
    annotations.append(dict(xref='paper', yref='paper', x=0.0, y=1.05,
                                  xanchor='left', yanchor='bottom',
                                  text=title,
                                  font=dict(family='Arial',
                                            size=30,
                                            color='rgb(37,37,37)'),
                                  showarrow=False))
    # Source
    annotations.append(dict(xref='paper', yref='paper', x=0.5, y=-0.1,
                                  xanchor='center', yanchor='top',
                                  text='Source: PewResearch Center & ' +
                                       'Storytelling with data',
                                  font=dict(family='Arial',
                                            size=12,
                                            color='rgb(150,150,150)'),
                                  showarrow=False))

    layout['annotations'] = annotations

    fig = go.Figure(data=traces, layout=layout)
    py.plot(fig, filename='news-source')
예제 #13
0
def isqrt(x):
    if x < 0:
        raise ValueError('square root not defined for negative numbers')
    n = int(x)
    if n == 0:
        return 0
    a, b = divmod(n.bit_length(), 2)
    x = 2**(a+b)
    while True:
        y = (x + n//x)//2
        if y >= x:
            return x
        x = y

#se.sign_in("scottt1987", "T7ztp3BTkd0kFqeqilZX")   # Do Not Share It
se.sign_in("mark99", "4F7tE4Uo3aKnQNEziTO6")   # Do Not Share It
xi = []

#data = pandas.read_csv("D3-data-file-refugee-main.csv", delimiter='\t')
#print(data['Syria'])

x_dat = []
y_dat = []
counter = 0
with open("D3-data-file-refugee-1.csv") as csvfile:
    reader = csvfile.readlines()
    skipline = 0
    for row in reader:
        if skipline >= 1:
            xi.append(counter)
            x_dat.append(row.split("\t")[0])
예제 #14
0
__author__ = 'Soumen'
#import pandas as pd
import plotly as plt
import csv
from plotly import session as sess
from plotly import graph_objs as go
import plotly.plotly as py

username = "******"
API_key = "ytAwGhmFGgzFGDH0axco"

#######################################################################
sess.sign_in(username,API_key)
"""
df_airports = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
df_airports.head()
df_flight_paths = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_aa_flight_paths.csv')
df_flight_paths.head()
airports = [ dict(
        type = 'scattergeo',
        locationmode = 'USA-states',
        lon = df_airports['long'],
        lat = df_airports['lat'],
        hoverinfo = 'text',
        text = df_airports['airport'],
        mode = 'markers',
        marker = dict(
            size=2,
            color='rgb(255, 0, 0)',
            line = dict(
                width=3,
예제 #15
0
 def setUp(self):
     self.stash_session()
     self.stash_files()
     defaults = dict(files.FILE_CONTENT[files.CREDENTIALS_FILE],
                     **files.FILE_CONTENT[files.CONFIG_FILE])
     session.sign_in(**defaults)