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 |
|---|---|---|---|---|---|---|
UltraNest | UltraNest-master/examples/evaluate_evolution.py | """
* same nearest neighbor is rare (in rosen, asymgauss, multishell for <=8 steps)
* likelihood rank difference between chain start and end is
typically ~ 117 (expectation from 400 live points)
in a converged chain (>= 8 steps in rosen, >= 64 steps in asymgauss, >= 8 in multishell)
* distance from start to end... | 4,618 | 35.370079 | 126 | py |
UltraNest | UltraNest-master/examples/testeggbox.py | import os
import sys
import argparse
import numpy as np
from numpy import cos, pi
def main(args):
def loglike(z):
chi = (cos(z / 2.)).prod(axis=1)
return (2. + chi)**5
def transform(x):
return x * 10 * pi
import string
paramnames = list(string.ascii_lowercase)[:args.x_dim... | 1,622 | 29.622642 | 84 | py |
UltraNest | UltraNest-master/examples/test_popsampler.py | #!/usr/bin/env python
# coding: utf-8
import numpy as np
from ultranest import ReactiveNestedSampler
from ultranest.mlfriends import RobustEllipsoidRegion, SimpleRegion, ScalingLayer
import ultranest.popstepsampler
import matplotlib.pyplot as plt
import sys
import argparse
def main(generate_direction_method, ndim, ns... | 2,654 | 34.878378 | 118 | py |
UltraNest | UltraNest-master/examples/testloggamma.py | import argparse
import numpy as np
from numpy import log
import scipy.stats
from ultranest.utils import verify_gradient
def main(args):
ndim = args.x_dim
scale = args.scale
adaptive_nsteps = args.adapt_steps
if adaptive_nsteps is None:
adaptive_nsteps = False
rv1a = scipy.stats.loggamma(1,... | 5,829 | 43.166667 | 136 | py |
UltraNest | UltraNest-master/examples/testsine.py | import argparse
import numpy as np
from numpy import pi, sin, log
import matplotlib.pyplot as plt
def main(args):
adaptive_nsteps = args.adapt_steps
if adaptive_nsteps is None:
adaptive_nsteps = False
np.random.seed(2)
Ndata = args.ndata
jitter_true = 0.1
phase_true = 0.
period_tru... | 4,970 | 36.946565 | 136 | py |
UltraNest | UltraNest-master/examples/testfeatures.py | import numpy as np
import shutil
import scipy.stats
import traceback
import json
import random
import sys
import os
import signal
import string
import hashlib
def get_arg_hash(runargs):
return hashlib.md5(str(runargs).encode()).hexdigest()[:10]
def main(args):
ndim = args.x_dim
paramnames = list(string.... | 9,824 | 32.762887 | 134 | py |
UltraNest | UltraNest-master/examples/testasymgauss.py | import argparse
import numpy as np
def main(args):
ndim = args.x_dim
sigma = args.sigma
sigma = np.logspace(-1, np.log10(args.sigma), ndim)
width = 1 - 5 * sigma
width[width < 1e-20] = 1e-20
centers = (np.sin(np.arange(ndim)/2.) * width + 1.) / 2.
#centers = np.ones(ndim) * 0.5
adaptiv... | 5,372 | 41.984 | 136 | py |
UltraNest | UltraNest-master/examples/evaluate_scaling.py | import matplotlib.pyplot as plt
import numpy as np
from numpy import pi, exp, log
import sys
import json
import scipy.stats, scipy.special
methods = {}
for filename in sys.argv[1:]:
info = json.load(open(filename))
ncall = info['ncall']
logz = info['logz']
logzerr = info['logzerr']
ndim = len(info[... | 2,985 | 35.414634 | 156 | py |
UltraNest | UltraNest-master/examples/testhyperrect.py | import argparse
import numpy as np
def main(args):
ndim = args.x_dim
adaptive_nsteps = args.adapt_steps
if adaptive_nsteps is None:
adaptive_nsteps = False
def flat_loglike(theta):
delta = np.max(np.abs(theta - 0.5))
volume_enclosed = ndim * np.log(delta + 1e-15)
if vol... | 5,061 | 40.834711 | 136 | py |
UltraNest | UltraNest-master/examples/testmultishell.py | import argparse
import numpy as np
from numpy import exp, log, pi
import scipy.stats
# analytic solution:
def shell_vol(ndim, r, w):
# integral along the radius
mom = scipy.stats.norm.moment(ndim - 1, loc=r, scale=w)
# integral along the angles is surface of hyper-ball
# which is volume of one higher d... | 7,224 | 38.917127 | 136 | py |
UltraNest | UltraNest-master/examples/testgauss.py | import argparse
import numpy as np
from numpy import log
def main(args):
ndim = args.x_dim
sigma = args.sigma
width = max(0, 1 - 5 * sigma)
centers = (np.sin(np.arange(ndim)/2.) * width + 1.) / 2.
centers = np.ones(ndim) * 0.5
def flat_loglike(theta):
like = -0.5 * (((theta - centers)/... | 2,333 | 35.46875 | 99 | py |
UltraNest | UltraNest-master/examples/evaluate_rosenbrock.py | import matplotlib.pyplot as plt
import numpy as np
from numpy import pi, exp, log
import sys
import json
import scipy.stats, scipy.special
def shell_vol(ndim, r, w):
# integral along the radius
mom = scipy.stats.norm.moment(ndim - 1, loc=r, scale=w)
# integral along the angles is surface of hyper-ball
... | 3,067 | 32.714286 | 100 | py |
UltraNest | UltraNest-master/examples/evaluate_scaling_logz.py | import matplotlib.pyplot as plt
import numpy as np
from numpy import pi, exp, log
import sys
import json
import scipy.stats, scipy.special
methods = {}
for filename in sys.argv[1:]:
info = json.load(open(filename))
ncall = info['ncall']
logz = info['logz']
logzerr = info['logzerr']
ndim = len(info[... | 1,820 | 27.453125 | 72 | py |
UltraNest | UltraNest-master/examples/testcorrpeak.py | # combination of:
# - varying sigmas
# - varying priors (uniform, log-uniform (every third))
# - tight parameter correlation
import argparse
import numpy as np
#from numpy import log
def main(args):
ndim = args.x_dim
sigmas = 10**(-2.0 + 2.0 * np.cos(np.arange(ndim)-2)) / (np.arange(ndim)-2)
sigmas[... | 3,530 | 36.168421 | 111 | py |
UltraNest | UltraNest-master/ultranest/dyhmc.py | """Experimental constrained Hamiltanean Monte Carlo step sampling
Contrary to CHMC, this uses the likelihood gradients throughout the path.
A helper surface is created using the live points.
"""
import numpy as np
import matplotlib.pyplot as plt
import scipy.special
import scipy.stats
def stop_criterion(thetaminus,... | 24,062 | 36.539782 | 132 | py |
UltraNest | UltraNest-master/ultranest/popstepsampler.py | """
Vectorized step samplers
------------------------
Likelihood based on GPUs (model emulators based on neural networks,
or JAX implementations) can evaluate hundreds of points as efficiently
as one point. The implementations in this module leverage this power,
by providing random walks of populations of walkers.
"""... | 19,858 | 35.572744 | 158 | py |
UltraNest | UltraNest-master/ultranest/netiter.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__doc__ = """
Graph-based nested sampling
---------------------------
A formulation of nested sampling exploration as a tree, presented in
section 3.4 of Buchner (2023, https://arxiv.org/abs/2101.09675).
The root represents the prior volume, branches and sub-branches spli... | 40,477 | 36.067766 | 149 | py |
UltraNest | UltraNest-master/ultranest/samplingpath.py | """Sparsely sampled, virtual sampling path.
Supports reflections at unit cube boundaries, and regions.
"""
import numpy as np
from numpy.linalg import norm
import matplotlib.pyplot as plt
def nearest_box_intersection_line(ray_origin, ray_direction, fwd=True):
r"""Compute intersection of a line (ray) and a unit... | 20,765 | 32.931373 | 138 | py |
UltraNest | UltraNest-master/ultranest/utils.py | """
Utility functions for logging and statistics
--------------------------------------------
"""
from __future__ import print_function, division
import logging
import sys
import os
import numpy as np
from numpy import pi
import errno
def create_logger(module_name, log_dir=None, level=logging.INFO):
"""
Set ... | 14,604 | 28.505051 | 134 | py |
UltraNest | UltraNest-master/ultranest/ordertest.py | """
Mann-Whitney-Wilcoxon U test for a uniform distribution of integers
-------------------------------------------------------------------
A test for biased nested sampling, presented in
section 4.5.2 of Buchner (2023, https://arxiv.org/abs/2101.09675).
This implements the same idea as https://arxiv.org/abs/2006.033... | 2,760 | 28.688172 | 114 | py |
UltraNest | UltraNest-master/ultranest/dychmc.py | """Constrained Hamiltanean Monte Carlo step sampling.
Uses gradient to reflect at nested sampling boundaries.
"""
from __future__ import print_function, division
import numpy as np
import matplotlib.pyplot as plt
def stop_criterion(thetaminus, thetaplus, rminus, rplus):
"""Compute the stop condition in the main ... | 25,176 | 40.683775 | 165 | py |
UltraNest | UltraNest-master/ultranest/flatnuts.py | """
FLATNUTS is a implementation of No-U-turn sampler
for nested sampling assuming a flat prior space (hyper-cube u-space).
This is highly experimental. It is similar to NoGUTS and suffers from
the same stability problems.
Directional sampling within regions.
Work in unit cube space. assume a step size.
1. starti... | 31,708 | 39.548593 | 144 | py |
UltraNest | UltraNest-master/ultranest/solvecompat.py | """Drop-in replacement for pymultinest.solve.
Example::
from ultranest.solvecompat import pymultinest_solve_compat as solve
# is a drop-in replacement for
from pymultinest.solve import solve
"""
import numpy as np
import string
from .integrator import ReactiveNestedSampler
from .stepsampler import S... | 3,121 | 30.535354 | 83 | py |
UltraNest | UltraNest-master/ultranest/viz.py | """
Live point visualisations
-------------------------
Gives a live impression of current exploration.
This is powerful because the user can abort partial runs if the fit
converges to unreasonable values.
"""
from __future__ import print_function, division
import sys
import shutil
from numpy import log10
import nu... | 14,799 | 37.642298 | 150 | py |
UltraNest | UltraNest-master/ultranest/plot.py | """
Plotting utilities
------------------
"""
from __future__ import (print_function, division)
from six.moves import range
import logging
import types
import warnings
import numpy as np
import matplotlib.pyplot as pl
from matplotlib.ticker import MaxNLocator, NullLocator
# from matplotlib.colors import LinearSegme... | 30,736 | 38.711886 | 147 | py |
UltraNest | UltraNest-master/ultranest/__init__.py | """
Performs nested sampling to calculate the Bayesian evidence and posterior samples
Some parts are from the Nestle library by Kyle Barbary (https://github.com/kbarbary/nestle)
Some parts are from the nnest library by Adam Moss (https://github.com/adammoss/nnest)
"""
from .integrator import NestedSampler, ReactiveNes... | 475 | 33 | 91 | py |
UltraNest | UltraNest-master/ultranest/store.py | """
Storage for nested sampling points
-----------------------------------
The information stored is a table with
- the likelihood threshold drawn from
- the likelihood, prior volume coordinates and physical coordinates of the point
"""
from __future__ import print_function, division
import numpy as np
import warni... | 7,205 | 31.606335 | 118 | py |
UltraNest | UltraNest-master/ultranest/stepsampler.py | """
MCMC-like step sampling
-----------------------
The classes implemented here are generators that, in each iteration,
only make one likelihood call. This allows running in parallel a
population of samplers that have the same execution time per call,
even if they do not terminate at the same number of iterations.
""... | 41,046 | 32.290349 | 142 | py |
UltraNest | UltraNest-master/ultranest/integrator.py | """
Nested sampling integrators
---------------------------
This module provides the high-level class :py:class:`ReactiveNestedSampler`,
for calculating the Bayesian evidence and posterior samples of arbitrary models.
"""
# Some parts are from the Nestle library by Kyle Barbary (https://github.com/kbarbary/nestle)
#... | 134,588 | 41.972222 | 157 | py |
UltraNest | UltraNest-master/ultranest/hotstart.py | """
Warm start
----------
Helper functions for deforming the parameter space to enable
a more efficient sampling.
Based on ideas from Petrosyan & Handley (2022, https://arxiv.org/abs/2212.01760).
"""
import numpy as np
import scipy.stats
from .utils import vectorize, resample_equal
def get_auxiliary_problem(logli... | 21,414 | 36.243478 | 134 | py |
UltraNest | UltraNest-master/ultranest/pathsampler.py | """MCMC-like step sampling on a trajectory
These features are experimental.
"""
import numpy as np
import matplotlib.pyplot as plt
from ultranest.samplingpath import SamplingPath, ContourSamplingPath, extrapolate_ahead
from ultranest.stepsampler import StepSampler
from ultranest.stepsampler import generate_region_o... | 29,581 | 36.732143 | 141 | py |
UltraNest | UltraNest-master/tests/test_netiterintegrate.py | from __future__ import print_function, division
import os
import numpy as np
from ultranest.store import TextPointStore
from ultranest.netiter import PointPile, TreeNode, count_tree, print_tree, dump_tree
from ultranest.netiter import SingleCounter, MultiCounter, BreadthFirstIterator
def integrate_singleblock(num_li... | 13,039 | 32.782383 | 140 | py |
UltraNest | UltraNest-master/tests/test_popstepsampling.py | import numpy as np
from ultranest import ReactiveNestedSampler
from ultranest.popstepsampler import PopulationSliceSampler, PopulationRandomWalkSampler
from ultranest.popstepsampler import generate_cube_oriented_direction, generate_random_direction, generate_cube_oriented_direction_scaled
from ultranest.popstepsampler ... | 3,624 | 41.151163 | 137 | py |
UltraNest | UltraNest-master/tests/test_store.py | from __future__ import print_function, division
import numpy as np
import tempfile
import os
from ultranest.store import TextPointStore, HDF5PointStore, NullPointStore
import pytest
def test_text_store():
PointStore = TextPointStore
try:
fobj, filepath = tempfile.mkstemp()
os.close(fobj)
ptst = PointStore(f... | 7,601 | 30.028571 | 81 | py |
UltraNest | UltraNest-master/tests/benchmark_maxradius.py | from ultranest.mlfriends import MLFriends, ScalingLayer, AffineLayer
import numpy as np
import time
import matplotlib.pyplot as plt
def benchmark_maxradius():
print(" ndim | npts | duration")
for ndim in 2, 4, 8, 16, 32, 64:
plotpoints = []
np.random.seed(ndim)
for npts in 100, 400, 1000, 4000:
points = np... | 3,347 | 31.504854 | 90 | py |
UltraNest | UltraNest-master/tests/test_regionsampling.py | import numpy as np
import os
import matplotlib.pyplot as plt
from ultranest.mlfriends import ScalingLayer, AffineLayer, MLFriends
from ultranest.mlfriends import RobustEllipsoidRegion, SimpleRegion, WrappingEllipsoid
from numpy.testing import assert_allclose
here = os.path.dirname(__file__)
def test_region_sampling_... | 8,215 | 40.494949 | 116 | py |
UltraNest | UltraNest-master/tests/test_ordertest.py | from __future__ import print_function, division
import numpy as np
from ultranest.ordertest import UniformOrderAccumulator, infinite_U_zscore
def test_invalid_order():
sample_acc = UniformOrderAccumulator()
sample_acc.add(2, 3)
try:
sample_acc.add(4, 3)
assert False
except ValueError:
pass
def test_diff_exp... | 1,331 | 25.117647 | 141 | py |
UltraNest | UltraNest-master/tests/test_hotstart.py | from __future__ import print_function, division
import numpy as np
import scipy.stats
from numpy import log10
from ultranest import ReactiveNestedSampler
from ultranest.utils import vectorize
from ultranest.integrator import warmstart_from_similar_file
from ultranest.hotstart import reuse_samples, get_extended_auxiliar... | 10,117 | 47.879227 | 156 | py |
UltraNest | UltraNest-master/tests/test_stepsampling.py | import numpy as np
from ultranest.mlfriends import ScalingLayer, AffineLayer, MLFriends
from ultranest import ReactiveNestedSampler
from ultranest.stepsampler import RegionMHSampler, CubeMHSampler, CubeSliceSampler, RegionSliceSampler, SpeedVariableRegionSliceSampler, RegionBallSliceSampler
from ultranest.stepsampler i... | 12,508 | 39.482201 | 159 | py |
UltraNest | UltraNest-master/tests/test_flatnuts.py | import numpy as np
from ultranest.mlfriends import AffineLayer, ScalingLayer, MLFriends
from ultranest.flatnuts import ClockedStepSampler, ClockedBisectSampler, ClockedNUTSSampler
from ultranest.flatnuts import SingleJumper, DirectJumper
from ultranest.samplingpath import SamplingPath, ContourSamplingPath
from numpy.te... | 14,966 | 41.885387 | 119 | py |
UltraNest | UltraNest-master/tests/test_clustering.py | from __future__ import print_function, division
import numpy as np
import os
import matplotlib.pyplot as plt
from ultranest.utils import create_logger
from ultranest import ReactiveNestedSampler
from ultranest.mlfriends import MLFriends, AffineLayer
here = os.path.dirname(__file__)
def test_clustering():
from ul... | 8,779 | 41.415459 | 138 | py |
UltraNest | UltraNest-master/tests/test_transforms.py | from ultranest.mlfriends import ScalingLayer, AffineLayer
import numpy as np
import matplotlib.pyplot as plt
def genpoints_following_cov(covmatrix, size=1000):
u = np.random.uniform(-5, 5, size=(100000, 2))
mask = np.einsum('ij,jk,ik->i', u, covmatrix, u) <= 1
points = u[mask,:][:size,:]
return points
def test_tr... | 4,886 | 35.744361 | 109 | py |
UltraNest | UltraNest-master/tests/test_samplingpath.py | import numpy as np
import matplotlib.pyplot as plt
from ultranest.mlfriends import AffineLayer, MLFriends
from ultranest.samplingpath import SamplingPath, ContourSamplingPath
from ultranest.samplingpath import box_line_intersection, nearest_box_intersection_line, linear_steps_with_reflection, angle, get_sphere_tangents... | 17,244 | 42.54798 | 151 | py |
UltraNest | UltraNest-master/tests/test_viz.py | import numpy as np
from ultranest.viz import round_parameterlimits
def wrap_single_test(vlo, vhi, plo_expected, phi_expected):
assert vlo < vhi
err_msg = 'for input values (%s, %s)' % (vlo, vhi)
plo, phi, fmts = round_parameterlimits(np.asarray([vlo]), np.asarray([vhi]))
np.testing.assert_allclose(plo... | 2,151 | 33.709677 | 94 | py |
UltraNest | UltraNest-master/tests/test_run.py | import os
import numpy as np
import shutil
import tempfile
import pytest
import json
import pandas
from ultranest import NestedSampler, ReactiveNestedSampler, read_file
from ultranest.integrator import warmstart_from_similar_file
import ultranest.mlfriends
from numpy.testing import assert_allclose
def test_run():
... | 23,520 | 38.933786 | 220 | py |
UltraNest | UltraNest-master/tests/test_utils.py | import numpy as np
import tempfile
import os
from ultranest.utils import vectorize, is_affine_transform, normalised_kendall_tau_distance, make_run_dir
from ultranest.utils import distributed_work_chunk_size
from numpy.testing import assert_allclose
import pytest
def test_vectorize():
def myfunc(x):
return (x**2).... | 2,560 | 29.129412 | 105 | py |
UltraNest | UltraNest-master/docs/gauss.py | import argparse
import numpy as np
from numpy import log
# define command line arguments:
parser = argparse.ArgumentParser()
parser.add_argument('--x_dim', type=int, default=2,
help="Dimensionality")
parser.add_argument("--num_live_points", type=int, default=400)
parser.add_argument('--sigma', typ... | 1,959 | 30.612903 | 106 | py |
UltraNest | UltraNest-master/docs/modoverview.py | import importlib
sections = [
('Modules commonly used directly', ['integrator', 'hotstart', 'plot', 'stepsampler', 'popstepsampler', 'solvecompat']),
('Internally used modules', ['mlfriends', 'netiter', 'ordertest', 'stepfuncs', 'store', 'viz']),
('Experimental modules, no guarantees', ['dychmc', 'dyhmc', 'flatnuts... | 1,057 | 24.804878 | 120 | py |
UltraNest | UltraNest-master/docs/simple.py | import scipy.stats
paramnames = ['param1', 'param2', 'param3']
centers = [0.4, 0.5, 0.6]
sigma = 0.1
def transform(cube):
return cube
def loglike(theta):
return scipy.stats.norm(centers, sigma).logpdf(theta).sum()
from ultranest import ReactiveNestedSampler
sampler = ReactiveNestedSampler(paramnames, loglik... | 820 | 25.483871 | 79 | py |
UltraNest | UltraNest-master/docs/conf.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# ultranest documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# a... | 5,899 | 27.780488 | 77 | py |
UltraNest | UltraNest-master/docs/_ext/edit_on_github.py | """
Sphinx extension to add ReadTheDocs-style "Edit on GitHub" links to the
sidebar.
Loosely based on https://github.com/astropy/astropy/pull/347
"""
import os
import warnings
__licence__ = 'BSD (3 clause)'
def get_github_url(app, view, path):
return (
'https://github.com/{project}/{view}/{branch}/{sr... | 1,519 | 27.148148 | 79 | py |
UltraNest | UltraNest-master/evaluate/problems.py | import numpy as np
from math import gamma, pi, exp
def random_vector(ndim, length=1):
v = np.random.normal(size=ndim)
return v * length / (v**2).sum()**0.5
def random_point_in_sphere(ndim, radius=1):
return random_vector(ndim, radius * np.random.uniform()**(1. / ndim))
def nsphere_volume(radius, ndim):
... | 7,381 | 30.147679 | 112 | py |
UltraNest | UltraNest-master/evaluate/viz_sampling.py | import numpy as np
import matplotlib.pyplot as plt
from ultranest.mlfriends import ScalingLayer, AffineLayer, MLFriends
from ultranest.stepsampler import RegionMHSampler, CubeMHSampler
from ultranest.stepsampler import CubeSliceSampler, RegionSliceSampler, SamplingPathSliceSampler, SamplingPathStepSampler, OtherSampler... | 7,322 | 37.340314 | 140 | py |
UltraNest | UltraNest-master/evaluate/evaluate_sampling.py | import numpy as np
import matplotlib.pyplot as plt
from ultranest.mlfriends import ScalingLayer, AffineLayer, RobustEllipsoidRegion
from ultranest.stepsampler import RegionMHSampler, CubeMHSampler
from ultranest.stepsampler import CubeSliceSampler, RegionSliceSampler, RegionBallSliceSampler, RegionSequentialSliceSample... | 13,011 | 42.959459 | 185 | py |
top-SAT-solvers-2021 | top-SAT-solvers-2021-main/experiment_gen_random_SATs.py | import os
import sys
import re
def terminal(cmd):
return os.popen(cmd).read()
def run(clauses, literals, num_vars):
terminal(f'python3 gen_random_SAT.py {clauses} {literals} {num_vars}')
output = terminal('./kissat_gb/build/kissat random_SAT.cnf | grep process-time:')
match = re.match('c process-time:\s+[^\s]+... | 1,399 | 22.728814 | 89 | py |
top-SAT-solvers-2021 | top-SAT-solvers-2021-main/gen_random_SAT.py | #!/usr/bin/python
import sys
import random
clauses = None
literals = None
num_vars = None
if len(sys.argv) == 4: # The file name with two arguments
clauses = int(sys.argv[1])
literals = int(sys.argv[2])
num_vars = int(sys.argv[3])
if num_vars == None:
print('Random SAT Generator')
clauses = int(input('How many... | 842 | 21.184211 | 57 | py |
FML | FML-master/FML/MakePythonWrapper/test.py | import MyLibrary as mylib
import numpy as np
# Call the first C++ function we defined in Main.cpp
mylib.test(123)
# Example of how to pass more complex data from C++ to Python
# We allocate a struct with a double* and an int and provide
# in the InterfaceFile.i how to extract this in python
data = mylib.getData(10)
... | 565 | 24.727273 | 61 | py |
FML | FML-master/FML/HaloModel/PythonWrapper/example.py | import numpy as np
from HaloModelWrapper import HaloModel
import matplotlib.pyplot as plt
import time
import gc
# Parameters
filename = "pofk_lin.txt"
OmegaM = 0.3
w0 = -1.0
wa = 0.0
mu0 = 0.0
mua = 0.0
deltacfac = 1.0
DeltaVirfac = 1.0
cofmfac = 1.0
sigma8norm = True
h... | 2,070 | 19.71 | 64 | py |
FML | FML-master/FML/HaloModel/PythonWrapper/HaloModelWrapper.py | import numpy as np
import HaloModelCXX as hm
import matplotlib.pyplot as plt
"""
Input: linear power-spectrum at z=0
Run the halomodel and get the power-spectra
P1h, P2h and P(k,z), halo-massfunctions etc.
"""
class HaloModel:
def __init__(self,
filename_pofk_lin,
OmegaM,
w0=-1.0,
wa=0.0,
... | 2,194 | 21.864583 | 58 | py |
caracal | caracal-master/caracal/main.py | # -*- coding: future_fstrings -*-
from caracal import log
import caracal
import os
import sys
import ruamel.yaml
import pdb
import traceback
import logging
import shutil
from caracal.dispatch_crew import config_parser
from caracal.dispatch_crew import worker_help
import caracal.dispatch_crew.caltables as mkct
from car... | 19,547 | 60.278997 | 135 | py |
caracal | caracal-master/caracal/__init__.py | # -*- coding: future_fstrings -*-
import logging.handlers
import pkg_resources
import os
import subprocess
import logging
from time import gmtime, strftime
import stimela
import stimela.utils
##############################################################################
# Globals
#####################################... | 6,844 | 30.837209 | 132 | py |
caracal | caracal-master/caracal/tests/__init__.py | 0 | 0 | 0 | py | |
caracal | caracal-master/caracal/schema/__init__.py | SCHEMA_VERSION = "1.1.1"
| 25 | 12 | 24 | py |
caracal | caracal-master/caracal/utils/requires.py | import importlib
from caracal import ExtraDependencyError
def checkimport(package):
"""
Check if a package is installed.
"""
exists = importlib.util.find_spec(package)
if exists:
return True
else:
return False
def extras(packages):
if isinstance(packages, str):
pa... | 635 | 21.714286 | 61 | py |
caracal | caracal-master/caracal/utils/__init__.py | 0 | 0 | 0 | py | |
caracal | caracal-master/caracal/utils/tests/__init__.py | 0 | 0 | 0 | py | |
caracal | caracal-master/caracal/notebooks/__init__.py | import os.path
import glob
import shutil
import jinja2
import traceback
import time
import caracal
from caracal import log
from stimela.utils import xrun, StimelaCabRuntimeError
_j2env = None
SOURCE_NOTEBOOK_DIR = os.path.dirname(__file__)
def setup_default_notebooks(notebooks, output_dir, prefix, config):
# ... | 4,613 | 39.473684 | 119 | py |
caracal | caracal-master/caracal/workers/ddcal_worker.py | # -*- coding: future_fstrings -*-
import os
import copy
import numpy as np
import sys
import caracal
import stimela.dismissable as sdm
from caracal.dispatch_crew import utils
from stimela.pathformatter import pathformatter as spf
from caracal.utils.requires import extras
NAME = 'Direction-dependent Calibration'
LABEL ... | 22,035 | 48.855204 | 209 | py |
caracal | caracal-master/caracal/workers/obsconf_worker.py | # -*- coding: future_fstrings -*-
import caracal.dispatch_crew.utils as utils
import caracal
import sys
import numpy as np
import os
import shutil
from caracal import log
NAME = 'Automatically Categorize Observed Fields'
LABEL = 'obsconf'
def repeat_val(val, n):
l = []
for x in range(n):
l.append(va... | 12,255 | 48.220884 | 157 | py |
caracal | caracal-master/caracal/workers/prep_worker.py | # -*- coding: future_fstrings -*-
import os
import sys
import caracal
from caracal.dispatch_crew.utils import closeby
import caracal.dispatch_crew.caltables as mkct
import numpy as np
from caracal.workers.utils import manage_flagsets as manflags
from caracal.dispatch_crew import utils
from caracal.utils.requires import... | 12,765 | 53.7897 | 183 | py |
caracal | caracal-master/caracal/workers/line_worker.py | # -*- coding: future_fstrings -*-
import sys
import os
import glob
import stimela.dismissable as sdm
import stimela.recipe
import shutil
import itertools
import json
import psutil
import re
import datetime
import numpy as np
import caracal
from caracal.dispatch_crew import utils, noisy
from caracal.workers.utils import... | 98,559 | 55.127563 | 253 | py |
caracal | caracal-master/caracal/workers/mask_worker.py | # -*- coding: future_fstrings -*-
import os
import sys
import shutil
import glob
import yaml
import numpy as np
from caracal.dispatch_crew import utils
from caracal.utils.requires import extras
NAME = 'Make Masks'
LABEL = 'mask'
@extras("astropy")
def worker(pipeline, recipe, config):
#########################... | 29,775 | 36.73891 | 110 | py |
caracal | caracal-master/caracal/workers/getdata_worker.py | # -*- coding: future_fstrings -*-
import os
import sys
import subprocess
import itertools
import caracal
import stimela.dismissable as sdm
import warnings
NAME = "Get Data"
LABEL = 'getdata'
def worker(pipeline, recipe, config):
pipeline.init_names(config["dataid"])
if pipeline.nobs == 0:
raise Runti... | 1,463 | 35.6 | 113 | py |
caracal | caracal-master/caracal/workers/__init__.py | 0 | 0 | 0 | py | |
caracal | caracal-master/caracal/workers/polcal_worker.py | # -*- coding: future_fstrings -*-
from collections import OrderedDict
import pickle
import sys
import os
import caracal.dispatch_crew.utils as utils
import caracal
import yaml
import stimela.dismissable as sdm
from caracal.workers.utils import manage_flagsets as manflags
from caracal.workers.utils import manage_antenna... | 67,720 | 47.47602 | 197 | py |
caracal | caracal-master/caracal/workers/flag_worker.py | # -*- coding: future_fstrings -*-
from caracal.workers.utils import manage_fields as manfields
from caracal.workers.utils import manage_flagsets as manflags
import os
from caracal.dispatch_crew import utils
import stimela.dismissable as sdm
import yaml
import re
import caracal
import sys
import glob
import fnmatch
impo... | 32,681 | 60.317073 | 441 | py |
caracal | caracal-master/caracal/workers/transform_worker.py | # -*- coding: future_fstrings -*-
import os
import sys
import caracal
import stimela.dismissable as sdm
import stimela.recipe
import json
import caracal
from caracal.workers.utils import manage_flagsets as manflags
from caracal import log
from caracal.workers.utils import remove_output_products
from caracal.workers.uti... | 22,609 | 52.705463 | 175 | py |
caracal | caracal-master/caracal/workers/worker_administrator.py | # -*- coding: future_fstrings -*-
from caracal.dispatch_crew import utils
from collections import OrderedDict
import caracal
from caracal import log, pckgdir, notebooks
import sys
import os
from datetime import datetime
import stimela
import glob
import shutil
import traceback
import itertools
import ruamel.yaml
asser... | 21,367 | 45.251082 | 135 | py |
caracal | caracal-master/caracal/workers/inspect_worker.py | # -*- coding: future_fstrings -*-
import os
import sys
from collections import Mapping, Sequence, OrderedDict, namedtuple
import itertools
import yaml
from stimela.dismissable import dismissable as sdm
from caracal import log, ConfigurationError
import caracal.dispatch_crew.utils as utils
import numpy as np
import json... | 21,274 | 32.398744 | 133 | py |
caracal | caracal-master/caracal/workers/crosscal_worker.py | # -*- coding: future_fstrings -*-
from collections import OrderedDict
import sys
import os
import caracal.dispatch_crew.utils as utils
import caracal
import stimela.dismissable as sdm
from caracal.workers.utils import manage_flagsets as manflags
from caracal.workers.utils import manage_caltabs as manGtabs
from caracal.... | 32,636 | 43.586066 | 141 | py |
caracal | caracal-master/caracal/workers/mosaic_worker.py | # -*- coding: future_fstrings -*-
import os
import glob
import sys
import caracal
import numpy as np
from caracal.dispatch_crew import utils
from caracal.utils.requires import extras
NAME = "Mosaic 2D-images or cubes"
LABEL = 'mosaic'
@extras(packages="astropy")
def worker(pipeline, recipe, config):
from astrop... | 22,412 | 48.476821 | 250 | py |
caracal | caracal-master/caracal/workers/selfcal_worker.py | # -*- coding: future_fstrings -*-
import os
import shutil
import glob
import sys
import yaml
import json
import re
import copy
import caracal
import numpy as np
import stimela.dismissable as sdm
from caracal.dispatch_crew import utils
from caracal.utils.requires import extras
from stimela.pathformatter import pathforma... | 133,533 | 52.692803 | 281 | py |
caracal | caracal-master/caracal/workers/utils/manage_flagsets.py | # -*- coding: future_fstrings -*-
import os
import sys
import json
import math
from caracal import log
def conflict(conflict_type, pipeline, wname, ms, config, flags_bw, flags_aw, read_version='version'):
av_flagversions = get_flags(pipeline, ms)
req_version = config['rewind_flags'][read_version]
if req_v... | 10,969 | 42.019608 | 146 | py |
caracal | caracal-master/caracal/workers/utils/flag_Uzeros.py | #!/bin/bash
import gc
from caracal.workers.utils import remove_output_products
from caracal import log
import caracal
import shutil
import argparse
import time
from collections import OrderedDict
import matplotlib.dates as mdat
from matplotlib import gridspec
from matplotlib import rc
from matplotlib import pyplot as ... | 50,992 | 47.611058 | 559 | py |
caracal | caracal-master/caracal/workers/utils/manage_fields.py | # -*- coding: future_fstrings -*-
def get_field(pipeline, i, field):
"""
gets field ids parsed previously in the pipeline
params:
field: list of ids or comma-seperated list of ids where
ids are in bpcal, gcal, target, fcal or an actual field name
"""
return ',... | 866 | 56.8 | 176 | py |
caracal | caracal-master/caracal/workers/utils/callibs.py | from os import pipe
import stimela
import os.path
from collections import OrderedDict, Iterable
_MODES = dict(
K="delay_cal",
B="bp_cal",
F="gain_cal",
G="gain_cal", # both F and G serve the same purpose, so same mode
Gpol="gain_xcal",
Kcrs='cross_delay',
Xref='cross_phase_ref',
Xf='c... | 5,641 | 42.068702 | 135 | py |
caracal | caracal-master/caracal/workers/utils/__init__.py | import os
def remove_output_products(files, directory=None, log=None):
"""
Removes output products (given by a list of files), in a directory (if specified)
"""
for fullpath in files:
if directory:
fullpath = os.path.join(directory, fullpath)
if os.path.exists(fullpath):
... | 456 | 29.466667 | 85 | py |
caracal | caracal-master/caracal/workers/utils/manage_caltabs.py | import json
import tempfile
import os
import codecs
| 52 | 9.6 | 15 | py |
caracal | caracal-master/caracal/workers/utils/image_contsub.py | #! /usr/bin/env python
import sys
from datetime import datetime
import numpy as np
import argparse
import textwrap
from caracal.utils.requires import extras
version = '1.0.2'
def printime(string):
now = datetime.now().strftime("%H:%M:%S")
print('{} {}'.format(now, string))
@extras(packages=["scipy", "astro... | 15,030 | 38.976064 | 83 | py |
caracal | caracal-master/caracal/workers/utils/manage_antennas.py | import json
import numpy as np
def get_refant(pipeline, recipe, prefix, msname, fields, min_baseline, max_dist, index):
"""Get reference antenna based on max distances to the array centre,
min baseline length and amount of flagged data."""
step = "antenna_flag_summary"
filename = "{0:s}-flag-{1:s}.... | 2,984 | 33.310345 | 88 | py |
caracal | caracal-master/caracal/dispatch_crew/stream_director.py | import sys
import logging
from io import StringIO
class stream_director(object):
def __init__(self, logger, log_level=logging.INFO):
class stream_logger(StringIO):
def __init__(self, logger, log_level, fileno=0, *args, **kwargs):
self.logger = logger
self.log_le... | 2,210 | 37.789474 | 93 | py |
caracal | caracal-master/caracal/dispatch_crew/caltables.py | import caracal.dispatch_crew.catalog_parser as cp
import caracal
import os
__DB_FILENAME = os.path.join(
caracal.pckgdir, "data/southern_calibrators.txt")
__DB_CASA_FILENAME = os.path.join(
caracal.pckgdir, "data/casa_calibrators.txt")
__CALIBRATOR_DB = None
__CASA_CALIBRATOR_DB = None
def calibrator_databa... | 1,272 | 27.931818 | 79 | py |
caracal | caracal-master/caracal/dispatch_crew/worker_help.py | import yaml
import sys
from argparse import ArgumentParser
class worker_options(object):
def __init__(self, name, worker_dict, parser=None):
"""
Prints out help for a worker
"""
self.worker = name
self.desc = worker_dict["desc"]
self.parser = parser or ArgumentP... | 2,276 | 34.578125 | 130 | py |
caracal | caracal-master/caracal/dispatch_crew/noisy.py | ######################
### IMPORT MODULES ###
######################
import numpy as np
import pyrap.tables as tables
import sys
import os
import caracal
########################
### DEFINE FUNCTIONS ###
########################
# Get Tsys/eff (possibly from file)
def GetTsyseff(tsyseff):
if os.path.exists(tsys... | 10,329 | 49.390244 | 212 | py |
caracal | caracal-master/caracal/dispatch_crew/utils.py | import ruamel.yaml
import numpy
import yaml
import caracal
import caracal.dispatch_crew.caltables as mkct
import re
import codecs
from caracal.utils.requires import extras
def angular_dist_pos_angle(ra1, dec1, ra2, dec2):
"""Computes the angular distance between the two points on a sphere, and
the position an... | 11,775 | 29.746736 | 105 | py |
caracal | caracal-master/caracal/dispatch_crew/config_parser.py | # -*- coding: future_fstrings -*-
from pykwalify.core import Core
import argparse
import yaml
import caracal
import os
import copy
import ruamel.yaml
from collections import OrderedDict
# shut this guy up
import logging
pykwalify_logger = logging.getLogger('pykwalify.core')
pykwalify_logger.propagate = False
pykwalif... | 17,997 | 43.330049 | 134 | py |
caracal | caracal-master/caracal/dispatch_crew/__init__.py | 0 | 0 | 0 | py | |
caracal | caracal-master/caracal/dispatch_crew/catalog_parser.py | import re
import numpy as np
import copy
from caracal.utils.requires import extras
class catalog_parser:
def __init__(self, filename):
"""
The all-knowning catalog class
Give me a filename and I shall pass on divine knowledge
"""
cls = self.__class__
self._c... | 11,235 | 45.04918 | 117 | py |
caracal | caracal-master/caracal/dispatch_crew/interruptable_process.py | from multiprocessing import Process
import os
import signal
class interruptable_process(Process):
def __init__(self, target):
"""
Interruptable process
Args:
@target: method to execute in separate process
"""
self.__pid = 0
def __run(target_proc):
... | 608 | 22.423077 | 60 | py |
CP2 | CP2-main/main.py | import argparse
import builtins
import math
import os
import random
import shutil
import time
import warnings
import logging
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.multiprocessing as mp
import tor... | 16,052 | 39.537879 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.