sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
10e417f1ed0e75d57cd7b940d08f2f84cb019250cd3c5bff165c22462c4f0fd0 | Python | 3,918 | 94 | """
@file: Planes2RecConverter
Created on 25.09.18
@project: deepcrazyhouse
@author: queensgambit
The Planes2RecConverter is used to transform the plane representation in a format which can be accessed
efficiently during training using multiprocessing
* This how you could read from a rec file (although it's recommend... |
7f6c8ceec92ba95030406c87cfedb0c3f054db6f48e689ad7eaa66452839c812 | Python | 3,921 | 115 | # Copyright 2019 DeepMind Technologies Limited
#
# 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 agr... |
59507d5fee92a8c12a3e2ab453603e98ce28fbae14a07bb1c6ac45fd643b677f | Python | 3,922 | 120 | # coding=utf-8
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
#
# 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
#
# ... |
c9a85c0c17b316eb745e0651e389a7ab546d1529c54a4a2daab950bad39e11c1 | Python | 3,923 | 180 | import numpy as np
def mare(Y_true, Y_pred):
sample_dim = Y_true.shape[0]
out_dim = Y_true.shape[1]
if out_dim == 1:
return np.linalg.norm((Y_pred - Y_true) / Y_true, ord=1) / sample_dim
else:
e = np.zeros((sample_dim,), dtype=float)
for i in range(sample_dim):
e[i]... |
f7c379db9a7d4ce97948a9fb1103fe55a356ad20f1f55a155bda16e948c6807d | Python | 3,924 | 123 | import os
import sys
import time
import datetime
import subprocess
import numpy as np
import torch
from models.se3transformer_layers.utils_data import to_np
_global_log = {}
def try_mkdir(path):
if not os.path.exists(path):
os.makedirs(path)
# @profile
def make_logdir(checkpoint_dir, run_name=None):
... |
16317780781625ed21a0c8d404a5989e6aa9634371221525707e9eba623657cd | Python | 3,926 | 122 | """ Pytorch Distributed utils
This piece of code was heavily inspired by the equivalent of Fairseq-py
https://github.com/pytorch/fairseq
"""
from __future__ import print_function
import math
import pickle
import torch.distributed
from onmt.utils.logging import logger
def is_master(opt, device_id):
ret... |
9b0cc71f09c4c4f917bed20a898f69eb0a321e1ad0e0a6c7e102aacd62ea5b09 | Python | 3,926 | 114 | from collections import UserDict
from collections.abc import Callable, Mapping
from types import MappingProxyType
from typing import Any
import pytest
import torch
from torch import nn
from transformers import BatchEncoding
from torchinfo import ModelStatistics, summary
MappingFactory = Callable[[dict[str, Any]], M... |
9c5071138dc4f11fc766cf22b81cf15499bb001d637b3a01336d10b7d41ce25d | Python | 3,928 | 114 | # Copyright 2019 DeepMind Technologies Limited
#
# 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 agr... |
dbd6225f2e2d1850c5ae466130d2433e9d69176149b380b8b42ef433eed87243 | Python | 3,928 | 129 | # BASILISK: A generative, probabilistic model of side chains in proteins
#
# Copyright (C) 2010 Tim Harder and Jes Frellsen
#
# BASILISK is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 ... |
dd40abf926f5a30589d7ee67b5e72dbf1827a99903881f5b648faf5aae5106be | Python | 3,928 | 131 | import os
import numpy as np
import keras
import matplotlib.pyplot as plt
import glob
import random
import tensorflow as tf
from sklearn.metrics import jaccard_score
from keras.models import load_model
import keras_contrib as Kc
from tensorflow_addons.layers import InstanceNormalization
import natsort as natsorted
# ... |
147298febb60845f1ec4ab311eb3e26830a1553033e6713d066c7e3365dc950f | Python | 3,929 | 131 | from __future__ import print_function
import numpy as np
from .augment import Augment
__all__ = ['LostSection', 'LostPlusMissing']
class LostSection(Augment):
"""Lost section augmentation.
Args:
nsec: number of consecutive lost sections.
skip (float, optional): skip probability.
TODO:... |
711a4edf4d3bcb6d07eea10556bc5261281f296bd7f222f96570346bd0416aca | Python | 3,930 | 97 | import os
from datetime import datetime
from joblib import Parallel, delayed
import h5py
import numpy as np
import pandas as pd
import torch
from torch.utils.data import DataLoader, Dataset, Sampler
from tqdm import tqdm
import pdb
from src.utils.config import process_config
from src.data_loader.dataset import MultiC... |
d1b35d42334954b484536ca141f77721e370f0ec9fa1ce7b4b18389f52a3b2af | Python | 3,930 | 102 | #!/usr/bin/env python
import sys
import os
import math
import subprocess
#import pandas as pd
from os.path import isfile, join, isdir
from kn_common import pipetools,pipedef
from kn_pipeline_class import CPipeError,CPipeStep
import torch
import torch.nn as nn
import torch.nn.functional as F
import hashlib
import niba... |
4fb4c23a6906d1fd0d5c2a9d5761afb86691ba547e9186ac748297af7a7cc28c | Python | 3,931 | 112 | #!/usr/bin/env python3
import inspect
from pathlib import Path
from git.repo import Repo
from rdflib import Graph, URIRef
from neurondm import *
from pyontutils.utils import subclasses
from neurondm.core import NeuronBase, auth, ont_checkout_ok # FIXME temporary until we can rework the config
__all__ = [
'AND',
... |
b973e5e411ac059861e3666dc0fc4e9b6817d55c09decafdfc4a78903eae7870 | Python | 3,931 | 115 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
#
# 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 appl... |
2dddbb9b91499f6fc4212e774230ab44e523ddc1f40cb0ddb4ea59def5905230 | Python | 3,938 | 107 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import sys
import os
def read_files_batch(file_list):
"""Reads the provided files in batches"""
batch = [] # Keep batch for each file
fd_list = [] # File descriptor list
exit = False # Flag used for quitting the program in case of error... |
50dc635bace09a99eab7a735868e857cfc82e4524701399504e1bb6e386412e8 | Python | 3,939 | 140 | # Copyright 2026 DeepMind Technologies Limited
#
# 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 agr... |
561487161df96b2482023c6df6aceb7140ee0ceafc7edbc813c0d8eb2061c912 | Python | 3,939 | 130 | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
class CenterCropPad(Base):
@staticmethod
def export_center_crop_pad_... |
f21d8b8109416a3d5acdf5ccc5da85dd82781cfaf3785121eeb46a67505301b3 | Python | 3,939 | 116 | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import torch
import torch.nn.functional as F
from mmcls.models.losses import Accuracy
from ..builder import HEADS, build_loss
from ..utils import is_tracing
from .base_head import BaseHead
@HEADS.register_module()
class ClsHead(BaseHead):
"""classi... |
f90ac4f2ffec3084d6585ce57dbc18f2c7593a9d76f467916de6460eeb6ea8f5 | Python | 3,939 | 125 | # Copyright 2019-2020 The ASReview Authors. All Rights Reserved.
#
# 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 appl... |
94f10ca2c9d70dd5cb8c09d67ce2abfe4d7ada59641ee5cf7ac1ed84a3eec0e6 | Python | 3,940 | 125 | #!/usr/bin/env python3
"""
Build lightweight slims from curie lists.
Used for sources that don't have an owl ontology floating.
"""
#TODO consider using some of the code from scr_sync.py???
from pathlib import Path
import requests
from pyontutils.core import createOntology
from pyontutils.utils import chunk_li... |
e2433946f51cb837602a778280c0df5c0771ce6f73ff017f009bb006dc0ef160 | Python | 3,942 | 97 | from pandas import read_csv
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_absolute_error
from hpsklearn import HyperoptEstimator
from hpsklearn import any_regressor
from hpsklearn import any_preprocessing
from hyperopt import tpe
import numpy as np
import pandas as pd
from collec... |
376573ff6d5714e962db1855a32add7f0ccb3f3b622ba0ca7054c97de641e7e9 | Python | 3,944 | 109 | """
Defines a WeightedTree class, to represent the information relevant in an SWC from the \
geodesic point of view. Defines functions for manipulating and processing WeightedTrees.
"""
from __future__ import annotations
from dataclasses import dataclass
import numpy as np
from scipy.spatial.distance import eu... |
4c8e636353cbe07f80472d62dc216a8bae2c9d5b15a4d9b15679309e5457f8e0 | Python | 3,944 | 104 | """
Test sounds and plot waveforms.
This script tests the sound waveform generator for a variety of sounds.
It is self-contained - computes sound waveforms, and does nothing
else.
"""
import sys
import numpy as np
import pyqtgraph as pg
from cnmodel.util import sound
from collections import OrderedDict
from scipy im... |
c44b303327b02409e583fbb7d23313824ff63c8edacd98547d067ab6492fdd67 | Python | 3,944 | 118 | # Copyright 2022 DeepMind Technologies Limited
#
# 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 agr... |
33bfcbc8cb40d42a7540139ae0d56bbd738d6457b3603326e6e8b2bc29e66f7e | Python | 3,945 | 132 | import os
import random
import re
import numpy as np
with open("dataset/abstracts.csv") as f:
abstracts = f.read().strip("\n").split("\n")
with open("dataset/authors.txt") as f:
authors = f.read().strip("\n").split("\n")
with open("dataset/author2id.csv") as f:
author2id = f.read().strip("\n").split("\n... |
054d06b054d66988bc5417ca4e3081cfb6fe5310e0b49f61243cccdc61f53ffe | Python | 3,950 | 129 | # Copyright 2019 DeepMind Technologies Limited
#
# 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 agr... |
4558d124f7f22e8ada18ce2772d5be8304b4ef7287e861c3aae764ce5830c6d4 | Python | 3,952 | 108 | '''
Pure-python implementation of UCSC "liftover" genome coordinate conversion.
Chain file "smart" locator routine test module.
NB: Look at the SKIP_TEST variable below.
Copyright 2013, Konstantin Tretyakov.
http://kt.era.ee/
Licensed under MIT license.
'''
import os, urllib, shutil, gzip
from tempfile import mkdte... |
4dd3372863465335bcd6072a93b4decfbf9ed902e453d936bb405b0d0b7186b8 | Python | 3,953 | 117 | # Copyright 2026 DeepMind Technologies Limited
#
# 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 agr... |
c6e1b558596abc4ad0ed874f7e039f9aa1dfb6ab796039fcc862a10b10bb7219 | Python | 3,953 | 140 | import torch
import torch.nn as nn
from lgn.cg_lib import CGModule
from lgn.g_lib import GTau, GScalar
class BasicMLP(nn.Module):
"""
The general MLP. It operates only on the last axis of the data.
Parameters
----------
num_in : int
Number of input channels
num_out : int
Num... |
bdb3dd1c0e76bf722a0b31f19be2d6a5fc13ea5853a9d4e50920bdca55bec26b | Python | 3,954 | 111 | import numpy as np
import torch
import time
from sns_toolbox.networks import Network
from sns_toolbox.neurons import SpikingNeuron
from sns_toolbox.connections import SpikingSynapse
from sns_toolbox import backends
backend = 2 # 0: manual
# 1: Numpy
# 2: Torch
# 3: Sparse
cpu = Tr... |
8311a8950543094d4211b47ef754df20e0848ef552e3157900b0d7a406af15cc | Python | 3,955 | 133 | import numpy as np
import tempfile
import torch
import os
from STIFMaps.STIFMap_generation import AlexNet, generate_STIFMap, collagen_paint, correlate_signals_with_stain
from PIL import Image
class DummyModel(torch.nn.Module):
def forward(self, x):
return torch.ones((x.shape[0], 1)) * 0.5 # constant predi... |
496f5bff8dd516682a92eded2a2674c25bd876e32d45697ca5b3d66b5cb04ef3 | Python | 3,956 | 141 | import torch
import torch.nn as nn
from lgn.cg_lib import CGModule
from lgn.g_lib import GTau, GScalar
class BasicMLP(nn.Module):
"""
The general MLP. It operates only on the last axis of the data.
Parameters
----------
num_in : int
Number of input channels
num_out : int
Num... |
5e47eefcf4ed2cbe7d2c0de26efe8ca79a2f71bbe925635e87395135f64da55d | Python | 3,958 | 117 | """End-to-end tests for the transcriptome distance calculation."""
from pathlib import Path
import pytest
from corset_tools.dist_calc.runner import run_dist_calc
def test_run_dist_calc_end_to_end(tmp_path: Path, data_dir: Path) -> None:
"""Aligning the fixture pairs produces a stats table and a recommendation.... |
5ece11b0b55207a24d6d265ed7640d290a35b82118b94b74cb7e56cba4e19b47 | Python | 3,959 | 111 | """Test bycycle.burst.utils."""
import pytest
import numpy as np
import pandas as pd
from bycycle.features import compute_features
from bycycle.burst.utils import *
###################################################################################################
##################################################... |
035dce87a45e173ee2ac0c5336cf9ed8d57cb9c25dba38411048b97cc2043db8 | Python | 3,961 | 67 | import numpy as np
import os
import torch
from tqdm import tqdm
from atom3d.util.transforms import mol_graph_transform
from atom3d.datasets import LMDBDataset
from torch_geometric.data import Data, Dataset, DataLoader
label_mean = {'A': 9.431132871932412, 'B': 1.4056874059499507, 'C': 1.1248823604150906, 'mu': 2.68912... |
1667a8e4bef97006be555c4d4ef48f6008d3daf24320c1de743db6cca3126f76 | Python | 3,962 | 125 | #Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
#This program is free software;
#you can redistribute it and/or modify
#it under the terms of the MIT License.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHA... |
17f9034e760e0a4bc7d08872417092ea8a6a3a73b35d51d0f86e4ea477dae06c | Python | 3,962 | 107 | from .dataset import Dataset, DatasetError
import os
import numpy as np
import scipy.io
class NST(Dataset):
"""An NST dataset.
An NST dataset usually consists of three files that are within a specific
subdirectory. The implementation follows this structuring, i.e. the user
needs to pass a base-direct... |
f5b7b84c03d1e12724cfd5542e6a8308e9e6b4b5a8bf993e1fcd1ece5bc72f30 | Python | 3,962 | 108 | import sys
import os
import glob
import tempfile
import json
from argparse import ArgumentParser
from argparse import RawTextHelpFormatter
import aqdnet
from model import ModelByTensorflow
from structure import ElementwiseDNN
MODEL_CLASSES = {
'ElementwiseDNN': ElementwiseDNN,
}
def parse_params_json(json_file):
... |
bae993e6f7eec3f86769504567d1dd2e60b3de9560b2419ab0fe10df1d6df7c6 | Python | 3,963 | 131 | # Copyright 2019 DeepMind Technologies Limited
#
# 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 agr... |
6b2c3778bfbf33270c306bba44048ffa02015fd1ad524a8f9aa4c19c2afaf32b | Python | 3,965 | 109 | # Copyright (c) OpenMMLab. All rights reserved.
from collections import OrderedDict
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import build_activation_layer, constant_init, kaiming_init
from ..builder import HEADS
from .cls_head import ClsHead
@HEADS.register_module()
class VisionTransforme... |
dd84c23415acfbb287a591acc6b19fa555e43065417330fb7784aca440449eaf | Python | 3,966 | 108 | # Copyright 2023 DeepMind Technologies Limited
#
# 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 agr... |
a013831864da977961ab45878cdc9e48176fffda0e3cf39eb7876e36a972b07d | Python | 3,968 | 80 | import sys
import matplotlib.pyplot as plt
import matplotlib
from functools import reduce
from os.path import splitext
import pickle
import numpy as np
from parameterSetup import ParameterSetup
from evaluationCriteria import labels2ID, getEpisodeLengths
from sequentialPrediction import classifySequentially
from writePr... |
48343a54eddd490bcf9342c75b73e19fe580f8f92d4066e4ed365b08b292d322 | Python | 3,969 | 107 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import warnings
from mmcv.runner import Hook
from torch.utils.data import DataLoader
class EvalHook(Hook):
"""Evaluation hook.
Args:
dataloader (DataLoader): A PyTorch dataloader.
interval (int): Evaluation interval (by ep... |
8548ed0a47a1395bf8a4ee27e6d49e37ef7b1866a22cd3161b48b737c8c611cc | Python | 3,969 | 108 | import numpy as np
from scipy.stats import mannwhitneyu, rankdata
from pandas import DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
import sciunit
from networkunit.scores import to_precision
class mwu_statistic(sciunit.Score):
r"""
Mann-Whitney-U test
.. math::
U_i = R_i - \f... |
9e4b05ef9ca8a206c26ac7f7647ea99798c50f8a544fbe717b7c6188c34c4b68 | Python | 3,969 | 63 | # -*- encoding: utf-8 -*-
from ._db import add_table_data
add_table_data('populations', row_key='field', col_key='cell_type',
species='mouse', data=u"""
---------------------------------------------------------------------------------------------------------------------------
sgc b... |
b39147c3fa2f41fb453bcb5121ac3332330359776b96ad7d19cbf918f6b3376d | Python | 3,969 | 114 | # Copyright 2019-2026 The AmpliGraph Authors. All Rights Reserved.
#
# This file is Licensed under the Apache License, Version 2.0.
# A copy of the Licence is available in LICENCE, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
import tensorflow as tf
from .AbstractScoringLayer import register_layer, Abstr... |
cb73faaa4a97bfe8544f03b61ad8f43adb9cc18c049b2803aff6996e16abd51f | Python | 3,969 | 90 | #!/usr/bin/env python
# -*- coding: utf-8
import os,math,sys
import pandas as pd
import numpy as np
__author__ = "Sihao Huang"
__copyright__ = ""
__credits__ = []
__license__ = "GPL 2.0"
__version__ = "1.1"
__maintainer__ = "Sihao Huang"
__email__ = "sihaohuang1024@gmail.com"
__status__ = "Development"
def main():
... |
14447a0cc9e43e15d25755cc65689b65dc81c1584881661250660c11810a6fd7 | Python | 3,970 | 117 | # Copyright 2018-2025
# Institute of Neuroscience and Medicine (INM-1), Forschungszentrum Jülich GmbH
# 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/LICE... |
2a421a5bb55ec8b7523e957b215549ca26d98b8aed377481cb28892f7f0e0505 | Python | 3,970 | 82 | """
@file: move_plane_round_trip_tests.py
Changed last on 16.01.19
@project: crazy_ara_cleaning
@author: queensgambit and matuiss2
Testing move and board plane
This file contains the test cases for testing the moving plane
"""
import unittest
import chess
from chess.variant import CrazyhouseBoard
from DeepCrazyhouse.... |
1f92238d39e479ea49694761f855dab4d080cedf4446ee81decdfac7eefc317c | Python | 3,971 | 121 | r"""
This module hosts several popular image-wise measures, such as Mean-Square Error (MSE),
Structural Similarity Index (SSIM) or Learned Perceptual Image Patch Similarity (LPIPS).
APPLIES TO ALL LOSSES:
- expected data type: torch.Tensor (data type: torch.float)
- expected shape: [b, t, c, h, w] ([b, t, 3, h, w] f... |
581c23562d5075aee840ccefe58809f6adb19df3ee5944c7af02055a0f869259 | Python | 3,971 | 111 | # Copyright 2019-2021 The ASReview Authors. All Rights Reserved.
#
# 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 appl... |
aa42c08b11ff1c84022b8cafc624203b9235296e2fc93fa62db80dd048cf145b | Python | 3,972 | 118 | """
Cortical thickness ratio (t_gyral/t_sulcal) calculated at various coverage ratios using mean curvature.
For more information, the users are referred to Wang et al, 2021 (https://link.springer.com/article/10.1007/s10237-020-01400-w)
Parameters:
---------
Surface measures: mean curvature from {h}.pial.H.asc and ... |
f6b922afe5f8aa6b3341eb22e8291009d6c8bef7dd637c3e8b84f7c46633e22f | Python | 3,973 | 119 | from collections import namedtuple
"""
Classes that organize groups of tensors into namedtuples.
Names and uses should be self-explanatory.
"""
LoadableData = namedtuple(
"LoadableData",
[
"train_data", # training spiking data, TRxTxDATA_DIM
"valid_data", # validation spiking data, VAxTxDATA... |
93db05e47258b1aae29dcdd12b3ab6a493010d9c946db3c1b71824f639fd50b5 | Python | 3,976 | 118 | # Copyright 2026 DeepMind Technologies Limited
#
# 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 agr... |
0bd2bb3294fe51e42a1ca0771d29173391a3a63bcd0ab9187631a09ba787a0c7 | Python | 3,977 | 115 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
#
# 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 appl... |
b544940c050f691ff984e16c971de865f251a7325fedf2f6ceb37d2fcadfd159 | Python | 3,977 | 129 | import argparse
import re
import os
import pickle
import numpy as np
from tqdm import tqdm
from rdkit import Chem
from collections import Counter
import torch
import random
from typing import Optional
def seed_everything(seed: Optional[int] = 0) -> None:
torch.manual_seed(seed)
random.seed(seed... |
dd24346b982fad32907e38083a621d31653a149fd07c986f1a2e7c4852d85a53 | Python | 3,977 | 148 | from __future__ import annotations
from functools import partial
from multiprocessing import Pool, cpu_count
from typing import Tuple, Union
import numpy as np
import pandas as pd
from libpysal.weights import W as libpysal_W
from .utils import pysal_to_pandas
def _hotspot_AI(
hotspot_series: pd.Series,
wei... |
157940b98ddf352840dd1df826459dc78a9d74233014c035f1fe5f006b3b0bb6 | Python | 3,978 | 71 | #-------------------------------------------------------------------------------
# elftools tests
#
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
import unittest
from pathlib import Path
from elftools.dwarf.die im... |
1f5a16eac4e14ca943057ea1589db6e8252a332bc4995ee464722457e4422a5a | Python | 3,980 | 149 | """
Legacy code from earlier implementations of the algorithm
2023-03-13
Code by C Parthiban
"""
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import scipy.stats as stat
############################################################################
######### Library for Conducting SFA on a... |
bae892fef46268b3ccfb7ac6eb81ae8f8cc5c7ed60a83b9c797a4ed814d22e2a | Python | 3,982 | 94 | # -------------------------------------------------------------------------------
# elftools: tests
#
# LeadroyaL (leadroyal@qq.com)
# This code is in the public domain
# -------------------------------------------------------------------------------
import os
import unittest
from elftools.ehabi.ehabiinfo import (
... |
d9c7d37917ac61cfd138beb8be23e00c37e3b4b54c14933c336a947b76a6d795 | Python | 3,982 | 82 | from rdkit import Chem
import os
import argparse
import re
from rdkit import RDLogger
lg = RDLogger.logger()
lg.setLevel(RDLogger.CRITICAL)
def smi_tokenizer(smi):
pattern = "(\[[^\]]+]|Br?|Cl?|N|O|S|P|F|I|b|c|n|o|s|p|\(|\)|\.|=|#|-|\+|\\\\|\/|:|~|@|\?|>|\*|\$|\%[0-9]{2}|[0-9])"
regex = re.compile(pattern)
... |
2a80d38cde6769f4c633f7f55a780be18ccf638f7af99135a205ca4251372d19 | Python | 3,983 | 109 | import ray
import yaml
import numpy as np
from ray import tune
from os import path
from sklearn.metrics import r2_score
from yacs.config import CfgNode as CN
from lfads_tf2.defaults import get_cfg_defaults
from lfads_tf2.utils import (
load_data,
load_posterior_averages,
read_fitlog,
flatten,
unfl... |
b59289d7ceed796f536d514e44685bac7688ee49f0e707a315cd49e258ca97a3 | Python | 3,984 | 45 | import numpy as np
from mprl.scripts.poker_parallel_algos.evaluators.evaluator_utils import make_get_policy_fn
from mprl.scripts.poker_parallel_algos.utils.policy_config_keys import SAC_ARCH1P_MODEL_CONFIG_KEY
from stratego_env import StrategoMultiAgentEnv
class BarrageAgentPolicyPopulationWrapper:
POLICY_KEYS_T... |
98bc51d368ccf845c97ced14a874c9f6d0a4e5f857bb2e20a58ac3b83aaa8d63 | Python | 3,985 | 120 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import itertools
import platform
from typing import TYPE_CHECKING, Any
import onnx.backend.base
import onnx.backend.test
import onnx.shape_inference
import onnx.version_converter
from onnx import ModelP... |
ef843859186b93c8269252eab88e6adc2da2a2644f7c3e376ef85d642675e5f8 | Python | 3,985 | 116 | import os
import re
import random
import numpy as np
from collections import Counter
from itertools import compress
with open("dataset/references.csv") as f:
references_all = [x.split("####") for x in f.read().strip("\n").split("\n")]
""" Ways to end the name list
replace and with ,
replace ,, with ,
replace ^\s*... |
ec278af99b23fbdd2534ab0c16ce22970fd89e02b91bfaa98aaddc1d826cbd9d | Python | 3,989 | 121 | # SPDX-License-Identifier: LGPL-3.0-or-later
"""Backend-independent discovery of on-disk data systems."""
from pathlib import (
Path,
)
from typing import (
Literal,
)
from deepmd.utils.path import (
DPOSPath,
DPPath,
)
DatasetFormat = Literal["deepmd", "lmdb"]
def is_lmdb(systems: str) -> bool:
... |
648f5f06391b1b50dd1aa8138348f402d2a902d0e64c7f56e96c0396e6230505 | Python | 3,990 | 134 | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 24 15:14:41 2020
@author: daniel
"""
from mpi4py import MPI
import d1msn as msn
import plasticity_experiment as pe
import parameters as pp
import numpy as np
import pickle
import json
import scipy.signal as ss
import sys
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
npr... |
aff33dd0ee7c565bc25d82f90627b82741132e36d1000743c4789d160209fdc6 | Python | 3,990 | 113 | import unittest
import numpy as np
import colorednoise as cn
class TestPowerlawPsdGaussian(unittest.TestCase):
# these only test very basic functioning as of yet
def test_powerlaw_psd_gaussian_scalar_output_shape(self):
n = cn.powerlaw_psd_gaussian(1, 16)
self.assertEqual(n.shape, (16,))
... |
19d534a8e704c194e29472b0c9155ec93c066c09acffc09af25d9aa792a8a699 | Python | 3,992 | 129 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GCNConv, global_max_pool as gmp
from torch_geometric.data import InMemoryDataset, DataLoader
TRAIN_BATCH_SIZE = 500
# GCN based model
class GCNNet(torch.nn.Module):
#def __init__(self, n_output=1, n_filters=32, embed... |
6906806c8dbc48006c0aa068d679ceddf5d76ae8f8ff17c084e47f1f929a5c99 | Python | 3,993 | 145 | import numpy as np
import pandas as pd
import pymaid
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import navis
volume_names = ["cns"]
def rgb2hex(r, g, b):
r = int(255 * r)
g = int(255 * g)
b = int(255 * b)
return "#{:02x}{:02x}{:02x}".format(r, g, b)
def simple_plot_neurons(
neuron... |
f4164b181a21e430c692c761a7632a37248ff9f7e2fdb940df4775906357abac | Python | 3,993 | 126 | #Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
#This program is free software;
#you can redistribute it and/or modify
#it under the terms of the MIT License.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHA... |
df03502c9b8045d5cc7792c579119b7f83aea84df487d5a1f39ea56978deb7bd | Python | 3,994 | 118 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
#
# 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 appl... |
03d588efa53d6d052e57a9ffde4412d95fb0dc3a62f2ac4e5d75d38f37836fe1 | Python | 3,995 | 114 | # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
"""Example fixtures for mtypes/scitypes.
Exports
-------
get_examples(mtype: str, as_scitype: str, return_lossy=False)
retrieves examples for mtype/scitype, and/or whether it is lossy
examples[i] are assumed "content-wise the same" for the sa... |
472d3bceff39849c250c570101369ff0fb0a90c3b895820384be783b8059230a | Python | 3,996 | 93 | #-------------------------------------------------------------------------------
# elftools tests
#
# Ricardo Barbedo (ricardo@barbedo.me)
# This code is in the public domain
#-------------------------------------------------------------------------------
import os
import unittest
from elftools.elf.descriptions import... |
24743a8775479dfce1005049e5af81b3a253e3f783d9d1f713ad792e69541544 | Python | 3,997 | 108 | # SPDX-License-Identifier: LGPL-3.0-or-later
"""Shared dataset configuration and sampling contracts."""
from pathlib import (
Path,
)
import numpy as np
import pytest
from deepmd.utils import random as dp_random
from deepmd.utils.data_config import (
resolve_data_groups,
)
from deepmd.utils.data_sampling imp... |
b14be9de76eb9149f1e3c16f88dd80df0d66ff2d5b715f72d50cb5ecf7d4a2b6 | Python | 3,998 | 124 | import torch
import torch.nn as nn
import model
def collect_leaves(module):
'''Generator function to collect all leaf modules of a module.
Parameters
----------
module: obj:`torch.nn.Module`
A module for which the leaves will be collected.
Yields
------
leaf: obj:`torch.nn.Module`
... |
e939b81a00e3314d40e4cb1d85b7b96ca2f5069b61dcfd2c2f7be7a130312a68 | Python | 4,002 | 105 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
#
# 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 appl... |
b2b0cf03c61d1070dc73c363db33b1b98fe71e2a777a8739ac5f4bd058e98469 | Python | 4,004 | 95 | # Copyright 2022 Diagnostic Image Analysis Group, Radboudumc, Nijmegen, The Netherlands
#
# 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... |
376172201adad8ecfd7b5782fe0ba4ccb7f9384ee31912bb0ff90ffe8a29efa6 | Python | 4,007 | 129 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GCNConv, global_max_pool as gmp
from torch_geometric.data import InMemoryDataset, DataLoader
TRAIN_BATCH_SIZE = 500
# GCN based model
class GCNNet(torch.nn.Module):
#def __init__(self, n_output=1, n_filters=32, embed... |
9a05c4685e218d3bf0afe45404ba09a38ac51d7288df5e1788129e11a981f6d5 | Python | 4,007 | 118 | # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
# Ported from skchange (BSD-3-Clause), original authors: Tveten
"""Univariate Gaussian likelihood cost."""
__author__ = ["Tveten"]
import numpy as np
from sktime.detection._utils import check_mean, check_var, col_cumsum, truncate_below
from skti... |
fc0062431e0bd456f059d7258eb82cfdc0b09fe2c9de08b19f26c6c2f73367c9 | Python | 4,008 | 134 | """Cluster Segmentation.
Implementing segmentation using clustering, Read more at
<https://en.wikipedia.org/wiki/Cluster_analysis>_.
"""
import pandas as pd
from sklearn.base import clone
from sklearn.cluster import KMeans
from sktime.detection.base import BaseDetector
__author__ = ["Ankit-1204"]
__all__ = ["Cluste... |
198ba8053a228b44ffa4b04ce56439f940400ac6f00fac2c629d2c387fdbc145 | Python | 4,009 | 119 | # coding=utf-8
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
#
# 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
#
# ... |
509f1cb06e06af18cb733c62318939cc14f550c7f2df27ac6a6c7f6b626ea7ca | Python | 4,010 | 123 | # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
# Ported from skchange (BSD-3-Clause), original authors: johannvk
"""Laplace distribution cost function."""
__author__ = ["johannvk"]
import numpy as np
from sktime.detection._utils import (
MeanType,
VarType,
check_mean,
check_n... |
b2f58b7b0e832948a82f169d4184e5aea928919c093a5adcbe5fe073c8e9cf98 | Python | 4,010 | 110 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.model import expect
from onnx.defs import AI_ONNX_PREVIEW_TRAINING_DOMAIN, ONNX_DOMAIN
class Gra... |
599724801442bc1383bcfd5a75e5dcb30d06fce0d43aff7b63dfcaeee013d7f9 | Python | 4,014 | 116 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
#
# 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 appl... |
c05d353139ad61b135576c6d77d2d1607dc9d1286469858d6747c9c1dc9d1f94 | Python | 4,015 | 67 | import numpy as np
import pandas as pd
import scanpy as sc
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
# matplotlib.rcParams['text.usetex']=True
# matplotlib.rcParams['text.latex.unicode']=True
# load information
adata = sc.read('/data/aronow/Kang/single_cell_projects/10X-Pak/integratio... |
d9458ed9d5b549303fde931e5590fd9397c4a0f2546cf28cf34e22092c9427b5 | Python | 4,017 | 88 | """
empirical.py -- Section 4 anchor on PUBLISHED pass@k curves (no model run).
Data are pass@k values transcribed from Zhou (2607.20543), "When RLVR Shrinks
the Reasoning Boundary", Table 2 (Qwen2.5-7B, GRPO on Omni-MATH-Train). They are
INDICATIVE and MUST be re-checked against the source table before submission.
W... |
f580eec8dd709fb986b219bcd75e86e293d4302d3136f4f3ac0fa34356139936 | Python | 4,018 | 109 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
#
# 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 appl... |
1f164a74fb6be5f7ddc3e0eab49bd5481de2cc90bd237707b6aa539018aef423 | Python | 4,020 | 73 | import os
import sys
sys.path.insert(0, "../src")
from subprocess import Popen, PIPE
import argparse
from torch_geometric.loader import DataLoader
from torch import save
from gnn_eads.functions import get_graph_sample, structure_to_graph, get_graph_formula, get_id
from gnn_eads.constants import ENCODER
if __name__ =... |
58bdfe338a4198cf71b61dcc366fa7bba54105cddda4424b57d5a7044af198cb | Python | 4,020 | 133 | import matplotlib.pyplot as plt
import numpy as np
from brian2 import *
# import matplotlib.pyplot as plt
import time
import pickle
"""
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NEURON AND SYNAPSE DEFINITIONS
"""
globalStart = time.time()
e... |
5743de04fab1f9bdf75f140c1ef38e623f567d40582f1f074834d07bf5331140 | Python | 4,021 | 76 | """
@file: main_config.py
Created on 24.09.18
@project: crazyara
@author: queensgambit
Main Config definition file used for the project.
Copy and rename this file to main_config.py and adjust the paths accordingly.
"""
# define the default dir where the training data in plane representation is located
# e.g. for sup... |
38b6e9186d0901a178b80cafb5bdf2eb6d5517cb87da1413fed36eb04820b090 | Python | 4,022 | 127 | #!/usr/bin/env python
import click
from functools import partial
import gzip
from multiprocessing import Pool
import os
import pandas as pd
import re
from sklearn.preprocessing import quantile_transform
import subprocess as sp
import sys
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])),
... |
7c1dd1a10e97e65f9c5bd8832f2f39b5b161af0bf7fb34febecc1c420b3be111 | Python | 4,022 | 110 | # Copyright 2019 DeepMind Technologies Limited
#
# 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 agr... |
fdd82f4402ba7c9c04a9b7a231604057310bf309bc98c36efcbdaf3219be5ed8 | Python | 4,024 | 113 | # Copyright 2022 DeepMind Technologies Limited
#
# 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 agr... |
9157cdf544f83a30c1eb0b6c1e5fa3fe89b9b05b2fd04c62fc4ec2b903424997 | Python | 4,025 | 93 | # coding=utf-8
# Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
#
# 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
#
# ... |
141d1cc6d970c96527af224633875b7ca413a65e630e22ce161b049a07433dab | Python | 4,026 | 114 | """Tests for the fetch-seqs subcommand."""
from pathlib import Path
from corset_tools.fetch_seqs import not_found_path, run_fetch_seqs
from corset_tools.fileio import read_cluster_map, read_fasta, read_target_list
def test_fetch_all_clusters(
tmp_path: Path, transcripts: Path, cluster_map: Path
) -> None:
"... |
15027c4da51e4b70b29dd64c32858a2a5ef5fd760ac70475e2ef40deb918bd8a | Python | 4,026 | 115 | # This code was adapted from https://github.com/khornlund/pytorch-balanced-sampler/blob/master/pytorch_balanced_sampler/sampler.py
# The original author of this code is Karl Hornlund (https://github.com/khornlund).
from typing import Iterator, List, Optional, Tuple
import numpy as np
import pandas as pd
from torch.ut... |
dd378c795320ff8f3ca1d93cf3960df5f4d5f5aee91c757eda04c813d61b0063 | Python | 4,029 | 99 | import logging
import sys
import pytest
from ts.metrics.dimension import Dimension
from ts.metrics.metrics_store import MetricsStore
from ts.service import emit_metrics
logging.basicConfig(stream=sys.stdout, format="%(message)s", level=logging.INFO)
def get_model_key(name, unit, req_id, model_name):
dimensions ... |
f22703ec85fefa98ecbc21e2e1387dc26d8efeaf583cb72916647418bb2d1c97 | Python | 4,035 | 67 | import pickle
import networkx as nx
from networkx.generators.random_graphs import erdos_renyi_graph
import time
from netrd.distance import Hamming
def hammingHelperfunction(G1, G2, G3, G4):
dist_obj = Hamming()
dis_1_3 = dist_obj.dist(G1, G3)
dis_1_2 = dist_obj.dist(G1, G2)
dis_1_4 = dist_obj.dist(G1,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.