Skip to content

Instantly share code, notes, and snippets.

@embray
Created August 22, 2014 12:43
Show Gist options
  • Save embray/eeca77fc78352a963e9f to your computer and use it in GitHub Desktop.
Save embray/eeca77fc78352a963e9f to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:698f43ffbc1037673aa67f6385d8b2d9c027d64232c4ac5fb2b03c623e76c637"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"from astropy.modeling import Model\n",
"from astropy.modeling.models import Rotation2D"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"class Swap(Model):\n",
" \"\"\"Passes through the given inputs, swapped.\"\"\"\n",
" \n",
" inputs = ('x', 'y')\n",
" outputs = ('y', 'x')\n",
" \n",
" # No parameters\n",
" \n",
" @staticmethod\n",
" def evaluate(x, y):\n",
" return y, x"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"r = Rotation2D(angle=90)\n",
"r(0, 1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": [
"(-1.0, 6.123233995736766e-17)"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"RotationSwapped = Rotation2D | Swap"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"r_swapped = RotationSwapped(90)\n",
"r_swapped(0, 1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"(6.123233995736766e-17, -1.0)"
]
}
],
"prompt_number": 5
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment