Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env python3 | |
from collections import defaultdict | |
from itertools import chain | |
def find_maximal_subsets(sets: list[set]) -> set[frozenset]: | |
""" | |
Find the maximal subsets of items that always appear together in a group of sets. |
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
#!/usr/bin/env python3 | |
import random | |
import matplotlib.pyplot as plt | |
numbers = tuple(range(100)) | |
def trial(N: int) -> bool: | |
S = random.choices(numbers, k=N) |
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
def rename_coordinates(dataset: "xarray.Dataset", dim: str, mapping: dict[str, str]) -> "xarray.Dataset": | |
return dataset.assign_coords(**{dim: [mapping[k] for k in dataset.coords[dim].values]}) | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | |
ax = plt.gca() | |
axis_to_data = ax.transAxes + ax.transData.inverted() | |
data_to_axis = axis_to_data.inverted() |
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 aesara as ae | |
import numpy as np | |
print("aesara version", ae.__version__) | |
np.random.seed(42) | |
m, n = 10, 12 | |
arr = np.random.choice([0, 1], p=[0.75, 0.25], size=m * n).reshape(m, n) | |
print("\ninput:") |
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 arviz as az | |
def make_trace(path: str, fun: Callable, *args, **kwargs): | |
""" | |
Try to load a pymc trace from a path. If the path doesn't exist then generate | |
the trace by calling fun. | |
Args: | |
path: Path to Netcdf file. | |
fun: Callable that returns a PyMC trace. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 IPython.display import HTML | |
HTML(""" | |
<script> | |
code_show = true; | |
function code_toggle() { | |
if (code_show) { | |
$('div.input').hide(); | |
} else { | |
$('div.input').show(); | |
} code_show = !code_show |
NewerOlder