Skip to content

Commit

Permalink
codespell commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rflamary committed Oct 30, 2024
1 parent 3cfa1c8 commit ce6d2ea
Show file tree
Hide file tree
Showing 169 changed files with 20,254 additions and 9,212 deletions.
12 changes: 6 additions & 6 deletions benchmarks/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
def setup_backends():
if jax:
from jax.config import config

config.update("jax_enable_x64", True)

if tf:
from tensorflow.python.ops.numpy_ops import np_config

np_config.enable_numpy_behavior()


Expand All @@ -36,10 +38,7 @@ def exec_bench(setup, tested_function, param_list, n_runs, warmup_runs):
print(nx, param_list[i])
args = inputs[i]
results_nx = nx._bench(
tested_function,
*args,
n_runs=n_runs,
warmup_runs=warmup_runs
tested_function, *args, n_runs=n_runs, warmup_runs=warmup_runs
)
gc.collect()
results_nx_with_param_in_key = dict()
Expand All @@ -64,10 +63,11 @@ def convert_to_html_table(results, param_name, main_title=None, comments=None):
assert cpus_cols + gpus_cols == len(devices_names)

if main_title is not None:
string += f'<tr><th align="center" colspan="{length}">{str(main_title)}</th></tr>\n'
string += (
f'<tr><th align="center" colspan="{length}">{str(main_title)}</th></tr>\n'
)

for i, bitsize in enumerate(bitsizes):

if i != 0:
string += f'<tr><td colspan="{length}">&nbsp;</td></tr>\n'

Expand Down
20 changes: 9 additions & 11 deletions benchmarks/emd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

import numpy as np
import ot
from .benchmark import (
setup_backends,
exec_bench,
convert_to_html_table
)
from .benchmark import setup_backends, exec_bench, convert_to_html_table


def setup(n_samples):
Expand All @@ -31,10 +27,12 @@ def setup(n_samples):
tested_function=lambda a, M: ot.emd(a, a, M),
param_list=param_list,
n_runs=n_runs,
warmup_runs=warmup_runs
warmup_runs=warmup_runs,
)
print(
convert_to_html_table(
results,
param_name="Sample size",
main_title=f"EMD - Averaged on {n_runs} runs",
)
)
print(convert_to_html_table(
results,
param_name="Sample size",
main_title=f"EMD - Averaged on {n_runs} runs"
))
20 changes: 9 additions & 11 deletions benchmarks/sinkhorn_knopp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

import numpy as np
import ot
from .benchmark import (
setup_backends,
exec_bench,
convert_to_html_table
)
from .benchmark import setup_backends, exec_bench, convert_to_html_table


def setup(n_samples):
Expand All @@ -33,10 +29,12 @@ def setup(n_samples):
tested_function=lambda *args: ot.bregman.sinkhorn(*args, reg=1, stopThr=1e-7),
param_list=param_list,
n_runs=n_runs,
warmup_runs=warmup_runs
warmup_runs=warmup_runs,
)
print(
convert_to_html_table(
results,
param_name="Sample size",
main_title=f"Sinkhorn Knopp - Averaged on {n_runs} runs",
)
)
print(convert_to_html_table(
results,
param_name="Sample size",
main_title=f"Sinkhorn Knopp - Averaged on {n_runs} runs"
))
46 changes: 34 additions & 12 deletions docs/nb_run_conv
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ Created on Fri Sep 1 16:43:45 2017
@author: rflamary
"""

import sys
import json
import glob
import hashlib
import subprocess

import os

cache_file = 'cache_nbrun'
cache_file = "cache_nbrun"

path_doc = 'source/auto_examples/'
path_nb = '../notebooks/'
path_doc = "source/auto_examples/"
path_nb = "../notebooks/"


def load_json(fname):
Expand All @@ -34,7 +33,7 @@ def load_json(fname):


def save_json(fname, nb):
f = open(fname, 'w')
f = open(fname, "w")
f.write(json.dumps(nb))
f.close()

Expand All @@ -60,22 +59,45 @@ def to_update(fname, cache):


def update(fname, cache):

# jupyter nbconvert --to notebook --execute mynotebook.ipynb --output targte
subprocess.check_call(['cp', path_doc + fname, path_nb])
print(' '.join(['jupyter', 'nbconvert', '--to', 'notebook', '--ExecutePreprocessor.timeout=600', '--execute', path_nb + fname, '--inplace']))
subprocess.check_call(['jupyter', 'nbconvert', '--to', 'notebook', '--ExecutePreprocessor.timeout=600', '--execute', path_nb + fname, '--inplace'])
# jupyter nbconvert --to notebook --execute mynotebook.ipynb --output target
subprocess.check_call(["cp", path_doc + fname, path_nb])
print(
" ".join(
[
"jupyter",
"nbconvert",
"--to",
"notebook",
"--ExecutePreprocessor.timeout=600",
"--execute",
path_nb + fname,
"--inplace",
]
)
)
subprocess.check_call(
[
"jupyter",
"nbconvert",
"--to",
"notebook",
"--ExecutePreprocessor.timeout=600",
"--execute",
path_nb + fname,
"--inplace",
]
)
cache[fname] = md5(path_doc + fname)


cache = load_json(cache_file)

lst_file = glob.glob(path_doc + '*.ipynb')
lst_file = glob.glob(path_doc + "*.ipynb")

lst_file = [os.path.basename(name) for name in lst_file]

for fname in lst_file:
if to_update(fname, cache):
print('Updating file: {}'.format(fname))
print("Updating file: {}".format(fname))
update(fname, cache)
save_json(cache_file, cache)
6 changes: 3 additions & 3 deletions docs/rtd/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from recommonmark.parser import CommonMarkParser

source_parsers = {'.md': CommonMarkParser}
source_parsers = {".md": CommonMarkParser}

source_suffix = ['.md']
master_doc = 'index'
source_suffix = [".md"]
master_doc = "index"
Loading

0 comments on commit ce6d2ea

Please sign in to comment.