Skip to content

Instantly share code, notes, and snippets.

View robintw's full-sized avatar

Robin Wilson robintw

View GitHub Profile
async def test_select_platform_type(test_datastore):
# Test application in a dummy session.
input = DummyInput()
output = DummyOutput()
# output = None
with create_app_session(output=output, input=input):
gui = MaintenanceGUI(test_datastore)
task = asyncio.create_task(gui.app.run_async())
import asyncio
from contextlib import asynccontextmanager
from prompt_toolkit.application import create_app_session
from prompt_toolkit.input import create_pipe_input
from prompt_toolkit.input.ansi_escape_sequences import REVERSE_ANSI_SEQUENCES
from prompt_toolkit.input.base import DummyInput
from prompt_toolkit.key_binding.key_processor import KeyPress
from prompt_toolkit.keys import Keys
from prompt_toolkit.output import DummyOutput
async def test_select_platform_type(test_datastore):
# Test application in a dummy session.
input = DummyInput()
# output = DummyOutput()
output = None
with create_app_session(output=output, input=input):
gui = MaintenanceGUI(test_datastore)
# Run the application.
from modulefinder import ModuleFinder
f = ModuleFinder()
# Run the main script
f.run_script('run.py')
# Get names of all the imported modules
names = list(f.modules.keys())
# Get a sorted list of the root modules imported
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.
[Info - 7:54:19 PM] Pylance language server 2020.6.1 starting
[Info - 7:54:19 PM] Server root directory: /Users/robin/.vscode-insiders/extensions/ms-python.vscode-pylance-2020.6.1/server
[Info - 7:54:19 PM] No configuration file found.
[Info - 7:54:19 PM] Setting pythonPath for service "pepys-import": "/Users/robin/anaconda3/envs/pepys/bin/python"
[Info - 7:54:20 PM] stubPath /Users/robin/Documents/IanMayo/pepys-import/typings is not a valid directory.
[Info - 7:54:20 PM] Assuming Python version 3.7
[Info - 7:54:20 PM] Assuming Python platform Darwin
[Info - 7:54:20 PM] Searching for source files
[Info - 7:54:20 PM] Found 181 source files
[Info - 7:54:20 PM] Background analysis root directory: /Users/robin/.vscode-insiders/extensions/ms-python.vscode-pylance-2020.6.1/server
#include<stdio.h>
#include<stdlib.h>
#include<array_alloc.h>
#include<math.h>
#include<mpi.h>
struct global_index
{
int x;
@robintw
robintw / bokeh_utils.py
Last active January 21, 2019 07:07
Bokeh Utils
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool
def scatter_with_hover(df, x, y,
fig=None, cols=None, name=None, marker='x',
fig_width=500, fig_height=500, **kwargs):
"""
Plots an interactive scatter plot of `x` vs `y` using bokeh, with automatic
tooltips showing columns from `df`.

What is your session about?

"I wish there was a way to easily manipulate this huge multi-dimensional array in Python...", I thought, as I stared at a huge chunk of satellite data on my laptop. The data was from a satellite measuring air quality - and I wanted to slice and dice the data in some supposedly simple ways. Using pure numpy - the go-to library when the words 'multi-dimensional', 'array' and 'python' are mentioned in the same sentence - was just such a pain. What I wished for was something like pandas - with datetime indexes, fancy ways of selecting subsets, group-by operations and so on - but something that would work with my huge multi-dimensional array.

The solution: XArray - a wonderful library which provides the power of pandas for multi-dimensional data. In this talk I will introduce the XArray library by showing how just a few lines of code can answer questions about my data that would take a lot of complex code to answer with pure numpy - questions like 'What is the average air quality in