sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
017944c85d943ed1e8b15f2b65c98bfca8d638c3a80d5fb6766ed8cce4f9e11a | Python | 5,996 | 210 | """
==========================
Iterated Dynamical Systems
==========================
Digraphs from Integer-valued Iterated Functions
Sums of cubes on 3N
-------------------
The number 153 has a curious property.
Let 3N={3,6,9,12,...} be the set of positive multiples of 3. Define an
iterative process f:3N->3N as fo... |
9c4aa8a4735d6d7c85e543b1dba39917eef17bb7785213b34f4bb455abd31963 | Python | 6,000 | 122 | from typing import Union
import numpy as np
import tensorflow as tf
from . import ModelVisualization, keras
from .utils import get_num_of_steps_allowed, listify, normalize
class Saliency(ModelVisualization):
"""Vanilla Saliency and Smooth-Grad
References:
* Vanilla Saliency: Deep Inside Convolution... |
56f2df2c02a17a1f5eacc35a41920c035c63154ab5aa7b12fd8334a0f47abb2d | Python | 6,005 | 182 | from __future__ import annotations
from functools import partial
from typing import TYPE_CHECKING
import joblib
import numpy as np
import pandas as pd
import pytest
from scipy import sparse
import anndata as ad
from anndata import AnnData
from anndata.compat import CupyArray
from anndata.tests.helpers import as_cupy... |
f483a29988f2a403ab0913496179edcb3a1b7b7079c1586f75e7400f768b7705 | Python | 6,006 | 174 | # A collection of help functions needed in peixotos_hierarchical_sbm.py
import math
import numpy as np
NUMBER_OF_RESTRICTED_PARTITIONS_PRECOMPUTED_LIMIT = 1000
spence_constants_a = [
4.65128586073990045278E-5,
7.31589045238094711071E-3,
1.33847639578309018650E-1,
8.79691311754530315341E-1,
2.71... |
6511fbc29deaabb119db5959804d88592c6249176a575a8a7e415f4f8d1cc92c | Python | 6,010 | 190 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import annotations
import itertools
from collections.abc import Callable, Sequence
from typing import NamedTuple, TypeAlias, TypeVar
import numpy as np
from attrs import define
from scipy.optimize import linear_sum_assignment
from ... |
f3f9d55009dd500670c406b1efe6bc1892b7b26d84364945423b930f2dd26a81 | Python | 6,010 | 200 | import numpy as np
from sklearn.base import BaseEstimator
from divik.core import configurable
from ._stat_selector_mixin import StatSelectorMixin
def _medcouple_1d(y):
"""
Calculates the medcouple robust measure of skew.
Parameters
----------
y : array_like, 1-d
Data to compute use in t... |
ad217271f26303b73340b067e642090eca86abf985ac0e0fd230c68c99d89768 | Python | 6,012 | 133 | import keras
from keras.models import Sequential, Model, model_from_json
from keras.layers import Input, Dense, Dropout, BatchNormalization, LocallyConnected1D, Flatten, Conv1D
from keras import backend as K
from keras import regularizers
#from keras.objectives import mse
from keras import regularizers, optimizers
from... |
826e33670899cbdc97945b442f2c77fa8f81042f26b752a87454d68493c94841 | Python | 6,013 | 232 | """
Store a sequence of 2D .tif images in 3D blockwise zarr format.
This script does not run in the default incasem environmet due to dependency
conflicts between dask and daisy.
Please create a new environment and install the following dependencies:
- python 3.8
- dask[complete]
- zarr
- configargparse
- sc... |
152779111500ecb9d8701077042b6e210b28a9a6911a5caca4c541a3d1df8a13 | Python | 6,014 | 199 | from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
import pytest
import anndata as ad
from anndata import ImplicitModificationWarning
from anndata.tests.helpers import GEN_ADATA_DASK_ARGS, assert_equal, gen_adata
from anndata.utils import asarray
if TYPE_CHECKING:
from typing... |
6529975b0e16694d8e2db6b4e9c6adda6e0d38ed697964bc715565bb2effadbe | Python | 6,015 | 138 | # 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... |
ad1c45febc0afe71bd2f3902cf373f2f009d87d069ef47a1adf959978d9abc5e | Python | 6,015 | 201 | # 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... |
6098e2367c82a6d7ecc41bdfe4a850979a07f743799e95e4846cff796c782a56 | Python | 6,016 | 198 | # -*- 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 ------------------------------------------------------------... |
7bc0bb005db08636aa77181aed64af0abb48c7b072046fc9c89f6062a27a1c10 | Python | 6,020 | 189 | """Generators - Directed Graphs
----------------------------
"""
import pytest
import networkx as nx
from networkx.classes import Graph, MultiDiGraph
from networkx.generators.directed import (
_random_k_out_graph_numpy,
_random_k_out_graph_python,
gn_graph,
gnc_graph,
gnr_graph,
random_k_out_g... |
d7148077dbc8e088f355d3e7671f9c3074147570c34b318057a0ea5c10fbc4e1 | Python | 6,021 | 151 | #!/local/cluster/bin/python
# last modified rmf 4.21.2021
# cleaned up 3.2.2022
import sys,math,argparse
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
from mpl_toolkits.mplot3d ... |
caaafec62a0134426fca65e9eff9db2034915201f4b049ab2e746daf0dd3103b | Python | 6,023 | 136 | import gc
import time
import pandas as pd
import numpy as np
import os
from sklearn.preprocessing import LabelBinarizer
def calculate_max_group(path):
print("Calculating max group")
all_prods = np.zeros((1, 5))
for folder in os.listdir(path):
filepath = (path + str(folder) + '/')
for file... |
e5665a80ba10e63c8a815b7d0eb022b95921315e6ccdc6feff60c1f14254ea91 | Python | 6,024 | 193 | """
=========
Antigraph
=========
Complement graph class for small footprint when working on dense graphs.
This class allows you to add the edges that *do not exist* in the dense
graph. However, when applying algorithms to this complement graph data
structure, it behaves as if it were the dense version. So it can be ... |
d30804a45378cf49beefc3c9e153979c7f2ddbbc5c673d93cd00a64198b16844 | Python | 6,025 | 170 | import sys
import numpy as np
import tensorflow as tf
from scipy import interpolate
from .model import Model, default_opt
from .layers.subpixel import SubPixel1D, SubPixel1D_v2
from tensorflow.python.keras import backend as K
from keras.layers import Concatenate, Add, MaxPooling1D, MaxPooling2D, AveragePooling1D
fro... |
8c8fd608dc32105f32051bd84d2d391e568d86ca71e6cd42227f97b4232518fb | Python | 6,026 | 146 | #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.
#
### ### ### ### ### ### ### ... |
fe0c0e8964a4bf33a32dde032f074a603c3dcac5bef167e5f00238b8a98e6d2f | Python | 6,027 | 218 | import re
import os
import xml.etree.ElementTree as ET
from nltk.tokenize import word_tokenize
from nltk.tokenize import TreebankWordTokenizer
#NOTE: I tried a few of the other ones and TreebankWordTokenizer worked best.
import nltk
# Example filename:
filename = 'deid_surrogate_train_all_version2.xml'
DATADIR = '../... |
75ff2eb586d6746b2a6403a7db18dbeb2e1916e7e256e17878d255c60cb9ae89 | Python | 6,033 | 162 | import os
import torch
from typing import Iterator, Dict, List, Tuple
from allennlp.data.vocabulary import Vocabulary
# from allennlp.data.iterators import BucketIterator, BasicIterator
from allennlp.common.tqdm import Tqdm
from allennlp.nn.util import get_text_field_mask
from sklearn.preprocessing import StandardSca... |
f236ab279b03815ebf012a6a4075e0b8b8307cda0ec09ffeb753a0087de73603 | Python | 6,033 | 113 | """Reconstruct the QTI covariance mean tensor <D> and supporting maps (S0, eigenvalues, v1,
FA, MD, uFA, brain mask) in dMRI space. Called by 02_register_dmri_to_T1.sh before
registration to T1.
Reads run_qti_cov_cohort.m's covariance fit only (qti_cov/cov_mfs.mat + cov_dps.mat), NOT the
full-DTD Monte-Carlo fit (dps.... |
4bc6797757cb741e4c432547c32e695a6910ee3b0c39a1b7096b67e5f439032f | Python | 6,034 | 196 | import numpy as np
from scipy import optimize as opt
class loss_function:
def __init__(self, y_true, class_weight = "balanced"):
self.y_true = y_true
if class_weight == "balanced":
majority = len(y_true) - np.sum(y_true)
minority = np.sum(y_true)
... |
37e27e76006023bef2b58514ad78ddb8bc6d0f2747ee34be69ff7c7f23c19187 | Python | 6,036 | 248 | import pytest
import networkx as nx
from networkx import NetworkXNotImplemented
def assert_components_edges_equal(x, y):
sx = {frozenset(frozenset(e) for e in c) for c in x}
sy = {frozenset(frozenset(e) for e in c) for c in y}
assert sx == sy
def assert_components_equal(x, y):
sx = {frozenset(c) fo... |
9d3d309adf90ebd09e6193b7045f0c8d9db2f5b3b042d06ebed27bd6ceb2a1ea | Python | 6,038 | 164 | import torch
from matplotlib import pyplot as plt
from matplotlib.ticker import AutoLocator, AutoMinorLocator
from ..utils.convert_units import freq_to_wl
from ..training.model.model_to_eps_grid import model_to_eps_grid
from ..trcwa.load_material_data import _load_material_data
from ..materials.material_collection imp... |
506c4e1216fa985bf3ebae698fa93aa8fd4e95c6bcd7fe7993d60e5e8645f385 | Python | 6,039 | 149 | import cooler
from sample_patches import run_sample_patches
from generate_node_features import run_generate_node_features
from train import train_run
from predict import run_output_predictions
from cool_handling import extract_oe_normalized, normalize_cooler, align_sequencing_depth, GCN_downsampling, rename_cooler_chr... |
cec416fe05c791551c4574cd66bb1b1b7d536bcf294a9959e582f12262757603 | Python | 6,040 | 225 | # test_bed_writer.py
# Contact: Jacob Schreiber <jmschreiber91@gmail.com>
from collections import OrderedDict
import pytest
from modiscolite.bed_writer import BEDTrackLine
from modiscolite.bed_writer import BEDRow
from modiscolite.bed_writer import BEDTrack
from modiscolite.bed_writer import BEDWriter
from numpy.te... |
ec40a2dc995419df87fc32757e3d96fd789f8dd96234d3cfd7d135ef12ec9962 | Python | 6,040 | 147 | from cellpose import io, metrics, models, utils, train, transforms, dynamics
import time
from tqdm import trange
import torch
import numpy as np
from pathlib import Path
from natsort import natsorted
import argparse
import os
torch.backends.cuda.matmul.allow_tf32 = True
def train_subsets(root, seed=0, ntrain=1,
... |
4f5c471abf29fde0b5a4453208ffa4a5a625218fe56bf9acf89d3ee747381039 | Python | 6,041 | 182 | """
===========================
Depth First Search on Edges
===========================
Algorithms for a depth-first traversal of edges in a graph.
"""
import networkx as nx
FORWARD = "forward"
REVERSE = "reverse"
__all__ = ["edge_dfs"]
@nx._dispatchable
def edge_dfs(G, source=None, orientation=None):
"""A d... |
d23d8adfa18cbff67d3fdb6a0288765ae42a1c8fd3d8dbaab9544916bb98a99c | Python | 6,043 | 155 | import pytest
import sklearn.linear_model
from himalaya.backend import set_backend
from himalaya.backend import ALL_BACKENDS
from himalaya.utils import assert_array_almost_equal
from himalaya.lasso import solve_sparse_group_lasso
from himalaya.lasso import solve_sparse_group_lasso_cv
def _create_dataset(backend):
... |
e501a54f4429287dde7cb5d059d5bd17b5a9b441f7128934cafa7e5601f96f1c | Python | 6,044 | 150 | # -*- 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
# get the path to the data of the respective figure or movie
# the data is in the data folder in a folder with the same
# name as the folder that t... |
75e3752c214cae3f9e1d0bacb4cdbc5c450c89ef43c6d7b77cc494b7b6d90f7e | Python | 6,045 | 213 | """Figure 2 plot - RSA models and timecourses."""
# %%
# Imports
import json
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from mpl_toolkits.axes_grid1 import make_axes_locatable
from config import ANALYSIS_DIR_LOCAL, STREAMS
from model_rdms import get_mo... |
d42ecbde575d49d907b7ab774dea04a38820ac83a06e42dc923628ae0f0cef23 | Python | 6,045 | 176 | import os
import sys
import argparse
from Bio import SeqIO
import warnings
from util import *
#'TER', 'END'
def delete_elements(fhandle, element='TER'):
for line in fhandle:
if line.startswith(element):
continue
yield line
def pad_line(line):
"""Helper function to pad line ... |
25fb4266ee5a976516f7c5525ab75c5c71bffb17738650f3351c31364c4d5dce | Python | 6,047 | 165 | """
Created on Jan 30, 2019.
Provides a memory and cpu sensitive version of the multiprocessing tool.
:author: voodoocode
"""
import multiprocessing
import time
import numpy as np
def _manage_sub_process(func, args, child_pipe, return_data_lock):
"""
Commands a sub-process to execute *func* with the argume... |
ded4dd0d631604ff52faebaa27478cbf0389c73ddaaab24c954980eb677f368b | Python | 6,047 | 147 | # 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... |
94a1eb9b88138546a1d6a07d47057b114855877255253abe98d7154eca8d9916 | Python | 6,049 | 151 | from django.conf import settings
from django.db import transaction
from projects.models import Project
from rest_flex_fields import FlexFieldsModelSerializer
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from .models import Label, LabelLink
class LabelListSerializer(ser... |
1b84e836bf9f71fa596066520863c0ae314e60636d3f3f396982109080994b1b | Python | 6,053 | 154 | #!/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 pandas as pd
from ax.core.arm import Arm
from ax.core.data import Data, MAP_KEY
from ax.core.ex... |
9cf36c8f44c237d2188e3111fcfb2c2ec63d6e813c40474145fbeb90e41a77e9 | Python | 6,055 | 121 | """
tests/validate_mean_tensor.py -- assert the QTI covariance mean tensor matches the facts the
sigma ~ <D> derivation claims, so a reviewer can verify them.
simnibs_python tests/validate_mean_tensor.py
PART A: rebuild <D> from cov_mfs m(2:7) (Mandel Voigt) and check against cov_dps:
trace/3==MD, lambda1==ad, (l... |
7219a732701958ac4e5d34f0b0eecd83e085518292783ed381dd6f0ac060cb57 | Python | 6,057 | 183 | """
The function art_of_tsne is from cytograph2 package.
https://github.com/linnarsson-lab/cytograph2/blob/master/cytograph/embedding/art_of_tsne.py
The idea behind that is based on :cite:p:`Kobak2019` with T-SNE algorithm implemented in
[openTSNE](https://opentsne.readthedocs.io/en/latest/) :cite:p:`Policar2019`.
"... |
481445eb5a9bb6d31d4a3bf30e787eb758db333b57d85a67040b460b020b55a0 | Python | 6,058 | 181 | from cogdl.wrappers import fetch_model_wrapper, fetch_data_wrapper
def set_default_wrapper_config():
node_classification_models = [
"gcn",
"deepergcn",
"drgcn",
"drgat",
"gcnii",
"gcnmix",
"grand",
"grace",
"mvgrl",
"graphsage",
... |
ac069ea6b22f9c0e11d525e5c143afc68640ef13ce4124ea9813ef2182e72747 | Python | 6,061 | 190 | # -*- coding: utf-8 -*-
"""
Voxelization
============
Converts point data into a voxelized image for visulalization and analysis.
"""
__author__ = 'Christoph Kirst <christoph.kirst.ck@gmail.com>'
__license__ = 'GPLv3 - GNU General Pulic License v3 (see LICENSE.txt)'
__copyright__ = 'Copyright © 2020 by Christoph ... |
c4c63690bbad9230ad8b95aa4e628e2d144bde8f03b3f93e7ce6c5cae32fd6d9 | Python | 6,061 | 207 | """This is invoked in a subprocess to call the build backend hooks.
It expects:
- Command line args: hook_name, control_dir
- Environment variable: PEP517_BUILD_BACKEND=entry.point:spec
- control_dir/input.json:
- {"kwargs": {...}}
Results:
- control_dir/output.json
- {"return_val": ...}
"""
from glob import glob... |
1f0ffb1f8bfa3dbb25b587e12f4d844defcd9bc48f64f96ec737ae6969203541 | Python | 6,062 | 156 | import os
import unittest
from unittest.mock import patch
import numpy as np
from bsb import Scaffold, parse_configuration_file
from bsb_test import NumpyTestCase, RandomStorageFixture
from matplotlib import pyplot as plt
from cerebellum.analysis.plots import Legend, Plot, ScaffoldPlot
def mock_update(self):
se... |
a9824327a30210e32f70d149fbdc06796758488d5a1f234c026ce678d1b37bc8 | Python | 6,062 | 141 | #!/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 dataclasses import replace
import torch
from ax.benchmark.benchmark_test_functions.botorch_test... |
21a6f148513c8b047c055cbe686fd605ace5edbd58b2fe1f721d9e95e8d823a0 | Python | 6,064 | 168 | import torch
import torch.nn as nn
import torch.nn.functional as F
from cogdl.utils import row_normalization, spmm
class RGCNLayer(nn.Module):
"""
Implementation of Relational-GCN in paper `"Modeling Relational Data with Graph Convolutional Networks"
<https://arxiv.org/abs/1703.06103>`_
Parameters
... |
573c6c1c510b9bb7f9b6989857ca64723dcb434fc7593a813aedebcab0d5d0da | Python | 6,064 | 152 | import json
from unittest.mock import patch
import pytest
from io_storages.azure_blob.models import AzureBlobImportStorage
from io_storages.azure_blob.utils import (
AZURE,
get_blob_service_client,
validate_azure_account_name,
validate_azure_account_url,
)
from io_storages.gcs.utils import GCS, GOOGLE_... |
cf79821a6f86b51eea25e9783b095458536b52821bce1dcd01e3801c78e01afa | Python | 6,064 | 224 | #!/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.storage.sqa_store.decoder import Decoder
from ax.storage.sqa_store.encoder import Encoder
from... |
0acc6e7870ce07d6853390fc18ff37bb564a1b3c45d7ddd7069be63117807109 | Python | 6,066 | 205 | """Bridge-finding algorithms."""
from itertools import chain
import networkx as nx
from networkx.utils import not_implemented_for
__all__ = ["bridges", "has_bridges", "local_bridges"]
@not_implemented_for("directed")
@nx._dispatchable
def bridges(G, root=None):
"""Generate all bridges in a graph.
A *bridg... |
232dc5e36b45a69ffbe6278fc2cb94bc3d7586b16ce8f89cc12e5f265c09acaa | Python | 6,066 | 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... |
3071c90f539e52a122b1ec3c7c0eb957cb275f529447c28fb6c6b72085554a91 | Python | 6,066 | 190 | """
Create an HDF5 file of patches for training super-resolution model.
"""
import os, argparse
import numpy as np
import h5py
import pickle
import librosa
from scipy import interpolate
from scipy.signal import decimate
# ----------------------------------------------------------------------------
parser = argparse... |
7125f5af4c031766b0ec69ad8fe5635cf48940cda1dae6849f8db94a742fe9f8 | Python | 6,066 | 184 | """
This module has two classes for splitting time series data temporally - where train/test or fold
splits are created within each of the time series' in the time series data. This splitting approach
is for evaluating how well the algorithm performs on segments drawn from the same time series but
excluded from the tra... |
a3ef0940e53a4d0cc8e0ce8764c0e1e7b1d552e6e7321c53d5d0b33c07130d05 | Python | 6,066 | 161 |
import numpy as np
import tensorflow as tf
import pprint
import pickle
from tqdm import tqdm
from sklearn import(manifold, datasets, decomposition, ensemble, discriminant_analysis, random_projection)
from time import time
import matplotlib.pyplot as plt
from tensorflow.python.keras import backend as K
import re
row... |
6beb5934803b84d0c4c142b6b0c0f42e9ed4c805fc2b57b752de9a39f1ee862c | Python | 6,071 | 171 | """
The LLM assistant in a web page, with the visitor's own API key.
Python in a browser (Pyodide) has no sockets: :class:`BrowserTransport`
sends the requests of an ``httpx`` client with the browser's
``XMLHttpRequest``, synchronously, as the REPL runs in a Web Worker,
where that is allowed. The page's origin is not ... |
a682c4a28e7fd5f8c5a2c8cb6372ce321e9f247c5fbf661d3efc84aefed1c21c | Python | 6,071 | 200 | # -*- coding: utf-8 -*-
"""Test Airy beam generation
Testing different descriptors of the Airy beam from theory and numerical simulations
"""
# Created on Tue Apr 7 10:01:32 2020
# Contributions and Changelog accessed via a private git repository:
# https://github.com/philipwijesinghe/deep-learning-lsm.git
# philip... |
e39c9c003e6412f445dc81fb70c2340b24864b61370e348d825b4f9174a29e1e | Python | 6,074 | 174 | import math
import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from .mlp import MLP
from cogdl.layers import GINLayer
from cogdl.utils import batch_mean_pooling, batch_sum_pooling, split_dataset_general
from .. import BaseModel
class Encoder(nn.Module):
r"""Encoder stacked with GIN... |
ebb34d5eaeffc7ad3332d6bb89d98cc37c596cefa24bdc9560a3cee3ac4c0c5f | Python | 6,074 | 136 | # 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... |
ddba40f01ea23dbe389e6eae39b18d8d5ca2e074c1c3f6603dac633345c1fcc7 | Python | 6,079 | 147 | """Function to compute library complexity"""
import numpy as np
from scipy import optimize
def interpolate_downsampled_counts(total_array, unique_array, ds_rate):
'''Given a series of total counts and a series of unique counts, corresponding to downsampling rates between 0 and 1,
find the downsampling interva... |
cf85ef9d8eb5a06a228230cd8d4a570520cdd7df622fe25df20986b554cbce45 | Python | 6,083 | 214 | from datetime import datetime
from enum import Enum
from typing import (
Annotated,
Any,
Literal,
Optional,
Union,
)
from pydantic import (
Field,
RootModel,
)
from galaxy.schema.schema import Model
from galaxy.util.hash_util import HashFunctionNames
class RemoteFilesTarget(str, Enum):
... |
e896917ab68fe3ae4d31718100d5b550b0537a1c34d5cc7b8bf237bc22de0b4b | Python | 6,083 | 128 | """
Properties for the CamCoil implementation. These include:
1. ACCEPTED_RES_ONE
2. pH2_prop
3. pH7_prop
4. weights
5. weights_LFP
"""
# Main imports.
import hashlib
from functools import partial
from numpy import nan as np_nan
from src.chemical_shifts.auxiliaries import ChemShifts
# Accepted r... |
921f7c2ef3b8156d1c89546fcef91e1869706d0c86175dce66ec4bd1a56e9b95 | Python | 6,087 | 183 | """
================================
Benchmark backends
================================
Compare motion energy computation speed across available backends
(numpy, torch, torch_cuda, torch_mps).
Usage::
python benchmarks/benchmark_backends.py
python benchmarks/benchmark_backends.py --nimages 200 --vdim 128 --... |
b6608b174250bc19a64c663e5522908ae2fd25aafdd8cdcd0d6bbea425d51979 | Python | 6,090 | 183 | """Metrics for TF training.
Classes
---------
InterquartileCapture(tf.keras.metrics.Metric)
SignTest(tf.keras.metrics.Metric)
CustomMAE(tf.keras.metrics.Metric)
"""
import tensorflow as tf
import tensorflow_probability as tfp
import numpy as np
class InterquartileCapture(tf.keras.metrics.Metric):
"""Compute the... |
ba41fdba4e8d16ec725661b94225b0e222aaddf4fb323a9482e5fde5abd83c86 | Python | 6,090 | 190 | # -*- coding: utf-8 -*-
# pidlockfile.py
#
# Copyright © 2008–2009 Ben Finney <ben+python@benfinney.id.au>
#
# This is free software: you may copy, modify, and/or distribute this work
# under the terms of the Python Software Foundation License, version 2 or
# later as published by the Python Software Foundation.
# No ... |
ccd6196a199cda2cca23caeeed454baf9529349517546b2808a3737708a1c770 | Python | 6,092 | 177 | '''
'''
import time
import numpy as np
from scipy import linalg
from importlib import reload
from moten import (pyramids,
extras,
utils,
core,
io,
)
reload(io)
##############################
# video info
#################... |
217ecc1065277fc2e2c79adc775ffd16705d26871198d53d281acb3307c78d45 | Python | 6,095 | 169 | #!/usr/bin/env python
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
import cellranger.matrix as cr_matrix
import cellranger.io as cr_io
import martian
import subprocess
import json
import os
import numpy as np
from pybedtools import BedTool
import tenkit.log_subprocess as tk_subproc
import tenkit.sa... |
33550229403f864fe8aaff1ba8c9b80d6b77a6fe2d6878c7a8fb3d504903db1b | Python | 6,095 | 172 | from abc import (
ABC,
abstractmethod,
)
from typing import (
Any,
Dict,
List,
Optional,
Type,
Union,
)
from pydantic import BaseModel
from typing_extensions import Literal
from galaxy.tool_util_models.parameters import (
create_job_internal_model,
create_job_runtime_model,
... |
c509670ba6e824294977c745ccbcc3b0c81b759eb2fc5ef58ed4ffc9e14b96fe | Python | 6,095 | 139 | import torch
import torch.nn as nn
from .. import ModelWrapper
from tqdm import tqdm
import torch.nn.functional as F
class TripleModelWrapper(ModelWrapper):
@classmethod
def add_args(self, parser):
# fmt: off
parser.add_argument("--negative_adversarial_sampling", default=False)
parser.... |
0a578a4865ce8b475e15ce40fd2e8a7cd2e8cb289f314542556dcf52253a2a0b | Python | 6,096 | 128 | """
04_extract_roi_efield.py - E-field per ROI per conductivity model (ISO/DTI/MD-dMRI), namespaced by
subject and montage. Group 1 ROIs (cortical/WM lobes, corpus callosum, mesencephalon/pons, WholeBrain)
come from _rois.py; Group 2 CIT168 deep nuclei (built by 07) are appended as extra E-field-only rows.
CHARM assig... |
ef29fbe0698e259429d00d5f6f55a3d37c2ed5d9d4bf8436d86665e474a3fa67 | Python | 6,096 | 115 | import tensorflow as tf
from tensorflow.keras import models, layers, regularizers
from tensorflow.keras import backend as K
from tensorflow.keras.layers import *
from tensorflow.keras.optimizers import Adam
#####################################################################################
def dice_coef(y_true, y_pre... |
539838d907a0248c5febb475eb6b8b5e3403013e2b18efbc3c4fd6b2a37138d6 | Python | 6,101 | 152 | """Annotation / cross-reference validation for Human-GEM.
Two kinds of check over the annotation tables (model/metabolites.tsv,
model/reactions.tsv, model/genes.tsv), aimed at catching curation mistakes:
* Format validation. Each row must have as many fields as the header, and each
external-database identifier ... |
b40666e9ab128e4b35e9ac124ee298e0163149538c5788e1e2e943f99ea54ab1 | Python | 6,101 | 153 | import numpy as np
import torch
from base import FactorCollection
from base import VideoWrapper
from factor import TensorFactor
class Video(VideoWrapper):
""" Manages Unrolled Tensor and multiplication with a Full Video """
def __init__(self,
video_shape,
device='cuda'):
... |
61bec36841b2bca0e3f90c9fa3fc414240ba16778b1ab473ef8fb8b82d3b151b | Python | 6,105 | 187 | #!/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 enum
from collections import defaultdict
from collections.abc import Callable, Mapping, Sequenc... |
51194ad37f96346af2ca13f6a7e25e7655e0ad39106dfbd9b4f4419372ac9f3f | Python | 6,106 | 170 | import matplotlib.pyplot as plt
from tabulate import tabulate
from brian2.equations.equations import Equations
from brian2lava.utils.files import scrap_folder
from brian2 import get_logger
class Model():
"""
This container class serves to describe a neuron model in preset mode. This has become necessary
for Loihi ... |
36ee8097a94754ad2ba54f7177679ca5b9c4f1e25fbe4252b06b3f5ffb905214 | Python | 6,107 | 130 | from typing import Union
import numpy as np
import tensorflow as tf
from scipy.ndimage.interpolation import zoom
from . import ModelVisualization, keras
from .utils import is_mixed_precision, normalize, zoom_factor
from .utils.model_modifiers import ExtractIntermediateLayerForGradcam as ModelModifier
class Gradcam(... |
76a4653611ad40c6ea966ec48fa2934403d0a01aef905d8b012287bd9a75ba12 | Python | 6,107 | 170 | import argparse
import os
import numpy as np
import math
import torchvision.transforms as transforms
from torchvision.utils import save_image
from PIL import Image
from torch.utils.data import DataLoader
from torchvision import datasets
from torch.autograd import Variable
from datasets import *
from models import *
... |
f11769508cf5a2945be47bb880d185ebdae8eb38f3552639e940f83eb1ede74e | Python | 6,108 | 190 | """
==================================================
Image Segmentation via Spectral Graph Partitioning
==================================================
Example of partitioning a undirected graph obtained by ``k-neighbors``
from an RGB image into two subgraphs using spectral clustering
illustrated by 3D plots of t... |
8ee9c19587fe38f016f2a979b2f319ae4d8eb1989972d61f05439dd50ea09eec | Python | 6,111 | 152 | # 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.api.utils.instantiation.from_string import optimization_config_from_string
from ax.core.objective import Objective
fro... |
a930a871e90d44e000edc2c1d3283e32d7d8a5372c10403335bc191ff14840ec | Python | 6,111 | 188 | # -*- 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... |
6a3926d4084608393d78ff82143353ce7a26204c267eed2a884af03e358e81a6 | Python | 6,113 | 110 | # 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... |
6175f17727bddcf0e79971d75c4a79c018c24b4a8a04574a8a94e1b300523808 | Python | 6,114 | 183 | import numpy as np
import pandas as pd
import math as math
from scipy.linalg import lu,det
import networkx as nx
class DegenerateGaussianScore:
dataframe = pd.DataFrame();
#The mixed variables of the original dataset.
variables = [];
#The continuous variables of the post-embedding dataset.
continu... |
2ecd6eea7549aad755e4bdeb7b1e084c202796ee8580d6fc43d10c7faa990b08 | Python | 6,115 | 133 | #TODO: integrate fully in ClearMap
__author__ = 'Sophie Skriabin, Christoph Kirst <christoph.kirst.ck@gmail.com>'
__license__ = 'GPLv3 - GNU General Pulic License v3 (see LICENSE.txt)'
__copyright__ = 'Copyright © 2020 by Christoph Kirst'
__webpage__ = 'http://idisco.info'
__download__ = 'http://www.github.com... |
f6de8c16d03987992f55399af64eb09e83fb51cd3d67fb41793d44bade77f5ab | Python | 6,115 | 201 | import numpy as np
import pytest
import tensorflow as tf
from hidten.hmm import HMMConfig as HidtenHMMConfig
from learnMSA.config.hmm import PHMMConfig
from learnMSA.hmm.tf.profile_emitter import ProfileEmitter
from learnMSA.hmm.tf.util import load_dirichlet
from learnMSA.hmm.util.value_set import PHMMValueSet
from le... |
30e9bbc6cfeb69873bc1beeb02df2ddf018295c9535ece811e1c196c73a3f48e | Python | 6,116 | 189 | from typing import Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.checkpoint import checkpoint
from .mlp_layer import MLP
from cogdl.utils import get_activation, edge_softmax, get_norm_layer, batch_max_pooling
class GENConv(nn.Module):
def __init__(
self,
... |
e5901fe6b89061a00143099dde5a034987cc248d41af399c3ffc1d9f1b09b0fb | Python | 6,117 | 186 | import logging
import zlib
from dataclasses import (
dataclass,
fields,
)
from struct import unpack
from urllib.parse import (
parse_qs,
unquote,
urlparse,
)
import requests
from galaxy.files.models import (
BaseFileSourceConfiguration,
BaseFileSourceTemplateConfiguration,
FilesSourceR... |
abf8f376ce0c6b2e58e77f2d875ba104da50723eef12e1c1485d0de121cb7ae4 | Python | 6,119 | 149 | import numpy as np
import tensorflow as tf
import keras.backend as K
def calculateIdx1D(vol_length, cube_length, stride):
one_dim_pos = np.arange(0, vol_length-cube_length+1, stride)
if (vol_length - cube_length) % stride != 0:
one_dim_pos = np.concatenate([one_dim_pos, [vol_length-cube_length]])
r... |
664f48d372c8299d34996d7cf70e21494509303736bd2f30d56bf0d3f3003ede | Python | 6,120 | 147 | import pandas as pd
from tensorflow.keras.models import load_model
from scipy.stats import mannwhitneyu
import numpy as np
from PARAMETERS import *
import argparse
from utils import make_all_seqs_prediction
def predict_fasta(model, src, dst):
"""
Makes predictions for a given fasta file
:param model: mod... |
8082176869162d50498113cf004d01c2ec02c39776de451808851dc91d43b4a0 | Python | 6,120 | 147 | from abc import ABC, abstractmethod
from typing import Union
import tensorflow as tf
from packaging.version import parse as version
from .. import keras
if version(tf.version.VERSION) >= version("2.16.0rc0"):
from keras.src.layers.convolutional.base_conv import BaseConv as Conv
elif version(tf.version.VERSION) >... |
3a6a76365c1ca7fcc26b028886b9c392c11126d80058ba445e5eb7334b25bc0c | Python | 6,123 | 148 | #!/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 Mapping
from enum import Enum
from typing import cast
from ax.core.data i... |
8d5e6815435433a85f0305059ba10a1ed1b7df4cdc0965f849b0a2a859333bb7 | Python | 6,126 | 163 | #!/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 unittest import mock
import numpy as np
from ax.adapter.prediction_utils import predict_at_point... |
379656ecd148e1bdb87fdd0aced3dfc65645bbde57702f466a5e82f0c8e06b7a | Python | 6,127 | 167 | import pandas as pd
import numpy as np
import os
from shutil import copytree
from sklearn.metrics import davies_bouldin_score
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
from sklearn.cluster import AgglomerativeClustering
import matplotlib
impor... |
bc98656916e5f980eb5a33b18662dde50ce3f991a69b27316e5e20bfe46532eb | Python | 6,127 | 182 |
import os
import sys
import glob
from math import sin, cos
import math
import random
from random import randrange as rand_num
import numpy as np
import sys
from rosetta import *
from pyrosetta import *
from rosetta.protocols.rigid import *
from rosetta.core.scoring import *
from pyrosetta import PyMOLMover
from rose... |
b8034b0b2abd8d76df2ac59c96efe88f7aa80fd4e0ff94e977e36ec399ad9d78 | Python | 6,128 | 150 | # MIT License
#
# Copyright (c) 2019-2024 The PyQMC Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, m... |
904dd50c6d9c09abdc6801d22cde432fc685a30bc302182318fcbae773b66b4c | Python | 6,132 | 239 | from scipy.spatial import cKDTree as KDTree
import graph_tool
import graph_tool.flow
import numpy as np
import time
def split_graph(
graph,
components,
position_attributes,
weight_attribute,
split_attribute):
'''Recursively split a graph via min-cuts such that the given com... |
bc2faf335ab6127a526ccd4219337e635724e89bd15bc249fcfa894adba73942 | Python | 6,135 | 177 | from typing import (
Any,
cast,
Dict,
Iterable,
List,
Optional,
TypeVar,
Union,
)
from typing_extensions import Protocol
from galaxy.tool_util_models.parameters import (
ConditionalParameterModel,
ConditionalWhen,
simple_input_models,
ToolParameterBundle,
ToolParame... |
c69a4e51fa5edca7144d6547390559bbaaa32d8610a237cb64db66b2bd6875df | Python | 6,136 | 164 | """Functions for computing rich-club coefficients."""
from itertools import accumulate
import networkx as nx
from networkx.utils import not_implemented_for, py_random_state
__all__ = ["rich_club_coefficient"]
@not_implemented_for("directed")
@not_implemented_for("multigraph")
@nx._dispatchable
@py_random_state(3)
... |
e735feb8433bc925afb8ed5464b66f7e4377a0a0c8fd6b28018e194c53cd4081 | Python | 6,138 | 128 | import numpy as np
import joblib
import tensorflow as tf
import pathlib
import pandas as pd
import optuna
from . import _base_model, _tensorflow_model, _param_free_base_model, _torch_model
from ..evaluation import eval_metrics
from ..utils import helper_functions
from ..postprocess import results_analysis
from ..prepr... |
8ae32fa166d9f9a947620b74e2b8a73cb297c9ad9cbcaf962c640b5006d8620a | Python | 6,139 | 148 | import logging
import os
from abc import ABC, abstractmethod
from typing import Optional
import numpy as np
import sqlalchemy
from rlmolecule.sql import Session
from rlmolecule.sql.tables import GameStore
logger = logging.getLogger(__name__)
class Reward:
def __init__(self, *, raw_reward: Optional[float] = Non... |
aa8b190226969faac82adf36619155aa08fd318105e3f10b8d54db6fa9b17e13 | Python | 6,142 | 185 | #!/usr/bin/env python
"""Download TCGA data from UCSC Xena's public data hub
UCSC Xena offers cancer genomics data from different sources, including
TCGA (both the origincal TCGA and the newer GDC TCGA data). The data
hubs can be accessed here: http://xena.ucsc.edu/public-hubs/
This script downloads the data that are... |
120796af7bf1e58ac66b66bdaada9a15902c01f72a03f3174759c20457015164 | Python | 6,143 | 154 | #!/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 collections.abc import Callable
from typing import TYPE_CHECK... |
589b4632449b01dd42bf4e95694783547a2c34eb5d8a0b2a12ca72bb1d04c42b | Python | 6,144 | 179 | import pytest
import networkx as nx
cycle = nx.cycle_graph(5, create_using=nx.DiGraph)
tree = nx.DiGraph()
tree.add_edges_from(nx.random_labeled_tree(10, seed=42).edges)
path = nx.path_graph(5, create_using=nx.DiGraph)
binomial = nx.binomial_tree(3, create_using=nx.DiGraph)
HH = nx.directed_havel_hakimi_graph([1, 2, ... |
45c4b03c35f79f771b3db1e19e01f22a8413bef34160ca79295d5918f6ae7b68 | Python | 6,148 | 95 | import argparse
from easypheno.utils import helper_functions
from easypheno.preprocess import encoding_functions
from . import optim_pipeline
if __name__ == '__main__':
"""
Run file to start the whole procedure:
Parameter Plausibility Check
Check and prepare data files
Baye... |
d24a5ba85f4872fb5787bef4907215941122ea5c5b049ec46a900ee4b202b667 | Python | 6,148 | 156 | import torch
import rdkit.Chem as Chem
import networkx as nx
from MolRep.Explainer.Attribution.utils.fuseprop.mol_graph import MolGraph
from MolRep.Explainer.Attribution.utils.fuseprop.chemutils import *
from collections import defaultdict
class IncBase(object):
def __init__(self, batch_size, node_fdim, edge_fdi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.