This file contains 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
/** | |
* Simple jQuery utility for saving element values in localStorage. | |
* | |
* Usage: | |
* - Add class "store-state" to the element you want to save. | |
* - Add id attribute to the element or specify your own storage key (attribute data-storage-name) | |
* - Add attribute "data-storage-name" to the element if you | |
* want to control under which name the value will be stored | |
* - Add attribute "data-storage-noload" to suppress loading (will be stored though, it is | |
* useful, when HTML-specified value is temporarily more important). |
This file contains 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 dicom | |
import h5py | |
def export_pixel_array(in_file, out_file, dataset_name="data"): | |
pixel_array = dicom.read_file(in_file).pixel_array | |
h5 = h5py.File(out_file) | |
h5.create_dataset(dataset_name, data=pixel_array) | |
h5.close() |
This file contains 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 numbers | |
from typing import Literal, Optional, Union | |
import numpy as np | |
import pandas as pd | |
def normalize_series( | |
series: pd.Series, | |
*, |
This file contains 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 | |
def gamma_matrix(rm, tm, dta=1.0, dd=0.05): | |
'''Compute matrix of gammma indices. | |
:param rm: reference matrix (relative values assumed) | |
:param tm: tested matrix (relative values assumed) | |
:param dta: maximum distance-to-agreement (in voxels) | |
:param dd: maximum dose difference |
This file contains 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 h5py | |
import os | |
def _report(operation, key, obj): | |
type_str = type(obj).__name__.split(".")[-1].lower() | |
print "%s %s: %s." % (operation, type_str, key) | |
def h5py_compatible_attributes(in_object): | |
'''Are all attributes of an object readable in h5py?''' | |
try: |
This file contains 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 matplotlib.pyplot as plt | |
import numpy as np | |
from draw import * | |
from data import * | |
fig, ax = plt.subplots(figsize=(20, 12)) | |
nonwallcolor = "#c0c0c0" | |
This file contains 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
# 1. Spočítejte a nakreslete graf, jak se v průběhu let vyvíjel | |
# celkový počet udělených medailí (zvlášť pro zimní a letní hry). | |
import pandas as pd | |
import seaborn as sns | |
%matplotlib inline | |
olympics = pd.read_csv("athlete_events.csv") |
This file contains 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 bokeh.plotting import figure, show, output_notebook | |
from bokeh.models import HoverTool | |
from bokeh.tile_providers import Vendors, get_provider | |
import pandas as pd | |
def web_mercator(long, lat): | |
import numpy as np | |
scale_x = 4e7 / 360 | |
limit_lat = 2 * np.arctan(np.exp(np.pi)) - np.pi / 2 |
This file contains 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 os | |
from typing import List, Optional | |
import pandas | |
class DataReader: | |
def __init__(self, root_path: str): | |
self.root_path = root_path |
This file contains 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 Jablko: | |
def __init__(self): | |
self.__bar = 123 | |
@staticmethod | |
def show_me(o): | |
print(o.__bar) | |
class IgnorePrivateMembers: | |
def __getattr__(self, name: str): |
NewerOlder