Skip to content

Instantly share code, notes, and snippets.

View Anthony-Hoo's full-sized avatar

Anthony-Hoo Anthony-Hoo

View GitHub Profile
@Anthony-Hoo
Anthony-Hoo / docstring_ast.py
Created June 13, 2024 09:53
Add docstrings to Python files using an OpenAI-compatible API
import ast
import requests
class FunctionExtractor(ast.NodeVisitor):
def __init__(self):
self.functions = []
self.function_calls = []
def visit_FunctionDef(self, node):
function_code = ast.unparse(node)
@Anthony-Hoo
Anthony-Hoo / picture_to_cie_diagram.py
Created December 19, 2023 06:51
Converts image input to CIE xy chromaticity coordinates with original pixel colour
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import time
from colour.plotting import *
def plot_xy_coordinates_with_color(xy_and_rgb_np, output_png_path):
start_time = time.time()
xy = xy_and_rgb_np[:, :2]