repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
emcee3 | emcee3-master/emcee3/numgrad.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
__all__ = ["numerical_gradient_1", "numerical_gradient_2"]
class numerical_gradient_1(object):
"""Wrap a function to numerically compute first order gradients.
The function is expected to take a numpy array as its fi... | 1,749 | 26.34375 | 76 | py |
emcee3 | emcee3-master/emcee3/backends/hdf.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
try:
import h5py
except ImportError:
h5py = None
from .backend import Backend
__all__ = ["HDFBackend"]
class HDFBackend(Backend):
def __init__(self, filename, name="mcmc", **kwargs):
if h5py is None:
... | 3,972 | 28.213235 | 76 | py |
emcee3 | emcee3-master/emcee3/backends/backend.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from ..autocorr import integrated_time
__all__ = ["Backend"]
class Backend(object):
"""The default backend that stores the data in memory as numpy arrays.
The backend can be subscripted to access the data.
Attr... | 7,700 | 31.357143 | 78 | py |
emcee3 | emcee3-master/emcee3/backends/__init__.py | # -*- coding: utf-8 -*-
"""
These backends abstract the storage of and access to emcee3 MCMC chains.
"""
from .backend import Backend
from .hdf import HDFBackend
__all__ = ["Backend", "HDFBackend"]
| 201 | 17.363636 | 72 | py |
emcee3 | emcee3-master/emcee3/pools/jl.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
__all__ = ["JoblibPool"]
try:
from joblib import Parallel, delayed
except ImportError:
Parallel = None
class JoblibPool(object):
def __init__(self, *args, **kwargs):
if Parallel is None:
raise ImportError("jobl... | 550 | 20.192308 | 55 | py |
emcee3 | emcee3-master/emcee3/pools/__init__.py | # -*- coding: utf-8 -*-
from .default import DefaultPool
from .interruptible import InterruptiblePool
from .jl import JoblibPool
__all__ = ["DefaultPool", "InterruptiblePool", "JoblibPool"]
| 192 | 23.125 | 60 | py |
emcee3 | emcee3-master/emcee3/pools/default.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
__all__ = ["DefaultPool"]
try:
from itertools import imap
except ImportError:
imap = map
class DefaultPool(object):
def map(self, fn, iterable):
return imap(fn, iterable)
| 269 | 14.882353 | 47 | py |
emcee3 | emcee3-master/emcee3/pools/interruptible.py | # -*- coding: utf-8 -*-
"""
Python's multiprocessing.Pool class doesn't interact well with
``KeyboardInterrupt`` signals, as documented in places such as:
* `<http://stackoverflow.com/questions/1408356/>`_
* `<http://stackoverflow.com/questions/11312525/>`_
* `<http://noswap.com/blog/python-multiprocessing-keyboardin... | 3,252 | 31.207921 | 78 | py |
emcee3 | emcee3-master/emcee3/tests/common.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import os
import numpy as np
from tempfile import NamedTemporaryFile
from .. import backends
from ..model import Model, SimpleModel
__all__ = ["NormalWalker", "MetadataWalker", "UniformWalker"]
class NormalWalker(Model):
def __init__(sel... | 1,935 | 24.813333 | 76 | py |
emcee3 | emcee3-master/emcee3/tests/__init__.py | # -*- coding: utf-8 -*-
from . import unit, integration
__all__ = ["unit", "integration"]
| 92 | 14.5 | 33 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_pickle.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import pickle
import numpy as np
from multiprocessing import Pool
from ... import moves, pools, Ensemble
from ...model import SimpleModel
from ..common import NormalWalker
__all__ = ["test_walker_pickle", "test_ensemble_pickle", "test_moves_pickl... | 1,493 | 26.163636 | 77 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_backends.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from ... import backends, Sampler, Ensemble
from ..common import NormalWalker, TempHDFBackend, MetadataWalker
__all__ = ["test_metadata", "test_hdf", "test_hdf_reload"]
def run_sampler(backend, model=NormalWalker(1.0), nwalk... | 2,894 | 34.740741 | 77 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_models.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
from ..common import UniformWalker
__all__ = ["test_simple"]
def test_simple():
UniformWalker()
| 177 | 13.833333 | 47 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_numgrad.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import pytest
import numpy as np
from itertools import product
from ...numgrad import numerical_gradient_1, numerical_gradient_2
__all__ = ["test_numgrad"]
def f1(x):
return -0.5 * np.sum(x**2)
def dfdx1(x):
return -x
def f2(x):
... | 882 | 17.020408 | 65 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_sampler.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import pytest
import numpy as np
from ... import moves, backends, Sampler, Ensemble
from ..common import NormalWalker, TempHDFBackend
__all__ = ["test_schedule", "test_shapes", "test_errors", "test_thin"]
def test_schedule():
# The default... | 6,278 | 34.275281 | 77 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_stretch.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from ... import moves, Ensemble
from ..common import NormalWalker
__all__ = ["test_live_dangerously"]
def test_live_dangerously(nwalkers=32, nsteps=3000, seed=1234):
# Set up the random number generator.
rnd = np.ra... | 834 | 24.30303 | 71 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_autocorr.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import pytest
import numpy as np
from ...autocorr import integrated_time, AutocorrError
__all__ = ["test_nd", "test_too_short"]
def get_chain(seed=1234, ndim=3, N=100000):
np.random.seed(seed)
a = 0.9
x = np.empty((N, ndim))
x[... | 1,109 | 25.428571 | 54 | py |
emcee3 | emcee3-master/emcee3/tests/unit/__init__.py | 0 | 0 | 0 | py | |
emcee3 | emcee3-master/emcee3/tests/unit/test_state.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from ...state import State
__all__ = ["test_dtype", "test_serialization", "test_repr"]
def test_dtype(seed=1234):
np.random.seed(seed)
dtype = [
("coords", np.float64, (4, )),
("log_prior", np.float... | 1,654 | 23.338235 | 77 | py |
emcee3 | emcee3-master/emcee3/tests/unit/test_ensemble.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import pytest
import numpy as np
from ... import Ensemble
from ..common import NormalWalker, UniformWalker
__all__ = ["test_invalid_coords_init", "test_invalid_dims_init",
"test_valid_init"]
def test_invalid_coords_init(nwalkers=32... | 1,237 | 29.195122 | 76 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_gaussian.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import pytest
import numpy as np
from ... import moves
from itertools import product
from .test_proposal import _test_normal, _test_uniform
__all__ = ["test_normal_gaussian", "test_uniform_gaussian",
"test_normal_gaussian_nd"]
@pyte... | 2,067 | 32.901639 | 78 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_proposal.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from scipy import stats
from ... import Ensemble
from ..common import NormalWalker, UniformWalker
__all__ = ["_test_normal", "_test_uniform"]
def _test_normal(proposal, ndim=1, nwalkers=32, nsteps=2000, seed=1234,
... | 2,389 | 30.038961 | 76 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_de_snooker.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
from ... import moves
from .test_proposal import _test_normal, _test_uniform
__all__ = ["test_normal_de_snooker", "test_uniform_de_snooker"]
def test_normal_de_snooker(**kwargs):
_test_normal(moves.DESnookerMove(), **kwargs)
def test_uni... | 398 | 22.470588 | 63 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_hmc.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
from ... import moves
from .test_proposal import _test_normal
__all__ = ["test_normal_hmc", "test_normal_hmc_nd"]
def test_normal_hmc(**kwargs):
_test_normal(moves.HamiltonianMove((10, 20), (0.05, 0.1)), nsteps=100,
check_... | 634 | 25.458333 | 74 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_walk.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
from ... import moves
from .test_proposal import _test_normal, _test_uniform
__all__ = ["test_normal_walk", "test_uniform_walk"]
def test_normal_walk(**kwargs):
_test_normal(moves.WalkMove(s=3), **kwargs)
def test_uniform_walk(**kwargs):... | 370 | 20.823529 | 54 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_nuts.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import pytest
from ... import moves
from .test_proposal import _test_normal
__all__ = ["test_normal_nuts", ]
@pytest.mark.xfail
def test_normal_nuts(**kwargs):
_test_normal(moves.NoUTurnsMove((1.0, 2.0)), nwalkers=1, nsteps=2000,
... | 352 | 21.0625 | 73 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_stretch.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
from ... import moves
from .test_proposal import _test_normal, _test_uniform
__all__ = ["test_normal_stretch", "test_uniform_stretch",
"test_nsplits_stretch"]
def test_normal_stretch(**kwargs):
_test_normal(moves.StretchMove(), ... | 620 | 22.884615 | 67 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_kde.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
from ... import moves
from .test_proposal import _test_normal, _test_uniform
__all__ = ["test_normal_kde", "test_uniform_kde", "test_nsplits_kde"]
def test_normal_kde(**kwargs):
_test_normal(moves.KDEMove(), **kwargs)
def test_uniform_kd... | 465 | 21.190476 | 69 | py |
emcee3 | emcee3-master/emcee3/tests/integration/test_de.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
from ... import moves
from .test_proposal import _test_normal, _test_uniform
__all__ = ["test_normal_de", "test_uniform_de"]
def test_normal_de(**kwargs):
_test_normal(moves.DEMove(1e-2), **kwargs)
def test_uniform_de(**kwargs):
_tes... | 360 | 20.235294 | 54 | py |
emcee3 | emcee3-master/emcee3/tests/integration/__init__.py | 0 | 0 | 0 | py | |
emcee3 | emcee3-master/emcee3/samplers/sampler.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import logging
import numpy as np
from collections import Iterable
from ..moves import StretchMove
from ..backends import Backend
try:
from tqdm import tqdm
except ImportError:
tqdm = None
__all__ = ["Sampler"]
class Sampler(object):... | 7,172 | 32.518692 | 79 | py |
emcee3 | emcee3-master/emcee3/samplers/__init__.py | # -*- coding: utf-8 -*-
from .sampler import Sampler
__all__ = ["Sampler"]
| 77 | 12 | 28 | py |
emcee3 | emcee3-master/emcee3/moves/de_snooker.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from .red_blue import RedBlueMove
__all__ = ["DESnookerMove"]
class DESnookerMove(RedBlueMove):
"""A snooker proposal using differential evolution.
Based on `Ter Braak & Vrugt (2008)
<http://link.springer.com/ar... | 1,444 | 32.604651 | 78 | py |
emcee3 | emcee3-master/emcee3/moves/kde.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
try:
from scipy.stats import gaussian_kde
except ImportError:
gaussian_kde = None
from .red_blue import RedBlueMove
__all__ = ["KDEMove"]
class KDEMove(RedBlueMove):
"""
Use a continuously evolving KDE prop... | 1,237 | 29.195122 | 93 | py |
emcee3 | emcee3-master/emcee3/moves/gaussian.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from .mh import MHMove
__all__ = ["GaussianMove"]
class GaussianMove(MHMove):
"""A Metropolis step with a Gaussian proposal function.
Args:
cov: The covariance of the proposal function. This can be a scalar... | 4,020 | 32.789916 | 78 | py |
emcee3 | emcee3-master/emcee3/moves/mh.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
__all__ = ["MHMove"]
class MHMove(object):
"""
A general Metropolis-Hastings proposal.
:param proposal:
The proposal function. It should take 2 arguments: a numpy-compatible
random number generato... | 2,019 | 30.5625 | 77 | py |
emcee3 | emcee3-master/emcee3/moves/walk.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from .red_blue import RedBlueMove
__all__ = ["WalkMove"]
class WalkMove(RedBlueMove):
"""
A `Goodman & Weare (2010)
<http://msp.berkeley.edu/camcos/2010/5-1/p04.xhtml>`_ "walk move" with
parallelization as de... | 1,087 | 29.222222 | 75 | py |
emcee3 | emcee3-master/emcee3/moves/hmc.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from ..state import State
__all__ = ["HamiltonianMove"]
class _hmc_wrapper(object):
def __init__(self, random, model, cov, epsilon, nsteps=None):
self.random = random
self.model = model
self.nste... | 5,773 | 33.16568 | 78 | py |
emcee3 | emcee3-master/emcee3/moves/stretch.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from .red_blue import RedBlueMove
__all__ = ["StretchMove"]
class StretchMove(RedBlueMove):
"""
A `Goodman & Weare (2010)
<http://msp.berkeley.edu/camcos/2010/5-1/p04.xhtml>`_ "stretch move" with
parallelizat... | 914 | 27.59375 | 77 | py |
emcee3 | emcee3-master/emcee3/moves/__init__.py | # -*- coding: utf-8 -*-
from .walk import WalkMove
from .stretch import StretchMove
from .de import DEMove
from .de_snooker import DESnookerMove
from .kde import KDEMove
from .mh import MHMove
from .gaussian import GaussianMove
from .hmc import HamiltonianMove
from .nuts import NoUTurnsMove
__all__ = [
"Stretch... | 472 | 17.192308 | 37 | py |
emcee3 | emcee3-master/emcee3/moves/nuts.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import copy
import numpy as np
from ..state import State
from .hmc import HamiltonianMove, _hmc_wrapper
__all__ = ["NoUTurnsMove"]
class _nuts_wrapper(_hmc_wrapper):
def __init__(self, random, model, cov, epsilon, max_depth=500,
... | 4,630 | 33.303704 | 78 | py |
emcee3 | emcee3-master/emcee3/moves/de.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
from .red_blue import RedBlueMove
__all__ = ["DEMove"]
class DEMove(RedBlueMove):
"""A proposal using differential evolution.
This `Differential evolution proposal
<http://www.stat.columbia.edu/~gelman/stuff_for... | 1,492 | 30.765957 | 77 | py |
emcee3 | emcee3-master/emcee3/moves/red_blue.py | # -*- coding: utf-8 -*-
from __future__ import division, print_function
import numpy as np
__all__ = ["RedBlueMove"]
class RedBlueMove(object):
"""
An abstract red-blue ensemble move with parallelization as described in
`Foreman-Mackey et al. (2013) <http://arxiv.org/abs/1202.3665>`_.
Args:
... | 3,974 | 34.810811 | 79 | py |
emcee3 | emcee3-master/examples/plot_face.py | # -*- coding: utf-8 -*-
"""
=====================
A short Python script
=====================
A script that is not executed when gallery is generated but nevertheless
gets included as an example.
Doing a list
"""
# Code source: Óscar Nájera
# License: BSD 3 clause
from __future__ import print_function
print([i for i ... | 335 | 20 | 72 | py |
emcee3 | emcee3-master/documents/emcee/plots/plot_acor.py | import numpy as np
import matplotlib.pyplot as pl
import os
import sys
# sys.path.prepend(os.path.abspath(os.path.join(__file__, "..", "..", "..")))
# import emcee
def plot_acor(acorfn):
pass
| 200 | 14.461538 | 77 | py |
emcee3 | emcee3-master/documents/emcee/plots/oned.py | import os
import sys
import time
import numpy as np
import matplotlib.pyplot as pl
import h5py
from multiprocessing import Pool
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..", "..")))
import emcee
# import acor
def lnprobfn(p, icov):
return -0.5 * np.dot(p, np.dot(icov, p))
def random_cov... | 2,164 | 22.791209 | 77 | py |
emcee3 | emcee3-master/docs/conf.py | # -*- coding: utf-8 -*-
import os
import sys
d = os.path.dirname
sys.path.insert(0, d(d(os.path.abspath(__file__))))
import emcee3 # NOQA
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx_gallery.gen_gallery",
]
templates_path = ["_templates"]
source_suffix = ... | 1,488 | 22.265625 | 62 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Image_Functions/image.py |
import numpy as np
def pad_vol_2_size(im, shape, fill_method='constant', fill_value=0):
r""" Utility function to center and copy the given volumetric image into a larger volume.
Parameters
----------
im : (MxNxL) array
input volume to copy
shape : (m,n,l) array
new volume shape
fill_method : str
met... | 13,486 | 31.420673 | 281 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Image_Functions/smoothn.py |
# from numpy import *
# def _H(y,t0=0):
# '''
# Step fn with step at t0
# '''
# h = np.zeros_like(y)
# args = tuple([slice(0,y.shape[i]) for i in y.ndim])
from scipy.fftpack.realtransforms import dct,idct
def smoothn(y, nS0=10,
axis=None,
smoothOrder=2.0,
sd=None,
verb... | 22,583 | 31.401722 | 151 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Image_Functions/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Image_Functions/recolor.py | """
This module collects together scripts to recolor images for applications such as histogram matching, color transfer etc.
"""
import numpy as np
def image_stats(image):
r""" Computes the mean and standard deivation of each channel in an RGB-like 2D image, (MxNx3)
Parameters
----------
image :... | 14,184 | 37.546196 | 262 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Unzipping/unzip.py |
import numpy as np
def voxelize_unwrap_params(unwrap_params,
vol_shape,
preupsample=None,
ksize=3,
smooth_sigma=3,
erode_ksize=1):
r""" Voxelizes an unwrapped surfa... | 58,212 | 47.269486 | 299 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Unzipping/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Visualisation/plotting.py |
import pylab as plt
def set_axes_equal(ax: plt.Axes):
r"""Set 3D plot axes to equal scale.
Make axes of 3D plot have equal scale so that spheres appear as
spheres and cubes as cubes. Required since `ax.axis('equal')`
and `ax.set_aspect('equal')` don't work on 3D.
Parameters
----------
... | 1,422 | 22.327869 | 86 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Visualisation/imshowpair.py |
def imshowpair(im1,im2, ax=None):
r""" Combines two potentially different sized grayscale images into one image.
Parameters
----------
im1 : (M1,N1) grayscale numpy array
input image 1
im2 : (M2,N2) grayscale numpy array
input image 2
ax : Matplotlib axes object
o... | 3,585 | 30.734513 | 198 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Visualisation/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Visualisation/volume_img.py |
import numpy as np
def montage_vol_proj(vol, proj_fn=np.max):
r"""Given a 3D grayscale volumetric imageand a projection function such as np.max, generates projected views onto x-y, x-z, y-z and montages them into one view.
Parameters
----------
vol : (M,N,L) numpy array
input grayscale vol... | 1,123 | 33.060606 | 166 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Visualisation/grid_img.py |
def viz_grid(im_array, shape=None, cmap='gray', figsize=(10,10)):
r""" given an array of images, plots them montage style in matplotlib
Parameters
----------
im_array : n_img x n_rows x n_cols (x 3) grayscale or color numpy array
array of n_img images to display
shape : (i,j) integer t... | 1,745 | 28.59322 | 141 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Visualisation/colors.py |
def get_colors(inp, colormap, vmin=None, vmax=None, bg_label=None):
r""" Maps a given numpy input array with the specified Matplotlib colormap with optional specified minimum and maximum values. For an array that is integer such as that from multi-label segmentation, bg_label helps specify the background class wh... | 1,328 | 38.088235 | 314 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Analysis_Functions/topography.py |
from ..Mesh import meshtools as meshtools
from ..Segmentation import segmentation as segmentation
from ..Unzipping import unzip as uzip
from ..Image_Functions import image as image_fn
def uv_depth_pts3D_to_xyz_pts3D( uv_pts3D, uv_depth_params):
r""" Linear Interpolation of the corresponding (x,y,z) coordinates ... | 35,882 | 50.334764 | 336 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Analysis_Functions/timeseries.py |
def linear_fit(x,y):
r""" Ordinary linear least regressions fit to a 1d array of x and y data
Parameters
----------
x : numpy array
the independent variable
y : numpy array
the dependent variable
Returns
-------
opts : ``LinregressResult`` instance
The return value is an object with the following att... | 17,506 | 31.907895 | 246 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Analysis_Functions/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Utility_Functions/file_io.py |
def read_czifile(czi_file, squeeze=True):
r""" Reads the data of a simple .czi microscope stack into a numpy array using the lightweight czifile library
Parameters
----------
czifile : filepath
path of the .czi file to read
squeeze : bool
specify whether singleton dimensions... | 4,215 | 28.900709 | 190 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Utility_Functions/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Utility_Functions/stack.py |
def bounding_box(mask3D):
r""" Given a binary mask in 3D, locate the xyz corners of the tightest bounding box without geometric transformation.
Parameters
----------
mask3D : (M,N,L) binary np.bool array
3D binary image to compute the bounding box coordinates for
Retur... | 4,547 | 33.984615 | 181 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Segmentation/segmentation.py |
import numpy as np
def smooth_vol(vol, ds=4, smooth=5, method='gaussian'):
r""" Smoothing particularly a 3D volume image with large Gaussian kernels or Median filters is extremely slow. This function combines downsampling of the original volume image with smaller kernel smoothing on the downsampled image before ... | 52,509 | 41.346774 | 442 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Segmentation/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Geometry/geometry.py |
import numpy as np
def squicircle(uv, _epsilon = 0.0000000001):
r""" Compute the squicircle mapping unit disk coordinates to the square on [-1,1]x[-1,1]
see 'Analytical Methods for Squaring the Disc' - https://arxiv.org/abs/1509.06344
Parameters
----------
uv_ : (n_vertices,2) array
th... | 57,256 | 33.265111 | 469 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Registration/registration.py | """
This module implements various different registration algorithms
"""
# these that are commented out should now be incorporated into individual functions below
# from ..Utility_Functions import file_io as fio
# from ..Visualisation import imshowpair as imshowpair
# from ..Geometry import geometry as geom
# from... | 52,919 | 39.73903 | 324 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Registration/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Tracking/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Tracking/tracking.py | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 15 16:50:05 2022
@author: felix
"""
from ..Utility_Functions import file_io as fio
import numpy as np
# is there a quick way to compute the occupied bbox density.
def remove_very_large_bbox(boxes, shape, thresh=0.5, aspect_ratio=None, method='density', max_density=4,... | 72,029 | 42.920732 | 256 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Parameters/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Parameters/params.py | """
This module generates some general default parameter settings to help get started with certain functions with many parameters
"""
def optimesh_relaxation_config():
r""" parameters for doing CVT relaxation of meshes using the optimesh library
see https://pypi.org/project/optimesh/
"""
params ... | 2,926 | 31.164835 | 151 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Mesh/meshtools.py |
from ..Geometry import geometry as geom
from ..Unzipping import unzip as uzip
def read_mesh(meshfile,
process=False,
validate=False,
keep_largest_only=False):
r""" Wrapper around trimesh.load_mesh such that the mesh is read exactly with the same vertices and face in... | 294,805 | 43.378443 | 411 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Mesh/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Features/features.py |
from ..Utility_Functions import file_io as fio
import numpy as np
from scipy import signal
class DsiftExtractor:
r"""
The class that does dense sift feature extractor. See https://github.com/Yangqing/dsift-python
Sample Usage:
extractor = DsiftExtractor(gridSpacing,patchSize,[optional params])
feaArr,positio... | 6,965 | 34.907216 | 175 | py |
u-unwrap3D | u-unwrap3D-master/unwrap3D/Features/__init__.py | 0 | 0 | 0 | py | |
u-unwrap3D | u-unwrap3D-master/docs/source/scipyoptdoc.py | """
===========
scipyoptdoc
===========
Proper docstrings for scipy.optimize.minimize et al.
Usage::
.. scipy-optimize:function:: scipy.optimize.minimize
:impl: scipy.optimize._optimize._minimize_nelder_mead
:method: Nelder-Mead
Produces output similar to autodoc, except
- The docstring is obtain... | 5,801 | 34.163636 | 104 | py |
u-unwrap3D | u-unwrap3D-master/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,702 | 31.178571 | 79 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/fc.py | """
This code is from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
"""
from __future__ import print_function
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
class FCNet(nn.Module):
"""Simple class for non-linear fully connect network
"""
... | 1,212 | 27.880952 | 76 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/main.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa)
"""
import os
import argparse
import torch
from torch.utils.data import DataLoader, ConcatDataset
import dataset_VQA
import base_model
from train import train
import utils
try:
import _pic... | 7,710 | 45.173653 | 132 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/base_model.py | """
This code is developed based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import torch
import torch.nn as nn
from attention import BiAttention, StackedAttention
from language_model import WordEmbedding, QuestionEmbedding
from classifier import... | 11,762 | 44.949219 | 141 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/test.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import argparse
import torch
from torch.utils.data import DataLoader
import dataset_VQA
import base_model
import utils
import pandas as pd
import os
import json
answer_typ... | 12,886 | 45.189964 | 154 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/evaluation_script.py | from utils import *
import math
import json
def bleu(candidate, references, n, weights):
pn = []
bp = brevity_penalty(candidate, references)
for i in range(n):
pn.append(modified_precision(candidate, references, i + 1))
if len(weights) > len(pn):
tmp_weights = []
for i in range(l... | 3,415 | 29.774775 | 69 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/dataset_VQA.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
from __future__ import print_function
import os
import json
import _pickle as cPickle
import numpy as np
import utils
import torch
from language_model import WordEmbedding... | 12,877 | 38.024242 | 146 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/learner.py | import torch
from torch import nn
from torch.nn import functional as F
import numpy as np
class MAML(nn.Module):
"""
Meta Learner
"""
def __init__(self, dataset_dir):
"""
:param args:
"""
super(MAML, self).__init__()
if 'RAD' in dataset_dir:
... | 9,463 | 34.051852 | 111 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/counting.py | """
Learning to Count Objects in Natural Images for Visual Question Answering
Yan Zhang, Jonathon Hare, Adam Prügel-Bennett
ICLR 2018
This code is from Yan Zhang's repository.
https://github.com/Cyanogenoid/vqa-counting/blob/master/vqa-v2/counting.py
MIT License
"""
import torch
import torch.nn as nn
from torch.autogr... | 7,535 | 42.310345 | 298 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/utils.py | """
This code is extended from Hengyuan Hu's repository.
https://github.com/hengyuan-hu/bottom-up-attention-vqa
"""
from __future__ import print_function
import errno
import os
import re
import collections
import numpy as np
import operator
import functools
from PIL import Image
import torch
import torch.nn as nn
impo... | 12,029 | 33.371429 | 117 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/classifier.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
class SimpleClassifier(nn.Module):
def __init__(self, in_dim, hid_dim, out_dim, args):
... | 936 | 35.038462 | 140 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/simple_cnn.py | """
MAML module for MEVF model
This code is written by Binh X. Nguyen and Binh D. Nguyen
<link paper>
"""
import torch
import torch.nn as nn
import numpy as np
import pickle
import torch.nn.functional as F
class SimpleCNN(nn.Module):
def __init__(self, weight_path='simple_cnn.weights', eps_cnn=1e-5, momentum_cnn=0... | 4,169 | 41.121212 | 104 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/bc.py | """
This code is from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
"""
from __future__ import print_function
import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
from fc import FCNet
class BCNet(nn.Module):
"""Simple class for non-lin... | 3,408 | 40.573171 | 119 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/attention.py | """
This code is extended from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
This code is modified from ZCYang's repository.
https://github.com/zcyang/imageqa-san
"""
import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
from bc import BCNet... | 4,448 | 33.488372 | 101 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/train.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import os
import time
import torch
import utils
import torch.nn as nn
from trainer import Trainer
warmup_updates = 4000
# Kaiming normalization initialization
def init_we... | 6,862 | 39.609467 | 282 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/auto_encoder.py | """
Auto-encoder module for MEVF model
This code is written by Binh X. Nguyen and Binh D. Nguyen
<link paper>
"""
import torch.nn as nn
from torch.distributions.normal import Normal
import functools
import operator
import torch.nn.functional as F
import torch
def add_noise(images, mean=0, std=0.1):
normal_dst = No... | 2,019 | 32.114754 | 106 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/trainer.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import torch
import utils
import contextlib
from collections import defaultdict, OrderedDict
from meters import AverageMeter, TimeMeter
class Trainer(object):
"""
... | 9,194 | 36.226721 | 152 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/language_model.py | """
This code is from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
"""
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
class WordEmbedding(nn.Module):
"""Word Embedding
The ntoken-th dim is used for padding_idx, which agr... | 3,405 | 35.234043 | 94 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/meters.py | """
This code is from https://github.com/pytorch/fairseq
"""
import time
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0
... | 1,513 | 21.264706 | 66 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/tools/create_embedding.py | """
This code is from Hengyuan Hu's repository.
https://github.com/hengyuan-hu/bottom-up-attention-vqa
"""
from __future__ import print_function
import os
import sys
import json
import functools
import operator
import numpy as np
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import _pickl... | 1,757 | 30.963636 | 108 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.