sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
57ea490147b366d6508eecd3a83452e384eecd17f4f621115b2bfa5afe523a4c | Python | 1,315 | 40 | """Example code for saving maps as nii files and plotting with workbench.
"""
import os
import numpy as np
from osl_dynamics.analysis import power
from osl_dynamics.utils import workbench
def get_data(name, output_dir):
if os.path.exists(output_dir):
print(f"{output_dir} already downloaded. Skipping..")... |
66aa9c86862697b9b3f0eb66c112ba52c74eb3a1b107accfbed032c466780af9 | Python | 1,315 | 38 | import unittest
from model_paper_mc_genetic.scripts.record_experiment import main
# from model_paper_mc_genetic.scripts.plot_experiment import main as plot
class TestExperiment(unittest.TestCase):
def test_00_minimal_experiment(self):
'''
Test minimal experiment without grid search and genetic al... |
c1b67a0a63c045a387083c099c7c7e38d5ffe9ca3eb128da57e436ffddccc53b | Python | 1,316 | 44 | import scanpy as sc
import pandas as pd
from glob import glob
import os
from params import *
from warnings import filterwarnings
filterwarnings("ignore")
def xlsx2h5ad(path):
filepath = os.path.join(path, "*.xlsx")
filenames = sorted(glob(filepath), key=os.path.basename)
print(filenames)
filepath... |
a5f9381fe6cfc7d00821a0a6bf22d487b33b85deab3fa1ddb1011946a620b0ff | Python | 1,318 | 41 |
import torch
import torch.nn as nn
import torch.nn.functional as F
class Generator(nn.Module):
def __init__(self):
super(Generator, self).__init__()
def convlayer(n_input, n_output, k_size=4, stride=2, padding=0):
block = [
nn.ConvTranspose2d(n_input, n_output, kernel_s... |
41bb9c636293de5aa0f8c9dabe0128c9a35d244a0926e9204559f0ccde498258 | Python | 1,319 | 30 | import os
import pandas as pd
import sys
gse_number = sys.argv[1]
for dirpath, dnames, fnames in os.walk("./"+gse_number+'/'):
all = None
for fname in fnames:
tail = 'celltype_annotation'
if tail in fname:
continue
if 'cell_ng' in fname and 'meta' in fname:
df = ... |
70ca33f32dcfbb9f459982c1a9f3283eb26a4d8a9705e3592c1cace8cd1d1da1 | Python | 1,319 | 44 | '''
- Generate plot for the README.md file
Cilia phases used: 16, 3
'''
import mesh.plot.vedo_viewer as mplot
import numpy as np
folder = 'data/cilia/' # pre-saved results of step01
phases = [16, 3]
num_phases = 20
mv = mplot.FlagellaPlaneViewer(folder, phases=phases, num_phases=num_phases)
# plotter = mv.show()
# ... |
9bd2275e29a49b617e4059660d0c13ad45354eeb76066c404a11a59df4703fc6 | Python | 1,319 | 62 | # This script calculates an approximately globally optimal threshold trajectory using gradient descent
# Load pytorch
import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
execfile("reduction.py")
dt = 160
Nsteps = 500... |
598b6847b27678fa320b9381a26b857c99d58311551cc8f5d125da9a3ac1c8f9 | Python | 1,322 | 34 | def get_values_as_in_dict(dict_to_copy: dict, summary_string: str) -> dict:
print(summary_string)
dict_to_return = {}
for key, value in dict_to_copy.items():
orig_cls = type(value)
try:
if orig_cls == bool:
print("Enter %s (default is %s) : " % (key, value))
... |
ddbcce3408a29b4591668b27eec3c87b6646adf9c344f8a3dea054868864b8d9 | Python | 1,322 | 41 | # 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... |
f940820426cf96341b985a3ac2c3a485f58a4d135adad0cf721f21db1a2f0a50 | Python | 1,323 | 41 | import hashlib
import os
import pytest
import backend.settings as settings
def sha256(data):
return hashlib.sha256(data).hexdigest()
def test_model_fetch_and_validation_use_declared_checksum(tmp_path, monkeypatch):
source_data = b'verified model package'
source = tmp_path / 'source.pt.zip'
source.... |
3072bcec4f33f0ad844968b60ece949494387757121381b0191831f8d5bd4e5a | Python | 1,324 | 35 | import torch
import torch.nn as nn
class ZoneoutLSTMCell(nn.Module):
def __init__(self, input_size, hidden_size, bias=True, zoneout_prob=0.1):
super().__init__()
self.input_size = input_size
self.hidden_size = hidden_size
self.zoneout_prob = zoneout_prob
self.lstm = nn.LSTM... |
8c04efdc1faafb36e173089136ac6245d1989f029c0dc89372f70bc72bc5c8f3 | Python | 1,324 | 46 | """
Simple script that checks if a checkpoint is corrupted with any inf/NaN values. Run like this:
python inspect_checkpoint.py model.12345
"""
import tensorflow as tf
import sys
import numpy as np
if __name__ == '__main__':
if len(sys.argv) != 2:
raise Exception("Usage: python inspect_checkpoint.py <file_na... |
136e7ce662f8be7b7a4df94e7771aca4fff946500392db51c8c986fcb8937ba7 | Python | 1,325 | 34 | # 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... |
f74f6fee949f21cb6e6740da7a3af2aa6816dfa47408a39944c4c8cffb2f557e | Python | 1,325 | 46 | import os
import logging
from http import HTTPStatus
from flask import url_for
from flask_restx import Api
from bds_api.exception.api_exception import BDSApiException
log = logging.getLogger(__name__)
# added for https bugfix https://github.com/noirbizarre/flask-restplus/issues/565
class SearchApi(Api):
@proper... |
314cca742dc5d751e44b0e4b05441ed57da0e70b23d0428b8a21410c3fa44e64 | Python | 1,326 | 47 | import logging
import os
import pandas as pd
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../scripts/PTFunctions"))
from PTQuery import *
logfile = snakemake.log[0]
logging.basicConfig(
filename=logfile,
filemode="w",
level=logging.DEBUG,
format="%(asctime)s:%(message)s",
... |
144f2963b00398eb7b6a7f1b4a9f05197298e51f29e19d5ad2fb1492f4252c00 | Python | 1,327 | 39 | import os
import argparse
parser = argparse.ArgumentParser(description='Process SMILES')
parser.add_argument('-s',
'--source',
type=str,
default='generated/multi',
help='directory that contains file that want to check')
parser.add_argumen... |
32d570581f6122ba733361353fd4ea7d615c7caf86d625c170b6a3e9ba00807c | Python | 1,327 | 47 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .batch_norm import FrozenBatchNorm2d
from .misc import Conv2d
from .misc import DFConv2d
from .misc import ConvTranspose2d
from .misc import BatchNorm2d
from .misc import interpolate
from .nms import nms
from .roi_align import RO... |
5ad3d7363653d1cd0dd3ed461bf1b4d36cb570832629531beb90b7407a271f22 | Python | 1,328 | 35 | from setuptools import setup, find_packages
import pathlib
here = pathlib.Path(__file__).parent.resolve()
long_description = (here / 'README.md').read_text(encoding='utf-8')
setup(
name='qMriMaps',
version='1.0',
description='qMriMaps',
long_description=long_description,
long_description_content_t... |
88f39ac4f9896412988703bf89ba663cdf2b9daeed88b77c66e1a9c8de2efc65 | Python | 1,329 | 52 | from pathlib import Path
from numpy.random import seed
seed(1)
import tensorflow as tf
tf.random.set_seed(2)
from datetime import datetime
from spotipy.model import SpotNet
from spotipy.model import Config
from cenfind.core.data import Dataset
from cenfind.core.loading import load_pairs
from cenfind.training.config... |
eb24f5e3ed2e019a79fab6deab0a71e987fe6763fd912a0a9f4cb2db69b05863 | Python | 1,329 | 59 | from darela import SUR
import autograd.numpy as anp
import matplotlib.pyplot as plt
# For fitting release parameters, initial values
# do not need to be specified (in this case, Vm and DAp)
release = {
"Km": 0.2,
"kS": 0.9,
"kE": 1.05,
"kads1": 0.035,
"kads2": 0.14,
"kads3": 0.09
}
# For fitt... |
ee0c2eecff257e57b6c27e39e1e74dbc1eb3a463ff7b860c6c1a19cd27a4450a | Python | 1,329 | 41 | import torch.nn as nn
import torch.nn.functional as F
from math import floor
import torchvision.models as models
from utils.quantify import *
class VGGMini_CNN(nn.Module):
def __init__(self):
super(VGGMini_CNN, self).__init__()
self.conv1 = nn.Sequential(
nn.Conv2... |
7c0b3068796267b32c1b56c2221e0b4b0d3ff7cd6d6d6186aa20638149c6fa27 | Python | 1,330 | 35 | # 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 a... |
e1569c6359e2e5ef283d3ca77bf1d217f24dadacf1d47638c6b3e40e26e66de0 | Python | 1,330 | 33 | import pandas as pd
import glob
def extract_gene_name(vectors):
for vec in vectors:
contents = vec.split(';')
for con in contents:
name, id = con.lstrip(' ').split(' ')
if name == 'gene_name':
yield id.strip('\"')
break
trans_file = "/home/rk... |
7790aefc861fa8bba69505a5545844c2212ddad0ca5e333a90fa9c4fd93115c9 | Python | 1,331 | 37 | from mmdet.core import bbox2result
from mmdet.models.detectors.retinanet import RetinaNet
from mmdet.models.registry import DETECTORS
@DETECTORS.register_module
class NASRetinaNet(RetinaNet):
def extract_feat(self, img):
x, sub_obj = self.backbone(img)
if self.with_neck:
x ... |
a0cd350d4ca8ededfc6c418f755a84d38afd414b00c4a360953aff20672a97f1 | Python | 1,331 | 22 | #!/usr/bin/env python3
"""channels.py DIFFUSE.png ORME.png OUT_DIFFUSE.webp OUT_ORME.webp: labelled channel strips of a building's textures."""
import sys
from PIL import Image, ImageDraw, ImageFont
F = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 22)
Fs = ImageFont.truetype('/usr/share/fo... |
c84f7f3cb0455d5a08764f37187396753204ac4c4eb771fe6bad3183c2955612 | Python | 1,332 | 46 | import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
tasks = [
"RomoTask1",
"RomoTask2",
"DMTask1",
"DMTask2",
"CtxDMTask1",
"CtxDMTask2",
"GoTask1",
"GoTask2",
"GoRtTask1",
"GoRtTask2",
"GoDlTask1",
"GoDlTask2",
]
def main():
N = 2999
... |
524912cbcd493ab6a6f3786fec9ccd7851363c8728770c51e528bba58370c53e | Python | 1,333 | 64 | """
Helper functions for fetching data from data tables.
"""
import numpy as np
# Get soma center coordinates ([um])
def get_soma_loc(data_dict, seg_id):
seg_ids = data_dict["segment_id"]
soma_locs = data_dict["loc"]
return soma_locs[seg_ids==seg_id][0]
# get stimulus label
def get_stim_label(data_dict, scan_i... |
e907c05676e02fed1a892434e7a7d5c23edc33bb3723a5562361a25e4e0e4720 | Python | 1,333 | 50 | from abc import ABCMeta, abstractmethod
class DataIOBase(metaclass=ABCMeta):
"""
This class defines the interface for reading and writing data.
Properties
----------
context : object
An object containing context information that is used when reading and writing data.
Methods
----... |
9bc7f7ca1cfe1781481e3ba40c5dfcf49a36ae4f5f6d08fbbd2762c3b972b660 | Python | 1,334 | 43 | import numpy as np
import mmcv
try:
import torch
except ImportError:
torch = None
def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True):
"""Convert tensor to 3-channel images.
Args:
tensor (torch.Tensor): Tensor that contains multiple images, shape (
N, C, H, W).
... |
afdd62265cb5e6d759e6ead0173d1f7359cd6700e9be51c50a592607ff17d8ce | Python | 1,334 | 56 | """Module with generic useful functions such as to return main dir path."""
import os
from pathlib import Path
def get_file_path(filename):
"""Find filename in the relative directory `../data/` .
Args:
filename (str): file we're looking for in the ./data/ directory.
Returns:
str: absol... |
a644e04fda29fc5f49ba8c99c58c24b4b8ba6fe41bde87f91bbf11f04fea91f5 | Python | 1,335 | 50 | """Shared job cancellation and diagnostic helpers."""
import threading
import typing as tp
import uuid
class OperationCancelled(RuntimeError):
"""Raised when a cooperative processing operation is cancelled."""
def new_diagnostic_id() -> str:
"""Return a short correlation ID suitable for UI and log messages... |
e206a61032ddf414c2c65e5db0e4703956060c29f058245417f5794781b289cf | Python | 1,335 | 37 | import os
import requests
from bs4 import BeautifulSoup
import pickle
types = ["true", "mostly-true", "half-true", "barely-true", "false", "pants-fire"]
url_base = "https://www.politifact.com/truth-o-meter/rulings/"
file_path = os.path.abspath('../../Dataset/Politifact/dataset.pkl')
dataset = []
def get_page(ruling... |
2d270fa6e56e01f23b02b64e7b778f21f52b4e0a81fffd498550b71f6bba1617 | Python | 1,336 | 20 | import glob
with open('copy_resources.sh','w') as out:
for f in glob.glob('/groups/umcg-biogen/tmp03/input/rawdata/ucl-upload-biogen//Public_RNA-seq_*/parameter_files/parameters.csv'):
with open(f) as input_file:
header = input_file.readline()
res_dir = ''
for line in in... |
e21ef3f1a1f0a7c5cbb8b644690cdd99f569228183be512669bc4e6f91206a34 | Python | 1,336 | 42 | # Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
import carla
import random
from . import SmokeTest
class TestPropsLoading(SmokeTest):
def tes... |
b60ce7832d0dbbb952d8181c945042da9123a30fa0e1c10fbc0a9cfa253f11de | Python | 1,337 | 30 | from .activation import build_activation_layer
from .context_block import ContextBlock
from .conv import build_conv_layer
from .conv_module import ConvModule
from .conv_ws import ConvAWS2d, ConvWS2d, conv_ws_2d
from .generalized_attention import GeneralizedAttention
from .hsigmoid import HSigmoid
from .hswish import HS... |
f4ea1a9758280af8cb8cab1447d172bd39d0bc9ef0408b2c92c74c88444ceda0 | Python | 1,337 | 54 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import click
import unetsl.data
import unetsl.comparisons
import numpy
def plotValues(raw_values, plotname):
from matplotlib import pyplot
N = 1000
nms = [vdict[pt] for vdict in raw_values for pt in vdict]
mn = min(nms)
mx = max(nms)
y = nump... |
43d44cd3e974d0ad4506682dd30eeebf0c172b1a9d4d706d3b99e409eb7914f9 | Python | 1,338 | 44 | from pathlib import Path
from typing import Iterable, List, Union
import numpy as np
from tqdm import tqdm
def compute_waic(nlls: np.ndarray) -> np.ndarray:
"""Agregate negative log-likelihood to WAIC.
:param nlls: 2d array. First dimension is batch, second is ensemble size
:return: 1d array with WAIC v... |
dbd01e58f80a4c95906ad329ee74741400093023483efa17ca2d9b572ca52593 | Python | 1,338 | 32 | # 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... |
5dcdb0964cd09c69ac06a465393c75a66a6317288c5abba6493f0a1461f67709 | Python | 1,339 | 20 | import unreal,json
from pathlib import Path
import os
P=Path(os.environ.get('CARLA_MODEL3_WORKDIR',Path(__file__).resolve().parents[4]/'artifacts/tesla-model3'));D='/Game/Carla/Static/Car/4Wheeled/TeslaModel3UE58/Meshes'
smes=unreal.get_editor_subsystem(unreal.StaticMeshEditorSubsystem) or unreal.new_object(unreal.Stat... |
5416b7ff2b535d451ec685c7a84d1a69dc834ef37f1aef60b1cac3a77aa0da72 | Python | 1,341 | 56 | """Text generation helpers"""
from typing import Iterable
def enumeration(items: Iterable[object], link: str = 'and'):
"['a', 'b', 'c'] -> 'a, b and c'"
items = list(map(str, items))
if len(items) >= 2:
return f"{', '.join(items[:-1])} {link} {items[-1]}"
elif len(items) == 1:
return i... |
753a8b955aeabe08ec0a706c8935c9d5a8e592c25e99bc3c9428ea42b57cc2bf | Python | 1,341 | 29 | ####################################################################################################
# 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 ... |
fb7d8704f1a60ad6c8c35c71f757f0d8e246b9c7d0701247d1de3776b44ae892 | Python | 1,341 | 44 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
from os.path import join
from warnings import catch_warnings, filterwarnings
import mne
from eelbrain import gui, load
from eelbrain.testing import gui_test, TempDir
from eelbrain._wxgui import ID
@gui_test
def test_select_components():
"Test Select-Epochs... |
2d0933c6d165b6f0a82a7ea246ac67fc73a644da290cda080158d5da0ec985f6 | Python | 1,344 | 39 | #!/usr/bin/env python
import sys
import getopt
import mappy as mp
def main(argv):
opts, args = getopt.getopt(argv[1:], "x:n:m:k:w:r:c")
if len(args) < 2:
print("Usage: minimap2.py [options] <ref.fa>|<ref.mmi> <query.fq>")
print("Options:")
print(" -x STR preset: sr, map-pb, map-ont, asm5, asm10 or splic... |
398f57293064525dcacfbf4bddf5b3a4b28626fb3bf5aa2cbca4844c31d28849 | Python | 1,344 | 47 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
import xml.etree.ElementTree as ET
class XML:
"""
A class used to represent an XML parser.
Attributes
----------
prot_... |
5176e44997b95b28b80f49f0402d056c60fd1013c295db4b9f7d6854484e8ed6 | Python | 1,344 | 36 | import numpy as np
import simulator as sm
year = ['2004', '2005']
nsim = 16
nparam = 11
files = []
obs_file = '/clusterfs/lawrencium/yaningl/Research/Ecosys_DukeForest/ecosys_duke_forest_weekly_data/observations.dat'
output_file = '/clusterfs/lawrencium/yaningl/Research/Ecosys_DukeForest/ecosys_duke_forest_weekly_data... |
9f293ef53f8ef0c1a4462b0d96833eba422bbff5c8837333ecf72d6686be9929 | Python | 1,345 | 52 | import numpy as np
from .sbm import stochastic_block_test, stochastic_block_test_paired
def _squeeze_value(old_misc, new_misc, old_key, new_key):
variable = old_misc[old_key]
variable = variable.values[0, 0]
new_misc[new_key] = variable
def erdos_renyi_test(A1, A2, method="score"):
stat, pvalue, sb... |
cac46cde7fda2c0b302c1b5bc0fa3d7daadf36bacb03f85f0fce5a4edaf85134 | Python | 1,345 | 64 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 14 11:45:32 2021
@author: spiros
"""
import os, pickle
import numpy as np
import pandas as pd
# import seaborn as sns
repo = 150
dirname = "data_analysis_poisson/"
if not os.path.exists(dirname):
os.mkdir(dirname)
with open(dirname + f'rate_... |
2e8452dc7dffeab14d92450b3e26d16da968ead0756a0d32e0c845000db2c199 | Python | 1,346 | 61 | """Train an HMM.
"""
from sys import argv
if len(argv) != 3:
print(
"Please pass the number of states and run id, e.g. python 2_train_hmm.py 8 1"
)
exit()
n_states = int(argv[1])
run = int(argv[2])
output_dir = f"results/models/{n_states:02d}_states/run{run:02d}"
import pickle
from osl_dynamic... |
81614f6de4d5aece4555a708bfb04dfea69aca4d3a36eb75a7c0d7c180483b28 | Python | 1,346 | 27 | ####################################################################################################
# Copyright (c) 2019, 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 softwar... |
f1fd03b4887b8eb14d6ea3b2ee9dfae95d85acd91a016cd40acd5721468651c0 | Python | 1,346 | 33 | # 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... |
7f9a1f68bc998e7e68391f401f23d778c298887b13392126d23bcb7ab4b23908 | Python | 1,349 | 54 | #%%
import datetime
import time
import numpy as np
import pandas as pd
from graspologic.utils import is_fully_connected
from src.data import join_node_meta, load_maggot_graph
t0 = time.time()
#%%
def join_index_as_indicator(index, name):
series = pd.Series(index=index, data=np.ones(len(index), dtype=bool), name... |
d3f82d42c56366f98d92270b6601fb5269d74d412c44ecfac6386398117a9446 | Python | 1,349 | 57 | import sys, time, os, pickle
import torch
import networkx as nx
import matplotlib.pyplot as plt
from graphxai.datasets.shape_graph import ShapeGGen
from graphxai.datasets import load_ShapeGGen
start_time = time.time()
# model_layers = 3,
# make_explanations=True,
# num_subgraphs = 1200,
# prob_conne... |
10440e6eb8c80b886c402e51fcc475eb16e4dcd78e51cd848eba85952a9d353d | Python | 1,350 | 41 | """Example code for plotting power maps calculated using the state/mode spectra
estimated from the source reconstructed data and inferred state/mode time course.
The spectra can be calculate with a multitaper (in the case of a state time
course) or regression (in the case of a mode time course).
See examples/spectra/... |
a4f6ffa51a8c3e60dcf4041c4ef3c6f65b09a8b4e42f29c89a09df0db8857714 | Python | 1,350 | 37 | import numpy as np
import functions_basic_sak as funsak
import AIS_import
import pandas as pd
import geopandas
import matplotlib.pyplot as plt
us_coastline = geopandas.read_file(None)
# world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
##
# url = "https://eric.clst.org/assets/wi... |
f23e9b1ebafd2d11862b87727688ed999ed8f536de261a9fe19eb3be68f1325d | Python | 1,350 | 46 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
import logging
from eelbrain import datasets, testnd
from eelbrain.fmtxt import html
from eelbrain._report import result_report
def test_result_report():
"Test result_report function for different Results"
ds = datasets.get_uts(True)
sds = ds.sub("... |
f28fb863e9a7a5f50363a54d9f595ba65821dfcf36084b7de6b016830aba899b | Python | 1,350 | 39 | from Classes.QueryParser import QueryParser
from Classes.Recommender import Recommender
from Classes.RelationshipIdentifier import RelationshipIdentifier
from Classes.SPARQLDB import SPARQLDB
from Classes.SearchResults import SearchResults
class SearchModule:
def __init__(self):
self.Parser = QueryParser... |
406419aefa24045629b723e3ecba2f9f3d30936271a2ae58931688fecf90fbdd | Python | 1,351 | 37 |
# loop through all subdirs to find all fastq files
import os.path
import glob
import os
import re
import argparse
parser = argparse.ArgumentParser(description='Make Molgenis Compute samplesheet for BipSeq.')
parser.add_argument('samplesheet', help='BipSeq samplesheet from synapse')
parser.add_argument('fastq_dir', h... |
3ad80d28cd71ad6d3327cb9055afba99ac7f2d9d7730e9866edd03558cae7584 | Python | 1,352 | 37 | """
© 2022, ETH Zurich
"""
import os
import numpy as np
from rescoss_logp_ml.run_training_for_model import get_final_results, run_model
from rescoss_logp_ml.utils import FOLDER_NAMES, PROC_DATA_PATH
import io
dataset = "az"
split_type = "random"
target = "logp_rescoss"
model_name = "rf_test_only"
basepath = os.path.... |
94dd99326413cb125bcab7d91f7f83ff64d1ec5f2604b3d229ffc5a7019f9042 | Python | 1,353 | 40 | #!/usr/bin/env python3
# Copyright 2021 Jiayu DU
# 2021 Xiaomi Corporation (Author: Yongqing Wang)
import sys, os
conversational_filler = ['UH', 'UHH', 'UM', 'EH', 'MM', 'HM', 'AH', 'HUH', 'HA', 'ER', 'OOF', 'HEE', 'HMM', 'ACH', 'EEE', 'EW']
unk_tags = ['<UNK>', '<unk>']
gigaspeech_punctuations = ['<COMMA... |
6ffbd6aa96f09cabd7c28998a1147efe51be0ac48ddd14e44bb1da624e30f1c1 | Python | 1,356 | 43 | # Author: Nikhil Bhagwat
# Date: 1 Aug 2021
# This script will take preprocessed brains from fmriprep and mask them.
import nibabel as nib
import glob
import os
import sys
import argparse
sys.path.append('../')
from lib.io_utils import get_masked_image
def main():
# argparse
parser = argparse.ArgumentPars... |
dc9e958e5bff8b2850dfaf0d4dfde72639c3ea49ea6e35ce6d17a5fc2c935230 | Python | 1,356 | 68 | """
Utilities for working with formats
See https://github.com/INCATools/ontology-access-kit/issues/687
"""
from enum import Enum
class OntologyModel(str, Enum):
"""
Enumerated types for ontology models.
A model is an abstract representation of an ontology that is potentially
serializable in multipl... |
86570ee397369229714a8e90fef8869bb96a0f145c79557d183aa86352506589 | Python | 1,358 | 58 | import sys
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
import pymaid
import pyoctree
from pymaid_creds import url, name, password, token
import numpy as np
import pandas as pd
import re
from itertools import chain
rm = pymaid.CatmaidInstance(url, token, name, password)
# breaking a... |
31ebda88867862bb27cfcdeaa642df1773b6ca83779a4e78948e46dcb1986d47 | Python | 1,359 | 35 | import numpy as np
from pytransform3d.urdf import UrdfTransformManager
from pytransform3d import transformations as pt
class CameraFrameTransformer:
def __init__(self):
self.transform_manager = self.create_transform_manager()
def transform_waypoints(self, local_waypoints, camera_frame):
cen... |
d71e6099a4c7d7eda9f38a453ba8260f21c149f2c31c8fcb124159d483b97f5b | Python | 1,360 | 37 | import cv2
import paddlehub as hub
import gradio as gr
import torch
# Images
torch.hub.download_url_to_file('https://cdn.pixabay.com/photo/2018/08/12/16/59/ara-3601194_1280.jpg', 'parrot.jpg')
torch.hub.download_url_to_file('https://cdn.pixabay.com/photo/2016/10/21/14/46/fox-1758183_1280.jpg', 'fox.jpg')
model = hub.... |
3679c0f3974ce4a566bd36a0d6c13487c429474b9fe97d4ab591056000a1e34d | Python | 1,361 | 34 | import connectome_tools.process_matrix as promat
import pandas as pd
import glob as gl
# load whole brain connectivity matrix
matrix = pd.read_csv('data/Gadn-pair-sorted.csv', header=0, index_col=0)
# import pair list CSV, manually generated
pairs = pd.read_csv('data/bp-pairs-2020-01-28.csv', header = 0)
# identify ... |
65cfe754ca6a1c928d7eb257f2ceb76104bd2e5b2184f3910eab5875de080b69 | Python | 1,361 | 53 | import torch
from pathlib import Path
from utils.data import make_blobs_dataset
from utils.nnet import get_device
from hebbcl.logger import LoggerFactory
from hebbcl.model import ModelFactory
from hebbcl.trainer import Optimiser, train_on_blobs
from hebbcl.parameters import parser
from joblib import Parallel, delaye... |
055b9bc290c4c37954e9e23fd0cb9051ec69a2fdc47bbc90c0a6c72c80e59beb | Python | 1,362 | 43 | from dataclasses import dataclass
from typing import Any, Type, Union
import yaml
from linkml_runtime import CurieNamespace
from linkml_runtime.dumpers import json_dumper
from linkml_runtime.utils.yamlutils import YAMLRoot
from pydantic import BaseModel
from oaklib.io.streaming_writer import StreamingWriter
def _ke... |
27c6e642b8ddbd568e33affa6fe742fa42a98b43d2b8f2458211caa04024ba79 | Python | 1,362 | 45 | from typing import Optional, Tuple
import norse.torch as snn
import torch
from norse.torch.functional.lif_refrac import LIFRefracParameters, LIFRefracState
from norse.torch.module.exp_filter import ExpFilter
from cgtasknet.net.save_states import save_states
class SNNLifRefrac(torch.nn.Module):
r"""This net incl... |
358e908f7bda22dae0311a10228318eb1104b8fad0edc511429b069bb3f37d99 | Python | 1,362 | 51 | # Copyright (c) Open-MMLab. All rights reserved.
from enum import Enum
import numpy as np
from mmcv.utils import is_str
class Color(Enum):
"""An enum that defines common colors.
Contains red, green, blue, cyan, yellow, magenta, white and black.
"""
red = (0, 0, 255)
green = (0, 255, 0)
blue... |
f755a62d273100fb22a243d6ca7f6a154ac930c32e97938446803d9770fd1e97 | Python | 1,362 | 51 | import numpy as np
from PIL import Image
def cvtColor(image):
if len(np.shape(image)) == 3 and np.shape(image)[2] == 3:
return image
else:
image = image.convert('RGB')
return image
def resize_image(image, size, letterbox_image):
iw, ih = image.size
w, h = size
if le... |
1666beede3f3e7fb8180c0d4ae6108d05d0f53f02b1b714e42e91910aeb95143 | Python | 1,363 | 24 | from .assigners import (AssignResult, BaseAssigner, CenterRegionAssigner,
MaxIoUAssigner)
from .builder import build_assigner, build_bbox_coder, build_sampler
from .coder import (BaseBBoxCoder, DeltaXYWHBBoxCoder, PseudoBBoxCoder,
TBLRBBoxCoder)
from .iou_calculators import B... |
70cf73b32994c1141b8729404d088d61966e71f71dd3b1f330f7dbcfef45fe60 | Python | 1,364 | 41 | __author__ = "Johannes Köster"
__copyright__ = "Copyright 2016, Johannes Köster"
__email__ = "koester@jimmy.harvard.edu"
__license__ = "MIT"
from snakemake.shell import shell
from os import path, popen
out_format = "-O v"
outfile = snakemake.output[0]
if outfile.endswith(".vcf.gz"):
out_format = "-O z"
log = s... |
88d0ad39198b992d002acdf52da42e862b38089a77a4642d72f96a8858a1ee93 | Python | 1,364 | 46 | import numpy as np
import polychrom
from polychrom import forcekits, forces, simulation, starting_conformations
def test_harmonic_bond_force():
N1 = 20
N = N1 * 2
for dist in [1, 1.5]:
for offset in [0, 0.05, 0.1, -0.05, -0.1, 2, -1]:
sim = simulation.Simulation(
plat... |
ac813e4a42883858558fe2d69dd4c5983fd33736b0aa89e6a8b89b143adae0bb | Python | 1,365 | 42 | import os
import matplotlib
from phys2bids import io, viz
def test_plot_all(samefreq_full_acq_file):
chtrig = 3
test_path, test_filename = os.path.split(samefreq_full_acq_file)
phys_obj = io.load_acq(samefreq_full_acq_file, chtrig)
viz.plot_all(
phys_obj.ch_name,
phys_obj.timeseries,... |
c3bad3dde5850ff707438cf259c7ab3c1c64837bfc15bf53b34b017449db4642 | Python | 1,365 | 60 | import abc
from torch import nn
from constants.constants import BASE_NETWORK
class BaseModel(nn.Module, abc.ABC):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.architecture_name = BASE_NETWORK
def supports_classic_training(self) -> bool:
return True
... |
c6e94cf1f6a67b075a815caf17d9e2eddb10cd014db28b47b6b5a210406d65de | Python | 1,367 | 58 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import List
class Index:
"""
Class for generating index of a sequence.
Parameters
----------
sequence : L... |
67c610854a83389e7dc4eb9d927f11020f7c1489605b057099f2edcdb241985d | Python | 1,370 | 19 | """Fetch the attributed source mesh and verify its exact bytes before authoring."""
import hashlib,json,os,subprocess
from pathlib import Path
import requests
P=Path(os.environ.get('CARLA_MODEL3_WORKDIR',Path(__file__).resolve().parents[4]/'artifacts/tesla-model3'))
for name in ['reference','audit','source','renders','... |
82f5cffe9bcdbd555a368d2b5813324ca9b23282ca441b53955fc86696c9a9c0 | Python | 1,370 | 41 | import os
if os.getcwd().endswith("UnitTests"):
os.chdir("..")
from Classes.RelationshipIdentifier import RelationshipIdentifier
import unittest
from Classes.QueryParser import QueryParser
from Classes.Recommender import Recommender
class RecommenderTest(unittest.TestCase):
@classmethod
def setUpClass(... |
e278d50fdd2c1eb9e0a75c37c8a00011a3686fa57b2239d1887eb7ef89f77d38 | Python | 1,371 | 42 | #!/usr/bin/env python3
import glob
import itertools
import os
import pytz
import click
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.signal as sg
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, mean_absolute_error
# Input/Output... |
959c2fe26687de36ca55b2a8d9c5390f481ae4e524a3801623cf80772bdff390 | Python | 1,373 | 35 | import glob
import gzip
disease_per_snp = {}
qtl_per_disease = {}
diseases = []
for f in glob.glob('GWAS*'):
disease = f.split('-')[-1].split('.')[0]
qtl_per_disease[disease] = []
diseases.append(disease)
with open(f) as input_file:
header = input_file.readline()
for line in input_file... |
60bb175ceac4e31515bee1f189b1e34ee5871a717716c71f45f4a243b09b77c3 | Python | 1,374 | 54 | # %%
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pathlib import Path
from box import Box
# %%
all_events = pd.read_csv("all_combined_with_80_20_taus.csv",index_col=0)
#%%
fix_scalar = lambda x : x.item() if x.ndim==0 else x
def read_npz_MAD(file_name):
data= np.load(file_name,all... |
f2f63cccf770f00ce8328005bce961dee1c60b7e1a0f0268e3347f22c6fcb46c | Python | 1,374 | 65 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 14 11:45:32 2021
@author: spiros
"""
import os, pickle
import numpy as np
import pandas as pd
# import seaborn as sns
repo = 150
dirname = "data_analysis_poisson/"
if not os.path.exists(dirname):
os.mkdir(dirname)
with open(dirname + f'rate_... |
a3972f9b714e716e605c261f15b37dd43724474e3a54de84c247e0123d74a841 | Python | 1,375 | 35 | import glob
import gzip
disease_per_snp = {}
qtl_per_disease = {}
diseases = []
for f in glob.glob('GWAS*'):
disease = f.split('-')[-1].split('.')[0]
qtl_per_disease[disease] = []
diseases.append(disease)
with open(f) as input_file:
header = input_file.readline()
for line in input_file... |
cb1792b50c0d516b593776ea445cca2eb948b773003f9682fdbb63049c7e05fe | Python | 1,375 | 47 | # -*- coding: utf-8 -*-
from .core import *
from .. import _logging as logging
import tensorflow as tf
__all__ = [
'PadLayer',
]
class PadLayer(Layer):
"""
The :class:`PadLayer` class is a padding layer for any mode and dimension.
Please see `tf.pad <https://www.tensorflow.org/api_docs/python/tf/pad... |
1e874f537b5171aef1b10da6821db2e2fd83c72f080de31c14bff1ce07724c6f | Python | 1,376 | 44 | import multiprocessing
import dask
import subprocess
# Generates fingerprints for testing set
n_cores = multiprocessing.cpu_count()
print("Number of cpus:", n_cores)
with open("all_test_pdbs.list") as f:
all_test_pdbs = f.read().splitlines()
files_per_core = len(all_test_pdbs) // n_cores + 1
for core in range(n_... |
36d6cedac8261d61fd5d96fc79bc06fb67ed8569b5c2fc6bc8730e104ac7e870 | Python | 1,376 | 43 | import palm_tools
import pandas as pd
from glob import glob
import logging
from palm_tools.utils.read_file import check_file_and_read, df_is_valid
__author__ = "Hippolyte Verdier"
__copyright__ = "Hippolyte Verdier"
__license__ = "MIT"
# def test_main(capsys):
# """CLI Tests"""
# # capsys is a pytest fixture t... |
df5823993e6d0cff69808e4dbb55b10726a4f64c4f3bcba95c9c6f88d9628760 | Python | 1,376 | 35 | # 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... |
82791ebe65b6c40d9adcf5a6f593c8d61c1dffc94b5814a53fe4465c4f8bd8f4 | Python | 1,378 | 39 | import os
import numpy as np
stats = []
cpu_seconds = []
for dirname in os.listdir('03-results/'):
full_dirname = os.path.join('03-results/',dirname)
if not os.path.exists(full_dirname+'/results.txt'):
continue
results = open(full_dirname+'/results.txt').readlines()
for time_fn in os.listdir(fu... |
91db6377ada6a2f26fbfaf8555a2f896bebe80499a4d2136f4195074d5ce8bfa | Python | 1,378 | 51 | #!/usr/bin/env python
# Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""Blocks until the simulator is ready or the time-out is met."""
import sys... |
a23e2620aa01e70644d6c86257e74dc96a3a05f13719fdb60a093bc143fc6380 | Python | 1,381 | 45 | """Time-to-live garbage collection for blobs and finished jobs."""
from __future__ import annotations
import asyncio
import logging
import shutil
import time
from .auth import TokenStore
from .config import Settings
from .store import Store
log = logging.getLogger(__name__)
def collect(store: Store, settings: Set... |
5058af0c191b72ebcb95552f290477705227dbc834850474586c20db076d7d64 | Python | 1,382 | 47 | from typing import Any, List, Optional
from zencfg import ConfigBase
from .distributed import DistributedConfig
from .datasets import NavierStokesDatasetConfig
from .models import ModelConfig, SimpleFNOConfig
from .opt import OptimizationConfig, PatchingConfig
from .wandb import WandbConfig
class TestConfig(ConfigBa... |
e2870a817090494511d239d862d34fc960878c551f6439fe0a72ccad80507ad1 | Python | 1,382 | 66 | import sys
import gzip
import os
inputfile=sys.argv[1]
referencefile=sys.argv[2]
print("Using "+referencefile+" to update "+inputfile)
idstoload = set()
snpmap = {}
fh = open(inputfile,'r')
ctr=0
for line in fh:
elems = line.rstrip().split('\t')
id = elems[0]+":"+elems[3]
idstoload.add(id)
ctr = ctr + 1
if (ct... |
89f70c459e1c6632d3556cdb08ae70d3548cebf5b5d85d82ccb42eaed72d5a68 | Python | 1,383 | 34 | # 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... |
842114a8bafc879f5cf2090e3b37383ed2041474f3b1f3616396259a9dcde91b | Python | 1,384 | 34 | #!/usr/bin/env python3
import sys
relative = sys.argv[1]
audio_list = sys.argv[2]
wavscp_file = sys.argv[3]
kaldi_root = sys.argv[4]
def main():
allowed_audio_type = ["wav", "flac", "sph"]
data_dir = "/".join(audio_list.split("/")[:-1])
with open(audio_list, 'r') as al:
with open(wavscp_file, 'w... |
cd8c2b85e399da61850cb2ee49b9146ff56723a50d66f53c49f411219668a3e7 | Python | 1,384 | 36 | """
Report results of bootstrap hypothesis testing that cooling impairs vowel discrimiantion
Motivation:
------------
Bootstrap data contains the number of correct trials for each stimulus condition (noise|clean) and treatment condition (e.g. cooled|control).
We want to know if cooling signficantly impairs performan... |
df0d521428702dbfd2110dac22f8594d6ce327670987fd968a275446c20b73b7 | Python | 1,384 | 48 | import pandas as pd
import pickle
import category_encoders as ce
import os
ENCODER_FOLDER = None
def base2_create(category: pd.DataFrame, save: str):
encoder = ce.BaseNEncoder(base=2)
encoder = encoder.fit(category)
outpath = os.path.join(ENCODER_FOLDER, save)
with open(outpath, 'wb') as ... |
6d5afa45264e0562191879ce5e0af8f8d286580f4bdba259a2427807a8eb5baa | Python | 1,385 | 54 | # Copyright (c) Open-MMLab. All rights reserved.
from enum import Enum
class Priority(Enum):
"""Hook priority levels.
+------------+------------+
| Level | Value |
+============+============+
| HIGHEST | 0 |
+------------+------------+
| VERY_HIGH | 10 |
... |
bb13c929972a3057d8a76947325ce02de7903a9c72a38f67339d7debd06b53b9 | Python | 1,385 | 45 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
def _register_generic(module_dict, module_name, module):
assert module_name not in module_dict
module_dict[module_name] = module
class Registry(dict):
'''
A helper class for managing registering modules, it extends a dictionary
... |
37a0469b13dea82aff16d125e9540ac020abc5450eb8da441b547d0d50e2e282 | Python | 1,386 | 66 | import numpy as np
class Metric:
def __init__(self):
pass
def __call__(self, outputs, target, loss):
raise NotImplementedError
def reset(self):
raise NotImplementedError
def value(self):
raise NotImplementedError
def name(self):
raise NotImplementedError... |
fb37cc7b3bc8ff122793bef91dc6d8bacc182d2e68a68170179bc72582bd1042 | Python | 1,386 | 47 | from abc import ABC
from dataclasses import dataclass
from typing import Dict, List, Tuple, Any
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface, RELATIONSHIP_MAP, RELATIONSHIP
#import oaklib.datamodels.summary_statistics_datamodel.slots as statdict_slots
from oaklib.types import CURIE, LA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.