sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d729a78a95a7e7231760ce8d2872b064a05c79fbb76e8cf10904d136955c20eb | Python | 6,542 | 208 | #!/usr/bin/env python
# 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
# "L... |
deaf35859c40bde3faf037be6d527d75cf633f784fbe6d3a58e7de02c395bad2 | Python | 6,545 | 182 | import io
import pickle
import sys
import time
from tqdm import tqdm
from src.gru import *
from src.pre_data import *
from src.train_and_evaluate import *
from src.warmupLR import *
import warnings
warnings.filterwarnings("ignore")
USE_CUDA = torch.cuda.is_available()
size_split = 0.8
PAD_token = 0... |
3671b71fe22d6f4a45b54818040f209ca44fa86928a84505c5ac58af54bd5a04 | Python | 6,547 | 203 | # 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... |
e646a0b9f3c81e67a3bcc358e216db7b9f154d671c77ef2b212be0905fa365a8 | Python | 6,549 | 245 | from nl_expr.expressions import Constant, Symbol
from .. import Fact
from ..instance import (FrozenMapInstance, FrozenSetInstance, MapInstance,
SetInstance)
S_ = Symbol
C_ = Constant
F_ = Fact
Q = Symbol('Q')
P = Symbol('P')
def test_frozenset_instance_contains_facts():
elements = {Q: ({... |
2f7a2d8dc8ca15fc64cfe62b21140eed8df38aaf0f1860b012953b8250639d9b | Python | 6,553 | 144 | import numpy as np
from ..strategy import ConnectionStrategy
from ...exceptions import *
from ...reporting import warn
class ConnectomeGranuleGolgi(ConnectionStrategy):
"""
Legacy implementation for the connections between Golgi cells and glomeruli.
"""
casts = {"aa_convergence": int, "pf_convergence... |
cbef14a5128c2cc04058320aa7b4d26db4b0f3ade8e2b1d2347a29f2ba601049 | Python | 6,554 | 190 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 26 15:20:33 2021
@author: Estefany Suarez
"""
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import os
import itertools as itr
import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt... |
c9aa4c6c7cbf64ea53f1ebbf0868d4549360fe6c89fd0e29d7e2f944ac961d36 | Python | 6,556 | 177 | import importlib.resources as resources
import logging
from typing import Sequence, cast
import numpy as np
import tensorflow as tf
from hidten.hmm import HMMConfig as HidtenHMMConfig
from hidten.tf.prior.dirichlet import TFDirichletPrior
from hidten.tf.prior.multivariate_normal import TFMVNormalPrior
def make_model... |
be45c63eb27c701cee00b6fd14f1db4753badad3a90ac3c09be9e852c6f9874a | Python | 6,558 | 191 | ### Not up-to-date
""" This script run the data preprocessing on a whole cohort using Preprocess class
Whole script has 3 steps
1. smooth data - write to new hdf5 file
2a. find outliers based on smoothed data & write in csv
2b. compute combat harmonisation parameter and save combat data into " combat" hdf5 file
3. int... |
c2cdefd2e9fc03eeacfd8d60d62820991ead903ac19ac7dee824d645e16adb49 | Python | 6,559 | 203 | """Tests for the catalog of the predicates of an engine."""
import io
import pytest
pytest.importorskip("prompt_toolkit")
pytest.importorskip("rich")
from rich.console import Console # noqa: E402
from neurolang.frontend import NeurolangPDL # noqa: E402
from neurolang_apps.utils import engine_registry # noqa: E4... |
ad9d8d38bb2dcb17da207ebd20ad9e12fa0499836c97b54ab845ab109ed76905 | Python | 6,560 | 189 | #!/usr/bin/env python
"""Create a foreground mask for raw EM Data using dask.
This script replicates the original logic that used daisy and funlib by:
- Reading a raw dataset from a Zarr container,
- Partitioning it into blocks (using a user\u2011provided chunk shape),
- For each block: thresholding the data, ap... |
694e672dc3699295973ec50a86d8116c7be51f662f2e13566646f14cf877c2cf | Python | 6,564 | 139 | import numpy as np, random
from ..strategy import ConnectionStrategy
from ...exceptions import ConfigurationError, ConnectivityError
class ConnectomeGlomerulusGranule(ConnectionStrategy):
"""
Legacy implementation for the connections between glomeruli and granule cells.
"""
casts = {"detailed": bool,... |
08a3553d03ea88c82464dd4a3bd104d205e8c3e3a6da4be2894df97eed19e156 | Python | 6,565 | 204 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import csv
import json
import os
import random
import sys
from itertools import product
NAME = "cloudstorages"
def read_rules(name):
rules = []
with open(os.path.join(sys.argv[1], f"{name}.csv")) as f:
reader = csv.DictReader(f)
... |
630422ffc8afeafbd15d622f8b210143f0b96ca969c649809490ec1e629a26f6 | Python | 6,567 | 171 | import os
import tempfile
from unittest.mock import MagicMock
import numpy as np
import pytest
import tensorflow as tf
from rlmolecule.alphazero.alphazero import AlphaZero
from rlmolecule.molecule.builder.builder import MoleculeBuilder
from rlmolecule.tree_search.reward import LinearBoundedRewardFactory, RankedReward... |
4e522e1ed2120f00eac7c0c6084b127837827a0ce6f1bbf500bd7c8cef12fe6b | Python | 6,570 | 189 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
import math
import unittest
from types import SimpleNamespace
from unittest.mock import Mock
from rest_framework import serializers
from cvat.apps.quality_control.attribute_comparators import (
AttributeCompa... |
5ee8b27237a2ac72f92687eb1f4027574b2e1ceec2a85e4228b5a5af416f50b9 | Python | 6,571 | 182 | #!/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 __future__ import annotations
from enum import Enum
class TrialStatus(int, Enum):
"""Enum ... |
5817e97a08c0e84be2ca15c31eaf65c748cb12dba87ecd9d3cc30cb64c4a55d8 | Python | 6,572 | 192 | #!/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 ax.core.metric import Metric, MetricFetchE
from ax.utils.common.result import Err
from ax.utils.c... |
45088e96679e4d4df3bd19e9488b5cc154d5b9b8963756d38224dd8f51988a95 | Python | 6,574 | 135 | import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42
plt.rcParams['font.size'] = 12
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Arial']
# All functions are used for plotting figures for the paper.
def plot_timeseries(... |
7189b1c563d5103498f1bfc1909deb93e2501cd520c9dffb40f900fe9c7baa9a | Python | 6,575 | 185 | # 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 final
from ax.adapter.base import Adapter
from ax.analysis.analysis import Analysis
from ax.analysis.plotl... |
6c9bfe029e01545f2bd51f3c5c680ca029121e321b3a2f5828d11b5bc6d0a5c7 | Python | 6,577 | 219 | # conftest.py
# Contact: Jacob Schreiber <jmschreiber91@gmail.com>
import os
# Both must be set before numba and matplotlib are first imported. numba
# otherwise starts one thread per core, which oversubscribes shared machines
# and gains nothing on inputs this small.
os.environ.setdefault("NUMBA_NUM_THREADS", "4")
o... |
6ccb7c48ee6273d9c03d387e16e3b7026dfcc9537d2685dd8485e454e3800a7f | Python | 6,577 | 170 | #emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
#ex: set sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See the COPYING file distributed along with the smile package for the
# copyright and license terms.
#
### ### ### ### ### ### ### ... |
de6c1c302bf6433e29b20bb6b0287c48a5315835e19026b9d4dd6fc57fb9fafa | Python | 6,577 | 220 | import struct
from pathlib import Path
import numpy as np
import pytest
import torch
from spikingjelly.datasets import transform, utils
def test_link_or_copy_falls_back_only_for_windows_privilege_error(
tmp_path, monkeypatch
):
source = tmp_path / "source"
target = tmp_path / "target"
source.write_b... |
edef7fad4568a100999c2a238942ffb93706ddf8e6cdee1c302d25c3d382b3df | Python | 6,581 | 154 | ## To be continued...
# Brainmasks in individual space were only eroded by a boxv of 1x1x1 only
# tbc
import pandas as pd
import numpy as np
import glob
import os
import nilearn.signal
import matplotlib.pyplot as plt
from scipy import stats
# import pingouin as pg
def load_arrays(one_sessid, two_sessid):
if one... |
25e6e6403d9ec220b679ca433ca1fb3df4e7dbb85c8d54cf913aecc5df7db051 | Python | 6,586 | 194 | #!/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 os
import shutil
import tempfile
from ax.core import (
BatchTrial,
Experiment,
Obj... |
fb082ab108bec703c04887359e23bb7ec373c49875d8889374d528de3d61da8c | Python | 6,589 | 222 | """
Trace
=====
Module to trace paths of minimal resitance between two points in a 3d array.
"""
__author__ = 'Christoph Kirst <ckirst@rockefeller.edu>'
__license__ = 'MIT License <http://www.opensource.org/licenses/mit-license.php>'
__copyright__ = 'Copyright (c) 2019 by Christoph Kirst'
import os
import numpy ... |
d70ad9ba2a8810df866686ca41679ea37c26d953d9e07db0c357ba5f0f09fa79 | Python | 6,592 | 177 | #!/usr/bin/env python3
import numpy as np
import torch
# -custom-written libraries
import utils
from utils import checkattr
from data.load import get_singlecontext_datasets
from models import define_models as define
from train import train_standard
from params import options
from params.param_values import check_for_er... |
933234d7e4ab804a188d8d39d114a28e84c16ce3811f2937f9acb5dfe2e7a176 | Python | 6,596 | 165 | """
Advanced example: training a NeuroQuery model from scratch
==========================================================
In this example, we train a NeuroQuery model from TFIDF descriptors and peak
activation coordinates for around 13K neuroimaging studies.
We transform the coordinates into brain maps, fit a regress... |
d07c569e6550558c6ca102fa5c7fdc128d61447f0759e6c23bc765c944b7824c | Python | 6,597 | 212 | import numpy as np
import sys
import datasets
import copy
import pickle
class DNN(object):
def __init__(self):
self.name = "MLP1"
self.pretrained = False
self.version = 1
self.layers = 2
self.stride = 2
self.c = 1
self.n_t = 1
class Hyperparameters(objec... |
55943ce2a629771718b49bbbdef1e45c43602b07e4f535cd2522cea1b408bd09 | Python | 6,602 | 245 | from collections import defaultdict
from pytest import raises
from .. import expression_walker
from .. import expressions
from typing import Callable, AbstractSet, Tuple
S_ = expressions.Symbol
C_ = expressions.Constant
F_ = expressions.FunctionApplication
def test_symbol_table_as_parameter():
symbol_table = e... |
ac57887c134a0bc289eb5bb1f8cb49c899440bd1bd82092609e17be75270551e | Python | 6,604 | 246 | from __future__ import absolute_import
from .packages.six.moves.http_client import (
IncompleteRead as httplib_IncompleteRead
)
# Base Exceptions
class HTTPError(Exception):
"Base exception used by this module."
pass
class HTTPWarning(Warning):
"Base warning used by this module."
pass
class Po... |
1817dfcbc5d2749e7ef32cf3dc6aad2e2358edb3eb8ace2a2648e69ec381cf15 | Python | 6,605 | 208 | ############################################################################## 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
... |
570130f0d5b7a1083f5d6279472f912dda1904535d80635f0b34e5bc8033f933 | Python | 6,607 | 195 | import numpy as np
import synthetic_spatial_datagen
import xarray as xr
from skimage.measure import regionprops
from ark.segmentation import signal_extraction
def test_positive_pixels_extraction():
# sample params
size_img = (1024, 1024)
cell_radius = 10
nuc_radius = 3
memb_thickness = 5
nuc_... |
b177600440c6d2a96c380ca65a5f73c93f9cfe5bb03903a15aebaceaababa340 | Python | 6,607 | 134 | from networkx.algorithms.assortativity import *
from networkx.algorithms.asteroidal import *
from networkx.algorithms.boundary import *
from networkx.algorithms.broadcasting import *
from networkx.algorithms.bridges import *
from networkx.algorithms.chains import *
from networkx.algorithms.centrality import *
from netw... |
3edf56ec8be063bd8a51ae6c06d86b140548eb9c2acfa8d422e88b5aa744c3b3 | Python | 6,608 | 208 | ############################################################################## 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
... |
a12dc146c4a878649b5e6f51cf849d90a5875b530198ee3fbf169cafa723d6bc | Python | 6,611 | 177 | import os, sys
import argparse, json, h5py, time
import numpy as np
import tensorflow as tf
import deeplift.dinuc_shuffle as ds
from basenji import dataset
from basenji import plots
from basenji import dna_io
try:
import rnann
except:
from basenji import rnann
# from basenji import trainer
if tf.__version__[0] == ... |
da4e24cb22458691bce2b22b5a1d5cf6385a93391f7a24f35f679530a06597b7 | Python | 6,614 | 158 | """
DataProvider related decorators.
"""
# I'd like to decorate the factory methods that give data_providers by the name they can be accessed from. e.g.:
# @provides( 'id_seq' ) # where 'id_seq' is some 'data_format' string/alias
# def get_id_seq_provider( dataset, **settings ):
# then in some central dispatch (maybe... |
19005269b631f9350001732ba5df54929c27dc115c78898320027c06cdde4140 | Python | 6,615 | 211 | import argparse
import os
import numpy as np
import math
import itertools
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 ... |
97b2840dd9a06bc6985104d8c8c85cc50a9c4f3b9e683ea21140040cf9671a8a | Python | 6,618 | 210 | """Supplementary washout analysis"""
import os
import numpy as np
import pandas as pd
from umap import UMAP
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt
import seaborn as sns
from surfplot import Plot
from adaptman.config import Config
from adaptman.utils import get_surfaces, fdr_co... |
d56a692c5ecc70f89dee43facce7ceef3fadf5d584f334af8815ab451b37322f | Python | 6,618 | 164 | import numpy as np
from ... import config
from ...config import types
from ...connectivity.strategy import roi_key
from .. import ConnectionStrategy
from .shape_morphology_intersection import _create_geometric_conn_arrays
from .shape_shape_intersection import ShapeHemitype
def overlap_boxes(box1_min, box1_max, box2_... |
9631d6e1127f8c16223697c712b3925ac4acfb6e76031bd5571c898606ddde06 | Python | 6,619 | 156 | # 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, Mapping, Sequence
from dataclasses import dataclass
import torch
from ax.adapter.torch... |
fdcea68af2176f27915adc933650e9f5948fdeb989698798be6ef62ce7c737eb | Python | 6,619 | 154 | import unittest, os, sys, numpy as np, h5py
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from bsb.core import Scaffold, from_hdf5
from bsb.config import JSONConfig
from bsb.models import Layer, CellType
from bsb.placement import Satellite
from test_setup import get_test_network
def relative_to_t... |
4548188ac6371a4ebf31ff8c134b50057434a66b0d65a72a7236ba5d9bdfb0f4 | Python | 6,620 | 122 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 5 13:47:17 2019
@author: schelskim
"""
from .generaltools import generalTools
import numpy as np
from skimage import morphology as morph
from scipy import ndimage
from matplotlib import pyplot as plt
import copy
from skimage.morphology import disk
class SomaTools():
... |
3303a7652cc0fb75f41c74b7738bd0e532e1995f097a5f4e10f539861bfe87aa | Python | 6,621 | 166 | # 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 MagicMock, patch
import torch
from ax.generators.torch.utils import (
_get_X_pending_and_obser... |
d993f2b89285c6229c9bcfe9b36609f0446c5538bfe9da744d72c4bb28a700bd | Python | 6,621 | 198 | """Test handling of values in `obs`/ `var`"""
from __future__ import annotations
from contextlib import nullcontext
import numpy as np
import pandas as pd
import pyarrow as pa
import pytest
from natsort import natsorted
from zarr.storage import MemoryStore
import anndata as ad
from anndata._io.specs.registry import... |
5cf7b72ae8fd8997d7c0e889abbd2661560d643e652422e7193fc2eb570eb0ac | Python | 6,623 | 176 | from __future__ import absolute_import
import logging
import os
from pip._internal.cli import cmdoptions
from pip._internal.cli.base_command import RequirementCommand
from pip._internal.operations.prepare import RequirementPreparer
from pip._internal.req import RequirementSet
from pip._internal.req.req_tracker import... |
8645735468ccfe5e45c48532bac922c77ca755a5240698e59c1f6479e06954e1 | Python | 6,628 | 227 | import operator
from typing import AbstractSet, Tuple
import pytest
from pytest import fixture
from ...datalog.translate_to_named_ra import TranslateToNamedRA
from ...datalog.wrapped_collections import WrappedRelationalAlgebraSet
from nl_expr.expressions import Constant, Symbol
from nl_expr.exceptions import NotRanke... |
95b1a01671ccdd8e6d27b2992f3b0931522082696b7e579d7b3a7adfa1b27a69 | Python | 6,628 | 185 | import numpy as np
import torch
import torch.nn.functional as F
from scipy.linalg import expm
from cogdl.layers import GCNLayer
from .. import BaseModel
class GDC_GCN(BaseModel):
r"""The GDC model from the `"Diffusion Improves Graph Learning"
<https://arxiv.org/abs/1911.05485>`_ paper, with the PPR and heat ... |
0cf97a1c712a83ae0a2e2d9c6336c0e3df9e84d226c1aac5e46f21c2ce2d1f7e | Python | 6,630 | 194 | from typing import AbstractSet
from ...datalog.basic_representation import DatalogProgram
from ...datalog.chase import (
ChaseGeneral,
ChaseNaive,
ChaseNamedRelationalAlgebraMixin,
)
from nl_expr.exceptions import ForbiddenDisjunctionError
from nl_expr.expression_walker import ExpressionBasicEvaluator
from... |
724ccc4e82c24157104d14a9a75a81a3c2a0b6ce399b186e1b5d961ce863897d | Python | 6,631 | 199 | import pytest
from pathlib import Path
import os
from typing import List
from clpipe.config.options import BatchManagerConfig
from clpipe.project_setup import project_setup, SourceDataError
from clpipe.config.options import ProjectOptions
PROJECT_TITLE = "test_project"
def test_project_setup_no_source(tmp_path: Pat... |
f8300dbe44256eb3da046c79f0c4d1ea5e9da92c63ffb69bc3bf25a9d140b1fe | Python | 6,631 | 204 | import pytest
import networkx as nx
from networkx import NetworkXNotImplemented
class TestStronglyConnected:
@classmethod
def setup_class(cls):
cls.gc = []
G = nx.DiGraph()
G.add_edges_from(
[
(1, 2),
(2, 3),
(2, 8),
... |
632bf99327f585ffcbee243f65b1bcfc50243fadfc49cff7378b424a807a275c | Python | 6,635 | 171 | """Functions for computing communities based on centrality notions."""
import networkx as nx
__all__ = ["girvan_newman"]
@nx._dispatchable(preserve_edge_attrs="most_valuable_edge")
def girvan_newman(G, most_valuable_edge=None):
"""Finds communities in a graph using the Girvan–Newman method.
Parameters
... |
c71de60262b2bb2155d88c756578acb7ec1952a4246f2744158a8c7d6015d194 | Python | 6,635 | 208 | # -*- coding: utf-8 -*-
#
# 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
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
impo... |
2e39285285227caca43bd44111f147e7b68874809f5c9f0ab5f4ff558444da53 | Python | 6,637 | 173 | # 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... |
30a6b7fe59982ee4b0ed9892b55adb9b3156f2e87c590eb5baefc05c293d8b4c | Python | 6,640 | 163 | """This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license."""
from typing import TypedDict
from drf_dynamic_fields import DynamicFieldsMixin
from drf_spectacular.utils import extend_schema_serializer
from org... |
e6b50321e8a51c43dd50f6d841c44fe6182c2a81d405d25e10108ef3d9c77893 | Python | 6,648 | 223 | # 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... |
956e12f1191b916363d33825f45103a2ce93df8830049343a132fcf10c27f765 | Python | 6,649 | 116 | from matplotlib import pyplot
import pandas as pd
from matplotlib.pyplot import figure
def generate_boxplot():
path_to_results_to_plot = "../results/ml_results/users_results_to_plot.csv"
df_results_to_plot = pd.read_csv(path_to_results_to_plot)
df_results_to_plot = df_results_to_plot.reset_index(drop=True... |
29f30fe7d2be0827c72ed24e44b75ab37b5e959877456b35c16b655de93edc6c | Python | 6,650 | 207 | """Internal constants not exposed to the user."""
from __future__ import annotations
from collections.abc import Callable, Mapping, Sequence
from typing import Any
from anndata import AnnData
_SEP = "_"
class cprop:
def __init__(self, f: Callable[..., str]):
self.f = f
def __get__(self, obj: Any,... |
6248eee6ae3ba3245681cce4005d229670384fafeedb64e17f82b3fad30a0db5 | Python | 6,652 | 155 | import os
import json
from tqdm import tqdm
import numpy as np
import pandas as pd
from sklearn import manifold, cluster, tree, model_selection
from data_analysis.extract_features import extract_features_information_metrics
from matplotlib import pyplot as plt, cm, colors
from scipy.cluster import hierarchy
PATH_TO_DA... |
70608084e91dfcb567a442f2f82fb379599f289e3408920f0b43edce17015ae6 | Python | 6,653 | 179 | import pandas as pd
import numpy as np
import glob
import os
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.colors import Normalize
from scipy import stats
import seaborn as sns
import pingouin as pg
def loadfc(allfc):
sz=allfc.shape
print(f"starting allfc shape is: {sz}")
nsubj... |
79d65d30ef1fb970e7a3b539872d87fece80ec55aeb923d577d9cff13bb1a903 | Python | 6,655 | 196 | from __future__ import annotations
import numpy as np
import pytest
import spatialdata_plot as sdp
import squidpy as sq
from squidpy.types import FelzenszwalbParams, WekaParams
from tests.conftest import PlotTester, PlotTesterMeta
_ = sdp
class TestDetectTissue(PlotTester, metaclass=PlotTesterMeta):
# test seg... |
c8570a7ca92223a16a1159415712dad5f6ea23561e8aa7bf0397e93e762f9401 | Python | 6,655 | 216 | import functools
import networkx as nx
__all__ = [
"edge_betweenness_partition",
"edge_current_flow_betweenness_partition",
]
@nx._dispatchable(edge_attrs="weight")
def edge_betweenness_partition(G, number_of_sets, *, weight=None):
"""Partition created by iteratively removing the highest edge betweennes... |
98699df34deaacdf134f0ce4be98271da8c296272bbeb994837c9fc71173359a | Python | 6,657 | 175 | import torch
import os
from rdkit import Chem
from torch_geometric.data import Batch
import sys
path = sys.argv[1]
os.system(f"babel {path}/ligase_ligand.mol2 {path}/ligase_ligand.mol2 >/dev/null 2>&1")
os.system(f"babel {path}/ligase_pocket.mol2 {path}/ligase_pocket.mol2 >/dev/null 2>&1")
os.system(f"babel {path}/t... |
f4e91897e11c5ac3ea437503080c7f674f5aeb88aaa8ee0ce070ae7798f4a057 | Python | 6,670 | 194 | from __future__ import print_function, unicode_literals, absolute_import, division
import numpy as np
from time import time
from .utils import _normalize_grid
import tensorflow as tf
def non_maximum_suppression(coord, prob, grid=(1,1), b=2, nms_thresh=0.5, prob_thresh=0.5, verbose=False, max_bbox_search=True):
"... |
c2f9643d42946911e2a3e3deae6fcdb14895f265c6000646e23ca2cedbbff58d | Python | 6,674 | 268 | #!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
"""
Simple Good-Turing estimator.
Based on S implementation in
William A. Gale & Geoffrey Sampson (1995) Good-turing frequency estimation without tears,
Journal of Quantitative Linguistics, 2:3, 217-237, DOI: 10.1080/09296179508... |
4a96d37c6df7553d2b66a6a97e62db1f46bf90cd8fc4bc6f7cfe44edd4e5b98a | Python | 6,675 | 214 | from functools import partial
import torch
import torch.nn.functional as F
from .. import BaseModel
from .mlp import MLP
from cogdl.data import Graph
from cogdl.utils import spmm
def autoscale_post(x, lower, upper):
return torch.clamp(x, lower, upper)
def fixed_post(x, y, nid):
x[nid] = y[nid]
return ... |
59c83e23029ca52228a7f3b5d6d6b3f5ac6928f19617655e8d693f183c0e0238 | Python | 6,677 | 122 | """Build the MD-dMRI conductivity tensor (sigma ~ <D>) -> tensor_MD_dMRI.nii.gz, via SimNIBS 'vn'
(same downstream physics as dwi2cond's DTI model; only the input tensor differs).
Reconstructs D = sum_k lambda_k v_k v_k^T in T1 space: eigenvalues are warped independently as
scalar maps (FLIRT trilinear), the frame via... |
b0b0edb9000acf90764abd630fede0d14dbbfbb2863e9da435826e8760670d33 | Python | 6,677 | 171 | # 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... |
08d8da12ef2eda8ac7b1607e3bc0db9283d26e18dfc3b1004008fd0e16d087d4 | Python | 6,687 | 169 | import os
import tempfile
import unittest
import warnings
import h5py
from bsb_test import RandomStorageFixture, skip_parallel
class TestHDF5Provenance(RandomStorageFixture, unittest.TestCase, engine_name="hdf5"):
"""Verify the HDF5 engine writes & maintains the provenance bundle."""
def test_create_writes_... |
9961b47ee9dfe841764e4b732cc0c6007c1af54925edbebf4a760557a9da8b84 | Python | 6,691 | 190 | #!/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 __future__ import annotations
from copy import deepcopy
from enum import StrEnum
from functools ... |
2d35add65eb6f665b7bc2e9c43f7edd322844634662f018328064f81be557dd1 | Python | 6,696 | 176 | import numpy as np
from bsb_native import connect_segments
from ... import config
from ...config import types
from ..strategy import ConnectionStrategy
from .shared import Intersectional
@config.node
class SegmentIntersection(Intersectional, ConnectionStrategy):
"""
Connect cells whose morphology branches, t... |
584b499bf61484c18a3d713f69555161a9a869a2379c777ec50a65d04dcb9cf6 | Python | 6,699 | 189 | """
This script implements the AMULET algorithm for doublet detection on snmC like data.
The AMULET algorithm consider coverage information of each cell to predict doublets.
It is complementary to the Scrublet like algorithm that uses molecular information.
This algorithm is only suitable for DNA based sequencing data... |
37a2dcf860e12e060f8709050ffdf8979d35abaf9f03f4cab5716a1d9f3d1b09 | Python | 6,700 | 167 | # -*- coding: utf-8 -*-
"""
Control experiment to check whether microtubules are photoconverted
along the entire neurite -
especially whether microtbules at the top are reached as well
Use hyperstacks with two channels (one for TUBB2a-mEos one for TUBB5-halo)
as zstacks with the photoconverted channel for mEos
... |
225250169857a0604a64f5b7857e080ffad387a2f3716fb7334ec527cc481cc8 | Python | 6,702 | 147 | # encoding: utf-8
# copyright: GeoDS Lab, University of Wisconsin-Madison
# authors: Yuhao Kang, Song Gao, Jinmeng Rao
import pandas as pd
import numpy as np
import os
import geopandas as gpd
import argparse
import datetime
parser = argparse.ArgumentParser(description='Month, start day, end day')
parser.add_argument('... |
4b2eefd057ff5030ba564ab73b70a9a2813f0f63a6174708b16e4d4bf1f726da | Python | 6,703 | 211 | from functools import partial
import pytest
import networkx as nx
class TestBFS:
@classmethod
def setup_class(cls):
# simple graph
G = nx.Graph()
G.add_edges_from([(0, 1), (1, 2), (1, 3), (2, 4), (3, 4)])
cls.G = G
def test_successor(self):
assert dict(nx.bfs_suc... |
cf7355a1f3c6af98db91fb37f96dc29ae7fccc9c5ba8312e57ff0fe6aaee2a04 | Python | 6,707 | 186 | import io
import pickle
import sys
import time
from tqdm import tqdm
from src.gsfsf import *
from src.pre_data import *
from src.train_and_evaluate import *
from src.warmupLR import *
import warnings
warnings.filterwarnings("ignore")
USE_CUDA = torch.cuda.is_available()
size_split = 0.8
PAD_token =... |
eca68cd44c9cdf71e9bf80e727a4b50059fa5429a951622782547eb23a1a6fb6 | Python | 6,708 | 198 | import operator as op
from typing import (AbstractSet, Any, Callable, Generic, Mapping, Set,
SupportsInt, T, Tuple, Union)
import pytest
from .. import (NeuroLangTypeException, Unknown, get_args, get_origin,
infer_type, is_leq_informative, is_parameterized,
is_param... |
f433231fb5c058b46609747240ec7bafc9a9def94972da76e09468df78a8832f | Python | 6,708 | 218 | # -*- coding: utf-8 -*-
"""
Interface to write points to VTK files
Notes:
- points are assumed to be in [x,y,z] coordinates as standard in ClearMap
- reading of points not supported at the moment!
"""
#:copyright: Copyright 2015 by Christoph Kirst, The Rockefeller University, New York City
#:license: GNU, see... |
e890f3b7e02ec17577be0c9fa4dbfeaedf6e23a7e30f99f67761ecc1aef973c4 | Python | 6,711 | 149 | # generated by datamodel-codegen:
# filename: https://opensource.ieee.org/2791-object/ieee-2791-schema/-/raw/master/provenance_domain.json
# timestamp: 2022-09-13T23:51:55+00:00
from __future__ import annotations
from datetime import datetime
from enum import Enum
from typing import (
List,
Optional,
)
... |
8486aa13ae8642b6979b97cb52d8178705b5db7149e81cfc520d8eedb0bdc65d | Python | 6,712 | 162 | from __future__ import annotations
import numpy as np
import pandas as pd
import pytest
from anndata import concat, read_h5ad
from spatialdata.models import TableModel
from squidpy import gr
from squidpy.gr.neighbors import KNNBuilder
@pytest.mark.parametrize("spatial_key", ["spatial", "custom_coordinates"])
@pytes... |
7c9ae7628bbf19222b5351ca511a42e671d93c67add23544ca333a7caf8a40be | Python | 6,713 | 191 | 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... |
e104076c6a2e7101dd458c0e52f18b830edd06cf20e360e0678f035af1291c1c | Python | 6,715 | 139 | # 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... |
19eb4e5541191be8f0a728aae7705bc79ed2a3208be0e02c7ca7e9da65dd4504 | Python | 6,717 | 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... |
7985f0779242be20ffeb6de0fbd54d82018beabe1b467796931c5b0cd5a85cf8 | Python | 6,719 | 167 | from os.path import basename
from pathlib import Path
from typing import (
cast,
Optional,
)
from galaxy import exceptions
from galaxy.files import ConfiguredFileSources
from galaxy.files.uris import stream_url_to_file
from galaxy.managers.context import ProvidesUserContext
from galaxy.model import DatasetInst... |
17088c5ef49c2343d1bb7e4f5c758bafdf242c57e0bbe771cd0307ae85af9c99 | Python | 6,723 | 122 | #author: Dimitris Spathis (ds806@cl.cam.ac.uk)
"""
what: pre-process acceleration and heart-rate data of Fenland I full cohort:
in: user IDs, ACC, HR
out: CSVs of extracted features + metadata per user
"""
import numpy as np
import pandas as pd
from tqdm import tqdm
import glob
#we use a sample user for this releas... |
e74cad27c3e22ba60a3b997674fd393c1c36ba1359f04359a5e6dfe845412af2 | Python | 6,723 | 154 | import numpy as np
import torch
from torch.nn import functional as F
##-------------------------------------------------------------------------------------------------------------------##
####################
## Loss functions ##
####################
def loss_fn_kd(scores, target_scores, T=2., weights=None, norm=F... |
5bf16a80210ce6dec46f2f424409197ec9a6fba764f08a2b59c240b7ac682ba5 | Python | 6,724 | 143 | import torch
import tqdm
import copy
from utils import checkattr
from models.cl.continual_learner import ContinualLearner
def train_on_stream(model, datastream, iters=2000, loss_cbs=list(), eval_cbs=list()):
'''Incrementally train a model on a ('task-free') stream of data.
Args:
model (Classifier): mo... |
7b5aed0cf620fc17043476f08ebb470db264d625f14d97cc34f0191b199fa0f7 | Python | 6,726 | 162 | # coding: utf-8
# 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"... |
5e8492c398a2e3f24d9fbeb44905ad9361be0a5cb69ec06ec1d49efff4329cd1 | Python | 6,731 | 191 | """
Local Regression (LOESS) estimation routine with optional
iterative robust estimation procedure. Setting `robustify=True`
indicates that the robust estimation procedure should be
performed.
"""
import numpy as np
import pandas as pd
import scipy
import warnings
warnings.simplefilter("ignore")
def loc_eval(x, ... |
7699525f5412deee24b62b4bc2243f1353d7c21d20577138ecd5f9f3c23205d7 | Python | 6,737 | 181 | '''
Processing the Drishti images.
We'll generate two different rims.
1. Using the whitest area (most agree on)
2. Using the largest area
We're assuming all images are .png format
We're assuming all images have a corresponding GT segmentation folder
We're assuming the cup segmentation folder contains 'cupseg' in the ... |
3357a8cbc3adb90559904bcd31ab95f6fa91ea11ed382aedaba20dbf6ab33320 | Python | 6,739 | 179 | """Maximum weight clique test suite."""
import pytest
import networkx as nx
class TestMaximumWeightClique:
def test_basic_cases(self):
def check_basic_case(graph_func, expected_weight, weight_accessor):
graph = graph_func()
clique, weight = nx.algorithms.max_weight_clique(graph, ... |
ccb59f83ad27404419bab0ef85607d0c5b4b9c9d4dbb5db67883c89fc69716a6 | Python | 6,742 | 122 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 5 13:47:17 2019
@author: schelskim
"""
from .generaltools import generalTools
import numpy as np
from skimage import morphology as morph
from scipy import ndimage
from matplotlib import pyplot as plt
import copy
from skimage.morphology import disk
cl... |
6befeafe9352b678119b1db74eb262bbf8a7a4c6a02a4463a5337c30019c155a | Python | 6,743 | 221 | import copy
import pytest
import numpy as np
import gunpowder as gp
import incasem as fos
class Source(gp.BatchProvider):
def __init__(self, voxel_size, key_a="A", key_b="B"):
self.voxel_size = gp.Coordinate(voxel_size)
self.roi = gp.Roi((0, 0, 0), (10, 10, 10)) * self.voxel_size
self.ra... |
f1703a694d2cc336e713a6c0b72d11f76a78e63e1745649c450a99e9fb67e2ad | Python | 6,746 | 218 | # -*- coding: utf-8 -*-
"""
Interface to write points to VTK files
Notes:
- points are assumed to be in [x,y,z] coordinates as standard in ClearMap
- reading of points not supported at the moment!
"""
#:copyright: Copyright 2015 by Christoph Kirst, The Rockefeller University, New York City
#:license: GNU, see... |
53e23c3b2fdf03fc8c77d49892e9554b2960a6723ed76b8859937a2b66cf473a | Python | 6,748 | 183 | """Tests for the script that builds the bundle of the REPL in the browser."""
import importlib.util
import os
from pathlib import Path
import pytest
requests = pytest.importorskip("requests")
SCRIPT = Path(__file__).resolve().parents[6] / "doc" / "make_repl_bundle.py"
@pytest.fixture
def bundle():
spec = impo... |
5d4db73c680c78e53c5535018a378a697a85e04e6393082b0fa2067337ff2aee | Python | 6,749 | 182 | import numpy as np
import matplotlib
from moten import (pyramids,
utils,
core,
io,
)
# need high accuracy for tests
DTYPE = np.float64
##############################
#
##############################
video_file = 'http://anwarnunez.github.io/... |
bfaa62878af8cee063736f1e7f0a8300dde99d734e61a3295e502d1ce231f715 | Python | 6,749 | 194 | """IWC (Intergalactic Workflows Commission) manifest fetching and search helpers.
Manifest fetches go through a process-wide TTL cache so the per-request
``AgentOperationsManager`` instances all share the same hit. Pre-warming
the cache via celery beat is a reasonable follow-up.
"""
import logging
import re
from thre... |
e9a59be534a872fd33c4f3b5d0af4b5824ff162c030d22095776b01e6e7c6025 | Python | 6,750 | 177 | """Isolated neuron/layout-chain timing and CUDA-profiler capture workload.
Launch this script with the NSYS CLI for capture; --profile only controls the
capture window and NVTX ranges. Use separate runs without --profile for timing.
The static-prefix workload computes Conv/BN once before expanding over time.
For isola... |
58b01dbc659cb0f4bd38636bcff83a770cb81521fba921f01c93a4ff2cb27f15 | Python | 6,756 | 211 | import os.path as osp
import pickle as pkl
import sys
import numpy as np
import torch
from cogdl.data import Dataset, Graph
from cogdl.utils import remove_self_loops, download_url, untar, coalesce, Accuracy, CrossEntropyLoss
def parse_index_file(filename):
index = []
for line in open(filename):
inde... |
b41e74a45b2a83203aeb3252dd8fa7bc5dd31bc7c77c50c78f839c340c325808 | Python | 6,760 | 191 | """ Edge info DataFrame IO for processing tasks """
import os
from sqlalchemy import select
import pandas as pd
from ... import io
from .. import colnames as cn
from . import filenames as fn
EDGE_INFO_COLUMNS = [cn.seg_id, cn.size, cn.presyn_id, cn.postsyn_id,
*cn.presyn_coord_cols, *cn.posts... |
892fb3664746703d4f16da917a46c8d21cf17b0236882a74fdde3acd4d676b7c | Python | 6,764 | 191 | """
Completion of the values inside quotes and of the variables of a tuple.
Inside a quoted string, the values of the column it fills are offered:
after the SQUALL verb ``mentions '``, those of its object (a term), and
in Datalog ``mentions(s, '``, those of the argument. They are read from
a stored relation: the plain... |
92e0271aa25470b23e632e7cab3b1673275896b0b600fadd27e6af7753820733 | Python | 6,765 | 174 | """
Datatypes for Anvi'o
https://github.com/merenlab/anvio
"""
import glob
import logging
import os
from typing import Optional
from galaxy.datatypes.metadata import MetadataElement
from galaxy.datatypes.protocols import (
DatasetProtocol,
HasExtraFilesAndMetadata,
)
from galaxy.datatypes.text import Html
lo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.