This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> I = 1 | |
>>> t = 1 | |
>>> ( +~~~~~~~~+ | |
... I | | |
... +~~~~~~~~t ) | |
1 | |
# You can also do 3D analog literals. It is not quite as nice as in C/C++ | |
# because none of python's unary math operators resemble a vertical ASCII art | |
# element. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://github.com/SDiot/chaco_troubles/blob/master/Plot_LayoutTrouble.py | |
""" Simple example to show a problem with the Layout | |
HOW TO: | |
1) Run Plot_LayoutTrouple.py | |
2) Zoom by creating a rectangular box with the left click so that the aspect_ratio is changed | |
3) Click on Reset Asp. Ratio | |
4) Click on Reset View ===> the plot is not taking all the room it could! | |
5) Resize the window ===> the plot is now taking all the room it can! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://github.com/SDiot/chaco_troubles/blob/master/Plot_PaddingTrouble.py | |
""" Simple example to show that I have a problem with padding | |
HOW TO: | |
1) Run Plot_PaddingTrouple.py | |
2) Click on Replot ===> the padding is not taken into account while it | |
is enforced in plot_please... Why?? | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from bokeh.plotting import * | |
N = 10 | |
import sys | |
output_file("bigint.html", title="bigint example") | |
for div in (1, 10, 100, 1000, 10000, 100000, 1000000): | |
bigint = sys.maxint / 2 / div - 100 | |
x = range(bigint, bigint+10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A replacement for the Instance.__get__() from | |
# https://github.com/ContinuumIO/bokeh/blob/master/bokeh/properties.py#L832 | |
def __get__(self, obj, owner, type=None): | |
# If the constructor for Instance() supplied a class name, we should | |
# instantiate that class here, instead of returning the class as the | |
# default object | |
if obj is not None and not hasattr(obj, self._name): | |
if type and self.default and isinstance(self.default, type): | |
setattr(obj, self._name, self.default()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Structure(object): | |
_fields = [] | |
def __init__(self, *args, **kw): | |
""" Generic constructor which initializes the object with the passed- | |
in values, based on positional order and name in the **_fields** | |
class variable. Subclasses need to define **_fields** appropriately. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fieldparse.py | |
import collections | |
def parse(lines,types,names): | |
if not isinstance(lines, collections.Iterable) or isinstance(lines, str): | |
raise TypeError("lines must be an iterable container of strings") | |
if not isinstance(types, collections.Sequence) or \ | |
not isinstance(names, collections.Sequence): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Originally from http://azurlingua-culture.com/en/general/loup-en-croute-de-sel-3/) | |
Not many foreigners know what “loup” means in France when it’s not the | |
male wolf that is being refered to. If you come to learn French in | |
Nice, you will know that ‘le loup (in the Mediterranean)’, or “bar” | |
(as it is called in the Atlantic) means “sea bass” in English, | |
“lubina” in Spanish, “Wolfsbarsch” in German, “baixo do mar” in | |
Portuguese, “mořský okoun” in Czech, “морской окунь” in Russian, | |
“branzino” in Italian, “mare bas” in Romanian, … One of the best fish | |
in ‘western seas’. I can’t guarantee that all of the translations are |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One man's constant is another man's variable. | |
Functions delay binding: data structures induce binding. Moral: Structure data late in the programming process. | |
If a program manipulates a large amount of data, it does so in a small number of ways. | |
Symmetry is a complexity reducing concept (co-routines include sub-routines); seek it everywhere. | |
It is easier to write an incorrect program than understand a correct one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# Create some dummy data (a 2D cosine function) and scale it to 255 | |
xs, ys = np.meshgrid(np.linspace(-5,5,500), np.linspace(-5,5,500), | |
indexing = "xy") | |
data = np.cos(np.sqrt(xs*xs + ys*ys)) * 255 | |
image = plt.imshow(data, cmap="ocean") | |
plt.colorbar() |
OlderNewer