sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
fcc4afbd0394243f2c1a729bc0f81af8e75bb6c3915531fc26e31df218553697 | Python | 6,765 | 191 | import numpy as np
import os
import pandas as pd
import pathlib
import pytest
import skimage.io as io
import tempfile
from alpineer import io_utils, image_utils
from ark.segmentation.ez_seg import ez_seg_utils
from typing import List, Union
@pytest.fixture(scope="module")
def tiff_dir(tmpdir_factory: pytest.TempPath... |
b76db0339f9002d8ae34febb3f09ef5a7deac7f832b920ebe2213379ecfb8dcb | Python | 6,767 | 185 | import sys
import argparse
import copy
import warnings
from cogdl.datasets import try_adding_dataset_args
from cogdl.models import try_adding_model_args
from cogdl.wrappers import fetch_data_wrapper, fetch_model_wrapper
from cogdl.utils import build_args_from_dict
from cogdl.wrappers.default_match import get_wrappers_... |
3d3b5436062ac4495a8fb13bf3f877898c071aacb428fedb0db585e2f5fcb01e | Python | 6,769 | 247 | import numpy as np
import scipy as sp
from scipy import stats
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import KFold
from sklearn.linear_model import Ridge, Lasso, LinearRegression
from sklearn.kernel_ridge import KernelRidge
from sklearn.svm import SVR
from sklearn.decomposition im... |
acff60a669093df319ccc31c9167105ed074c748d45fff853428d8135a541846 | Python | 6,771 | 178 | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
from typing import Any
from ax.adapter.registry import Generators
from ax.benchmark.benchmark_method import BenchmarkMethod
... |
b57a5a91029ba56457fbf8f09906e88bedbe6a97a0b496ee68201d0ea927cfad | Python | 6,772 | 233 | from typing import Optional
import numpy as np
import pytest
from numcodecs.abc import Codec
from numcodecs.compat import ensure_contiguous_ndarray_like
from numcodecs.registry import get_codec, register_codec
import zarr.codecs
from zarr.core import Array
from zarr.creation import array, empty, full, ones, zeros
fro... |
6c6dd498671c4249a13a480ec33cf6ffac3aa25a2dfed4242cb8d960bbd8df28 | Python | 6,774 | 160 | from .editor_tool import EditorTool
from . import shape_editor
import matplotlib
from matplotlib import widgets
import functools
class RectangleEditor(shape_editor.ShapeEditor):
def __init__(self, max_dist_resize_rect=10, **kwargs):
super().__init__(**kwargs)
self.element_type = matplotlib.patches... |
35265ac2c25be416333c14039ec913f2ea81e2deb4ea9a0c28cfc89b89751849 | Python | 6,775 | 183 | # -*- coding: utf-8 -*-
# Author: Florian Boudin
# Date: 09-11-2018
"""PositionRank keyphrase extraction model.
PositionRank is an unsupervised model for keyphrase extraction from scholarly
documents that incorporates information from all positions of a word's
occurrences into a biased PageRank. The model is describe... |
b5716612398fc289b70891c01ab1f28855b4825c69e7c75b8b21a041e5a98061 | Python | 6,775 | 193 | from __future__ import annotations
from typing import Any
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import gaussian_kde
from spatialdata import SpatialData
from spatialdata._logging import logger as logg
from squidpy._validators import normalize_choice
from squidpy.experimental.im._qc_metri... |
d013366890657ca776cc424a7d62598b3b102aacecf011531d285eecc6c71d7a | Python | 6,777 | 193 | #!/usr/bin/env python3
# Standard libraries
import sys
import os
import numpy as np
import tqdm
# Pytorch
import torch
from torch.nn import functional as F
from torchvision import datasets, transforms
# For visualization
from torchvision.utils import make_grid
import matplotlib.pyplot as plt
# Expand the module searc... |
fce915c59f299d14c3f1526b23bbc4da0f42009434dd9c1a2cc581d15e8ec9cd | Python | 6,777 | 190 | """
Manager for workflow invocation completion detection and recording.
This module provides the WorkflowCompletionManager class which handles:
- Checking if workflow invocations have completed
- Recording completion details in the database
- Polling for invocations that need completion checks
"""
import logging
from... |
a5c23e2710fc14fab67a8fc90101cce2a099b9fdad59a003cf848462c6bedb7b | Python | 6,782 | 175 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 12 14:04:32 2018
@author: jacobrosenstein
"""
import numpy as np
import chemcpupy as ccpu
class MixtureCoder:
def __init__(self,num_molecules=32,num_mixtures=8,block_size=(4,8,4)):
""" A MixtureCoder performs random block coding... |
822cb39840cbb15648b207902be5c58e40aeb6c1a85d002cdea4b7133c95cbb7 | Python | 6,796 | 147 | import xarray as xr
import pandas as pd
import numpy as np
def load_day(day, no_NNs, path, data_source='narval', resolution_narval='R02B04'):
'''
We load data from path from a given day. The data is saved in a folder per variable manner.
This function returns an array of dataframes, where each dataframe co... |
931f9d74fce32a68a22735b7373de7eefc74fb8528d0678e45e8299000403c60 | Python | 6,797 | 160 | """The prepare function converts a .bam file of paired-end sequencing reads to a .bigwig file of Tn5 cut sites
counts that are normalized for use with maxatac predict and maxatac train. The maxatac prepare
function requires samtools, bedtools, pigz, and bedGraphToBigWig be installed on your PATH to run.
See:
https://g... |
a49d20d5c8f9151eb3c23a1f0d09a5944895b161eaa8ad6cec156812d16b5b59 | Python | 6,797 | 138 | import logging
from abc import ABC
from typing import Dict, Optional
import sqlalchemy as sqlalchemy
import tensorflow as tf
from tensorflow.keras import layers
from rlmolecule.alphazero.tensorflow.tfalphazero_problem import TFAlphaZeroProblem
from rlmolecule.crystal.crystal_state import CrystalState
from rlmolecule.... |
dd4ccbca124fe61d6ee3f45d1216b70b89e0570a9600d40a92ee4a9fcf4f1ce8 | Python | 6,798 | 187 | """Define trials for the experiment."""
import numpy as np
def gen_trial(rng, nsamples):
"""Generate trials for a participant.
A trial consists out of `nsamples` samples, which are
digits between 1 and 9 that are of two colors - here
indicated by the sign (negative or positive). Each trial
contai... |
00085b37b8fe45a7fd9ff2c9227294e994e3ca051b3c4f8a0c09aebd117d34e3 | Python | 6,799 | 162 | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
d64922328417b2563e5674f58f4d2615b45d8fbe40e1dd5be8e3d350e25581a6 | Python | 6,802 | 174 | import pytest
import networkx as nx
from .base_test import BaseTestAttributeMixing, BaseTestDegreeMixing
np = pytest.importorskip("numpy")
class TestDegreeMixingDict(BaseTestDegreeMixing):
def test_degree_mixing_dict_undirected(self):
d = nx.degree_mixing_dict(self.P4)
d_result = {1: {2: 2}, 2:... |
d5b536a1bcd602d780d47d3475ce6e33d12e31800c77ea0a90c0fe3f9f27ffb4 | Python | 6,803 | 140 |
from typing import List
import pandas as pd
from pymatgen.analysis.phase_diagram import PhaseDiagram, PDEntry
from pymatgen.core.composition import Composition
from pymatgen.core.periodic_table import Element
from src.reward_utils import get_conducting_ion
# ---FERE reference chemical potentials------
fere_chempot ... |
76ba2e260d56b19e6dec3a6894801282a307d035f85a9424419e48edf83dafb2 | Python | 6,804 | 187 | """
Gomory-Hu tree of undirected Graphs.
"""
import networkx as nx
from networkx.utils import not_implemented_for
from .edmondskarp import edmonds_karp
from .utils import build_residual_network
default_flow_func = edmonds_karp
__all__ = ["gomory_hu_tree"]
@not_implemented_for("directed")
@nx._dispatchable(
ed... |
c0825c66eb1e328222d77148a4fb6482fdea6fc8606068da4fbf47732bb962d8 | Python | 6,804 | 162 | """
Create a density field for each metype listed in
`app/data/mtypes/probability_map/probability_map.csv`.
This input file can be replaced by user's custom file of the same format.
Volumetric density nrrd files are created for each metype listed `probability_map.csv`.
This module re-uses the computation of the densi... |
0d5454fe4ac3a61aadd7284936ed081d7b3bf390992205bf0a4fc3a00782cb65 | Python | 6,807 | 203 | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
import os
from ax.benchmark.benchmark_metric import BenchmarkMetric
from ax.benchmark.benchmark_problem import BenchmarkProb... |
df23800c4532beb5def10a8b576fd96595e73c2dac49fef0e69005373a6abc55 | Python | 6,807 | 206 | import matplotlib.pyplot as plt # To plot
from scipy.optimize import curve_fit
from pylab import *
import numpy as np
import random
import math
import time
import os
import glob
def rmsd(x,y):
Nx = len(x)
Ny = len(y)
if Nx!=Ny:
print('WARNING! Nx!=Ny. Could not calculate rmsd va... |
3a297e1010b00a270dbb02ada99475dafa5f89d9ccd724bda24a8d77d36cb335 | Python | 6,808 | 179 | import numpy as np
from maxatac.utilities.constants import BP_ORDER
from maxatac.utilities.genome_tools import load_bigwig, load_2bit, get_one_hot_encoded
from tensorflow.keras.models import load_model
from Bio.Seq import Seq
import pandas as pd
import pybedtools
def get_roi_variant_overlap(variants_bed: str, roi_BT:... |
e225c00941a65aab00d5f404a09f6b5b382a8fdd598b8a38f2bc45f058384850 | Python | 6,808 | 215 | ############################################################################## Setup
"""
1D Bayesian Optimization Test:
(1) Gemerate 1D objective.
(2) Initialize with data.
(3) Test predictions, variance estimation, and sampling.
(4) Run single iteration of each acquisition function.
"""
# Imports
import numpy as np
... |
105f61ee0c9f3100987c8beda24f65921d77b373c7de12084fb034be41da7a13 | Python | 6,812 | 172 | '''
Test clustering performance on synthetic dataset.
'''
from numpy import *
from klustakwik2 import *
from numpy.testing import assert_raises, assert_array_almost_equal, assert_array_equal
from nose import with_setup
from nose.tools import nottest
from numpy.random import randint, rand, randn
from six.moves import r... |
4d83a3112c51c5dd4b4ed1e1e0b3c2223dd9649e199740e835524e64fc7aba49 | Python | 6,812 | 186 | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
import warnings
from typing import Any
from ax.core.experiment import Experiment
from ax.core.search_... |
61bc491df23a42f2d940da188a3f636b510f4ad4426bd0cad1df187102694b3a | Python | 6,812 | 191 | import numpy as np
from scipy import linalg
from ..processing import knee
def regress(y, X):
"""
This function was originally written by Guo-Rong Wu, the output of this function MUST coincide with the one in function wgr_regress in rsHRF_estimation_FIR.m which is a "copy from function [b,bint,r,rint,stats] = ... |
e953bde2a1297f44b67f354332845bfc13797a583a632fe0640a50aa4c5514d2 | Python | 6,812 | 209 | import argparse
import os
import numpy as np
import math
import torchvision.transforms as transforms
from torchvision.utils import save_image
from torch.utils.data import DataLoader
from torchvision import datasets
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch... |
33afa87d85be9cca1990d7cbfacc6f3524a5a2d59ce64cd69cc04f193d755028 | Python | 6,814 | 172 | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
from unittest.mock import patch
from ax.analysis.plotly.surface.utils import (
_get_best_trial_info,
get_fixed_value... |
8c693e8e2e842e5c96d84ff79600f813a250e5f039fa892a47b54ae36af1a51f | Python | 6,815 | 200 | import logging
from tqdm import tqdm
import numpy as np
import torch
from torch.utils.data import DataLoader
from sklearn.model_selection import StratifiedKFold, GridSearchCV
from sklearn.svm import SVC
from sklearn.metrics import f1_score
from graphmae.utils import (
build_args,
create_optimizer,
set_ra... |
ae52b1d4dfcca27dc3d481c0d86827f85462e3a8c5ae88e1eee7c05710feddec | Python | 6,815 | 177 | """QC test: metabolite formula/charge (model/Human-GEM.yml) must be consistent
with the SMILES/InChI stored in model/metabolites.tsv.
Formula and charge live in the YAML (they define the model's mass and charge
balance); the structures (SMILES, InChI) live in metabolites.tsv alongside the
other metabolite annotations.... |
c3bb442aaaddc39e3fceb1d65490fd14bc116e49f995562ca014bbef186298eb | Python | 6,816 | 191 | """
Completion of SQUALL from the sorts of the engine's predicates.
An engine declares the arguments of its predicates (see
:func:`~neurolang_apps.utils.engine_registry.get_signatures`): the entities
they relate, each of a sort spanning one or more columns. A voxel
``(i, j, k)`` is one entity, so ``reports(study_id, i... |
9795f446c559e9a73bcb9d43e086c897235fe52949e737324172848851350148 | Python | 6,818 | 139 | import os, argparse
import numpy as np
from cellpose import io, transforms
import cv2
def main():
parser = argparse.ArgumentParser(description='Make slices of XYZ image data for training. Assumes image is ZXYC unless specified otherwise using --channel_axis and --z_axis')
input_img_args = parser.add_argument_... |
e498364a8174550983478e82953d99d48e72bb4bab9f64458ec19c3a19d9cfba | Python | 6,819 | 179 | import logging
from enum import Enum
from typing import (
Dict,
List,
Tuple,
)
from galaxy.tool_util.edam_util import (
ROOT_OPERATION,
ROOT_TOPIC,
)
from galaxy.util import ExecutionTimer
from .interface import (
ToolBoxRegistry,
ToolPanelView,
ToolPanelViewModel,
ToolPanelViewMode... |
1b1c05d81ae21efbedd1c1d69fd816f30bf08ded58331b2fd9b32683b32fe3eb | Python | 6,820 | 195 | from dataclasses import dataclass
from lark import Lark
from lark.exceptions import UnexpectedCharacters, UnexpectedToken
from lark.parsers.lalr_interactive_parser import InteractiveParser
from nl_expr.exceptions import UnexpectedTokenError
# Code based on https://github.com/MegaIng/lark-autocomplete/blob/master/lark... |
756f805d927510be5e63ef0af2075bba590ecae93083dd8f843369c112aa1ddb | Python | 6,822 | 185 | # -*- coding: utf-8 -*-
# Authors: Ygor Gallina, Florian Boudin
# Date: 10-18-2018
"""TextRank keyphrase extraction model.
Implementation of the TextRank model for keyword extraction described in:
* Rada Mihalcea and Paul Tarau.
TextRank: Bringing Order into Texts
*In Proceedings of EMNLP*, 2004.
"""
from __fu... |
81f7e22304b839958a2204647ef8218b141db39858d2d3c18bcea9d25a55ede6 | Python | 6,823 | 192 | # This file contains utilities for testing the dispatching feature
# A full test of all dispatchable algorithms is performed by
# modifying the pytest invocation and setting an environment variable
# NETWORKX_TEST_BACKEND=nx_loopback pytest
# This is comprehensive, but only tests the `test_override_dispatch`
# functio... |
ec614562242cd426be6b0447f24f559d47fcbbad371fea72a3d541ec02de6364 | Python | 6,824 | 221 | import numpy as np
from random import randint
################# ORIGINAL DATASETS
def NS0(imsize):
left = np.random.randint(0, 256, (imsize, imsize // 2))
right = np.random.randint(0, 256, (imsize, imsize // 2))
return np.concatenate([left, right], axis=1), 0
def NS2(imsize):
left = np.random.randint(... |
81fb997ff498e933c6e55a5930a36a137ad31a16ae5f3727b6a712031c57ce98 | Python | 6,825 | 189 | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
from collections.abc import Callable
from logging import Logger
from typing import Any, final
import pandas as pd
from ax.ad... |
32d5632f53cf7a933eb62837aeeecd9e618be4af750a70ab4bd1ac065be558e3 | Python | 6,827 | 169 | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
from collections.abc import Sequence
import numpy.typing as npt
from ax.core.types import TGenMetadat... |
2697401e0cc32e3537d81b91f57e83315cbd7c0c7200665b60ddae47cbf8d349 | Python | 6,829 | 170 | #*
# Copyright (c) Zhewei Yao, Amir Gholami, Sheng Shen
# All rights reserved.
# This file is part of AdaHessian library.
#*
import math
import torch
from torch.optim.optimizer import Optimizer
class Adahessian(Optimizer):
"""Implements Adahessian algorithm.
It has been proposed in `ADAHESSIAN: An Adaptive S... |
914d5d46f6775283cdbee074002e937da7cff4212adcc2b02a1b461af24da4a2 | Python | 6,829 | 187 | from io import BytesIO
import pytest
import networkx as nx
import networkx.readwrite.graph6 as g6
from networkx.utils import edges_equal, nodes_equal
def test_from_graph6_invariant_to_trailing_newline():
"""See gh-7557"""
G = nx.from_graph6_bytes(b">>graph6<<P~~~~~~~~~~~~~~~~~~~~~~{\n")
H = nx.from_grap... |
a70db56ac6a9c8d02b9d9c28cce9fe5ea17938eaf4faada0459eaa4b2309b43d | Python | 6,831 | 242 | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... |
bb78f7573b9e03d7cce682cdd8e28506882b57f441de905e0907dea3c5490739 | Python | 6,832 | 173 | import numpy as np
class GPSJastrow:
def __init__(self, mol, X_support, f=100):
"""
X_support: (nsupport, 2, 3) array
alpha: (nsupport) weights of each gaussian
f: spread of the gaussians
"""
self.n_support = X_support.shape[0]
self.dtype = float
sel... |
0283b629f89af7db30d5e8c211ee0f32ba5f1c16d36863b230ea24adc461ff92 | Python | 6,833 | 148 |
import os
import json
import numpy as np
import concurrent.futures
from MolRep.Utils.logger import Logger
from MolRep.Utils.config_from_dict import Config
from MolRep.Evaluations.DataloaderWrapper import DataLoaderWrapper
from MolRep.Utils.utils import *
class KFoldAssessment:
"""
Class implementing a suff... |
878bd30303b9bf343b7ae60c29730994e9a277c6f9359a689d8bb195ab4444a3 | Python | 6,833 | 185 |
"""
Created on 2020.05.19
@author: Jiahua Rao, Weiming Li, Hui Yang, Jiancong Xie
Code based on:
Shang et al "Edge Attention-based Multi-Relational Graph Convolutional Networks" -> https://github.com/Luckick/EAGCN
Coley et al "Convolutional Embedding of Attributed Molecular Graphs for Physical Property Prediction" -... |
901120fc5a906d3357a88109dc767678638e9e85c927449802a1af1b212cb0e9 | Python | 6,833 | 186 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
python %prog study.file population.file gene-association.file
This program returns P-values for functional enrichment in a cluster of
study genes using Fisher's exact test, and corrected for multiple testing
(including Bonferroni, Holm, Sidak, and false discovery rate... |
eef0ec473397866329602e2cff4cd86e5dcd941b679a35e3b7dc3309512fbc13 | Python | 6,834 | 241 | from nl_expr.expressions import (
Expression,
Symbol,
FunctionApplication as Fa,
Constant as C,
)
from nl_expr.expression_walker import (
add_match,
ExpressionWalker,
ReplaceSymbolWalker,
)
from .chart_parser import Quote, CODE_QUOTE
from .english_grammar import S, V, NP, VP, PN, DET, N, VAR... |
468082ca216ef967eddd04159be7973659690d44299cf3476fcfd9e1db3bdba5 | Python | 6,836 | 140 | # -*- coding: utf-8 -*-
from figureflow import figure
import seaborn as sb
import numpy as np
import os
import importlib
importlib.reload(figure)
Figure = figure.Figure
input_folder = os.path.dirname(os.path.abspath(__file__))
figure = Figure(input_folder,number=8, dpi=600, width=5)
figure.creat... |
353802896f76ce3722724e4993f8936c51ce5f62cf2f23ec03a5bc51a6d82e44 | Python | 6,838 | 145 | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
009655b4ac5afe7a403ae820e336cd0d45330465f7281b4068141d8c7cf502f2 | Python | 6,848 | 206 | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 26 10:43:30 2021
@author: YoussefMabrouk
"""
import numpy as np
import matplotlib.pyplot as plt
from pylab import meshgrid,cm,imshow,contour,clabel,colorbar,axis,title,show
import matplotlib.gridspec as gridspec
from oct2py import Oct2Py
from oct2py import oc... |
dde9631a562652be409ebaafe8265e758da2acf05fc7483f35dd67c874c33c09 | Python | 6,848 | 161 | import tensorflow as tf
import numpy as np
import os
from data_reload import *
# REGULARIZER = 0.01
BATCH_SIZE = 10
def compute_accuracy(v_xs, v_ys):
global prediction
y_pre = sess.run(prediction, feed_dict={xs: v_xs, keep_prob: 1})
correct_prediction = tf.equal(tf.argmax(y_pre, 1), tf.argmax(v_ys, 1))
... |
73bf1f72302b70e815651fafd93bfb4a657540fbab67fe98efa528b63dc10539 | Python | 6,850 | 169 | # -*- coding: utf-8 -*-
import pandas as pd
import os
import re
import copy
import numpy as np
import time
def goDeeper(props,this_path,a,max_a,conditions,folders):
a += 1
for newFolder in os.listdir(this_path):
if conditions[a-1] != "":
if newFolder.replace(conditions[a-1],""... |
40a55c85c75358b82edefd3e8470b3937c8f05c8900c746224fd5b3ef89e1e86 | Python | 6,851 | 203 | import argparse
import os
import numpy as np
import math
import sys
import torchvision.transforms as transforms
from torchvision.utils import save_image
from torch.utils.data import DataLoader
from torchvision import datasets
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
i... |
d1460d07681e49fce62c48372dddc9204d627c2a837a19c9374562155f8f27ea | Python | 6,853 | 146 | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
14e38f1f12c39d9187a61e8974b0a8d35123028069d7cec462d01ba13af8517f | Python | 6,855 | 146 | # Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, so... |
b7fc1e0a46bee78386149aead7b7cee1abc76e145944a4b689e757f2e0186a04 | Python | 6,858 | 217 | import argparse
import math
import os
import shutil
from collections import Counter
from pathlib import Path
import nfp
import numpy as np
import pandas as pd
import tensorflow as tf
import tensorflow_addons as tfa
import nfp
from nfp.layers import RBFExpansion
from sklearn.model_selection import train_test_split
from... |
33611d3d7e202446068cc04824c14a456188f6e6076c5396631b082de689b8e1 | Python | 6,859 | 200 | """Load centrality."""
from operator import itemgetter
import networkx as nx
__all__ = ["load_centrality", "edge_load_centrality"]
@nx._dispatchable(edge_attrs="weight")
def newman_betweenness_centrality(G, v=None, cutoff=None, normalized=True, weight=None):
"""Compute load centrality for nodes.
The load ... |
f5ed9498e05847cd6654448255fc6d7e749cf2e4753d743e18b0833f98d2740c | Python | 6,864 | 181 | # %% import
import sys, os, platform
from src.imaging_derivs import DataMatrix
from src.pipelines import ComputeMinimumControlEnergy
from src.plotting import my_reg_plot, my_distpair_plot, my_null_plot
from src.utils import rank_int, get_null_p, mean_over_states, get_fdr_p
from bct.algorithms.distance import distance_... |
1a534cc924cad72dd64f08f7cfc5b4c53de45830764afb8416e1a4e786bbfae4 | Python | 6,865 | 213 | import pytest
import networkx as nx
from networkx.algorithms import bipartite
pytest.importorskip("scipy")
class TestBipartiteLinkAnalysis:
@classmethod
def setup_class(cls):
cls.davis_southern_women_graph = nx.davis_southern_women_graph()
cls.women_bipartite_set = {
node
... |
d37d7bf23dede5111457e7959012a985d8ecf8c5e8cf7abf558efdea95f3724c | Python | 6,866 | 199 | import json
from pkg_resources import resource_stream
import os
import subprocess
import sys
from .utils import get_logger
from clpipe.config.options import BatchManagerConfig
# TODO: We need to update the batch manager to be more flexible,
# so as to allow for no-quotes, no equals, and to not have various options
# ... |
58e79a0defae6b3dea12cae1f28737645439c97f1de24463e47e8f97b094619d | Python | 6,868 | 145 | from .common import *
# Standard Demographics Logging
@Subroutine
def Demographics(self):
buttons = []
buttons2 = []
buttons3 = []
with Parallel():
# Gotta have a cursor
MouseCursor()
# background rectangle
rc = Rectangle(color='GRAY', top=self._exp.screen.top,
... |
7c84231bda09454e191540cd753859597af5fea660de122a489ef2f174d16f1b | Python | 6,868 | 199 | import json
from pkg_resources import resource_stream
import os
import subprocess
import sys
from .utils import get_logger
from clpipe.config.options import BatchManagerConfig
# TODO: We need to update the batch manager to be more flexible,
# so as to allow for no-quotes, no equals, and to not have various options
# ... |
47ee2750b15c50a2e8822161bf5bdaddad513a2a476c0f677d4e2168e7989a6e | Python | 6,869 | 228 | import numpy as np
from matplotlib import pyplot as plt
import os
import glob
from scipy.stats import zscore
import importlib
import zipfile
import math
import utils
import scipy as sp
from scipy import io
from scipy.sparse.linalg import eigsh
import csv
import power_law
import sys
import time
import scipy.stats
import... |
7764f29358c4f870b06d183727ac74f87a7dd26f6e73619855e7adbf34abca6c | Python | 6,872 | 218 | import tensorflow as tf
import numpy as np
import sys
import math
from binarization_utils import BinaryDense, AcidBaseDense, ph_activation
from keras.layers import Dense, Convolution2D, Activation, Flatten, MaxPooling2D,Input,Dropout,GlobalAveragePooling2D
from keras.layers.normalization import BatchNormalization
fr... |
b4d0ff81d9f3d73158f0317e3351356d68c7d7811601e92875b23bf135f586ee | Python | 6,872 | 317 | # -*- coding: utf-8 -*-
"""
GT
==
Interface to read and write graph tool files.
Note
----
The module utilizes the gt writer/reader from graph_tool.
See also
--------
:mod`ClearMap.Analysis.Graphs`
"""
__author__ = 'Christoph Kirst <christoph.kirst.ck@gmail.com>'
__license__ = 'GPLv3 - GNU General Pulic License ... |
7c57952be196b3da2248d3598d087a732acdd508c5d6e147dd4416d86b4c94cc | Python | 6,878 | 249 | import pytest
import networkx as nx
from networkx import convert_node_labels_to_integers as cnlti
@pytest.fixture(params=[nx.find_cliques, nx.find_cliques_recursive])
def find_clique_fn(request):
return request.param
@pytest.fixture
def G():
z = [3, 4, 3, 4, 2, 4, 2, 1, 1, 1, 1]
return cnlti(nx.generat... |
092bb2c171050ad9dfffeada37ce2aad8f989ea5b61a627c61c25068b475e126 | Python | 6,879 | 171 | '''
=================================================
Using different backends (NumPy, PyTorch, GPU)
=================================================
This example shows how to use the different computational backends available in
``pymoten`` to extract motion energy features. Backends let you run the exact
same pyra... |
62e8e0be10ac09b571e9e7ad9772599d58413c553e0d72b56009090025da5969 | Python | 6,883 | 242 | from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
import pandas as pd
import pytest
import zarr
from scipy import sparse
from zarr.storage import MemoryStore
import anndata as ad
from anndata import AnnData
from anndata.experimental import read_lazy
from anndata.tests.helpers imp... |
921cb4d5f38af329128cf8b0dd508573d098f8eccaa8f4691a7c3aa69526e062 | Python | 6,886 | 219 | '''
The implementation of PIGNPI, baseline and GN+ (lemos2021rediscovering)
'''
import numpy as np
import torch
import torch.nn as nn
from torch.functional import F
from torch.optim import Adam
from torch.nn import Sequential as Seq, Linear as Lin, ReLU, GELU, Tanh, Softplus, Sigmoid, LeakyReLU
from torch.autograd imp... |
c82283fa773ad701b176280fc5a06592b5529f18043842acaca1edb69d667aaa | Python | 6,888 | 175 | """Motion direction repulsion with 2 inner and 2 outer RDK, as in Takemura et al. (2011)"""
import numpy as np
from datetime import datetime
from strinf import WorldVeloFunction, ObservationGeneratorVelo, \
FilterStrinfNaturalParameters, FilterStrinfAdiabaticDiagonalSigma,\
inf_me... |
cf27c6d82ce153a998e981848f424fa70f065faa064989187c903c6b082ae531 | Python | 6,888 | 190 | import dataclasses
import typing
import numpy as np
from bsb import AdapterError, ConnectionModel, config, types
from bsb_neuron._util import ignore_arborize_proxy_warnings
@config.dynamic(
attr_name="model_strategy",
required=False,
default="transceiver",
auto_classmap=True,
)
class NeuronConnectio... |
64dd78338f0f631dda50bf3d5e46d17b9c09ab4890c6cb99c7beebe8cda72890 | Python | 6,892 | 282 | # -*- coding: utf-8 -*-
"""
SharedMemoryArray
=================
Shared ctype memory arrays.
"""
__author__ = 'Christoph Kirst <christoph.kirst.ck@gmail.com>'
__license__ = 'GPLv3 - GNU General Pulic License v3 (see LICENSE)'
__copyright__ = 'Copyright © 2020 by Christoph Kirst'
__webpage__ = 'http://idisco.info... |
86d41a2bc3a254e883b8ebb6cfec74f0eb3cacf9097a425fc9a12042cb742eb4 | Python | 6,894 | 210 | #!/usr/bin/env python
"""Generates go source code for any constants defined in the given python
modules."""
import optparse
import os.path
import re
import subprocess
import sys
def main(argv):
"""Process the given python modules (from PYTHONPATH) into go source."""
parser = optparse.OptionParser(
us... |
a0d2147ae86fc8afc1472490b4c6ab9d49fee1e4a717703816216332821bf06e | Python | 6,894 | 172 | from typing import (
Any,
Dict,
List,
Optional,
Union,
)
from galaxy.tool_util.deps.requirements import (
ContainerDescription,
ToolRequirement,
ToolRequirements,
)
from galaxy.util import bunch
from .mulled.util import DEFAULT_CHANNELS
class AppInfo:
def __init__(
self,
... |
8084d13144c7e27441b0e889228d4a411caa68f14510f4a4e9d9c6ff0722e10f | Python | 6,895 | 166 | # -*- coding: utf-8 -*-
import pandas as pd
import os
import seaborn as sb
from matplotlib import pyplot as plt
import numpy as np
def change_cell_number_to_string(number):
#not needed right now since all cells are just ints
#convert int to string with cellXXXX
#where XXXX is the int filled to 4 ... |
967f0dff20b429278d73c6ba1f7ca82f262a57df3f8a798eb1fa682940ba87d8 | Python | 6,901 | 155 | from __future__ import annotations
import numpy as np
import pytest
from anndata import AnnData
from squidpy.tl import var_by_distance
@pytest.fixture()
def adata_custom_spatial() -> AnnData:
adata = AnnData(np.ones((4, 1)))
adata.obs_names = ["cell_3", "cell_1", "cell_4", "cell_2"]
adata.obs["cluster"]... |
c5a390c7961ad00c61b08940cf029c36f69b68bdd6d22277ae585b633eba57be | Python | 6,902 | 190 | import numpy as np
class Subject:
"""
Stores the information corresponding to a particular subject.
Attrbutes:
1. index : This is the index of the subject (as determined by BIDS convention)
2. BOLD_raw : An array which stores the corresponding Raw BOLD time-series for the s... |
dfa8fb58ac2de0a268d886b4f8e44041646fbea3da0cd983838a490d23cb2646 | Python | 6,902 | 209 | """Abstract class implementing abstract factory pattern for building layers."""
from collections import ChainMap
from typing import Dict, List, Union
import numpy as np
from tensorflow.keras.layers import Layer
class MetaLayer:
"""Abstract class implementing abstract factory for building Layer objects.
The ... |
93be181d0b3a8684d7ba6511afd815f484f46beee52e08a8e4cb608b2368a582 | Python | 6,905 | 245 | import operator
import pytest
from nl_expr.exceptions import UnsupportedProgramError
from nl_expr.expression_walker import ExpressionWalker
from nl_expr.expressions import Constant, Symbol
from nl_expr.logic import (
FALSE,
Conjunction,
Disjunction,
ExistentialPredicate,
Implication,
Union,
)
... |
e8fc54d38aec828fab1f7bd01d5871099241982eca135fdaedae39d8bec2f6f9 | Python | 6,905 | 191 | import numpy as np
import tensorflow as tf
from packaging import version
def inverse_softplus(features):
# Cast to float64 to prevent overflow of large entries
features64 = tf.cast(features, tf.float64)
result = tf.math.log(tf.math.expm1(features64))
# Cast back to the original data type of `features`... |
2493791adc3bce498ab1f8cf6e745462f4a8745dd2d88caa89494a7d6a55b18a | Python | 6,907 | 163 | """
Created on Apr 18, 2024.
@author: voodoocode
"""
import numpy as np
import pyexcel
import finnpy.src_rec.coreg # @UnresolvedImport
import finnpy.src_rec.utils # @UnresolvedImport
def run(subj_name, anatomy_path):
"""
Execute the complete coregistration for a specific subject.
Parameters
-... |
181ea22ce10c1e1ebbe8b24dda8b69c867091164908e863cb1aabb44f7caa94b | Python | 6,912 | 215 | import logging
import os
import numpy as np
import gunpowder as gp
import incasem as fos
logger = logging.getLogger(__name__)
class PredictionBaseline:
"""Prediction pipeline with U-Net for semantic segmentation.
"""
def __init__(
self,
data_config,
run_id,
... |
d9da5d3766d6f9af3e3fb6bccc8d815a20911d3c6ab0c4250f1f6f6ae706763c | Python | 6,916 | 165 | #### tests for dataset.py (Dataset class) ####
# tested functions:
# load_combined_hemisphere_data
# Dataset - behaviour with different flags, active selection
# NOTE:
# these tests require a test dataset, that is created with get_test_data()
# executing this function may take a while the first time (while the ... |
b6424ad09f25c10a43abc3de64f82fe10ab793b47fa6e24d1a7c729d239082d4 | Python | 6,917 | 134 | import logging
import os
import shutil
import string
import time
import traceback
from xml.sax.saxutils import escape
from galaxy.util import RW_R__R__
from galaxy.util.renamed_temporary_file import RenamedTemporaryFile
from .panel import (
panel_item_types,
ToolPanelElements,
)
log = logging.getLogger(__name... |
5f80a7e797e338752a0100c0f8f7e36226c14acbf66818075f0fe83b20eea50b | Python | 6,918 | 194 | import importlib
twokenize = importlib.import_module("uff.ic.mell.sentimentembedding.utils.ark-twokenize-py.twokenize")
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.tokenize import TweetTokenizer
#nltk.download('stopwords')
#nltk.download('punkt')
import emoji
impor... |
c650ba1b179b15795be161ceabf25073cabac2eaaeaab8ab929f5ca4fb441e7e | Python | 6,920 | 159 | import numpy as np
import networkx as nx
import scipy.sparse as sp
from sklearn import preprocessing
from sklearn.utils.extmath import randomized_svd
from multiprocessing import Pool
from tqdm import tqdm
import time
from cogdl.utils import alias_draw, alias_setup
from .. import BaseModel
class NetSMF(BaseModel):
... |
53cf8377ba530ffd58292a6ad543dd0bd39ad2d985255894f2a154fd38c74f01 | Python | 6,923 | 165 | """
Multiple-kernel ridge with scikit-learn API
===========================================
This example demonstrates how to solve multiple kernel ridge regression, using
scikit-learn API.
"""
import numpy as np
import matplotlib.pyplot as plt
from himalaya.backend import set_backend
from himalaya.kernel_ridge import... |
3d45058e194673e10825d51249ec00a88a91e42cdbb84c68e09b37dd65ab7db5 | Python | 6,924 | 229 | import logging
import pkg_resources
import os
import sys
import subprocess
from os import path, getcwd, makedirs, error, walk, environ
from maxatac.utilities.constants import CPP_LOG_LEVEL
from re import match
from multiprocessing import cpu_count
def get_absolute_path(p, cwd_abs_path=None):
cwd_abs_path = getcwd... |
8bd2d493484f13cced138af72dce074b86d0d5fa9e368910d3f614dd87ed5836 | Python | 6,925 | 146 | # -*- coding: utf-8 -*-
'''
Created on 2020.05.19
@author: Jiahua Rao, Weiming Li, Hui Yang, Jiancong Xie
'''
import re
import os
import json
import yaml
import torch
import argparse
import pickle
from pathlib import Path
from MolRep.Utils.utils import *
def check_device(config):
if re.match('^(cuda(:[0-9]+)?|c... |
30e521b9c5a5eb13fb327c78394c8bbad5b5a9fc3660bd719398217f0ecdb61e | Python | 6,936 | 256 | import numpy as np
import scipy as sp
import scipy.io
from scipy.sparse.linalg import eigsh
import utils
import matplotlib.pyplot as plt
import power_law
import time
import matplotlib as mpl
from cycler import cycler
mpl.rcParams['axes.prop_cycle'] = cycler(color='bgrcmyk')
fig_dir = 'figures/'
def sorted_spectral_d... |
656e9edb2ec29714bf356ec86fc9b159946b939e4363628797eeef663648e7e9 | Python | 6,936 | 205 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 31 10:00:03 2018
@author: jacobrosenstein
"""
import numpy as np
import chemcpupy as ccpu
# This file is for miscellaenous methods.
# Note:
# To avoid creating a messy code base please refrain from adding final methods to this file.
# It is mu... |
90e353f8703dfbb9752cfe1e5dd15f2b034452963c85fa4bc4bf27ef9fcc8e9c | Python | 6,936 | 181 | #!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
""" Functions for calling cell-associated barcodes """
from collections import namedtuple
import numpy as np
import numpy.ma as ma
from cellranger.analysis.diffexp import adjust_pvalue_bh
import cellranger.stats as cr_stats
import ... |
a75bf4bc0c6aa55040ac52f0b6e9917a921050586b5689343737cf8404179a11 | Python | 6,936 | 206 | # rmf 9.24.2021, last modified 10.27.2021
import sys, re
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
from matplotlib import pyplot as plot
from cycler import cycler
# USAGE
usage = 'python ' + sys.argv[0] + ' <fileList of cleaned up/down groups> <DEGs file> <escore thresh>'
if len(sys.argv) != 4:
p... |
a6a833c043af73aada530fe04ad921876d442f193bfbd9d9012e81a0ec7d7b48 | Python | 6,938 | 195 | import os
import tempfile
import numpy as np
import pandas as pd
import pytest
import xarray as xr
from pytest_mock import MockerFixture
import ark.settings as settings
from ark.analysis import cell_neighborhood_stats
def test_shannon_diversity():
props1 = np.array([0, 0, 1])
assert cell_neighborhood_stats... |
ec1855d06c89138b6eaa7186ef156234b9632f4bf654957bbf4c4d77064021f0 | Python | 6,939 | 226 | import pytest
import torch
from spikingjelly.activation_based import functional
from spikingjelly.activation_based.encoding import (
LatencyEncoder,
PeriodicEncoder,
PoissonEncoder,
PopEncoder,
PopSpikeEncoderDeterministic,
PopSpikeEncoderRandom,
WeightedPhaseEncoder,
)
from spikingjelly.ac... |
613f50ff3373b6b3150be6021504a697e02b7bd6e8a914f9310992e7e0195c20 | Python | 6,944 | 195 | #### All original code is copyright of Graham King, Trinity College Institute of Neuroscience.
### Plotting histograms of m-values, the slopes of the regressors
from statistics import mean, median
import pandas as pd
import numpy as np
import glob
import os
import matplotlib.pyplot as plt
from scipy import stats
from... |
d49584c51630a89abab25ce9ad456ad2eda7c53ce619e9bef0bd42c54d2d755b | Python | 6,944 | 211 | """Locations where we look for configs, install stuff, etc"""
from __future__ import absolute_import
import os
import os.path
import platform
import site
import sys
import sysconfig
from distutils import sysconfig as distutils_sysconfig
from distutils.command.install import SCHEME_KEYS # type: ignore
from pip._inter... |
bf65188413427b3069421314bab43278b7c036f667cbae31a9b3d847ad3e3893 | Python | 6,948 | 138 | import numpy as np
from ..strategy import ConnectionStrategy
from ...helpers import DistributionConfiguration
from ...functions import get_distances
from scipy.stats.distributions import truncexpon
class ConnectomeGlomerulusGolgi(ConnectionStrategy):
"""
Legacy implementation for the connections between Golgi... |
13689ee61447d43d0d0fce544677d20ceee10fc0e15fc70ebe56e4ffb497ab91 | Python | 6,950 | 267 | from errr import exception as _e
from errr import make_tree as _t
_t(
globals(),
ScaffoldError=_e(
CodeImportError=_e(),
CLIError=_e(
CommandError=_e(),
ConfigTemplateNotFoundError=_e("template", "path"),
InputError=_e(),
DryrunError=_e(),
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.