<commit_before>
import phidl.utilities as pu
from phidl import Device
from matplotlib import pyplot as plt


import phidl.geometry as pg
from phidl import quickplot as qp
import os


def create_image(D, filename, size = 300, filepath = '_static/'):
    # if any(D.size == 0):
    #     D = pg.text('?')
    qp(D)
    fig = plt.gcf()
    # ax = plt.gca()
    fig.set_size_inches(10, 4, forward=True)
    # ax.autoscale()
    # plt.draw()
    # plt.show(block = False)
    filename +=  '.png'
    filepathfull = os.path.join(os.path.curdir, filepath, filename)
    print(filepathfull)
    fig.savefig(filepathfull, dpi=96)


# example-rectangle
import phidl.geometry as pg
D = pg.rectangle(size = (4.5, 2), layer = 0)
create_image(D, 'rectangle')


# example-bbox
import phidl.geometry as pg
A = pg.arc(radius = 10, width = 0.5, theta = 85, layer = 1)
D = pg.bbox(bbox = A.bbox, layer = 0)
create_image(D, 'bbox')

# example-cross
import phidl.geometry as pg<commit_msg>Update gen_geometry.py<commit_after>
import phidl.utilities as pu
from phidl import Device
from matplotlib import pyplot as plt


import phidl.geometry as pg
from phidl import quickplot as qp
import os


def create_image(D, filename, filepath = '_static/'):
    # if any(D.size == 0):
    #     D = pg.text('?')
    qp(D)
    fig = plt.gcf()
    # ax = plt.gca()
    scale = 0.75
    fig.set_size_inches(10*scale, 4*scale, forward=True)
    # ax.autoscale()
    # plt.draw()
    # plt.show(block = False)
    filename +=  '.png'
    filepathfull = os.path.join(os.path.curdir, filepath, filename)
    print(filepathfull)
    fig.savefig(filepathfull, dpi=int(96/scale))


# example-rectangle
import phidl.geometry as pg
D = pg.rectangle(size = (4.5, 2), layer = 0)
create_image(D, 'rectangle')


# example-bbox
import phidl.geometry as pg
A = pg.arc(radius = 10, width = 0.5, theta = 85, layer = 1)
D = pg.bbox(bbox = A.bbox, layer = 0)
create_image(D, 'bbox')

# example-cross
import phidl.geometry as pg
{'fraction_non_alphanumeric': 0.1368474404460213, 'fraction_numerical': 0.021287379624936646, 'mean_word_length': 3.357615894039735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3996298', 'n_tokens_mistral': 794, 'n_tokens_neox': 760, 'n_words': 198}