sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
0557273d60ee082b71fe9e209106139d984faa8d70a2cfe3798c3a69756cc7f0 | Python | 3,904 | 110 | """
File: combine_eqtlprobes.py
Created: 2020/10/08
Last Changed: 2021/07/08
Author: M.Vochteloo
Copyright (C) 2020 M.Vochteloo
This program 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, eith... |
0f9e567a7ee6c596a3ccadf325dcc02996bd4d229a0d13893468a958d136be06 | Python | 3,904 | 128 | import re
from pathlib import Path
import PIL
import labelbox
import numpy as np
import tifffile as tf
from dotenv import dotenv_values
from tqdm import tqdm
from cenfind.core.data import Dataset
config = dotenv_values(".env")
def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser(
... |
ed8f0b8d1100964b57728e94852f9505c1162ff8970ba0f3cc551f1ec2db865e | Python | 3,904 | 125 | '''
Functions to pickle/unpickle
Functions to load/save data from time-series:
- one trajectory may be split into parts
'''
import os
import numpy as np
def define_dump_object(default_output_folder='.'):
'''
Define a function-shortcut for pickling objects.
- Pickling is a way to save python objects to t... |
03d278db3bae98669dd717f5ece650398bf5fe87306e2317f736edd1be93b919 | Python | 3,906 | 125 | import json
from pathlib import Path
from collections import OrderedDict
from itertools import repeat
import pandas as pd
import os
import numpy as np
from glob import glob
import math
def load_folds_data_shhs(np_data_path, n_folds):
files = sorted(glob(os.path.join(np_data_path, "*.npz")))
r_p_path = r"utils/... |
8cfef460bf0f2245aabff00883cd725416625a1b1ec6c284013d5d987f97c7a3 | Python | 3,907 | 122 | import numpy as np
import matplotlib.pyplot as plt
from matplotlib import lines
import matplotlib.patches as patches
from mpl_toolkits.axes_grid1 import make_axes_locatable
import seaborn as sns
import copy
blue = [0.231, 0.549, 0.761]
blue2 = [0.141, 0.278, 0.588]
red = [0.882, 0.402, 0.188]
red2 = [0.89, 0.094, 0... |
8e3e07531241d0f7d997b87c9820ef4b84407d42530fd73fb4c65d5f781aaab4 | Python | 3,908 | 115 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# 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... |
a0c3ba2b195b73a004135f77bf5917833e89d4e8831e21700b520ec834f424a4 | Python | 3,908 | 115 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# 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... |
1740fed527e55b5de9dd67f590dff59a740cc82a36c478244aaa4cc1bcc3b901 | Python | 3,915 | 90 | import plyfile
import argparse
import torch
import numpy as np
import skimage.measure
import scipy
import mrcfile
import os
def create_samples(N=256, voxel_origin=[0, 0, 0], cube_length=2.0):
# NOTE: the voxel_origin is actually the (bottom, left, down) corner, not the middle
voxel_origin = np.array(voxel_ori... |
47db8274c4439bb929aa6f42513887591bf5aa85efd829c4c659aa8bd15395e7 | Python | 3,915 | 166 | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 20 21:08:56 2021
@author: N.V
"""
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 20 18:47:06 2021
@author: N.V
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.animation import FuncAnimation
import os
# not... |
aa264781824c88d6ad35ff480a978d07a5f0ac4fd06e226bc459199b3e8a9053 | Python | 3,915 | 101 | """
===========================================
Sparse filtering on Olivetti faces
===========================================
Unsupervised learning of features for images from the Olivetti faces dataset
using the sparse filtering algorithm. Linear features for sub-patches of the
Olivetti faces are learned using the s... |
9c1e97bb6a1aeafab285ab72db5e386b62ee2fab39e2dba4fae9a517ee88601a | Python | 3,919 | 104 | """A text annotator based on Gilda."""
from __future__ import annotations
import logging
from dataclasses import dataclass
from typing import TYPE_CHECKING, Iterator, Optional
from oaklib.datamodels.text_annotator import TextAnnotation, TextAnnotationConfiguration
from oaklib.interfaces import TextAnnotatorInterface... |
d61834500b84da5c12d76c30357bc895ac3aa8102767971e8eab21c632e115f0 | Python | 3,919 | 117 | #!/usr/bin/python
# -*- encoding: utf-8 -*-
import torch
import torch.nn as nn
import torch.nn.functional as F
# from modules.bn import InPlaceABNSync as BatchNorm2d
resnet18_url = 'https://download.pytorch.org/models/resnet18-5c106cde.pth'
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with ... |
a8e7bef06888511a0375c29837cbebc9eae7bf728c9ccd28d54ed9704a67b79b | Python | 3,920 | 91 | ## main.py -- sample code to test attack procedure
##
## Copyright (C) 2018, IBM Corp
## Chun-Chen Tu <timtu@umich.edu>
## PaiShun Ting <paishun@umich.edu>
## Pin-Yu Chen <Pin-Yu.Chen@ibm.com>
##
## Licensed under the Apache License, Version 2.0 (the "L... |
af9cf9842198c8303f05140a8edda4df62a4f9a8dac78c59a6a989b3f8e3c7ea | Python | 3,920 | 148 | #%%
import time
import matplotlib.pyplot as plt
import numpy as np
from giskard.hierarchy import BaseNetworkTree
from giskard.plot import plot_dendrogram
from src.data import load_maggot_graph, load_palette
from src.io import savefig
from src.visualization import adjplot, set_theme, ORDER_KEY, HUE_KEY
print("ORDER_KE... |
00987eb0e396655a8d2960dc4f58804ad39ae3bb12fc5c9d0c76dcd426fb7537 | Python | 3,921 | 103 | import torch
import numpy as np
import networkx as nx
def to_networkx_conv(data, node_attrs=None, edge_attrs=None, to_undirected=False,
remove_self_loops=False, get_map = False):
r"""Converts a :class:`torch_geometric.data.Data` instance to a
:obj:`networkx.Graph` if :attr:`to_undirected` is se... |
806e06f35af1b94b76b1e5cba48071002852e9721546c749089c59c53d5fe2f5 | Python | 3,921 | 109 |
# %%import numpy as np
from numpy.core.numeric import ones
import scipy
from scipy import io
import matplotlib.pyplot as plt
from pathlib import Path
import pandas as pd
import pymc3 as pm
import seaborn
import arviz as az
import numpy as np
import theano.tensor as tt
import theano
from sklearn.preprocessing import Po... |
0cf9a8fc8ae7c98eda47afcba995104a381ff6bf9ae19d19ff3b5cf248c2aaf2 | Python | 3,922 | 143 | """
For plotting.
"""
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
from scipy.stats import pearsonr
from lib.calcium import get_section
def view_trials(trace, condition, show_lines=True):
plt.figure(figsize=(16,16))
angle_list = np.unique(condition)
for i in range(16):
... |
d2b081ae02dbcefbf38f088b2e8134fcffdf26e424b42361b620fbac031d5fd4 | Python | 3,922 | 112 | # This script is part of navis (http://www.github.com/schlegelp/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# This program 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 of... |
09c453af01ee2cf5f9e5f1a5ffd8569366e4080915de6a2dbf0a1345f24f072a | Python | 3,925 | 86 | #%%
# do local neurons (LNs) or projection neurons (PNs)
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pymaid_creds import url, name, password, token
import pymaid
rm = pymaid.CatmaidInstance(url, token, name, password)
import connectome_tools.celltype as ct
import ... |
116b7f77ec0c340fac14e184553ab603131f41aedc4d17da284ee42f1bc2ea66 | Python | 3,925 | 126 | from ase.io import read, write, Trajectory
import torch
from typing import List
import asap3
import numpy as np
from scipy.spatial import distance_matrix
# def ase_properties(atoms):
# """Guess dataset format from an ASE atoms"""
# atoms_prop = []
#
# if atoms.pbc.any():
# atoms_prop.append('cell'... |
296cf432ffbe349ca21283dd422cc65ea4ee27a23e7523bd1c3457ffd399237c | Python | 3,925 | 93 | # Copyright 2020-2022 Huawei Technologies Co., Ltd
#
# 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 agre... |
7a36f3729f2380e7e662adc9306347ad79fcc038674cf078c2ea74bb81fc8450 | Python | 3,925 | 117 | #!/usr/bin/env python
import argparse
from os.path import basename, splitext
import HTSeq
import seaborn as sns
import matplotlib.pyplot as plt
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--chromsize", metavar="FILE", help="Index file of "
"reference genome")
parser.add_argument(... |
53b29e69beef159a3f4a7ba926612fcbf6c94344f195cfd4e0772853d31bf849 | Python | 3,928 | 132 | #!/usr/bin/env python
from .masker import MaskerModel
import unetsl.data
import os, pathlib, sys, numpy
import click
@click.group(chain=True)
def masker():
pass
@masker.command("create")
@click.argument("steady", default = 5)
def create(steady):
print(steady)
mm = MaskerModel( (1, 384, 384, 384, ), steady... |
7c0045d4121985a6cf358300be39d869613721b627b6db669fe4e75d65eb0802 | Python | 3,929 | 105 | import torch
import torchvision.transforms as transforms
import torch.utils.data as data
import os
import pickle
import numpy as np
import nltk
from PIL import Image
from build_vocab import Vocabulary
from pycocotools.coco import COCO
class CocoDataset(data.Dataset):
"""COCO Custom Dataset compatible with torch.u... |
a16bb0cba45b080772ebbbf9c9a8b729046da4c31296e4f44d932e6ea9efbbbb | Python | 3,929 | 116 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# 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... |
e12f44d8eb228eecf7fa5a886d31700fb873d0b1fba174406faede2eda64bf71 | Python | 3,929 | 116 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# 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... |
a3c97f31d440e5d525a5e61ff3aedfee387e5932c186c27fede07fd01bb5cf40 | Python | 3,931 | 103 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# 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... |
307d8fa802471bc492689bf58cdad80cdae2f6e864cdc7305452c5216c2b248b | Python | 3,932 | 108 | import math
from functools import reduce
import torch
from torch import nn
import torch.nn.functional as F
# helpers
def prob_mask_like(t, prob):
return torch.zeros_like(t).float().uniform_(0, 1) < prob
def mask_with_tokens(t, token_ids):
init_no_mask = torch.full_like(t, False, dtype=torch.bool)
mask =... |
555f495c4d3616962a3d1ba5f8518b5f8c62ad80b1c85ea5e76875757c6edd0a | Python | 3,932 | 154 | """Deploy UI elements depending on the current environment."""
import os
USE_WX = True
_progress_monitors = []
def get_ui():
global USE_WX
if USE_WX:
try:
from . import wx_ui
from ..._wxgui import get_app
get_app()
return wx_ui
except ImportEr... |
9bd314fb2d31858cd4ae342685064b58e7517ddbcce6b0a9ba55a483d7d40b01 | Python | 3,932 | 119 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# 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... |
ac44293de9af0aa0ac7e353238a097872bcfb126bde1115eccad8a97448e2c42 | Python | 3,937 | 105 | import torch
import torchvision.transforms as transforms
import torch.utils.data as data
import os
import pickle
import numpy as np
import nltk
from PIL import Image
from build_vocab import Vocabulary
from pycocotools.coco import COCO
class CocoDataset(data.Dataset):
"""COCO Custom Dataset compatible with torch.r... |
5f4ac2ba323c8bf0c904916ac7a1d41abfde0eba0fdd2d2525f5b3458e61f242 | Python | 3,938 | 150 | #%%
import time
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from giskard.hierarchy import BaseNetworkTree
from src.data import load_maggot_graph, load_palette
from src.io import savefig
from src.visualization import adjplot, set_theme
t0 = time.time()
set_theme()
def stashfig(name, **kw... |
7c4b261c83b68fed0cb0bd4a5ab65658523b9924b38793f90919cfb82c7d9504 | Python | 3,938 | 108 | import cv2,os,argparse,pickle,re
import numpy as np
def str_to_time(time):
# '%H_%M_%S_%f'
time = re.split(':|_|\.', time)
return int(time[0])*60*60*1000 + int(time[1])*60*1000 + int(time[2])*1000 + int(time[3])//1000
def convert_stroke(mat_img,stroke_point):
if len(stroke_point) == 5:
color ... |
3376d699b9e9c874ad50114ed91105598a9219d0b298077b31d8b69c1e6a6ab4 | Python | 3,939 | 107 | import os
import numpy as np
import torch
from rdkit import Chem
from rdkit.Chem.Draw import SimilarityMaps
import matplotlib.pyplot as plt
from .nn_utils import index_select_ND
def visualize_atom_attention(viz_dir: str,
smiles: str,
num_atoms: int,
... |
52bb221fc5e12ed30a22c23f0b3b9a828825aaef39f95f81da8ddbcdf7476e32 | Python | 3,939 | 90 | ####################################################################################################
# Copyright (c) 2019 - 2021, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free ... |
749cd429ddfc4bb1f2eea3bb19ae5d08497c3a80fa8167ccc11945037e6c130c | Python | 3,939 | 101 | import os
import sys
import json
import time
import datetime
import pandas as pd
from dicom_scp_class import Retriever_SCP
from dicom_scu_class import Retriever_SCU
def move_daily_regs(day):
infofile = "setup_information.json"
f = open(infofile)
info = json.load(f)
f.close()
tx_ct_file = os.path.j... |
93602c1314d310044aea054e51cf3a5dcab0e7e0a2c6d65423f5c9d037b60a3c | Python | 3,939 | 113 | import pandas as pd;
import argparse
import gzip
from multiprocessing import Process,Pool
parser = argparse.ArgumentParser(description='Compare eQTLgen to MetaBrain')
parser.add_argument('meataBrain_eQTL_file',
help='File with eQTL data')
parser.add_argument('eQTLgen_eQTL_file',
... |
1b77c637263a13f255c603664c54d9f4ccee320aa36efda6f47a7441b8435675 | Python | 3,940 | 115 | """Shared center-crop logic for the center cropping strategies.
``negativeCenterC`` and ``positiveCenterC`` perform identical center-crop math
once a case is accepted. This module holds that shared implementation so both
strategies call a single source of truth. The function operates on the
controller instance (``obj`... |
1cea19c6b638cf5b708254c2d47c07641fc0a465117b109be6f0e779a2d5a67a | Python | 3,940 | 99 | import os
import numpy as np
import torch
from matplotlib import pyplot as plt
from norse.torch import LIFAdExState
import seaborn as sns
from create_dataset_one_value import create_dataset_default_values
from load_network import load_network
criterion = torch.nn.MSELoss()
def run_one_trial(task, model, init_state,... |
30c117fc291ee17cb25b4b78f99a1730feba3c0289490631c94ac88d693ded78 | Python | 3,943 | 120 | import numpy as np
from .Tools import timeToIndex
class GainEstimator(object):
"""Estimate the gain of a process from measured input and output."""
def __init__(self, dt=0.1):
"""Initialize GainEstimator.
Arguments
---------
dt : float, default 0.1
Time step of m... |
3488b181b02a0a23e089b57624521f29fca1e346d6e146ef1fe136a5a52295a6 | Python | 3,944 | 98 | # basic imports
import os
import pickle
import numpy as np
import matplotlib.pyplot as plt
def recover_position(state: int, width: int) -> np.ndarray:
'''
This function recover the position coordinates of a state.
Parameters
----------
state : The state index.
... |
45c4ec22ca549344e655f4e7a4f076d0ac2b27d464455fff82c868a9e2b6cf8e | Python | 3,944 | 129 | import numpy as np
from scipy.optimize import minimize
from functools import partial
def energy(Y, gamma, theta):
return 0.5 * gamma * Y**2 + theta * Y
def cgf_from_inputs(I, gamma, theta):
return 0.5 * (I - theta)**2 / gamma + 0.5 * np.log(2 * np.pi / gamma)
def mean_from_inputs(I, gamma, theta):
ret... |
71d96e84fa2a34f63a15abe4ae24c61b116ba3b3972bde9cf5e9f5e38dfa23ff | Python | 3,944 | 117 | #!/usr/bin/env python
# Copyright 2015 David Snyder
# Apache 2.0.
#
# This script refines the annotation files produced by
# make_annotations_bn.py. In order to create unambiguous annotations,
# we remove any part of a segment that overlaps with another. Also,
# this script merges together contiguous segments that ha... |
c835ebea00d61a38206be6fdb1cb3afe76f81c8b13db3655459d8d70dbacaef8 | Python | 3,944 | 132 | import torch
from torch.nn import functional as F
from torch.autograd import Function
from torch.utils.cpp_extension import load
upfirdn2d_op = load('upfirdn2d', sources=['/apdcephfs/share_1330077/starksun/projects/pi-GAN/siren/op/upfirdn2d.cpp', '/apdcephfs/share_1330077/starksun/projects/pi-GAN/siren/op/upfirdn2d_ke... |
01622406b18cb8b0d0a5cda6f2667fb1e66c425199ed5d64e4e5547043ed8456 | Python | 3,949 | 100 | ####################################################################################################
# Copyright (c) 2019 - 2023, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free ... |
979b7b9709067f18c223b9fee31c173432f7d69a3e410a66127f083323cc91b5 | Python | 3,951 | 108 | # Copyright 2020 Google Research. 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 applicable law... |
cbbfbd6042da7135c5c3186717f92c85eb2a17c1cfbea6d76363defc93af42a3 | Python | 3,954 | 103 | import os
import pandas as pd
import torch
import torch.nn as nn
import argparse
from sklearn.model_selection import KFold
from dataset import ViscosityDataset
from model import ViscosityNet
from trainer import Trainer, TrainerConfig
from utils import seed_everything, prepare_training_input
from base import VISCOSITY... |
cb5919ea5ac65f0c02145e91db8996e54918d5e4a387d407bbdad8cfe4a23628 | Python | 3,955 | 110 | import unittest
import numpy as np
from selene_sdk.sequences.genome import _get_sequence_from_coords
from selene_sdk.sequences.sequence import sequence_to_encoding, \
encoding_to_sequence
class TestGenome(unittest.TestCase):
def setUp(self):
self.bases_arr = np.array(['A', 'C', 'G', 'T'])
s... |
6aa1d297716952f7a6a0299801706fbe2177cfa8286f8e131129504d5fcbbf6c | Python | 3,956 | 132 | """Base class for all mappers."""
from abc import ABC
from collections import defaultdict
from dataclasses import dataclass
from typing import Any, Dict, Iterable, Iterator, List, Tuple
from curies import Converter
from sssom_schema import SEMAPV, Mapping
from oaklib.datamodels.vocabulary import SKOS_EXACT_MATCH
fro... |
de7ac799659554fd071e0f0926645f05c04a71c4be2a05bee4ee411b06ac26a3 | Python | 3,956 | 118 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# 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... |
860e123def30b41165a584e886e3e9ffbbd3400e1ad619eefe10a4c82290815e | Python | 3,957 | 155 | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 20 18:47:06 2021
@author: N.V
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.animation import FuncAnimation
import os
# note that this must be executed before 'import numba'
os.environ['NUMBA_DISABLE_INTEL_... |
e45cb24a37c71f359a83163a7ffe147adf0b2dc629e1cc636436337ab3c44348 | Python | 3,957 | 92 | import os
import torch
"""
Code based on ZSSR provided by Assaf Shocher
https://github.com/assafshocher/ZSSR
"""
class Config:
# network meta params
python_path = '~/.conda/envs/pytorch/bin/python'
scale_factors = [[2.0, 2.0]] # list of pairs (vertical, horizontal) for gradual increments in resolution... |
1e18bb548f505665e0e3c4386995b029fd80fdcdf9e9cbf056e181ca0bcd2ac3 | Python | 3,960 | 108 | 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,
unfla... |
4311bcb5f7629181ae9da7ed8b64e40bdbc7b10eae08a6a7911e90249ea348fe | Python | 3,960 | 137 | from functools import lru_cache
from typing import Optional
from pydantic import BaseModel
from oaklib import BasicOntologyInterface, get_adapter
from oaklib.datamodels.vocabulary import RDFS_LABEL
LICENSE_NAME_TO_URL_PREFIX = {
"CC0": ("https://creativecommons.org/publicdomain/zero/", "1.0"),
"CC-BY": ("htt... |
57b0601c540b2b66b4c4dd92d2eb578e01501c83fb304ddf3e11674e954995fb | Python | 3,961 | 112 | """A persistent local cache of entity embeddings, backed by sqlite."""
import logging
import sqlite3
import time
from pathlib import Path
from typing import Callable, Dict, Iterable, Optional, Union
import numpy as np
from oaklib.types import CURIE
__all__ = [
"EmbeddingCache",
]
logger = logging.getLogger(__n... |
ca780fc1b49488719120ecad619df0355f29adbbb190ad90b7aa03934a544518 | Python | 3,961 | 104 | import torch
from typing import List
from torch_geometric.data import Data
from torch_geometric.utils import convert
from torch_geometric.utils.subgraph import k_hop_subgraph
from networkx.linalg.graphmatrix import adjacency_matrix as adj_mat
from .nx_modified import swap
def rewire_edges(edge_index: torch.Tensor, ... |
75f1ff28a237f6c184f8d83e9d26c745435c60649184de80da1d233a416cf4da | Python | 3,962 | 90 | """Clean API"""
import logging
from pathlib import Path
from . import readers
log = logging.getLogger(__name__)
def kinetic_model(src, dst=None, params=None, models=None, input_interp_method='linear', w=None,
r1=1, k2p=0.000250, beta_lim=None, n_beta=40, linear_phase_start=500,
l... |
8698fe87f938b28de5cef5e8a0aa7f84817e1f4b376ce895f769c3724eb7e5e2 | Python | 3,963 | 67 | import pandas as pd
import numpy as np
import argparse
import sys
from cmseq import __version__
from .cmseq import CMSEQ_DEFAULTS
from .cmseq import BamFile
def poly_from_file():
parser = argparse.ArgumentParser(description="Reports the polymorpgic rate of each reference (polymorphic bases / total bases). Focuses on... |
3567d4d7a0a16b4f183f6888bf39da8ea14d3b8d28e456d70e366aad55e8e97c | Python | 3,965 | 114 | import argparse
import json
import numpy as np
import os
import torch
from datetime import datetime
from pathlib import Path
from sklearn import metrics
from evaluate import run_model
from loader import load_data
from model import TripleMRNet
def train(rundir, task, backbone, epochs, learning_rate, use_gpu,
... |
a715d9a1fbe38c7abc94416f51a428e8e811eb403b0ddf80baf65ae2a98b5245 | Python | 3,966 | 132 | # Header variables and parameters.
import time
import os
import numpy as np
from IPython.core.debugger import set_trace
import sys
import importlib
from masif_modules.train_masif_site import run_masif_site
from default_config.masif_opts import masif_opts
"""
masif_site_predict.py: Evaluate one or multiple proteins on ... |
334dc62b3da532a48435afd4a3572b228c448cd5f3101e4d7c6545150afef71e | Python | 3,967 | 128 | import logging
from scipy.interpolate import interp1d
import numpy as np
from tqdm import tqdm
import pandas as pd
from dask import delayed
import dask.array as da
from skimage.registration import phase_cross_correlation
def get_optimal_shift(pos1, pos2, L, step):
# objective : find dx, dy to move pos2 on pos1
... |
d7699bf030e6f3778ba36fd4f8dae42c4c145845ef9ee001dbba0bfbe4190a7e | Python | 3,967 | 102 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# 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... |
04a608caf94072c36973c061776960185a176c08653d46af562ad444b2737f5b | Python | 3,968 | 114 | from collections import defaultdict
import numpy as np
import pandas as pd
from sklearn.metrics import auc, roc_curve
from sklearn.utils import resample
from tabulate import tabulate
from tqdm import tqdm
white = "White"
asian = "Asian"
black = "Black"
def get_boostrap_ci_for_split_sex_experiment(
targets_sex: ... |
129947f74b1c50fd9fdf6220b5314688bece3c2abf9daa908148f604553e2bad | Python | 3,968 | 125 | from __future__ import print_function, division
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
import torch.backends.cudnn as cudnn
import numpy as np
import torchvision
from torchvision import datasets, models, transforms
import matplotlib.pyplot as plt
from PIL imp... |
33d146fa91208625664e7ce8cad4348cc89fccbfbea06905c1466db030c12270 | Python | 3,970 | 147 | #!/usr/bin/env python3
"""
Plotting module for phys2cvr.
Attributes
----------
FIGSIZE : tuple
Figure size
SET_DPI : int
DPI of the figure
LGR :
Logger
"""
import logging
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import zscore as zs
SET_DPI = 100
FIGSIZE = (18, 10)
LGR = loggi... |
702bfbbffaa2011710e25613f52f5a23c0f0a8f305a97b1864804d87bc49bc66 | Python | 3,970 | 103 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
def session(graph=None,
allow_soft_placement=True,
log_device_placement=False,
allow_growth=True):
"""Return a Session with simple config."""
... |
0e5eab250a739aec27a89fd98aeb1583c8b306b1383f000f51139f619000886b | Python | 3,971 | 142 | #%%
import datetime
import time
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from giskard.plot import crosstabplot
from giskard.utils import get_paired_inds
from graspologic.cluster import DivisiveCluster
from graspologic.cluster.autogmm import _... |
3ff70db1a0ff804ac780cd9741d4b781e21a94b4b58d5bc0c31caecf0e11a082 | Python | 3,974 | 130 | from math import ceil, floor
import torch
from torch.utils.data import DataLoader
from torch_harmonics.examples import ShallowWaterSolver
def load_spherical_swe(
n_train,
n_tests,
batch_size,
test_batch_sizes,
train_resolution=(256, 512),
test_resolutions=[(256, 512)],
device=torch.device... |
7cd4f6b4fd63b1292f181f0cb6ecf9525f4311281b3eb7b9b983f96c10f14874 | Python | 3,975 | 119 | # *- encoding: utf-8 -*-
"""
cogalign version, required package versions, and utilities for checking
"""
# Author: Qing Wang (Vincent), adpoted from https://github.com/neurodatascience/cog-align/blob/main/cogalign/version.py by Bertrand Thirion.
# License: MIT
# PEP0440 compatible formatted version, see:
# https://ww... |
c463943e044e438a0d6e2f22d42a367f808dcd96637e746886b158511d1c33a5 | Python | 3,976 | 96 | import matlab.engine
import numpy as np
from sklearn.svm import OneClassSVM
import os
import glob
from sklearn.model_selection import GridSearchCV
import joblib
from sklearn import metrics
import argparse
import logging
import random
random.seed(6666)
eng = matlab.engine.start_matlab()
def get_color_feat(img_paths):
... |
fc3f81567afbfd69823274af4c4ebe6f83c27a21888b34388468998ee89f15a9 | Python | 3,976 | 125 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# 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... |
3f9e37cb3ef9da44c101ff60a5829c73b7837b5d536a53770ab70f3808a6208a | Python | 3,980 | 116 | """ from https://github.com/keithito/tacotron """
import re
from . import cleaners
from .symbols import eng_symbols, cmu_symbols, kor_symbols, cht_symbols
class Language():
def __init__(self, lang, text_cleaners, use_eos=True):
# Regular expression matching text enclosed in curly braces:
self._curly_re = re... |
00da80a3130ee21ea6a98b1981ceb016d2731779a30284ebe0cf7f45d17d6ae5 | Python | 3,982 | 163 | from .base import Detector, SubpixelLocalizer
from ...quot.core import localize_frame, detect
import pandas as pd
import numpy as np
from typing import Dict
import enum
detection_methods_dict = {
"log": "Laplacian of Gaussians",
"llr": "Likelihood ratio",
}
class BaseDetector(Detector):
def __init__(
... |
990b26d43633307576af571831c4f31f78779ae867a702d530914d637f1f1203 | Python | 3,982 | 79 | import argparse
import yaml
def create_parser():
parser = argparse.ArgumentParser(description='Training Keypoint Discovery')
parser.add_argument('--data', metavar='DIR',
help='path to dataset')
parser.add_argument('--dataset', default='CalMS21', type=str,
... |
85c2051546fdb84ab67763661ef3671d944009e2889ee2ca0438583eea9f306c | Python | 3,985 | 130 | import numpy as np
from importlib import reload
from itertools import product
from math import sqrt
import preprocessing_images as pre_process
reload(pre_process)
# TEST - trim
######################################################
# basic test image
test_im_0_edges = np.array([
[0,0,0,0,0],
[0,1,2,0,0],
... |
958fc23b6f575d8da6661a624b0766de1077b7ef4cf9df73d75a34928fdc43ae | Python | 3,987 | 166 | from math import prod
import pytest
import torch
from tensorly import tenalg
try:
import torch_harmonics
except ModuleNotFoundError:
pytest.skip("Skipping because torch_harmonics is not installed", allow_module_level=True)
from neuralop.models import LocalNO
tenalg.set_backend("einsum")
@pytest.mark.param... |
dd12f30e01f5bcda43b80e88e1b8b651735aac20693cf80b0becc14ee23af590 | Python | 3,987 | 124 | '''
Loads and builds a model description from a yaml description.
TODO: load_models could be made more general
'''
import yaml
import os
from brian2 import *
from brian2.units.constants import faraday_constant as F
from brian2.units.constants import gas_constant as R
import re
__all__ = ['load_models', 'build_model',... |
5b21f926b1bc75c06220253678ce37721e021e051dcca81b52b46274ebd28461 | Python | 3,990 | 124 | import argparse
import io
import mmcv
import onnx
import torch
from mmcv.ops import RoIAlign, RoIPool
from mmcv.runner import load_checkpoint
from onnx import optimizer
from torch.onnx import OperatorExportTypes
from mmdet.models import build_detector
def export_onnx_model(model, inputs, passes):
"""Trace and e... |
eb131e202bbbf3dd656e92463f6ee1bfc2459c35124552c4a8a677e72191d6b5 | Python | 3,991 | 88 | # %%
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pymaid_creds import url, name, password, token
from data_settings import data_date, pairs_path
import pymaid
rm = pymaid.CatmaidInstance(url, token, name, password)
from contools import Celltype, Celltype_Analyzer, P... |
55386a46f5df55c6bc7af7d742794f967c9d17a682ab57e08ed61b1270c5ac34 | Python | 3,992 | 137 | from skimage.morphology import convex_hull_image
from skimage.transform import resize
from skimage.segmentation import expand_labels
from skimage import img_as_float32
import numpy as np
from cellpose.models import Cellpose
import gc
from tqdm import tqdm
from image_manipulation import (
image_downsample_shape,
... |
90092ab566e54b1ec048689dcdd46d873316eb31c1d34318b7fb79e9eefaf751 | Python | 3,994 | 141 | import numpy as np
import torch
import torch.nn as nn
from torch.nn import MSELoss
import torch.nn.functional as F
from torch_scatter import scatter_mean
from torch_geometric.datasets import MNISTSuperpixels
import torch_geometric.transforms as T
from torch_geometric.data import DataLoader
from torch_geometric.utils im... |
18e35e6a84b852edf13169276dad04c7c14bf0e6f5538ee7bdd7e5af12e469ab | Python | 3,995 | 121 | # This script performs forward runs using saved NN and noisy input data to calculate data-related uncertainty for 1 (one) pretrained NN
# Input files: 'amsre_3dm_seas_cycle.pkl'
# pretrained NN: amsr_smap_transfer_1.h5
# Output files: data_uncer_amsre_ver1.pkl
import sklearn as skl
from sklearn import preprocessing... |
e21f49fda0e9451f61cb868488ebd58d0359b4581285e1dfdf662e764a945b33 | Python | 3,996 | 107 | ####################################################################################################
# Copyright (c) 2019 - 2023, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free ... |
de92eb9686c0356d3e34ea2defeca4e93dbb298336b9e1473e7a87a732c11cc1 | Python | 3,997 | 104 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import re
import tensorflow as tf
def session(graph=None, allow_soft_placement=True,
log_device_placement=False, allow_growth=True):
"""Return a Session with simple config."""
config = tf... |
e99147df2c0385e2f3933e5dcc934587a034b076001039e2e57cfb75f05115e3 | Python | 3,997 | 126 | """
function plot_paired_data_for_Robin
function plot_paired_data_for_Robin
INPUT:
- csv file containing behavioral data with cross-referenced temperature
values for each trial
Notes:
Animals were tested twice daily (in AM and PM sessions).
Input data for Robin consists of paired sessions in which cooling was... |
44cf7d13d04f6f3bada195ee50de4d65db66162aca563d8796a34bb05bccdac8 | Python | 3,998 | 182 | # Generic
import torch
import skorch
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Basic Functions in Torch
from torch import nn
from torch import optim
from torch.utils.data import DataLoader
# Basic Functions in Skorch
from skorch import NeuralNet
from skorch.callbacks import EpochTimer
f... |
91b63ec8bcae1451b8ad5545664a05983cd7f20b7d94e932d14bff5425b328c5 | Python | 3,998 | 92 | # Copyright 2020 Huawei Technologies Co., Ltd
#
# 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... |
f4f0731d4ce32aa6406b28d465c3c23e635180198914f0da17950c6488fde357 | Python | 4,002 | 105 | """The version is written in three places; make drift a test failure."""
import json
import sys
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO / "src"))
def _plugin_manifest() -> dict:
return json.loads((REPO / ".claude-plugin" / "plugin.json").read_text())
def ... |
54445fa1cf1020e2995b3bc03d024df451d29aa8139e5bfb268a0575fcac7c09 | Python | 4,003 | 117 | import logging
import sys
import warnings
from dataclasses import asdict
from functools import partial
import chika
import numpy as np
import pandas as pd
import scipy.stats as stats
from imblearn.metrics import geometric_mean_score
from pyts.metrics import dtw
from sklearn.metrics import cohen_kappa_score, roc_auc_sc... |
b77642be9479527d611243691b6979988c1fe165dd72b2a70e4007a2c42d38d8 | Python | 4,003 | 117 | import torch
import torch.nn.functional as F
def compute_label_loss(states, actions, labels, approx_rnn, approx_fc, categorical, loss_weight = 1.0):
'''Compute attribute consistency loss'''
assert states.size(0) == actions.size(0)
hiddens, _ = approx_rnn(torch.cat([states, actions], dim=-1))
... |
f82ef1935a537f642f8cace9e2f4d0a7593fe381c4a5128f616a8b18ae28787c | Python | 4,004 | 74 | """Tiny SVG helpers shared by the doc diagrams (consistent palette and fonts)."""
import html
FONT = "Lato, 'Helvetica Neue', Arial, sans-serif"
MONO = "'DejaVu Sans Mono', Consolas, monospace"
C = dict(ink="#2b2b2b", sub="#5f6b73", line="#c9d3da", card="#f5f8fa", blue="#2980b9", red="#d9534f",
green="#3c9a5f"... |
749c58beb5beeff53c38bbc3055afe487dd38e68163feb8530283b792acb552b | Python | 4,005 | 124 | """
Runs unit tests on utils.py
"""
import json
import os
from csv import reader
from pytest import raises
from phys2bids import utils
# Tests check_input_ext
def test_check_input_ext():
test_filename = "help"
ext = "py"
out_filename = utils.check_input_ext(test_filename, ext)
assert str(out_filena... |
c77b2098f45e25d972686b60228ec6723f4d4a5286094d2c6565ae146910818f | Python | 4,006 | 130 | import argparse
import pickle
import os
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.models import inception_v3, Inception3
import numpy as np
from tqdm import tqdm
from inception import InceptionV3
f... |
d4107a9ee71b14b96e880a38ad051e9bf0407c4973d9ec61e123afe82ba1ee2b | Python | 4,008 | 105 | import numpy as np
from scipy.integrate import simps
import pickle
def freq_index(frequencies, freq):
"""Returs the index of frequencies sequence closest to freq.
Args:
frequencies (array_like): frequencies to index from
freq (int / float): frequency of interest to look for
"""
... |
5dbcc1224666b488be810cedd4a04af22df13c2ff380c8243d1a8a9989866019 | Python | 4,010 | 119 | import glob
import argparse
import torch
import torchvision.transforms as transforms
import numpy as np
from PIL import Image
from networks.drn_seg import DRNSeg, DRNSub
from utils.tools import *
from utils.visualize import *
from sklearn.metrics import average_precision_score, accuracy_score
def load_global_classif... |
289f5ce7d1b45b44f37f438c7c835733ae012c37f3968a89114704768708c1b6 | Python | 4,011 | 115 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# 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 a... |
332210b6056eadbbc4490ecab5cb3e17fa9264d2afccc1aa38af365eabed699c | Python | 4,011 | 126 | import numpy as np
import matplotlib.pyplot as plt
import time
from helper import *
from ALsim import ALsim
import sim
import sys
import os
from ALsimParameters import std_paras
import random
"""
Run and experiment to investigate the effect of decreasing response with higher concentration.
We generate N_odour-1 odour... |
953150f9406c2251c9fbb975b505d3e75ca1d19c61d0068274c374a413ee9e0c | Python | 4,011 | 114 | import torch
from model.cell import CellMTRNN, MaskMaker
from model.rnntg import RNNTG
class MTRNN(RNNTG):
def __init__(self, h_dim, time_scale, data_size, device):
"""
This class is designed in that the lowest hidden layer is equal to
input and output layer. So, if you use 1 layer mtrnn ... |
d2f0c9bdc83bc676824afde4d252bb7fb3449e29ee6cda6cd11da8ff75ec78b7 | Python | 4,011 | 130 | import pymesh
import os
import sys
from IPython.core.debugger import set_trace
from sklearn.metrics import roc_auc_score
import importlib
import numpy as np
from default_config.masif_opts import masif_opts
"""
masif_site_label_surface.py: Color a protein ply surface file by the MaSIF-site interface score.
Pablo Gainza... |
d731f07c954b5b2147b6061bf5248fc43b48e2f8613f8d17f6bf0908496cbe03 | Python | 4,012 | 94 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.