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
>>> tprint("test","mix") | |
†Ɛѕ† | |
>>> tprint("test","mix") | |
tᏋѕt | |
>>> tprint("test","mix") | |
꓄єร꓄ |
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 library | |
from undouble import Undouble | |
# Init with default settings | |
model = Undouble(method='phash', hash_size=8) | |
# Import example data | |
targetdir = model.import_example(data='flowers') | |
# Importing the files files from disk, cleaning and pre-processing |
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
# Load library | |
import matplotlib.pyplot as plt | |
from clustimage import Clustimage | |
# init | |
cl = Clustimage() | |
# Load example digit data | |
X = cl.import_example(data='mnist') | |
print(X) | |
# Each row is an image that can be plotted after reshaping: |
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
# Load library | |
import matplotlib.pyplot as plt | |
from clustimage import Clustimage | |
# init | |
cl = Clustimage() | |
# Load example digit data | |
X = cl.import_example(data='mnist') | |
print(X) | |
# Each row is an image that can be plotted after reshaping: |
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
# Get the unique images | |
unique_samples = cl.unique() | |
# | |
print(unique_samples.keys()) | |
# ['labels', 'idx', 'xycoord_center', 'pathnames'] | |
# | |
# Collect the unique images from the input | |
X[unique_samples['idx'],:] | |
# Plot unique images. |
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
# Make scatterplot | |
cl.scatter(zoom=None) | |
# Plot the image that is in the center of the cluster | |
cl.scatter(zoom=4) | |
# Lets change some more arguments to make a pretty scatterplot | |
cl.scatter(zoom=None, dotsize=200, figsize=(25, 15), args_scatter={'fontsize':24, 'gradient':'#FFFFFF', 'cmap':'Set2', 'legend':True}) |
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
@cache | |
def factorial(n): | |
return n * factorial(n-1) if n else 1 | |
>>> factorial(10) # no previously cached result, makes 11 recursive calls | |
3628800 | |
>>> factorial(5) # just looks up cached value result | |
120 | |
>>> factorial(12) # makes two new recursive calls, the other 10 are cached | |
479001600 |
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 functools import lru_cache | |
@lru_cache(maxsize=30) | |
def get_articles(on_date): | |
# Здесь затратная операция, выбирающая статьи | |
# на определённую дату. | |
articles = [...] |
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
<div id="d1"> | |
<ol id="ol1"> | |
<li id="li1">1</li> | |
<li id="li2">2</li> | |
</ol> |
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
var div = document.getElementById('d1') | |
var elems = div.getElementsByTagName('*') | |
for(var i=0; i<elems.length; i++) alert(elems[i].id) |