- Update HISTORY.rst
- Update version number in
my_project/__init__.py - Update version number in
setup.py - Run the tests:
python setup.py test
tox
- Commit the changes:
| for i = 1:10 | |
| print(i) | |
| end |
| import urllib | |
| from xml.etree.ElementTree import parse | |
| URL = '''http://jameslyons0.blogspot.com.au/feeds/posts/default?max-results=9999''' | |
| xml = parse(urllib.urlopen(URL)).getroot() | |
| info = {} | |
| for post in xml.getchildren(): | |
| if post.tag=='{http://www.w3.org/2005/Atom}entry': | |
| headers,title,link=[],None,None |
| # we need 2 helper mappings, from letters to ints and the inverse | |
| L2I = dict(zip("ABCDEFGHIJKLMNOPQRSTUVWXYZ",range(26))) | |
| I2L = dict(zip(range(26),"ABCDEFGHIJKLMNOPQRSTUVWXYZ")) | |
| key = 3 | |
| plaintext = "DEFEND THE EAST WALL OF THE CASTLE" | |
| # encipher | |
| ciphertext = "" | |
| for c in plaintext.upper(): |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <ctype.h> | |
| int main(int argc, char *argv[]){ | |
| char plaintext[] = "DEFEND THE EAST WALL OF THE CASTLE"; | |
| int L = strlen(plaintext); | |
| char *ciphertext = malloc(sizeof(char)*(L+1)); |
| // enciphering | |
| plaintext = "DEFEND THE EAST WALL OF THE CASTLE"; | |
| var key = 3; | |
| ciphertext = ""; var re = /[a-z]/; | |
| for(i=0; i<plaintext.length; i++){ | |
| if(re.test(plaintext.charAt(i))) ciphertext += String.fromCharCode((plaintext.charCodeAt(i) - 97 + key)%26 + 97); | |
| else ciphertext += plaintext.charAt(i); | |
| } | |
| // deciphering |
| # return the autocorrelation of x | |
| function ac(x) | |
| N = length(x) | |
| # zero pad x | |
| x = [x,zeros(N-1)] | |
| R = irfft(abs(rfft([2,3,1,0,0])).^2, 2*N-1) | |
| R[1:N] | |
| end | |
| x = [2,3,1] |
| function levinson(R,L) | |
| a = zeros(L,L) | |
| P = zeros(1,L) | |
| # for m = 1 | |
| a[1,1] = -R[2]/R[1] | |
| P[1] = R[1]*(1-a[1,1]^2) | |
| # for m = 2,3,4,..L | |
| for m = 2:L |
| function arcov(x,L) | |
| N = length(x) | |
| phi = zeros(L+1,L+1) | |
| for k = 0:L, i=0:L, n=L:N-1 | |
| phi[k+1,i+1] += x[n+1-k]*x[n+1-i] | |
| end | |
| phi = phi./(N-L) | |
| a = phi[2:end,2:end]\-phi[2:end,1] | |
| P = phi[1,1] + phi[1,2:end]*a |
| function armcov(x,L) | |
| N = length(x) | |
| phi = zeros(L+1,L+1) | |
| for k = 0:L, i=0:L, n=0:N-L-1 | |
| phi[k+1,i+1] += x[n+1+k]*x[n+1+i] + x[n+1+L-k]*x[n+1+L-i] | |
| end | |
| phi = phi./(2*(N-L)) | |
| a = phi[2:end,2:end]\-phi[2:end,1] | |
| P = phi[1,1] + phi[1,2:end]*a |
my_project/__init__.pysetup.pypython setup.py test
tox