Random query recipes of JMESPath for the AWS CLI tools that I might have written or stumbled upon.
#!/usr/bin/env python | |
import sys | |
""" | |
For each character c, if its value is: | |
#13: treat as newline | |
#128, #160: treat as space ' ' | |
#169..#171, #173, #174: treat as dash '-' | |
#192..#236: skip ahead and ignore all characters until another occurrence |
# From https://coderwall.com/p/-wbo5q/pip-install-a-specific-github-repo-tag-or-branch | |
pip install -e git://github.com/{ username }/{ reponame }.git@{ tag name }#egg={ desired egg name } |
#!/usr/bin/python3 | |
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
#============================================================================== | |
# Copyright (c) 2018, William Gurecky | |
# All rights reserved. | |
# | |
# DESCRIPTION: | |
# Inspired from stack overflow question: | |
# https://stackoverflow.com/questions/52227599/interpolate-griddata-uses-only-one-core |
IPython shell assignment (the !
operator) evaluates a command using the local shell (e.g., bash
) and returns a string list (IPython.utils.text.SList
). An SList
is a list-like object containing "chunks" of stdout and stderr, properties for accessing those chunks in different forms, and convenience methods for operating on them.
The SList.ipynb
notebook below uses SList
properties to access the output of a shell command as a list-like of strings, a newline-separated string, a space-separated string, and a list of pathlib.Path
objects. The notebook then uses the SList.fields()
and SList.grep()
methods to extract columns from and search command output.
In some applications of machine learning/TensorFlow, it is desirable to start multiple processes, and have separate training procedures running concurrently in each of those processes. A useful Python method for achieving this is the multiprocessing.pool.Pool.map()
method (or the equivalent starmap()
method when the target function takes multiple arguments; see the section "Process Pools" from the description of the multiprocessing module in the Python Library Reference).
The Pool.map()
method takes a target-function and a list (or more generally an iterable) of arguments, and returns an equivalent iterable of the results of the function evaluated on each member of the argument-list (which is similar to the [built-in Python function map()
import pathlib | |
from itertools import product | |
from tqdm import tqdm | |
import rasterio | |
import geosoft | |
import geosoft.gxpy.gx as gx | |
import geosoft.gxpy.coordinate_system as gxcs | |
import geosoft.gxpy.grid as gxgrid |