diff --git a/README.md b/README.md index f9d7d430517..db0eb12d13e 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,7 @@ In the scripts the comments etc are lined up correctly when they are viewed in [ - `testlines.py` - This very simple script open a file and prints out 100 lines of whatever is set for the line variable. -- `serial_scanner.py` contains a method called ListAvailablePorts which returns a list with the names of the serial ports that are in use in our computer, this method works only on Linux and Windows (can be extended for mac osx). If no port is found, an empty list is returned. \ No newline at end of file +- `serial_scanner.py` contains a method called ListAvailablePorts which returns a list with the names of the serial ports that are in use in our computer, this method works only on Linux and Windows (can be extended for mac osx). If no port is found, an empty list is returned. + +- `test.py` Build a connection string from a dictionary of parameters.Returns string. +- `ch1.py` matplotlib test diff --git a/ch1.py b/ch1.py new file mode 100644 index 00000000000..80360a037ea --- /dev/null +++ b/ch1.py @@ -0,0 +1,12 @@ +from matplotlib import pyplot as plt +#%matplotlib inline +variance = [1,2,4,8,16,32,64,128,256] +bias_squared=[256,128,64,32,16,8,4,2,1] +total_error=[x+y for x,y in zip(variance,bias_squared)] +xs = [i for i,_ in enumerate(variance)] +plt.plot(xs,variance,'g-',label='variance') +plt.plot(xs,bias_squared,'r-',label='bias^2') +plt.plot(xs,total_error,'b:',label='total_error') +plt.title('bias variance') +plt.legend(loc=9) +plt.show() \ No newline at end of file diff --git a/test.py b/test.py new file mode 100644 index 00000000000..3b08e356508 --- /dev/null +++ b/test.py @@ -0,0 +1,18 @@ + +def buildConnectionString(params): + """Build a connection string from a dictionary of parameters. + + Returns string.""" + return ";".join(["%s=%s" % (k, v) for k, v in params.items()]) + + +if __name__ == "__main__": + myParams = { + "server": "mpilgrim", + "database": "master", + "dfw": "dsfwee", + "uid": "sa", + "pwd": "secret", + "name":"hmq" + } + print buildConnectionString(myParams)