Skip to content

Instantly share code, notes, and snippets.

View pllim's full-sized avatar
💭
Clickety clack clack. ⌨

P. L. Lim pllim

💭
Clickety clack clack. ⌨
View GitHub Profile
@bmorris3
bmorris3 / find_available_voila_templates.py
Last active October 14, 2022 13:20
Voila template help for @rosteen, related issue: spacetelescope/jdaviz#1729
import sys
import os
from glob import glob
prefix_targets = [
"nbconvert/templates",
"voila/templates",
]
def user_dir():
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import matplotlib.pyplot as plt
import numpy as np
import re
from collections import defaultdict
# flake8 --select=E501 astropy/ > pep8length.txt
with open('pep8length.txt') as f:
text = f.read()
matches = re.findall(r'astropy/(.*?)/.*.py:.*(\d\d) > 79 characters', text)
@astrofrog
astrofrog / v3.0.5_vs_v3.1.x.log
Created October 29, 2018 14:46
Astropy performance changes from v3.0.5 to v3.1.x
Benchmarks that have improved:
before after ratio
[df4c75aa] [66ff20b9]
- 28.4±0.03ms 4.85±0.01ms 0.17 coordinates.FrameBenchmarks.time_concatenate_array
- 24.3±0.03ms 3.36±0.03ms 0.14 coordinates.FrameBenchmarks.time_concatenate_scalar
- 1.08±0.01ms 744±2μs 0.69 coordinates.FrameBenchmarks.time_init_array
- 390±0.4μs 82.6±0.6μs 0.21 coordinates.FrameBenchmarks.time_init_nodata
- 905±2μs 556±1μs 0.61 coordinates.FrameBenchmarks.time_init_scalar
- 18.4±0.01ms 1.79±0ms 0.10 coordinates.FrameBenchmarks.time_init_scalar_diff
class ImageWidget:
def __init__(self, properties...): # all the properties below should be valid kwargs
"""
Minimal widget does *not* have any fancy initializer parsing. The user
has to call a `load` method. Future-proofing against future `load_*`
methods so that the initializer doesn't get too confusing.
"""
# OPTION 2 / stretch goal - I favor only option 1:
def __init__(self, image=None, properties...):
"""
@StuartLittlefair
StuartLittlefair / quick_altaz.py
Created May 31, 2018 13:52
Use broadcasting to transform many SkyCoords into frames with vector properties
from astropy.coordinates import SkyCoord, EarthLocation
from astropy.coordinates.tests.utils import randomly_sample_sphere
from astropy.time import Time
import numpy as np
# 1000 random locations on the sky
ra, dec, _ = randomly_sample_sphere(1000)
coos = SkyCoord(ra, dec)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.