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 |
|---|---|---|---|---|---|---|
perm_hmm | perm_hmm-master/perm_hmm/policies/ignore_transitions.py | """For the special case of two states and two outcomes, computes the optimal
permutations for the related HMM that has transition matrix equal to the
identity matrix.
Because there are only two states, we adopt the convention that the two states
are called the ``dark`` and ``bright`` states. The ``dark`` state is the ... | 5,005 | 40.371901 | 111 | py |
perm_hmm | perm_hmm-master/perm_hmm/policies/min_tree.py | """Make a belief tree labelled with costs, then select the paths giving lowest
costs.
This module contains the
:py:class:`~perm_hmm.policies.min_tree.MinTreePolicy` class, which is a
:py:class:`~perm_hmm.policies.policy.PermPolicy` that selects the
permutations that minimize the cost, computed using a belief tree.
"""... | 18,477 | 42.683215 | 153 | py |
perm_hmm | perm_hmm-master/perm_hmm/policies/policy.py | """This module contains the abstract class
:py:class:`~perm_hmm.policies.policy.PermPolicy`. This class provides
boilerplate to implement a policy for the permutation-based HMM.
"""
import warnings
import torch
from perm_hmm.util import flatten_batch_dims
class PermPolicy(object):
"""
This is an abstract cl... | 8,293 | 39.458537 | 80 | py |
perm_hmm | perm_hmm-master/perm_hmm/policies/rotator_policy.py | """This is an example of a very simple PermPolicy.
The :py:class:`~perm_hmm.policies.policy.PermPolicy` is a class that is
used to select a permutation based on data seen thus far. It takes care of some
boilerplate, but should be subclassed to implement the actual selection
algorithm, and done so in a particular way. ... | 3,629 | 38.456522 | 80 | py |
perm_hmm | perm_hmm-master/perm_hmm/policies/__init__.py | r"""
This module contains classes that select permutations for the HMM.
The base class is
:py:class:`~perm_hmm.policies.policy.PermPolicy`,
which should be subclassed to make a custom
policy. A simple example of a policy is given in
:py:class:`~perm_hmm.policies.rotator_policy.RotatorPolicy`.
The :py:class:`~perm_hmm.... | 1,555 | 44.764706 | 79 | py |
perm_hmm | perm_hmm-master/perm_hmm/training/interrupted_training.py | r"""Trains the interrupted classifier.
The :py:class:`~perm_hmm.classifiers.interrupted.InterruptedClassifier` has a
parameter that dictates when the likelihood has risen to the point that we can
conclude the inference early. This parameter needs to be learned, which is what
this module provides methods for.
"""
impor... | 6,869 | 40.636364 | 134 | py |
perm_hmm | perm_hmm-master/perm_hmm/training/__init__.py | """
Methods for training parameters of the classifiers.
""" | 59 | 19 | 51 | py |
perm_hmm | perm_hmm-master/perm_hmm/models/hmms.py | """
An adaptation of the `pyro.distributions.DiscreteHMM`_ class.
The additions are to the log_prob method (which is incorrect as written in the
pyro package), and the ability to sample from the model, functionality which is
not included in the `pyro`_ model.
.. _pyro.distributions.DiscreteHMM: https://docs.pyro.ai/e... | 34,164 | 41.23115 | 146 | py |
perm_hmm | perm_hmm-master/perm_hmm/models/__init__.py | """
This module contains the class for the Hidden Markov Models. Included are
a classes that generate data after applying permutations to the underlying
states, both in the case that the initial state generates data, and in the case
that it does not. Heterogeneous output processes are not supported.
""" | 304 | 49.833333 | 79 | py |
perm_hmm | perm_hmm-master/perm_hmm/analysis/graph_utils.py | import anytree as at
def uniform_tree(num_steps: int, num_outcomes: int):
"""
Creates a tree of height num_steps, where each internal node has num_outcomes children.
:return: An AnyTree representing the tree.
"""
tree = _uniform_tree_helper(num_steps, num_outcomes, at.Node(None))
return tree
... | 1,548 | 31.957447 | 102 | py |
perm_hmm | perm_hmm-master/perm_hmm/analysis/__init__.py | r"""
Provides a way to view policies as trees.
""" | 50 | 16 | 41 | py |
perm_hmm | perm_hmm-master/perm_hmm/analysis/policy_viz.py | """Tools for visualizing permutation policies.
"""
import os
import argparse
from copy import deepcopy
import torch
import anytree as at
from anytree.exporter import UniqueDotExporter
from perm_hmm.util import id_and_transpositions
from perm_hmm.policies.policy import PermPolicy
from perm_hmm.policies.min_tree import M... | 4,371 | 33.425197 | 154 | py |
perm_hmm | perm_hmm-master/perm_hmm/classifiers/generic_classifiers.py | class Classifier(object):
"""
A generic classifier, has only the classify method.
"""
def classify(self, data, verbosity=0):
"""Performs classification
:param torch.Tensor data: Data to classify. Arbitrary shape.
:param verbosity: Flag to return ancillary data generated in the ... | 2,015 | 37.769231 | 93 | py |
perm_hmm | perm_hmm-master/perm_hmm/classifiers/perm_classifier.py | from perm_hmm.classifiers.generic_classifiers import MAPClassifier
class PermClassifier(MAPClassifier):
"""
MAP classifier for an HMM with permutations.
"""
def classify(self, data, perms=None, verbosity=0):
"""Classifies data.
Calls MAPClassifier(self.model.expand_with_perm(perms)).... | 979 | 38.2 | 96 | py |
perm_hmm | perm_hmm-master/perm_hmm/classifiers/interrupted.py | """
This module defines the interrupted classification scheme.
Using an iid model, we can make an inference based on data
which "collects enough evidence".
"""
import torch
from perm_hmm.util import first_nonzero, indices
from perm_hmm.classifiers.generic_classifiers import Classifier
class IIDInterruptedClassifier... | 9,158 | 41.207373 | 145 | py |
perm_hmm | perm_hmm-master/perm_hmm/classifiers/__init__.py | """
Classifiers built from models in perm_hmm.
:py:class:`~perm_hmm.classifiers.generic_classifiers.MAPClassifier`
is a maximum a posteriori classifier.
:py:class:`~perm_hmm.classifiers.perm_classifier.PermClassifier`
Uses permutations to compute the posterior log initial state distributions, then
computes the classi... | 377 | 33.363636 | 80 | py |
perm_hmm | perm_hmm-master/tests/sample_min_entropy_test.py | import unittest
from perm_hmm.models.hmms import PermutedDiscreteHMM
import torch
import pyro
import pyro.distributions as dist
from perm_hmm.util import ZERO
from perm_hmm.policies.min_tree import MinEntPolicy
class MyTestCase(unittest.TestCase):
def setUp(self):
self.num_states = 2
self.observat... | 4,700 | 46.01 | 99 | py |
perm_hmm | perm_hmm-master/tests/postprocessing_tests.py | import unittest
import torch
import torch.distributions
import pyro.distributions as dist
from perm_hmm.policies.min_tree import MinEntPolicy
from perm_hmm.models.hmms import DiscreteHMM, PermutedDiscreteHMM
from perm_hmm.classifiers.interrupted import IIDInterruptedClassifier
from perm_hmm.training.interrupted_trainin... | 6,561 | 47.25 | 114 | py |
perm_hmm | perm_hmm-master/tests/ignore_transitions_tests.py | import pytest
import numpy as np
from scipy.special import logsumexp, log1p
import torch
import pyro.distributions as dist
from perm_hmm.util import num_to_data
from perm_hmm.policies.ignore_transitions import IgnoreTransitions
from perm_hmm.models.hmms import PermutedDiscreteHMM
from perm_hmm.classifiers.perm_classi... | 4,190 | 37.1 | 105 | py |
perm_hmm | perm_hmm-master/tests/loss_function_tests.py | import torch
import perm_hmm.loss_functions as lf
from perm_hmm.util import ZERO
def expanded_log_zero_one(state, classification):
sl = state // 2
cl = classification // 2
loss = sl != cl
floss = loss.float()
floss[~loss] = ZERO
log_loss = floss.log()
log_loss[~loss] = 2*log_loss[~loss]
... | 751 | 22.5 | 49 | py |
perm_hmm | perm_hmm-master/tests/perm_hmm_tests.py | import numpy as np
import torch
import pyro.distributions as dist
from perm_hmm.models.hmms import PermutedDiscreteHMM
from perm_hmm.policies.policy import PermPolicy
from perm_hmm.policies.min_tree import MinEntPolicy
from perm_hmm.policies.rotator_policy import RotatorPolicy, cycles
from perm_hmm.util import ZERO, ... | 7,129 | 36.925532 | 116 | py |
perm_hmm | perm_hmm-master/tests/tree_strategy_tests.py | import pytest
import numpy as np
import torch
import pyro.distributions as dist
from example_systems.three_states import three_state_hmm
from perm_hmm.models.hmms import PermutedDiscreteHMM
from perm_hmm.util import all_strings, id_and_transpositions, ZERO
from tests.min_ent import MinEntropyPolicy
from perm_hmm.polici... | 5,907 | 52.225225 | 138 | py |
perm_hmm | perm_hmm-master/tests/test_min_ent_again.py | from functools import wraps
from functools import reduce
from operator import mul
import numpy as np
import pytest
import torch
import pyro.distributions as dist
from pyro.distributions.hmm import _logmatmulexp
from perm_hmm.models.hmms import PermutedDiscreteHMM
from typing import NamedTuple
from perm_hmm.util impor... | 31,332 | 37.778465 | 140 | py |
perm_hmm | perm_hmm-master/tests/perm_selector_tests.py | import pytest
import unittest
from copy import deepcopy
import numpy as np
import torch
import pyro.distributions as dist
from perm_hmm.models.hmms import DiscreteHMM, PermutedDiscreteHMM
from perm_hmm.policies.min_tree import MinEntPolicy
from perm_hmm.util import bin_ent, ZERO, perm_idxs_from_perms
def get_marginal... | 8,690 | 38.148649 | 148 | py |
perm_hmm | perm_hmm-master/tests/skip_first_tests.py | import numpy as np
import torch
import pyro.distributions as dist
from perm_hmm.models.hmms import SkipFirstDiscreteHMM
from perm_hmm.util import num_to_data, all_strings
def state_sequence_lp(seq, il, tl):
n = len(seq) - 1
return il[seq[0]] + tl.expand((n,) + tl.shape)[
torch.arange(n), seq[:-1], seq... | 3,666 | 35.67 | 167 | py |
perm_hmm | perm_hmm-master/tests/test_exhaustive.py | import pytest
from operator import mul
from functools import reduce
import numpy as np
from scipy.special import logsumexp
import matplotlib.pyplot as plt
import torch
import pyro.distributions as dist
import adapt_hypo_test.two_states.util as twotil
from perm_hmm.models.hmms import PermutedDiscreteHMM, random_phmm
... | 5,647 | 43.472441 | 244 | py |
perm_hmm | perm_hmm-master/tests/confusion_matrix_test.py | import unittest
import torch
import torch.distributions as dist
from perm_hmm.postprocessing import EmpiricalPostprocessor, ExactPostprocessor
from perm_hmm.util import ZERO
class MyTestCase(unittest.TestCase):
def setUp(self) -> None:
self.num_states = 10
self.testing_states = torch.tensor([0, 3,... | 5,022 | 58.094118 | 129 | py |
perm_hmm | perm_hmm-master/tests/nphotons_tests.py | import pytest
import numpy as np
from scipy.special import logsumexp
import example_systems.beryllium as beryllium
@pytest.mark.parametrize("time", [
1e-7, 1e-6, 1e-5, 1e-4
])
def test_prob_of_n_photons(time):
integration_time = beryllium.dimensionful_gamma * time
pn0 = np.exp(beryllium.log_prob_n_given_l... | 489 | 27.823529 | 67 | py |
perm_hmm | perm_hmm-master/tests/bernoulli_tests.py | import unittest
import torch
import pyro.distributions as dist
from perm_hmm.classifiers.interrupted import IIDInterruptedClassifier
from perm_hmm.models.hmms import DiscreteHMM, PermutedDiscreteHMM
from perm_hmm.simulator import HMMSimulator
from perm_hmm.util import transpositions, num_to_data
from perm_hmm.policies.... | 3,643 | 41.870588 | 90 | py |
perm_hmm | perm_hmm-master/tests/nt_rate_tests.py | import numpy as np
from scipy.special import log1p, logsumexp
import matplotlib.pyplot as plt
from adapt_hypo_test.two_states import no_transitions as nt
def main():
chis = []
p = .09
n = 10
qs = np.arange(.1, .6, .01)
for q in qs:
sigmas, chi = nt.solve(p, q, n)
chis.append(chi.ra... | 1,029 | 25.410256 | 81 | py |
perm_hmm | perm_hmm-master/tests/interrupted_tests.py | import unittest
import torch
import pyro.distributions as dist
from perm_hmm.classifiers.interrupted import IIDInterruptedClassifier, IIDBinaryIntClassifier
from perm_hmm.models.hmms import DiscreteHMM, PermutedDiscreteHMM
from perm_hmm.postprocessing import ExactPostprocessor, EmpiricalPostprocessor
import perm_hmm.tr... | 5,890 | 48.091667 | 207 | py |
perm_hmm | perm_hmm-master/tests/beryllium_tests.py | import pytest
from perm_hmm.util import ZERO
import example_systems.beryllium as beryllium
from example_systems.beryllium import N_STATES, BRIGHT_STATE, DARK_STATE
import numpy as np
from scipy.special import logsumexp, logit, expit
import itertools
def expanded_transitions(integration_time):
r"""Log transition m... | 6,354 | 33.166667 | 183 | py |
perm_hmm | perm_hmm-master/tests/sample_test.py | import unittest
import torch
import numpy as np
import pyro.distributions as dist
from pyro.distributions import DiscreteHMM
from perm_hmm.models.hmms import DiscreteHMM as MyDiscreteHMM
from perm_hmm.models.hmms import PermutedDiscreteHMM
from perm_hmm.util import ZERO, num_to_data
def to_base(x, y, max_length=None)... | 6,266 | 41.632653 | 131 | py |
perm_hmm | perm_hmm-master/tests/min_ent.py | """Conditioned on the data seen thus far, computes the expected posterior
entropy of the initial state, given the yet to be seen next data point, in
expectation. This computation is done for each allowed permutation. Then
minimizing the computed quantity over permutations, we obtain the permutation
to apply.
"""
from ... | 4,170 | 34.347458 | 113 | py |
perm_hmm | perm_hmm-master/tests/util_tests.py | import unittest
import torch
from perm_hmm import util
class MyTestCase(unittest.TestCase):
def test_first_nonzero(self):
batch_shape = (5,)
sample_shape = (100, 6, 7)
foos = torch.distributions.Bernoulli(torch.rand(batch_shape)).sample(sample_shape).bool()
for foo in foos:
... | 2,652 | 41.111111 | 97 | py |
perm_hmm | perm_hmm-master/tests/binning_tests.py | import pytest
import torch
import pyro.distributions as dist
from perm_hmm.binning import bin_histogram, bin_log_histogram, binned_expanded_hmm, binned_hmm, optimally_binned_consecutive
from perm_hmm.models.hmms import DiscreteHMM, PermutedDiscreteHMM, ExpandedHMM
from example_systems.bin_beryllium import binned_hmm_c... | 4,281 | 29.585714 | 124 | py |
perm_hmm | perm_hmm-master/example_systems/beryllium.py | r"""
Computes the output probabilities of the Beryllium ion.
The transition matrix was calculated separately [Zarantonello]_
All equations from [Langer]_, Chapter 2.
This module computes the populations of the various energy levels, when
addressed by a laser resonant with the :math:`^2S_{1/2}, F=2, m_F=2
\leftrighta... | 25,367 | 35.24 | 168 | py |
perm_hmm | perm_hmm-master/example_systems/three_states.py | r"""
This module implements a simple three state model shown in the figure. The
circles on the left represent states, while the squares on the right are
outputs.
.. image:: _static/three_state_model.svg
"""
import numpy as np
import torch
import pyro.distributions as dist
from perm_hmm.util import ZERO, log1mexp
from ... | 2,438 | 30.269231 | 136 | py |
perm_hmm | perm_hmm-master/example_systems/__init__.py | r"""Two example systems.
The :py:mod:`~example_systems.beryllium` module contains a calculation of the
process matrices for a :math:`^9\text{Be}^+` ion
addressed by a laser resonant with the :math:`^2S_{1/2}, F=2, m_F=2
\leftrightarrow ^2P_{3/2}, m_J=3/2` level, with perfect :math:`\sigma^+`
polarization.
The :py:mod... | 409 | 33.166667 | 77 | py |
perm_hmm | perm_hmm-master/example_systems/bin_beryllium.py | import os
import argparse
from itertools import combinations
import numpy as np
import matplotlib.pyplot as plt
import torch
from scipy.special import logsumexp
import pyro.distributions as dist
from pyro.distributions import Categorical
from perm_hmm.models.hmms import ExpandedHMM
from perm_hmm.simulator import HMMSim... | 8,753 | 37.906667 | 223 | py |
perm_hmm | perm_hmm-master/docs/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,450 | 34.014286 | 79 | py |
AdaGCN_TKDE | AdaGCN_TKDE-main/inits.py | import tensorflow as tf
import numpy as np
def glorot(shape, name=None):
"""Glorot & Bengio (AISTATS 2010) init."""
init_range = np.sqrt(6.0/(shape[0]+shape[1]))
initial = tf.random_uniform(shape, minval=-init_range, maxval=init_range, dtype=tf.float32)
return tf.Variable(initial, name=name)
def zer... | 454 | 27.4375 | 95 | py |
AdaGCN_TKDE | AdaGCN_TKDE-main/utils.py | import math
import numpy as np
import pickle as pkl
import networkx as nx
import scipy
import scipy.sparse as sp
import scipy.io as sio
from scipy.sparse.linalg.eigen.arpack import eigsh
from scipy.sparse import csc_matrix, hstack, vstack
from sklearn.decomposition import PCA
from sklearn.decomposition import Truncated... | 9,244 | 35.254902 | 132 | py |
AdaGCN_TKDE | AdaGCN_TKDE-main/layers.py | from inits import *
import tensorflow as tf
flags = tf.app.flags
FLAGS = flags.FLAGS
# global unique layer ID dictionary for layer name assignment
_LAYER_UIDS = {}
def get_layer_uid(layer_name=''):
"""Helper function, assigns unique layer IDs."""
if layer_name not in _LAYER_UIDS:
_LAYER_UIDS[layer_n... | 6,120 | 28.427885 | 84 | py |
AdaGCN_TKDE | AdaGCN_TKDE-main/models.py | from layers import *
from metrics import *
flags = tf.app.flags
FLAGS = flags.FLAGS
def define_variables(hiddens, weight_name, bias_name, flag=False):
variables = {}
for i in range(len(hiddens)-1):
variables[weight_name.format(i)] = glorot([hiddens[i], hiddens[i+1]], name=weight_name.format(i))
... | 16,541 | 47.368421 | 146 | py |
AdaGCN_TKDE | AdaGCN_TKDE-main/metrics.py | import tensorflow as tf
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
import numpy as np
def masked_sigmoid_cross_entropy(preds, labels, mask):
"""Sigmoid cross-entropy loss with masking"""
# loss has the same shape as logits: 1 loss per class and per sa... | 1,832 | 33.584906 | 85 | py |
AdaGCN_TKDE | AdaGCN_TKDE-main/train_WD.py | from __future__ import division
from __future__ import print_function
import os
os.environ["CUDA_VISIBLE_DEVICES"]="0"
import time
from utils import *
from models import GCN
# Define model evaluation function
def evaluate(sess, model, features, y, support, labels, mask, placeholders):
t_test = time.time()
fe... | 12,208 | 52.784141 | 153 | py |
GOAD | GOAD-master/train_ad.py | import argparse
import transformations as ts
import opt_tc as tc
import numpy as np
from data_loader import Data_Loader
def transform_data(data, trans):
trans_inds = np.tile(np.arange(trans.n_transforms), len(data))
trans_data = trans.transform_batch(np.repeat(np.array(data), trans.n_transforms, axis=0), trans... | 2,244 | 37.050847 | 105 | py |
GOAD | GOAD-master/opt_tc.py | import torch.utils.data
import numpy as np
import torch
import torch.utils.data
from torch.backends import cudnn
from wideresnet import WideResNet
from sklearn.metrics import roc_auc_score
cudnn.benchmark = True
def tc_loss(zs, m):
means = zs.mean(0).unsqueeze(0)
res = ((zs.unsqueeze(2) - means.unsqueeze(1)) ... | 3,871 | 38.510204 | 124 | py |
GOAD | GOAD-master/train_ad_tabular.py | import numpy as np
from data_loader import Data_Loader
import opt_tc_tabular as tc
import argparse
def load_trans_data(args):
dl = Data_Loader()
train_real, val_real, val_fake = dl.get_dataset(args.dataset, args.c_pr)
y_test_fscore = np.concatenate([np.zeros(len(val_real)), np.ones(len(val_fake))])
rat... | 2,329 | 39.877193 | 85 | py |
GOAD | GOAD-master/data_loader.py | import scipy.io
import numpy as np
import pandas as pd
import torchvision.datasets as dset
import os
class Data_Loader:
def __init__(self, n_trains=None):
self.n_train = n_trains
self.urls = [
"http://kdd.ics.uci.edu/databases/kddcup99/kddcup.data_10_percent.gz",
"http://kdd.ics.uc... | 7,157 | 34.79 | 98 | py |
GOAD | GOAD-master/transformations.py | import abc
import itertools
import numpy as np
from keras.preprocessing.image import apply_affine_transform
# The code is adapted from https://github.com/izikgo/AnomalyDetectionTransformations/blob/master/transformations.py
def get_transformer(type_trans):
if type_trans == 'complicated':
tr_x, tr_y = 8, 8
... | 2,988 | 33.755814 | 115 | py |
GOAD | GOAD-master/opt_tc_tabular.py | import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import fcnet as model
from sklearn.metrics import precision_recall_fscore_support as prf
def tc_loss(zs, m):
means = zs.mean(0).unsqueeze(0)
res = ((zs.unsqueeze(2) - means.unsqueeze(1)) ** 2).sum(-1)
pos = torch.diagonal(res... | 3,968 | 39.5 | 128 | py |
GOAD | GOAD-master/fcnet.py | import torch.nn as nn
import torch.nn.init as init
import numpy as np
def weights_init(m):
classname = m.__class__.__name__
if isinstance(m, nn.Linear):
init.xavier_normal_(m.weight, gain=np.sqrt(2.0))
elif classname.find('Conv') != -1:
init.xavier_normal_(m.weight, gain=np.sqrt(2.0))
e... | 1,759 | 30.428571 | 56 | py |
GOAD | GOAD-master/wideresnet.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
# The code is adapted from https://github.com/xternalz/WideResNet-pytorch/blob/master/wideresnet.py
class BasicBlock(nn.Module):
def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
super(BasicBlock, self).__init__(... | 4,139 | 40.4 | 116 | py |
RM-Tools | RM-Tools-master/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
import os
import sys
from shutil import rmtree
from setuptools import find_packages, setup, Command
NAME = 'RM-Tools'
DESCRIPTION = 'RM-synthesis, RM-clean and QU-fitting on polarised radio spectra'
URL = 'https://github.com/CIRADA-Tools/RM-Tools'
REQUIRES_PYTH... | 3,183 | 38.8 | 88 | py |
RM-Tools | RM-Tools-master/RMutils/util_misc.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: util_misc.py #
# ... | 40,930 | 38.356731 | 103 | py |
RM-Tools | RM-Tools-master/RMutils/util_RM.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: util_RM.py #
# ... | 84,630 | 40.917286 | 130 | py |
RM-Tools | RM-Tools-master/RMutils/mpfit.py | """
Perform Levenberg-Marquardt least-squares minimization, based on MINPACK-1.
AUTHORS
The original version of this software, called LMFIT, was written in FORTRAN
as part of the MINPACK-1 package by XXX.
Craig Markwardt converted the FORTRAN code to IDL. The information for the
IDL version is:
... | 78,840 | 32.478132 | 93 | py |
RM-Tools | RM-Tools-master/RMutils/util_rec.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: util_rec.py #
# ... | 4,619 | 51.5 | 79 | py |
RM-Tools | RM-Tools-master/RMutils/util_FITS.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: util_FITS.py #
# ... | 17,314 | 36.559653 | 79 | py |
RM-Tools | RM-Tools-master/RMutils/util_plotTk.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: util_plotTk.py #
# ... | 78,650 | 37.050798 | 92 | py |
RM-Tools | RM-Tools-master/RMutils/__init__.py | #! /usr/bin/env python
"""Dependencies for RM utilities """
__all__ = ['mpfit',
'normalize',
'util_FITS',
'util_misc',
'util_plotFITS',
'util_plotTk',
'util_rec',
'util_RM']
| 251 | 21.909091 | 36 | py |
RM-Tools | RM-Tools-master/RMutils/util_plotFITS.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: util_plotFITS.py #
# ... | 10,191 | 35.141844 | 79 | py |
RM-Tools | RM-Tools-master/RMutils/nestle.py | # License is MIT: see LICENSE.md.
"""Nestle: nested sampling routines to evaluate Bayesian evidence."""
import sys
import warnings
import math
import numpy as np
try:
from scipy.cluster.vq import kmeans2
HAVE_KMEANS = True
except ImportError: # pragma: no cover
HAVE_KMEANS = False
__all__ = ["sample",... | 36,212 | 32.041058 | 80 | py |
RM-Tools | RM-Tools-master/RMutils/normalize.py | # The APLpyNormalize class is largely based on code provided by Sarah Graves.
import numpy as np
import numpy.ma as ma
import matplotlib.cbook as cbook
from matplotlib.colors import Normalize
class APLpyNormalize(Normalize):
'''
A Normalize class for imshow that allows different stretching functions
for... | 4,842 | 26.674286 | 84 | py |
RM-Tools | RM-Tools-master/RMutils/corner.py | # -*- coding: utf-8 -*-
import logging
import numpy as np
import matplotlib.pyplot as pl
from matplotlib.ticker import MaxNLocator, NullLocator
from matplotlib.colors import LinearSegmentedColormap, colorConverter
from matplotlib.ticker import ScalarFormatter
try:
from scipy.ndimage import gaussian_filter
excep... | 22,901 | 34.071975 | 81 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/tests.py | #!/usr/bin/env python
# encoding: utf-8
"""
Defines various nose unit tests
"""
import numpy as np
from .mh import MHSampler
from .ensemble import EnsembleSampler
from .ptsampler import PTSampler
logprecision = -4
def lnprob_gaussian(x, icov):
return -np.dot(x, np.dot(icov, x)) / 2.0
def lnprob_gaussian_nan... | 9,160 | 31.485816 | 79 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/sampler.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
The base sampler class implementing various helpful functions.
"""
from __future__ import (division, print_function, absolute_import,
unicode_literals)
__all__ = ["Sampler"]
import numpy as np
class Sampler(object):
"""
An abstract ... | 5,471 | 29.4 | 80 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/autocorr.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, print_function, absolute_import,
unicode_literals)
__all__ = ["function", "integrated_time"]
import numpy as np
def function(x, axis=0, fast=False):
"""
Estimate the autocorrelation function of a time se... | 2,885 | 26.226415 | 78 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/mpi_pool.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, print_function, absolute_import,
unicode_literals)
__all__ = ["MPIPool"]
# If mpi4py is installed, import it.
try:
from mpi4py import MPI
except ImportError:
MPI = None
class _close_pool_message(object):... | 8,554 | 33.35743 | 78 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/utils.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, print_function, absolute_import,
unicode_literals)
__all__ = ["sample_ball", "MH_proposal_axisaligned", "MPIPool"]
import numpy as np
from .mpi_pool import MPIPool
def sample_ball(p0, std, size=1):
"""
... | 1,713 | 27.566667 | 70 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/interruptible_pool.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,313 | 31.490196 | 78 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/ptsampler.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, print_function, absolute_import,
unicode_literals)
__all__ = ["PTSampler"]
import numpy as np
import numpy.random as nr
import multiprocessing as multi
from . import autocorr
from .sampler import Sampler
def def... | 20,206 | 34.575704 | 126 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/mh.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A vanilla Metropolis-Hastings sampler
"""
from __future__ import (division, print_function, absolute_import,
unicode_literals)
__all__ = ["MHSampler"]
import numpy as np
from . import autocorr
from .sampler import Sampler
# === MHSampler =... | 4,835 | 30.402597 | 77 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, print_function, absolute_import,
unicode_literals)
from .sampler import *
from .mh import *
from .ensemble import *
from .ptsampler import *
from . import utils
from . import autocorr
__version__ = "2.1.0"
def t... | 933 | 23.578947 | 69 | py |
RM-Tools | RM-Tools-master/RMutils/emcee/ensemble.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
An affine invariant Markov chain Monte Carlo (MCMC) sampler.
Goodman & Weare, Ensemble Samplers With Affine Invariance
Comm. App. Math. Comp. Sci., Vol. 5 (2010), No. 1, 65–80
"""
from __future__ import (division, print_function, absolute_import,
... | 18,685 | 35.283495 | 79 | py |
RM-Tools | RM-Tools-master/tests/import_test.py | """Tests for importing modules."""
import unittest
class test_imports(unittest.TestCase):
def test_imports(self):
"""Tests that package imports are working correctly."""
# This is a bit of a weird test, but package imports
# have not worked before.
modules = [
'RMtools_... | 1,330 | 30.690476 | 63 | py |
RM-Tools | RM-Tools-master/tests/__init__.py | 0 | 0 | 0 | py | |
RM-Tools | RM-Tools-master/tests/cli_test.py | """Tests for CLI."""
import subprocess
import unittest
class test_cli(unittest.TestCase):
def test_cli_rmsynth1d(self):
"""Tests that the CLI `rmsynth1d` runs."""
res = subprocess.run(['rmsynth1d', '--help'])
self.assertEqual(res.returncode, 0)
def test_cli_rmsynth3d(self):
""... | 876 | 28.233333 | 53 | py |
RM-Tools | RM-Tools-master/tests/QA_tests.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
QA testing tools for RM-tools.
These tools are intended to produce test simulated data sets, and run them
through RM-tools. Automated tools will only be able to confirm that things ran,
but user inspection of the results will be needed to confirm that the expected
valu... | 11,939 | 43.059041 | 139 | py |
RM-Tools | RM-Tools-master/RMtools_3D/do_fitIcube.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: do_fitIcube.py #
# ... | 19,285 | 36.594542 | 158 | py |
RM-Tools | RM-Tools-master/RMtools_3D/do_RMsynth_3D.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: do_RMsynth_3D.py #
# ... | 30,557 | 44.814093 | 128 | py |
RM-Tools | RM-Tools-master/RMtools_3D/RMpeakfit_3D.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# NAME: RMpeakfit_3D.py #
# #
# PURPOSE: Fit peak of RM spectra, for every pixel in 3D FDF cube. #
#
# Initial version: Cameron ... | 15,185 | 37.251889 | 110 | py |
RM-Tools | RM-Tools-master/RMtools_3D/extract_region.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 30 10:44:28 2019
Extract subregion of a FITS file, with option to extract a plane.
There are many cutout tools like it, but this one is mine.
@author: cvaneck
May 2019
"""
import astropy.io.fits as pf
from astropy.wcs import WCS
import argparse
... | 5,503 | 32.560976 | 109 | py |
RM-Tools | RM-Tools-master/RMtools_3D/create_chunks.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 28 13:25:30 2019
This code will divide a FITS cube into individual chunks.
To minimize problems with how to divide the cube, it will convert the image
plane into a 1D list of spectra.
Then the file will divided into smaller files, with fewer pixels,... | 3,555 | 31.036036 | 85 | py |
RM-Tools | RM-Tools-master/RMtools_3D/mk_test_cube_data.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: mk_test_cube_data.py #
# ... | 19,234 | 42.81549 | 101 | py |
RM-Tools | RM-Tools-master/RMtools_3D/do_RMclean_3D.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: do_RM-clean.py #
# ... | 20,350 | 44.527964 | 139 | py |
RM-Tools | RM-Tools-master/RMtools_3D/make_freq_file.py | #This script creates a frequency file from a FITS header. This is a helper
# script to make it easier to run RMsynth 1D or 3D. Run this first to generate
# the required frequency file. If you create a spectrum or cube from multiple
# FITS files, run it on the individual input files.
#This script assumes the FITS header... | 1,746 | 28.610169 | 83 | py |
RM-Tools | RM-Tools-master/RMtools_3D/__init__.py | 0 | 0 | 0 | py | |
RM-Tools | RM-Tools-master/RMtools_3D/assemble_chunks.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 29 13:10:26 2019
This code reassembles chunks into larger files. This is useful for assembling
output files from 3D RM synthesis back into larger cubes.
@author: cvaneck
"""
import numpy as np
import argparse
import astropy.io.fits as pf
import os... | 4,106 | 30.113636 | 105 | py |
RM-Tools | RM-Tools-master/RMtools_1D/do_RMsynth_1D_fromFITS.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: do_RMsynth_1D_fromFITS.py #
# ... | 10,163 | 49.82 | 112 | py |
RM-Tools | RM-Tools-master/RMtools_1D/clean_model.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This is an experimental tool to generate Stokes Q and U models from
clean components produced by RMclean1D.
Author: cvaneck, Aug 2021
"""
import numpy as np
from RMtools_1D.do_RMsynth_1D import readFile as read_freqFile
from RMutils.util_misc import calculate_Stokes... | 4,955 | 36.545455 | 86 | py |
RM-Tools | RM-Tools-master/RMtools_1D/calculate_RMSF.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 27 11:01:48 2019
@author: cvaneck
This routine will determine the RMSF and related parameters,
giving the following input information. One of:
a file with channel frequencies and weights
OR
a file with channel frequencies (assumes equal weights)
OR... | 9,428 | 43.060748 | 147 | py |
RM-Tools | RM-Tools-master/RMtools_1D/rmtools_bwpredict.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#=============================================================================#
# #
# NAME: rmtools_bwpredict.py #
# ... | 7,892 | 44.102857 | 157 | py |
RM-Tools | RM-Tools-master/RMtools_1D/do_QUfit_1D_mnest.py | #!/usr/bin/env python
# =============================================================================#
# #
# NAME: do_QUfit_1D_nest.py #
# ... | 25,632 | 35.882014 | 142 | py |
RM-Tools | RM-Tools-master/RMtools_1D/do_RMsynth_1D.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: do_RMsynth_1D.py #
# ... | 31,823 | 44.724138 | 158 | py |
RM-Tools | RM-Tools-master/RMtools_1D/do_RMclean_1D.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: do_RMclean_1D.py #
# ... | 21,451 | 44.642553 | 128 | py |
RM-Tools | RM-Tools-master/RMtools_1D/__init__.py | 0 | 0 | 0 | py | |
RM-Tools | RM-Tools-master/RMtools_1D/rmtools_bwdepol.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: rmtools_bwdepol.py #
# ... | 55,464 | 39.693324 | 157 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.