Beispiel #1
0
def display_dot(dot_file):
    svg_file = _to_tmp_file('.svg')
    # print "write dot file to {f}".format(f=dot_file)
    dot_file_to_svg(dot_file, svg_file)
    with open(svg_file, 'r') as f:
        s = f.read()
    display_svg(s, raw=True)
Beispiel #2
0
def display_dot(dot_file):
    svg_file = _to_tmp_file('.svg')
    # print "write dot file to {f}".format(f=dot_file)
    dot_file_to_svg(dot_file, svg_file)
    with open(svg_file, 'r') as f:
        s = f.read()
    display_svg(s, raw=True)
Beispiel #3
0
def __display(ref):
    try:
        from graphviz import Source
        from IPython.display import display_svg
    except:
        raise Exception('Missing module: graphviz and/or IPython')
    display_svg(Source(dot(ref)))
Beispiel #4
0
def plotArchitecture(model, file_name=None, save_path=None):
    """
    Visualizes Keras model. Depending on the parameters, model is either plotted in the console, 
    or saved to PNG file. If saved to PNG file, the file is created in the '/Models' subdirectory of 
    parent's directory. If the directory doesn't exist, it is created.
    
    Inputs:
        MODEL Keras model object to be visualized
        FILE_NAME Name of file where the model is saved. If FILE_NAME is not provided or empty, 
            the model is plotted in the console
    """
    
    if save_path == "" or save_path == None:
        path = os.path.realpath('..') + '/'
    else:
        path = save_path
    
    if model is not None:
        if file_name is not None and len(file_name.replace(" ", ""))>0:
#            print "Path when saving model is: " + path
            dir_path = path + 'Plots/'
            if not os.path.isdir(dir_path):
                os.makedirs(dir_path)
            file_path = dir_path + file_name + '.png'
            plot_model(model, to_file=file_path, show_shapes=True)
            print('Model is saved to a file "' + file_path + '"')
        else:
            from IPython.display import SVG, display_svg
            print('Model architecture:')
            display_svg(SVG(model_to_dot(model).create(prog='dot', format='svg')))
    else:
        print("No model is provided")
def plot_model(model, path='', prefix=''):
    dot = keras.utils.vis_utils.model_to_dot(model,
                                             show_shapes=True,
                                             show_layer_names=True)
    svg = dot.create(prog='dot', format='svg')
    display_svg(svg, raw=True)
    if path and prefix:  #37427362
        keras.utils.plot_model(model, to_file=path + prefix + '_mod.png')
Beispiel #6
0
    def _display(self):
        '''Displays SVG representation directly in IPython notebook.

        Requires IPython and (through method _repr_svg_) graphviz modules.
        '''
        try:
            from IPython.display import display_svg
        except:
            raise Exception('Missing moduke: IPtyhon')
        display_svg(self)
Beispiel #7
0
def print_balance_sheets_and_money_stocks(*args):
    MusteriA.book_end_of_period()
    MusteriB.book_end_of_period()
    MusteriC.book_end_of_period()
    
    if len(args)==0:
        args = ("bk","hd","fd","ts","pd")
    
    if "bk" in args and Bank.get_total_assets() > 0: display_svg(SVG(Bank.draw_balance_sheet("Bank", width=500)))
    if "hd" in args and Household.get_total_assets() > 0: display_svg(SVG(Household.draw_balance_sheet("Household", width=500)))
    if "fd" in args and Fed.get_total_assets() > 0: display_svg(SVG(Fed.draw_balance_sheet("Fed", width=500)))
    if "ts" in args and Treasury.get_total_assets() > 0: display_svg(SVG(Treasury.draw_balance_sheet("Treasury", width=500)))  
    if "pd" in args and Primary_Dealer.get_total_assets() > 0: display_svg(SVG(Primary_Dealer.draw_balance_sheet("Primary Dealer", width=500)))
    print_money_stocks()
Beispiel #8
0
def iPATH_display(data,
                  output='svg',
                  filename=None,
                  default_opacity=0.1,
                  default_width=2,
                  default_radius=5,
                  **kwargs):

    url = 'https://pathways.embl.de/mapping.cgi'

    elements = edge_mapper(data)

    parameters = {
        'map': 'metabolic',
        'export_type': 'svg',
        'selection': '\n'.join(elements),
        'default_opacity': default_opacity,
        'default_width': default_width,
        'default_radius': default_radius
    }

    parameters.update(kwargs)

    r = requests.post(url, data=parameters)

    if r.headers['Content-Type'] != 'image/svg+xml':
        print(r.text)
        return

    if output == 'svg':
        if filename is None:
            filename = 'iPath.svg'
        with open(filename, 'wb') as f:
            f.write(r.content)

    elif output == 'png':
        from cairosvg import svg2png
        if filename is None:
            filename = 'iPath.png'
        svg2png(bytestring=r.content, write_to=filename)

    elif output == 'notebook':
        from IPython.display import SVG, display_svg
        display_svg(SVG(data=r.content))

    else:
        print('Output format not supported.')
Beispiel #9
0
def iPATH_display(data, output='svg', filename=None, default_opacity=0.1, default_width=2, default_radius=5, **kwargs):

    url = 'https://pathways.embl.de/mapping.cgi'

    elements = edge_mapper(data)

    parameters = {
        'map': 'metabolic',
        'export_type': 'svg',
        'selection': '\n'.join(elements),
        'default_opacity': default_opacity,
        'default_width': default_width,
        'default_radius': default_radius
    }

    parameters.update(kwargs)

    r = requests.post(url, data=parameters)

    if r.headers['Content-Type'] != 'image/svg+xml':
        print(r.text)
        return

    if output == 'svg':
        if filename is None:
            filename = 'iPath.svg'
        with open(filename, 'wb') as f:
            f.write(r.content)

    elif output == 'png':
        from cairosvg import svg2png
        if filename is None:
            filename = 'iPath.png'
        svg2png(bytestring=r.content, write_to=filename)

    elif output == 'notebook':
        from IPython.display import SVG, display_svg
        display_svg(SVG(data=r.content))

    else:
        print('Output format not supported.')
Beispiel #10
0
def print_balance_sheets_and_money_stocks(*args):
    MusteriA.book_end_of_period()

    if len(args) == 0:
        args = ("b1", "b2", "pA", "pB", "pC", "cb", "ts")
    if "b1" in args and Xbankasi.get_total_assets() > 0:
        display_svg(SVG(Xbankasi.draw_balance_sheet("Banka X", width=500)))
    if "b2" in args and Ybankasi.get_total_assets() > 0:
        display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
    if "pA" in args and MusteriA.get_total_assets() > 0:
        display_svg(SVG(MusteriA.draw_balance_sheet("Müşteri A", width=500)))
    if "cb" in args and Merkez_Bankasi.get_total_assets() > 0:
        display_svg(
            SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası",
                                                  width=500)))

    print_money_stocks()
Beispiel #11
0
def print_balance_sheets_and_money_stocks(*args):
    MusteriA.book_end_of_period()
   
    
    if len(args)==0:
        args = ("b1","b2","pA")
    if "b1" in args and Xbankasi.get_total_assets() > 0: display_svg(SVG(Xbankasi.draw_balance_sheet("JP Morgan", width=500)))
    if "b2" in args and Ybankasi.get_total_assets() > 0: display_svg(SVG(Ybankasi.draw_balance_sheet("Citibank", width=500)))
    if "pA" in args and MusteriA.get_total_assets() > 0: display_svg(SVG(MusteriA.draw_balance_sheet("Goodlife", width=500)))

        
    print_money_stocks()
Beispiel #12
0
    def draw(self, filename=None, opts={}, **kwargs):
        """
        filename specifies the name of the file to produce.  If None,
        the schematic is displayed on the screen.

        Note, if using Jupyter, then need to first issue command %matplotlib inline

        kwargs include:
           label_ids: True to show component ids
           label_values: True to display component values
           draw_nodes: True to show all nodes, False to show no nodes, 
             'primary' to show primary nodes,
             'connections' to show nodes that connect more than two components,
             'all' to show all nodes
           label_nodes: True to label all nodes, False to label no nodes, 
             'primary' to label primary nodes,
             'alpha' to label nodes starting with a letter,
             'pins' to label nodes that are pins on a chip,
             'all' to label all nodes
           style: 'american', 'british', or 'european'
           scale: schematic scale factor, default 1.0
           node_spacing: spacing between component nodes, default 2.0
           cpt_size: size of a component, default 1.5
           oversample: oversampling factor for png or pdf files
           help_lines: distance between lines in grid, default 0.0 (disabled)
           debug: True to display debug information
        """

        for key, val in opts.items():
            if key not in kwargs or kwargs[key] is None:
                kwargs[key] = val

        def in_ipynb():
            try:
                ip = get_ipython()
                cfg = ip.config

                kernapp = cfg['IPKernelApp']

                # Check if processing ipynb file.
                if 'connection_file' in kernapp:
                    return True
                elif kernapp and kernapp[
                        'parent_appname'] == 'ipython-notebook':
                    return True
                else:
                    return False
            except (NameError, KeyError):
                return False

        if not self.hints:
            raise RuntimeWarning('No schematic drawing hints provided!')

        png = 'png' in kwargs and kwargs.pop('png')
        svg = 'svg' in kwargs and kwargs.pop('svg')

        if not png and not svg:
            png = True

        if in_ipynb() and filename is None:

            if png:
                from IPython.display import Image, display_png

                pngfilename = tmpfilename('.png')
                self.tikz_draw(pngfilename, **kwargs)

                # Create and display PNG image object.
                # There are two problems:
                # 1. The image metadata (width, height) is ignored
                #    when the ipynb file is loaded.
                # 2. The image metadata (width, height) is not stored
                #    when the ipynb file is written non-interactively.
                display_png(
                    Image(filename=pngfilename,
                          width=self.width * 100,
                          height=self.height * 100))
                return

            if svg:
                from IPython.display import SVG, display_svg

                svgfilename = tmpfilename('.svg')
                self.tikz_draw(svgfilename, **kwargs)

                # Create and display SVG image object.
                # Note, there is a problem displaying multiple SVG
                # files since the later ones inherit the namespace of
                # the first ones.
                display_svg(
                    SVG(filename=pngfilename,
                        width=self.width * 100,
                        height=self.height * 100))
                return

        if filename is None:
            filename = tmpfilename('.png')
            self.tikz_draw(filename=filename, **kwargs)
            display_matplotlib(filename)
            return

        self.tikz_draw(filename=filename, **kwargs)
Beispiel #13
0
# Merkez Bankasının varlık ve yükümlülük kalemleri tanımlanıyor.
Merkez_Bankasi.make_asset_accounts(['Devlet Tahvili','Bankalara Verilen Krediler'])
Merkez_Bankasi.make_liability_accounts(['Nakit','Rezervler','Kamu Mevduatı']) # Kamu Mevduatı eklendi.

# Hazinenin varlık ve yükümlülük kalemleri tanımlanıyor.
Hazine.make_asset_accounts(['Kamu Mevduatı'])  # Bu satır eklendi.
Hazine.make_liability_accounts(['Devlet Tahvili'])  # Bu satır eklendi.



#Banka Y, M.B'dan Borç Alır.
Ybankasi.book(debit=[('Rezervler',100)],credit=[('Merkez Bankasına Borçlar',100)])
Merkez_Bankasi.book(debit=[('Bankalara Verilen Krediler',100)],credit=[('Rezervler',100)])

#Bilançolar
display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
display_svg(SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası", width=500)))

#Para Arzı
print_money_stocks()

#kod2 Banka Y, Hazineden "Devlet Tahvili" alır.

#Banka Y, Hazineden "Devlet Tahvili" alır.
Ybankasi.book(debit=[('Devlet Tahvili',100)],credit=[('Rezervler',100)])
Hazine.book(debit=[('Kamu Mevduatı',100)],credit=[('Devlet Tahvili',100)])
Merkez_Bankasi.book(debit=[('Rezervler',100)],credit=[('Kamu Mevduatı',100)])


#Bilançolar
display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
Beispiel #14
0
                    print(cos_sim(vecs.toarray()[x], vecs.toarray()[y]))


# In[33]:


g = nx.DiGraph()
for node in range(len(comments)):
    g.add_node(comments[node][:5])
    
#plt.figure(figsize=(15, 15))
#pos = nx.spring_layout(g)
#nx.draw_networkx(g, pos)

svg = nx.nx_agraph.to_agraph(g).draw(prog='fdp', format='svg')
display_svg(svg, raw=True)


# In[12]:


#辞書の指定
m = MeCab.Tagger("-d /usr/local/lib/mecab/dic/mecab-ipadic-neologd")
#m = MeCab.Tagger("-Ochasen")

#print('@'+issue.user.login)
#print(m.parse(issue.body))
#for comment in issue.get_comments():
#    print('@'+comment.user.login)
#    print(m.parse(comment.body))
Beispiel #15
0
    def draw(self, filename=None, **kwargs):
        """
        filename specifies the name of the file to produce.  If None,
        the schematic is displayed on the screen.

        Note, if using Jupyter, then need to first issue command %matplotlib inline

        kwargs include:
           label_ids: True to show component ids
           label_values: True to display component values
           draw_nodes: True to show all nodes,
             False or 'none' to show no nodes, 
             'primary' to show primary nodes,
             'connections' to show nodes that connect more than two components,
             'all' to show all nodes
           label_nodes: True to label all nodes,
             False or 'none' to label no nodes, 
             'primary' to label primary nodes,
             'alpha' to label nodes starting with a letter,
             'pins' to label nodes that are pins on a chip,
             'all' to label all nodes,
             'none' to label no nodes
           style: 'american', 'british', or 'european'
           scale: schematic scale factor, default 1.0
           node_spacing: spacing between component nodes, default 2.0
           cpt_size: size of a component, default 1.5
           dpi: dots per inch for png files
           help_lines: distance between lines in grid, default 0.0 (disabled)
           debug: True to display debug information
        """

        # None means don't care, so remove.
        for key in list(kwargs.keys()):
            if kwargs[key] is None:
                kwargs.pop(key)

        # Remove options that may be overridden
        for elt in self.elements.values():
            for key in list(elt.opts.keys()):
                if key in kwargs:
                    elt.opts.remove(key)

        # Default options
        opts = SchematicOpts()
        for key, val in opts.items():
            if key not in kwargs:
                kwargs[key] = val

        # Global options (at end of list for historical reasons)
        for eltname in reversed(self.elements):
            elt = self.elements[eltname]
            if not elt.directive:
                break
            for key, val in elt.opts.items():
                # val is a str
                kwargs[key] = val

        def in_ipynb():
            try:
                ip = get_ipython()
                cfg = ip.config

                kernapp = cfg['IPKernelApp']

                # Check if processing ipynb file for Jupyter notebook.
                if 'connection_file' in kernapp:
                    return True
                elif kernapp and kernapp[
                        'parent_appname'] == 'ipython-notebook':
                    return True
                else:
                    return False
            except (NameError, KeyError):
                return False

        if not self.hints:
            raise RuntimeWarning('No schematic drawing hints provided!')

        if in_ipynb() and filename is None:
            png = 'png' in kwargs and kwargs.pop('png')
            svg = 'svg' in kwargs and kwargs.pop('svg')

            if not png and not svg:
                svg = False

            if svg:
                try:
                    from IPython.display import SVG, display_svg

                    svgfilename = tmpfilename('.svg')
                    self.tikz_draw(svgfilename, **kwargs)

                    # Create and display SVG image object.
                    # Note, there is a problem displaying multiple SVG
                    # files since the later ones inherit the namespace of
                    # the first ones.
                    display_svg(SVG(filename=svgfilename))
                    return
                except:
                    pass

            from IPython.display import Image, display_png

            pngfilename = tmpfilename('.png')
            self.tikz_draw(pngfilename, **kwargs)

            # Create and display PNG image object.
            # There are two problems:
            # 1. The image metadata (width, height) is ignored
            #    when the ipynb file is loaded.
            # 2. The image metadata (width, height) is not stored
            #    when the ipynb file is written non-interactively.
            width, height = png_image_size(pngfilename)
            # width, height specify the image dimension in pixels
            display_png(Image(filename=pngfilename, width=width,
                              height=height))
            return

        if filename is None:
            filename = tmpfilename('.png')
            # Thicken up lines to reduce aliasing causing them to
            # disappear, especially when using pdftoppm.
            self.tikz_draw(filename=filename,
                           options='bipoles/thickness=2',
                           **kwargs)
            display_matplotlib(filename, self.dpi)
            return

        self.tikz_draw(filename=filename, **kwargs)
Beispiel #16
0
parents = {}

for name, clss in classes:
    parent = _semantics.SemanticType
    parent_name = "SemanticType"

    for name2, base in classes:
        if name2 == name:
            continue

        if issubclass(clss, base) and issubclass(base, parent):
            parent = base
            parent_name = name2

    parents[name] = parent_name

for name, parent in parents.items():
    if name == parent:
        continue

    graph.add_edge(pydot.Edge(parent, name))

graph.write(output_file + ".svg", format="svg")
graph.write(output_file + ".png", format="png")
graph.write(output_file + ".pdf", format="pdf")

display_svg(graph.create_svg().decode("utf8"), raw=True)

# %%
Beispiel #17
0
def print_balance_sheets_and_money_stocks(*args):
    MusteriA.book_end_of_period()
    MusteriB.book_end_of_period()
    MusteriC.book_end_of_period()
    
    if len(args)==0:
        args = ("b1","b2","pA","pB","pC","cb","ts") #ts ekledik.
    if "b1" in args and Xbankasi.get_total_assets() > 0: display_svg(SVG(Xbankasi.draw_balance_sheet("Banka X", width=500)))
    if "b2" in args and Ybankasi.get_total_assets() > 0: display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
    if "pA" in args and MusteriA.get_total_assets() > 0: display_svg(SVG(MusteriA.draw_balance_sheet("Müşteri A", width=500)))
    if "pB" in args and MusteriB.get_total_assets() > 0: display_svg(SVG(MusteriB.draw_balance_sheet("Müşteri B", width=500)))
    if "pC" in args and MusteriC.get_total_assets() > 0: display_svg(SVG(MusteriC.draw_balance_sheet("Müşteri C", width=500)))
    if "cb" in args and Merkez_Bankasi.get_total_assets() > 0: display_svg(SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası", width=500)))
    if "ts" in args and Hazine.get_total_assets() > 0: display_svg(SVG(Hazine.draw_balance_sheet("Hazine", width=500)))  #bu satırı ekledik.
    print_money_stocks()
Beispiel #18
0
@author: YJ
"""

import pandas as pd
import requests
from bs4 import BeautifulSoup
from nose.tools import assert_equal
from IPython.display import display_svg
"""
Visualize the results of the 2016 Presidental Election.
And the number of electoral votes on the map
"""

with open('../data/usa.svg') as f:
    usa = f.read()
    display_svg(usa, raw=True)

# ElectoralCollege2016.csv file contains
# the number of electoral votes for each state
# and who won

elec = '../data/ElectoralCollege2016.csv'

votes = pd.read_csv(elec, index_col='State')

dem = '#698dc5'  # a blue color
rep = '#f07763'  # a red color

another_soup = BeautifulSoup(usa, 'xml')

res = {}
Beispiel #19
0
    def draw(self, filename=None, args=None, stretch=1, scale=1, **kwargs):

        self.node_spacing = 2 * stretch * scale
        self.cpt_size = 1.5 * scale
        self.scale = scale

        def in_ipynb():
            try:
                ip = get_ipython()
                cfg = ip.config

                kernapp = cfg['IPKernelApp']

                # Check if processing ipynb file.
                if 'connection_file' in kernapp:
                    return True
                elif kernapp and kernapp['parent_appname'] == 'ipython-notebook':
                    return True
                else:
                    return False
            except (NameError, KeyError):
                return False

        if not self.hints:
            raise RuntimeWarning('No schematic drawing hints provided!')

        png = 'png' in kwargs and kwargs.pop('png')
        svg = 'svg' in kwargs and kwargs.pop('svg')

        if not png and not svg:
            png = True

        if in_ipynb() and filename is None:

            if png:
                from IPython.display import Image, display_png

                pngfilename = self._tmpfilename('.png')
                self.tikz_draw(pngfilename, args=args, **kwargs)

                # Create and display PNG image object.
                # There are two problems:
                # 1. The image metadata (width, height) is ignored
                #    when the ipynb file is loaded.
                # 2. The image metadata (width, height) is not stored
                #    when the ipynb file is written non-interactively.
                display_png(Image(filename=pngfilename,
                                  width=self.width * 100, 
                                  height=self.height * 100))
                return

            if svg:
                from IPython.display import SVG, display_svg

                svgfilename = self._tmpfilename('.svg')
                self.tikz_draw(svgfilename, args=args, **kwargs)

                # Create and display SVG image object.
                # Note, there is a problem displaying multiple SVG
                # files since the later ones inherit the namespace of
                # the first ones.
                display_svg(SVG(filename=pngfilename, 
                                width=self.width * 100, height=self.height * 100))
                return

        display = False
        if filename is None:
            filename = self._tmpfilename('.png')
            display = True

        self.tikz_draw(filename=filename, args=args, **kwargs)
        
        if display:
            # TODO display as SVG so have scaled fonts...

            from matplotlib.pyplot import figure
            from matplotlib.image import imread

            img = imread(filename)

            fig = figure()
            ax = fig.add_subplot(111)
            ax.imshow(img)
            ax.axis('equal')
            ax.axis('off')
Beispiel #20
0
print(top20.head(3))

# ### Problem 9.3. Data Visualization.
#
# - Use the blank U.S. map with 20 major cities
#   [airports.svg](https://rawgit.com/INFO490/spring2015/master/week09/images/airports.svg)
#   to visualize the `top20` dataframe.
#
# Run the following cell to display the SVG template.

# In[16]:

resp = requests.get(
    "https://rawgit.com/INFO490/spring2015/master/week09/images/airports.svg")
usairports = resp.content
display_svg(usairports, raw=True)

# You should use `BeautifulSoup` to adjust the size and color of the circles
#   to create a figure similar to the following.
#   Again, the radius of a circle is proportional to the total traffic
#   of that airport.
#   The color of a circle depends on the current temperature at that airport.

# In[39]:

resp = requests.get(
    "https://rawgit.com/INFO490/spring2015/master/week09/images/top20.svg")
SVG(resp.content)

# (Your figure does not have to look exactly the same.
#   Choose a different set of sizes and colors if you wish.)
Beispiel #21
0

# Merkez Bankasının varlık ve yükümlülük kalemleri tanımlanıyor.
Merkez_Bankasi.make_asset_accounts(['Dış Varlıklar','İç Varlıklar','Degerleme','APİ'])
Merkez_Bankasi.make_liability_accounts(['Hazinenin Döviz Rezervleri','Emisyon','Kamu Mevduatı','Rezervler'])

#Başlangıç
MusteriA.book(debit=[('Mevduat',50)],credit=[('Kredi',50)])
Ybankasi.book(debit=[('Kredi',50)],credit=[('Müşteri A Mevduatı',50)])
Ybankasi.book(debit=[('Rezervler',50)],credit=[('Merkez Bankasına Borçlar',50)])
Xbankasi.book(debit=[('Rezervler',50)],credit=[('Merkez Bankasına Borçlar',50)])
Merkez_Bankasi.book(debit=[('APİ',100)],credit=[('Rezervler',100)])


#Başlangıç- Bilançolar
display_svg(SVG(Xbankasi.draw_balance_sheet("Banka X", width=500)))
display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
display_svg(SVG(MusteriA.draw_balance_sheet("Müşteri A", width=500)))
display_svg(SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası", width=500)))

"""
Müşteri A, 30 TL vergi ödemesini Banka Y üzeriden yapıyor.
Banka Y'den çıkan mevduat, Ziraat Bankasına (Banka X) gidiyor.



"""


#Kod-1
MusteriA.book(debit=[('Sermaye',30)],credit=[('Mevduat',30)])
Beispiel #22
0

# Merkez Bankasının varlık ve yükümlülük kalemleri tanımlanıyor.
Merkez_Bankasi.make_asset_accounts(['Dış Varlıklar','İç Varlıklar','Degerleme','APİ'])
Merkez_Bankasi.make_liability_accounts(['Bankaların Döviz Rezervleri','Hazinenin Döviz Rezervleri','Emisyon','Kamu Mevduatı','Rezervler'])



#Başlangıç
Xbankasi.book(debit=[('Dış Varlıklar',50)],credit=[('Sermaye',50)])
Xbankasi.book(debit=[('Devlet Tahvili',50)],credit=[('Sermaye',50)])
Merkez_Bankasi.book(debit=[('Dış Varlıklar',50)],credit=[('Sermaye',50)])


#Başlangıç- Bilançolar
display_svg(SVG(Xbankasi.draw_balance_sheet("Banka X", width=500)))
display_svg(SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası", width=500)))



"""
Kod1
https://paravefinans595106776.wordpress.com/2021/03/05/
bolum-ii-para-politikasi-islemlerinden-alacaklar-ve-borclar/

"""


#Kod1

Xbankasi.book(debit=[('Rezervler',200)],credit=[('Merkez Bankasına Borçlar',200)])
Beispiel #23
0
# Primary Dealer 
Primary_Dealer.make_asset_accounts(['Deposits','Treasury Securities'])
Primary_Dealer.make_liability_accounts(['Debts to Fed'])  
                                                                      
# Household 
Household.make_asset_accounts(['Deposits','Treasury Securities'])
Household.make_liability_accounts(['Loans'])




#Kod0 Banka, hanehalkına kredi verir.
Bank.book(debit=[('Loans',100)],credit=[('Deposits',100)])
Household.book(debit=[('Deposits',100)],credit=[('Loans',100)])

display_svg(SVG(Bank.draw_balance_sheet("Bank", width=500)))
display_svg(SVG(Household.draw_balance_sheet("Household", width=500)))



#Kod1

"""Fed,primary dealers ile repo işlemi yapar. Burada primary dealerslerin repo için teminat verdiği tahvilleri bilanço dışında gösterdiğini varsayıyoruz """



Fed.book(debit=[('Credits to Financial Institutions',200)],credit=[('Reserves',200)])
Bank.book(debit=[('Reserves',200)],credit=[('Deposits',200)])
Primary_Dealer.book(debit=[('Deposits',200)],credit=[('Debts to Fed',200)])

number of votes
"""


def winColumn(row):
    if row['후보자별 득표수'] > row['Unnamed: 7']:
        return '문재인'
    elif row['후보자별 득표수'] < row['Unnamed: 7']:
        return '홍준표'
    else:
        return ''


with open('../data/korea.svg', encoding='utf-8') as f:
    kor = f.read()
    display_svg(kor, raw=True)

soup = BeautifulSoup(kor, 'xml')

# color code

hong = '#C9151E'
moon = '#1870B9'

path = '../data/kor_elec.xlsx'

# vote data

df = pd.read_excel(path, index_col='구시군명')

# format df
Beispiel #25
0
    def draw(self, filename=None, opts={}, **kwargs):
        """
        filename specifies the name of the file to produce.  If None,
        the schematic is displayed on the screen.

        Note, if using Jupyter, then need to first issue command %matplotlib inline

        kwargs include:
           label_ids: True to show component ids
           label_values: True to display component values
           draw_nodes: True to show all nodes, False to show no nodes, 
             'primary' to show primary nodes,
             'connections' to show nodes that connect more than two components,
             'all' to show all nodes
           label_nodes: True to label all nodes, False to label no nodes, 
             'primary' to label primary nodes,
             'alpha' to label nodes starting with a letter,
             'pins' to label nodes that are pins on a chip,
             'all' to label all nodes,
             'none' to label no nodes
           style: 'american', 'british', or 'european'
           scale: schematic scale factor, default 1.0
           node_spacing: spacing between component nodes, default 2.0
           cpt_size: size of a component, default 1.5
           oversample: oversampling factor for png or pdf files
           help_lines: distance between lines in grid, default 0.0 (disabled)
           debug: True to display debug information
        """

        # Add schematic options defined with ;; are stored in the append
        # field of opts.
        for key, val in opts.items():
            if key not in kwargs or kwargs[key] is None:
                kwargs[key] = val

        def in_ipynb():
            try:
                ip = get_ipython()
                cfg = ip.config

                kernapp = cfg['IPKernelApp']

                # Check if processing ipynb file.
                if 'connection_file' in kernapp:
                    return True
                elif kernapp and kernapp['parent_appname'] == 'ipython-notebook':
                    return True
                else:
                    return False
            except (NameError, KeyError):
                return False

        if not self.hints:
            raise RuntimeWarning('No schematic drawing hints provided!')

        if in_ipynb() and filename is None:
            png = 'png' in kwargs and kwargs.pop('png')
            svg = 'svg' in kwargs and kwargs.pop('svg')
            
            if not png and not svg:
                svg = False

            if svg:
                try:
                    from IPython.display import SVG, display_svg

                    svgfilename = tmpfilename('.svg')
                    self.tikz_draw(svgfilename, **kwargs)
                    
                    # Create and display SVG image object.
                    # Note, there is a problem displaying multiple SVG
                    # files since the later ones inherit the namespace of
                    # the first ones.
                    display_svg(SVG(filename=svgfilename)) 
                    return
                except:
                    pass

            from IPython.display import Image, display_png

            pngfilename = tmpfilename('.png')
            self.tikz_draw(pngfilename, **kwargs)
            
            # Create and display PNG image object.
            # There are two problems:
            # 1. The image metadata (width, height) is ignored
            #    when the ipynb file is loaded.
            # 2. The image metadata (width, height) is not stored
            #    when the ipynb file is written non-interactively.
            display_png(Image(filename=pngfilename,
                              width=self.width * 100, 
                              height=self.height * 100))
            return

        if filename is None:
            filename = tmpfilename('.png')
            # Thicken up lines to reduce aliasing causing them to
            # disappear, especially when using pdftoppm.
            self.tikz_draw(filename=filename, preamble='bipoles/thickness=2',
                           **kwargs)
            display_matplotlib(filename)
            return

        self.tikz_draw(filename=filename, **kwargs)
Beispiel #26
0
Ybankasi.make_asset_accounts(['Reserves'])
Ybankasi.make_liability_accounts(['Goodlife Deposit','Equity'])

# Müşterilerin varlık ve yükümlülük kalemleri tanımlanıyor.
MusteriA.make_asset_accounts(['Fixed Assets','Goodlife Deposit'])
MusteriA.make_liability_accounts(['Equity'])


#Başlangıç
Xbankasi.book(debit=[('Reserves',100)],credit=[('Equity',100)])
Ybankasi.book(debit=[('Reserves',100)],credit=[('Equity',100)])
MusteriA.book(debit=[('Fixed Assets',100)],credit=[('Equity',100)])


#Başlangıç- Bilançolar
display_svg(SVG(Xbankasi.draw_balance_sheet("JP Morgan", width=500)))
display_svg(SVG(MusteriA.draw_balance_sheet("Goodlife", width=500)))
display_svg(SVG(Ybankasi.draw_balance_sheet("Citibank", width=500)))


#kod2
#Başlangıç
Xbankasi.book(debit=[('Fixed Assets',100)],credit=[('Goodlife Deposit',100)])
MusteriA.book(debit=[('Goodlife Deposit',100)],credit=[('Fixed Assets',100)])


#Başlangıç- Bilançolar
display_svg(SVG(Xbankasi.draw_balance_sheet("JP Morgan", width=500)))
display_svg(SVG(MusteriA.draw_balance_sheet("Goodlife", width=500)))

#kod3
Beispiel #27
0
resp = requests.get(
    "http://upload.wikimedia.org/wikipedia/commons/5/5f/USA_Counties_with_FIPS_and_names.svg"
)
usa = resp.content

with open('usa.svg', 'wb') as fout:
    fout.write(usa)

# Display the original image. This is an SVG so it can scale seamlessly

# The data file on the website http://www.bls.gov/lau/#tables
# spans the years 1990 to 2013, so we can simply change the 13
# in the URL to a different value to get data/plot for a different year.

display_svg(usa, raw=True)

# We specify our Column Names

headers = ['LAUS Code', 'StateFIPS', 'CountyFIPS', 'County Name', 'Year', \
           'Labor Force', 'Employed', 'Unemployed', 'Rate']

# The column widths for fixed width formatting
cs = [(0, 16), (17, 21), (22, 28), (29, 79), (80, 85), (86, 99), (100, 112),
      (113, 123), (124, 132)]

# The converter functions. We simply use string, we can't use dtypes with a Python engine
cvf = {0: str, 1: str, 2: str, 3: str, 4: str, 5: str, 6: str, 7: str, 8: str}

# Read in the data. We skip first five rows that are header info
ud = pd.read_fwf('http://www.bls.gov/lau/laucnty13.txt', converters = cvf, colspecs = cs, \
Beispiel #28
0
# Primary Dealer
Primary_Dealer.make_asset_accounts(['Deposits', 'Reverse Repo'])
Primary_Dealer.make_liability_accounts(['Repo'])

# MMF
MMF.make_asset_accounts(['Reverse Repo', 'Deposits'])
MMF.make_liability_accounts(['Repo', 'Loans'])

#Code0, Fed makes a repo with Primary Dealer.
Fed.book(debit=[('Repo', 200)], credit=[('Reserves', 200)])
Bank.book(debit=[('Reserves', 200)], credit=[('Deposits', 200)])
Primary_Dealer.book(debit=[('Deposits', 200)], credit=[('Repo', 200)])

#Balance Sheet
display_svg(SVG(Fed.draw_balance_sheet("Fed", width=500)))
display_svg(SVG(Bank.draw_balance_sheet("Bank", width=500)))
display_svg(SVG(Primary_Dealer.draw_balance_sheet("Primary Dealer",
                                                  width=500)))

#Code1, Fed makes a reverse repo with Primary Dealer
Fed.book(debit=[('Reserves', 50)], credit=[('Reverse Repo', 50)])
Bank.book(debit=[('Deposits', 50)], credit=[('Reserves', 50)])
Primary_Dealer.book(debit=[('Reverse Repo', 50)], credit=[('Deposits', 50)])

#Balance Sheet
display_svg(SVG(Fed.draw_balance_sheet("Fed", width=500)))
display_svg(SVG(Bank.draw_balance_sheet("Bank", width=500)))
display_svg(SVG(Primary_Dealer.draw_balance_sheet("Primary Dealer",
                                                  width=500)))