text
stringlengths 1
93.6k
|
|---|
args = "" if nbs else "--ignore=tests/test_sample_notebooks.py"
|
c.run(f"pytest {args}", pty=True)
|
c.run("flake8")
|
@task
|
def setup(c, version=None):
|
"""
|
Setup dev environment, requires conda
|
"""
|
version = version or "3.9"
|
suffix = "" if version == "3.9" else version.replace(".", "")
|
env_name = f"soorgeon{suffix}"
|
c.run(f"conda create --name {env_name} python={version} --yes")
|
c.run(
|
'eval "$(conda shell.bash hook)" '
|
f"&& conda activate {env_name} "
|
"&& pip install --editable .[dev]"
|
)
|
print(f"Done! Activate your environment with:\nconda activate {env_name}")
|
@task(aliases=["v"])
|
def version(c):
|
"""Create a new version of this project"""
|
from pkgmt import versioneer
|
versioneer.version(project_root=".", tag=True)
|
@task(aliases=["r"])
|
def release(c, tag, production=True):
|
"""Upload to PyPI (prod by default): inv upload {tag}"""
|
from pkgmt import versioneer
|
versioneer.upload(tag, production=production)
|
@task
|
def install_git_hook(c, force=False):
|
"""Installs pre-push git hook"""
|
path = Path(".git/hooks/pre-push")
|
hook_exists = path.is_file()
|
if hook_exists:
|
if force:
|
path.unlink()
|
else:
|
sys.exit(
|
"Error: pre-push hook already exists. "
|
'Run: "invoke install-git-hook -f" to force overwrite.'
|
)
|
shutil.copy(".githooks/pre-push", ".git/hooks")
|
print(f"pre-push hook installed at {str(path)}")
|
@task
|
def uninstall_git_hook(c):
|
"""Uninstalls pre-push git hook"""
|
path = Path(".git/hooks/pre-push")
|
hook_exists = path.is_file()
|
if hook_exists:
|
path.unlink()
|
print(f"Deleted {str(path)}.")
|
else:
|
print("Hook doesn't exist, nothing to delete.")
|
# <FILESEP>
|
import gc, os, glob, argparse, h5py
|
import numpy as np
|
import tflearn
|
import tensorflow as tf
|
import tensorflow.contrib.slim as slim
|
from functools import reduce # for calculating PSNR
|
from operator import mul # for calculating the num of parameters
|
import net_MFCNN
|
def transformer(batch, chan, flow, U , out_size, name='SpatialTransformer', **kwargs):
|
def _repeat(x, n_repeats):
|
with tf.variable_scope('_repeat'):
|
rep = tf.transpose(
|
tf.expand_dims(tf.ones(shape=tf.stack([n_repeats, ])), 1), [1, 0])
|
rep = tf.cast(rep, 'int32')
|
x = tf.matmul(tf.reshape(x, (-1, 1)), rep)
|
return tf.reshape(x, [-1])
|
def _repeat2(x, n_repeats):
|
with tf.variable_scope('_repeat'):
|
rep = tf.expand_dims(tf.ones(shape=tf.stack([n_repeats, ])), 1)
|
rep = tf.cast(rep, 'int32')
|
x = tf.matmul(rep, tf.reshape(x, (1, -1)))
|
return tf.reshape(x, [-1])
|
def _interpolate(im, x, y, out_size):
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.