sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
19158e5b15a99f6e4421f2c89c647869dfdd1a7d84dc111e0bf5d85bbb111cd7 | Python | 4,108 | 100 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
ed190b6249a3f2447f24677ff4628cf5761331ecbf89993ee413e9b9e9e86ebd | Python | 4,108 | 131 | import exputils as eu
import numpy as np
import base64
import cloudpickle
try:
import json
except ImportError:
import simplejson as json
class ExputilsJSONEncoder(json.JSONEncoder):
"""
Encodes objects into json strings. Allows to encode numpy arrays and functions.
The exputils_json_object_hook() ... |
70f03ff5cb892fc849c954b03f320b3664820506fb5be28e83017560a7b8fd7d | Python | 4,109 | 143 | from typing import Any, Dict
from data_profiling.config import Settings
from data_profiling.report.formatters import fmt, fmt_bytesize, fmt_percent
from data_profiling.report.presentation.core import Container, Table, VariableInfo
from data_profiling.report.utils import image_or_empty
from data_profiling.visualisation... |
b6c7b36201ee4a3478246c79340fb14ab3348fd77403b7927bb76d28a2d6fce7 | Python | 4,109 | 160 | # -*- coding: utf-8 -*-
"""
Created on Wed May 22 12:16:12 2024
@author: jpv88
"""
import os
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import minimize_scalar
from DCISIv import DCISIv
import SpikeSim
... |
73e017cbf912b731414b22e80849fd528960a0c46ba1aa323b37d7212aebada3 | Python | 4,110 | 123 | from __future__ import annotations
"""GAT model used by the vendored gsMap latent-representation workflow."""
try:
import torch
from torch import nn
import torch.nn.functional as F
from torch_geometric.nn import GATConv
_TORCH_AVAILABLE = True
except ImportError:
_TORCH_AVAILABLE = False
... |
94f273952c331592ed03dea19ec32054c0d298ebe841f2aebd3eec0aa294632f | Python | 4,110 | 117 | """Read Nifti write BrainVoyager VMR and V16 (anatomical image) files."""
import os
import bvbabel
import nibabel as nb
import numpy as np
import pprint
FILE = "/home/faruk/data2/DATA-AHEAD/3D_reconstructions/Ahead_brain_122017_Bieloschowsky-interpolated.nii.gz"
SUFFIX = "bvbabel"
# =================================... |
19f4815c6ff66f54e3fe3902edbf8ddf14998a63cb44dc50875cfa1380aec968 | Python | 4,113 | 120 | import os
from deepinterpolation.generator_collection import EphysGenerator
from deepinterpolation.trainor_collection import core_trainer
from deepinterpolation.network_collection import unet_single_ephys_1024
import datetime
import pathlib
if __name__ == '__main__':
# This is used for record-keeping
now = dat... |
81ff9a32dab8d88969488c0840bd232b8d77830b1d4ca535386f632bde59eb7e | Python | 4,113 | 147 | # %%
from collections import namedtuple
from typing import Iterable, Optional, Sequence, Tuple
import numpy as np
import scipy.stats as st
from matplotlib import pyplot as plt
from sklearn.metrics import average_precision_score, precision_recall_curve
all = [
"plot_precision_recall_curve",
"plot_precision_rec... |
97f8b225dba3aedbc3d249dd2b12d87222f12b13e046f6f6ee1b577878d5a944 | Python | 4,114 | 73 | # Copyright 2021 Division of Medical Image Computing, German Cancer Research Center (DKFZ)
# and Applied Computer Vision Lab, Helmholtz Imaging Platform
#
# 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 L... |
56b44c911f3781107ccd5ae7d077b13b7cb394d43ee5d6dfd828484385df891d | Python | 4,115 | 139 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#... |
c8432b4a1874e9b8dae7f38ac85a43f11b083e86f389fbb72fb5944c4b9f5ee9 | Python | 4,115 | 111 | # built-in dependencies
from typing import Any, List, Tuple, Union, cast
# 3rd party dependencies
import numpy as np
from numpy.typing import NDArray
# project dependencies
from deepface.commons import weight_utils
from deepface.models.spoofing.tf import FasNetBackbone
from deepface.models.spoofing.FasNetUtils import... |
7823735afc51a47e27a709ceb291078e1e731398ac7ef2a67b20d25b5b645585 | Python | 4,117 | 122 | import rdkit
from rdkit import Chem
from optparse import OptionParser
from rdkit import RDLogger
lg = RDLogger.logger()
lg.setLevel(4)
BOND_TYPE = [0, Chem.rdchem.BondType.SINGLE, Chem.rdchem.BondType.DOUBLE, Chem.rdchem.BondType.TRIPLE, Chem.rdchem.BondType.AROMATIC]
def copy_edit_mol(mol):
new_mol = Chem.RWMo... |
471d6aeee6e044befdb82691a35f6e1288e1dce5aff054e1c04c21ba57443003 | Python | 4,119 | 136 | # © Kohulan Rajan - 2020
import os
import pickle
from datetime import datetime
import tensorflow as tf
print(datetime.now().strftime("%Y/%m/%d %H:%M:%S"), "Process started", flush=True)
# Initial Setup for GPU
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
gpus = tf.config.experimental.list_physical_devices("GPU")
for gp... |
603f3218248d4b2c23467d1f658506dd7eebde2e39d86d62a87b711d8635ddbd | Python | 4,119 | 128 | #
# Copyright (c) 2021, NVIDIA CORPORATION.
#
# 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 ... |
4d37d2daf545d3cd8bc14fdd90e5a419b492cbf25b4adbca19f8f0d1ca0050fa | Python | 4,120 | 132 | import os
from typing import List, Optional
import boto3
from ci.ray_ci.utils import logger
bazel_workspace_dir = os.environ.get("BUILD_WORKSPACE_DIRECTORY", "")
PYTHON_VERSIONS = [
"cp310-cp310",
"cp311-cp311",
"cp312-cp312",
"cp313-cp313",
"cp314-cp314",
]
ALL_PLATFORMS = [
"manylinux2014_... |
b76640f68a50335cd677a116241dd202ee1a0b62da720b10a34a9258236624d8 | Python | 4,120 | 105 | import torch
import torch.nn.functional as F
from torch.cuda.amp import autocast
from tqdm import tqdm
import DataSet
import numpy as np
from sklearn.metrics import accuracy_score
from Config import *
from model.TextCNN import TextCNN
from model.TextRCNN import TextRCNN
from model.TextRNN import TextRNN
from model.Tex... |
6d72044e0bc4b4c90b4f6b2ca8b45f783e75617cab20123b7fe2bc9fdab620c2 | Python | 4,121 | 118 | import torch
from diffusers import EulerAncestralDiscreteScheduler
from diffusers.utils import torch_device
from .test_schedulers import SchedulerCommonTest
class EulerAncestralDiscreteSchedulerTest(SchedulerCommonTest):
scheduler_classes = (EulerAncestralDiscreteScheduler,)
num_inference_steps = 10
de... |
89cee1649e6e978988ecc03815bb58c2a10bef5e9f6db1270f69f7afe1a41ed4 | Python | 4,121 | 157 | """
Django settings for site1 project.
Generated by 'django-admin startproject' using Django 3.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
import os
impor... |
ce68c22bdf810a39d8ec62f50bff2afe519d57bf534cb8c359f2ce1e92c473b9 | Python | 4,123 | 119 | # Copyright (c) DP Technology.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import lmdb
import os
import pickle
from functools import lru_cache
from . import data_utils
import numpy as np
import logging
logger = logging.getLogger(__name__... |
b43e505a505f5e39e142352ea28e07c06241ef8286f5867957d45786023a1f15 | Python | 4,124 | 125 | # flake8: noqa
# __rllib-adv_api_counter_begin__
import ray
@ray.remote
class Counter:
def __init__(self):
self.count = 0
def inc(self, n):
self.count += n
def get(self):
return self.count
# on the driver
counter = Counter.options(name="global_counter").remote()
print(ray.get(... |
8c1ec5a59901d891d421a379cb0d7dfeca3a48c9635b1128d2e4738758026ae2 | Python | 4,125 | 100 | import math
import torch
import itertools as it
from torch.optim import Optimizer
from collections import defaultdict
class Lookahead(Optimizer):
'''
PyTorch implementation of the lookahead wrapper.
Lookahead Optimizer: https://arxiv.org/abs/1907.08610
'''
def __init__(self, optimizer,alpha=0.5, k=... |
0e59fd6ce02162f83e8ab0a9d91d1cb27cbcfc2e27c592d93b335307f9439c43 | Python | 4,126 | 105 | # muninn_weights.py --- Extract muninn weights from log file
# Copyright (C) 2008-2013 Wouter Boomsma, Jes Frellsen
#
# This file is part of Phaistos
#
# Phaistos 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... |
0cfdce82a30be488d2fc964daac651ffbce2c5fe0e5f88558bbbce664431e044 | Python | 4,127 | 119 | import functools
import unittest
from unittest import mock
import gym
import gym.spaces
import numpy as np
import pytest
import pfrl
from pfrl.wrappers.atari_wrappers import FrameStack, LazyFrames
from pfrl.wrappers.vector_frame_stack import VectorEnvWrapper, VectorFrameStack
class TestVectorEnvWrapper(unittest.Tes... |
bbcfa8ab0fbf1d413bcecad9a540c67f342d5909c96d86a66cf591068ede378a | Python | 4,128 | 123 | #!/usr/bin/python
"""Utility scripts for correlation class."""
import logging
import numpy as np
from scipy.stats import norm
from scipy import sparse
def triu_mask(A):
"""Get the upper triangular part a matrix."""
m = A.shape[0]
r = np.arange(m)
mask = r[:, None] < r
return A[mask]
def calcula... |
d128124ff5523ce72b2e2c72748d8567106529b3f46677c9f1eb30fa6523e219 | Python | 4,130 | 160 | # Author: Zachary Chiang, Buenrostro Lab, Harvard University
# Finds haplotype-informative reads
import sys
import numpy as np
import os.path
import gzip
import pysam
snp_dict = {}
snp_chrs = []
snp_locs = []
# open files
vcf_file_1 = open(sys.argv[1],'r')
vcf_file_2 = open(sys.argv[2],'r')
bam_file = pysam.Alig... |
43f514f88587668d3730cab5ef87d7f63d55404eef3e15a26c54a283db0f5f6f | Python | 4,131 | 95 | import os
import torch
import pandas as pd
from model import Model
from data import ProcessingData, train_model, validation_model, test_model, convert_batch_data
#######################################################################
# predifined parameters
#############################################################... |
ac8050e1e2f40ede76417e22e27aac0c5965467c4c880b50470c53b809cd54ce | Python | 4,131 | 109 | # plot_reweighted_hist.py --- Plot reweighted 2d histogram over columns from an observable file
# Copyright (C) 2008-2013 Wouter Boomsma, Jes Frellsen
#
# This file is part of Phaistos
#
# Phaistos is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as publishe... |
5cc5095de92d77bdb91b27e918a878547e07979add2049e373ddced35c37cf4c | Python | 4,132 | 132 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
fb4c3f1ad2c21932a6f53794107802177c79ce490e1ab224ac0de83b7544b924 | Python | 4,132 | 129 | """Transforms on the short time fourier transforms of wav samples."""
__author__ = 'Erdene-Ochir Tuguldur'
import random
import numpy as np
import librosa
from torch.utils.data import Dataset
from .transforms_wav import should_apply_transform
class ToSTFT(object):
"""Applies on an audio the short time fourier... |
6441eae3cd1ea6821e6cc7c98649d2280e5913ce7c0f37190c0a8a3a48a9b6e7 | Python | 4,134 | 127 | """Simple utilities for composing research reports with citations."""
from __future__ import annotations
from dataclasses import dataclass
from typing import List, Sequence, Tuple
from ..research.agent import SourceCitation
@dataclass
class Section:
"""A single report section.
Parameters
----------
... |
d7212e5d8fdb30aa6297e3b0393d8bad9f87f9b07b53f9bb35da9cd466c2b142 | Python | 4,134 | 119 | # Copyright 2026 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
e7b2d497e8aa53a67af6ad3863ba4e7cf69cbe59339de0fc9153019ec0dfcb69 | Python | 4,136 | 127 | # Copyright 2026 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
8dfb360a8af72dfac3eb1fa519636fdf9d0ddc9c8d5ba8ea249c7b71beefb5ea | Python | 4,137 | 116 | import shutil
import os
from os.path import join
import argparse
import numpy as np
import pandas as pd
import PIL
from tqdm import tqdm
import torch
from stylegan2_pytorch import Trainer
from stylegan2_pytorch.stylegan2_pytorch import image_noise
from util import LATENT_DIR, get_latent_bolt, IMG_DIR, get_img_dir... |
c61abb0ce644801c656de1a89404b19641e61a2eedd9b25f41f78624ca33cacf | Python | 4,137 | 140 | from types import SimpleNamespace
import numpy as np
import pytest
from sklearn.datasets import make_classification
from siapy.core.configs import TEST_DATA_DIR
from siapy.datasets.tabular import TabularDataset, TabularDatasetData
from siapy.entities import Pixels, SpectralImage, SpectralImageSet
from siapy.entities.... |
f97bb1186967825d70511ac0a73c01e9a6e473a87f80645ff4b352ad654ac60c | Python | 4,137 | 138 | import sys
import os
from os.path import *
import subprocess
import argparse
import bqd, graph_qualdepth as qd
import samtools
from bam_to_qualdepth import set_unmapped_mapped_reads
import json
import log
logc = log.get_config( 'graphsample.log' )
logger = log.setup_logger( 'graphsample', logc )
def main():
args... |
205a0ff3591e8ec29d6d7624f018d3adad989352374c285f032a5a7cbda31758 | Python | 4,138 | 136 | import sys
from unittest import mock
import pytest
from ci.ray_ci.pipeline.gap_filling_scheduler import BLOCK_STEP_KEY, GapFillingScheduler
@mock.patch(
"ci.ray_ci.pipeline.gap_filling_scheduler.GapFillingScheduler._get_latest_commits"
)
@mock.patch("ci.ray_ci.pipeline.gap_filling_scheduler.GapFillingScheduler.... |
8293dd93a77380cdd313a12d16fc4fa7147926dca2564b3bdbe319ca3ee67887 | Python | 4,138 | 89 | import logging
from datetime import datetime
from agent.classifiers.utils.device_mgmt import get_gradient_accumulation_steps
from agent.classifiers.transformer_classifier import transformer_classifier
from agent.classifiers.data.transformer_text_cw_dataset_mgmt import get_datasets as cw_get_datasets
from agent.classi... |
f066a0c1a0b7853468edf417adf7fde95e4e6b761a7ea1573f1215f17b0bb048 | Python | 4,142 | 110 | import json
import logging
from http.client import RemoteDisconnected
from ray.autoscaler.node_provider import NodeProvider
from ray.autoscaler.tags import TAG_RAY_CLUSTER_NAME
logger = logging.getLogger(__name__)
class CoordinatorSenderNodeProvider(NodeProvider):
"""NodeProvider for automatically managed priva... |
a6f76c022e7a5e8ac65228c77c9dbd44b8beaaff168674b58ae4b3d829352e47 | Python | 4,143 | 96 | import logging
import subprocess
from ray.autoscaler._private.updater import (
STATUS_UP_TO_DATE,
TAG_RAY_NODE_STATUS,
NodeUpdater,
)
from ray.autoscaler._private.util import with_envs, with_head_node_ip
from ray.autoscaler.node_provider import NodeProvider as NodeProviderV1
from ray.autoscaler.v2.instance... |
a9e7cc3b3c91f82a5398cc9d2a069434d4efb968752ebd4590e4560cfefb93c4 | Python | 4,143 | 108 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 31 2026
@author: ju-bar
Functions handling input and output of structure data
via the PDB file format.
The PDB file format is a text format used to store biological structure
data. The format is similar to CIF. Established parsers are used to
extract the atomic structure... |
c819691d5853b9c9fcb8eb4a78ceaa01846d6c89e9428234201e3a5d56d26693 | Python | 4,144 | 102 | import os
def main():
SEQ_LEN = "800"
HALF_SEQ_LEN = int(SEQ_LEN) // 2
QUATER_SEQ_LEN = int(SEQ_LEN) // 4
print("QUATER_SEQ_LEN: ", QUATER_SEQ_LEN)
# output_files = ["./dataset/pos/", "./dataset/neg_can/", "./dataset/neg_noncan/", "./dataset/outlier_test/"]
output_dir = "./dataset/"
outpu... |
e338b7de35cb3b1989e6e898146fce465c8109451ac4206e56690c9aa5e649c7 | Python | 4,145 | 122 | from docutils import nodes, utils, frontend
from docutils.parsers.rst import directives, Parser
from sphinx.util.docutils import SphinxDirective
class URLQueryParamRefNode(nodes.General, nodes.Element):
"""Node type for references that need URL query parameters."""
class WrapperNode(nodes.paragraph):
"""A w... |
ffedd19f904fa4a21c940407852ad3800635f0e235e9a4a7b373a557962ac91f | Python | 4,145 | 110 | '''
Visualization tools for MBEANN in Python.
pyMBEANN (Author: Motoaki Hiraga)
'''
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
plt.switch_backend('agg')
plt.rcParams['figure.constrained_layout.use'] = True
import networkx as nx
from matplotlib.colors import Normalize
def visualizeI... |
d10d43399e48961c6cf6fe136c100d0e8eab18c9089764943e4ae41fb5b8de48 | Python | 4,146 | 57 | #!/usr/local/bin/ipython -i
import sys
sys.path.append('/home/jan/projects/mozaik/')
import matplotlib
import time
import os
import pylab
from mozaik.framework.experiment_controller import run_experiments, setup_experiments, setup_logging
from mozaik.visualization.plotting import *
from mozaik.visualization.MRfig impo... |
ba44636dd83e012e050eb257202681612153913b46c4115bf00b5f17e6ea061a | Python | 4,148 | 88 | import numpy as np
from src.networks.transformers.performer import Performer
from src.networks.transformers.transformer import TransformerBase
from src.networks.transformers.xtransformer import XTransformer
from src.utils.constants import (
TransformerPositionalConditioningTypes,
TransformerNetworks,
)
def g... |
522f435c6503b1f8ff204f2c2335c3f6dd6e22004c3ed76f040bb8a6e68cd63d | Python | 4,149 | 107 | # Parser for .gff NCBI files -> extract introns into .bed file
import os
import gffutils
from progress.bar import Bar
def run(db_name):
# define output folder
output_folder = './1_output/'
input_folder = '../data/'
input_filename = input_folder + db_name + '.gff'
db_filename = input_folder + ... |
3724d54116a75903f4a1395e41a35e12d623e956cf1efc5ef44a6749e2159d54 | Python | 4,150 | 121 | """
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from __future__ import annotations
import torch
from fairchem.core.common.gp_utils import GPPartition
PartitionStrategy = GPPartition
... |
b36662ca9d94a006ae44d5d855ebb91736aee194b447c5a57c3590419899122f | Python | 4,150 | 110 | import os
import json
import gffutils
def clean_gff(outdir, gff_db, threshold, bad_intron_num):
threshold = float(threshold)
bad_intron_num = int(bad_intron_num)
print(f"[Info] Threshold: '{threshold}'")
print(f"[Info] Bad intron number threshold: '{bad_intron_num}'\n")
trans_intron_num_txt = os.pa... |
80390c65c2e6677f9bedbe31624636cab86235b4527f5245dd307cafe36e812f | Python | 4,151 | 119 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Utils for configurations presets for resistive processing units."""
# pylint: disable=too-many-instance-attributes
from dataclasses import dataclass
from a... |
aebed73c2d5af6922e3042a10befde4fefaecf90d0d18937fb4311e451527a3b | Python | 4,151 | 118 | """Single-query HiveServer2 datasource for the Ray Data V2 read path."""
from typing import AbstractSet, Iterable, Iterator, List, Optional
import pyarrow as pa
from ray.data._internal.datasource_v2.formats.hive.hive_contract import HiveReadSpec
from ray.data._internal.datasource_v2.formats.hive.hive_hs2 import (
... |
06615a7e1eda4a6b327107dbc392085206eec2e1da2c0beed4b3fe8a8347cbbc | Python | 4,152 | 115 | from typing import Sequence
import torch
from rising.transforms.abstract import AbstractTransform, BaseTransform
from rising.transforms.functional.painting import local_pixel_shuffle, random_inpainting, random_outpainting
__all__ = ["RandomInpainting", "RandomOutpainting", "RandomInOrOutpainting", "LocalPixelShuffle... |
2c2c841ba50107abfe2b20aa731e59d5ee95e0e4780b680ac50d99f318d13960 | Python | 4,154 | 135 | # built-in dependencies
import hashlib
import importlib.util
import logging
from typing import Optional
# package dependencies
from deepface.commons.logger import Logger
# tensorflow is imported within the functions below on purpose, importing it here would
# force it onto users running deepface on pytorch
logger = ... |
450b8affa05163c0176109a73916b7befd03d7e5c6a7d1276b4c106c9f431058 | Python | 4,154 | 124 | import os
import tempfile
import unittest
import torch
import pfrl
def create_simple_link():
link = torch.nn.Module()
link.param = torch.nn.Parameter(torch.zeros(1))
return link
class Parent(pfrl.agent.AttributeSavingMixin, object):
saved_attributes = ("link", "child")
def __init__(self):
... |
98f8fdb2dad6e04db7be4bf411ebce61aa0b1fe7b0095053341eb0da796a9b72 | Python | 4,154 | 101 | import os
import re
import logging
from typing import Dict, Tuple, Callable
import h5py
import numpy as np
from ml4h.defines import TENSOR_EXT
from ml4h.tensormap.general import get_tensor_at_first_date
def token_dictionary_and_text_from_file(
text_file: str,
remove_special_chars: bool = True,
) -> ... |
eb4d94c3c1fc8d803826432706d8f1b041afb1c46178e0f46527089bcec9024a | Python | 4,154 | 143 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Spyder Editor
author: agiovann
"""
#%%
from builtins import zip
from builtins import str
from builtins import range
from past.utils import old_div
import cv2
import logging
import numpy as np
import pylab as pl
pl.ion()
from . import timeseries as ts
try:
cv2.set... |
5d1fbc0b27cdaeff10fcf5f429fa6a6547a8bd792b042f3683bb04eafebdf320 | Python | 4,155 | 100 | #!/usr/bin/env python
import argparse
import os
from dxencode import dxencode as dxencode
ASSAY_TYPE = 'RNA-seq'
ASSAY_TERM_ID = "OBI:0001271"
PROJECT_NAME = 'long-rna-seq-pipeline'
GENOME_MAPPING = {
"human": "hg19",
"mouse": "mm10"
}
def get_args():
'''Parse the input arguments.'''
ap = argparse.... |
bb0a04ac52585f8e309692c1737cc0d34568cf2f0248d8ba485610d593b9cbeb | Python | 4,155 | 114 | import numpy as np
from sklearn.decomposition import PCA
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
def optimal_kmeans(data, k_range):
# Function to determine the optimal number of clusters for KMeans
best_score = -1
best_k = 2
for k in k_range:
kmeans = KM... |
ceeb07cd783b76151d94de0b7d8ac6688d63a30e0faaee67337ce52cd5a39288 | Python | 4,156 | 121 | #
# CEBRA: Consistent EmBeddings of high-dimensional Recordings using Auxiliary variables
# © Mackenzie W. Mathis & Steffen Schneider (v0.4.0+)
# Source code:
# https://github.com/AdaptiveMotorControlLab/CEBRA
#
# Please see LICENSE.md for the full license document:
# https://github.com/AdaptiveMotorControlLab/CEBRA/bl... |
4335239fcccb4cf2153e273591f07801274a0f39c6c308105869da9cc90d2944 | Python | 4,157 | 99 | # Copyright 2023 The HuggingFace Team. 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 applicabl... |
917348f13f5ec183d7c0abcae3b4be344d594da07384a441c417c9a8e7be56f6 | Python | 4,157 | 130 | import nir
import torch
import numpy as np
# import os
# import torch.nn as nn
from torch.utils.data import DataLoader
from snntorch import functional as SF
# nirtorch loading for lava-dl and snntorch
from lava_rnn import from_nir
from snntorch import import_nirtorch
from nirtorch.from_nir import GraphExecutorState
... |
b291e535fa2dc4d433ff46361ad92017e65b25598702df6c224f72d5b2e4da79 | Python | 4,157 | 123 | """GeoSketch baseline (Hie et al., Cell Systems 2019).
GeoSketch is *not* a metacell aggregator — it picks ``n_metacells``
density-aware sketch cells. To produce a partition we then assign every
non-sketch cell to its nearest sketch cell (cosine), so each sketch cell
becomes the prototype of a 1-or-more-cell "metacel... |
961a105622a7a77ae6a7128c8a36501e350200181ebaf2b0fd3a011477bdcc97 | Python | 4,158 | 110 | import pickle
from sphinx.project import Project
import os
import time
from typing import List
from datetime import datetime
import click
PENDING_FILES_PATH = "pending_files.txt"
ENVIRONMENT_PICKLE = "_build/doctrees/environment.pickle"
def list_pending_files(ray_dir: str) -> List[str]:
"""List all files that ar... |
f3f278d2981354e154f99df9716e8a27d7d546ab36c38517f0d9c290daf27660 | Python | 4,158 | 143 | import numpy as np
import pytest
import torch
from datamate import Namespace
from flyvis.network.initialization import InitialDistribution, Parameter
from flyvis.utils.class_utils import forward_subclass
# -- Fixtures ------------------------------------------------------------------
groupby = {
"RestingPotentia... |
b6d6d3abd4c15fc5ab0a11ab267ff8b4ff9b7672dcd8666b05422a0df5500851 | Python | 4,159 | 93 | import pathlib
path = pathlib.Path.cwd()
if path.stem == 'tmb_survival':
cwd = path
else:
cwd = list(path.parents)[::-1][path.parts.index('tmb_survival')]
import sys
sys.path.append(str(cwd))
import numpy as np
from lifelines import CoxPHFitter
import pandas as pd
import pickle
from model import utils
from matp... |
0d5dc10f7e897720ec1739940be1c487bf8491cc7c8985eaa1f9a06f3d2ed886 | Python | 4,160 | 110 | import numpy as np
from lib.qc_surface import compute_qc, compute_topology
from lib.surface_repair import (
fill_holes,
remove_bad_faces,
repair_mesh,
split_nonmanifold_vertices,
)
from test_qc_surface import disk, grid
def holed_disk(half_width=0.2):
points, faces, u, v = disk()
centre = (np.... |
688630b0064de475144f3378e05d8106e3a22076cf09321468c7e99d87e94611 | Python | 4,160 | 89 | ####################################################################################################
# Copyright (c) 2016 - 2024, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
9acb8bc677284399cc0ea2369405328ac6e274cc68be76b584b60c0ec58e13f6 | Python | 4,160 | 84 | from tensorflow.keras.layers import Dropout, Activation, BatchNormalization,LeakyReLU
from tensorflow.keras.layers import Add, Input, Conv2D, MaxPooling2D, UpSampling2D, Conv3D, MaxPooling3D, UpSampling3D, AveragePooling2D, AveragePooling3D, Conv3DTranspose
from tensorflow.keras.initializers import RandomNormal
from te... |
074d88dac0f62c7631d185fa78c01770c6b8e468c17b2f7aa8538e0f12e4c172 | Python | 4,162 | 88 | import requests
from .__config import base_url
from .__aux_funcs import process_response
def get_discrete_copy_numbers_in_molecular_profile(molecular_profile_id, sample_list_id, discrete_cn_evt_type="HOMDEL_AND_AMP", projection="SUMMARY"):
"""
Get discrete copy number alterations in a molecular profile by samp... |
4b315ad9293a3dc5c859d79ffeb173d06e5b6cdc8e25abebf5c8ffa279c020f6 | Python | 4,164 | 121 | # Copyright (c) 2017-present, Facebook, Inc.
#
# 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... |
52d1b3e4f8b37b65def7868710ebfb47bfeafdafa46581a6244309a81b7e889f | Python | 4,164 | 127 | import os
import json
import xarray as xr
from typing import Dict, Any, Union, Optional
import boto3
import numpy as np
from neuron_morphology.swc_io import morphology_from_swc
import neuron_morphology.transforms.affine_transform as aff
from neuron_morphology.transforms.upright_angle.compute_angle import get_upright... |
69b3dc08b96e1e18d855548c95d4e28208dead8532cd71e9c766e6e9a78c8c31 | Python | 4,165 | 135 | from __future__ import annotations
from pathlib import Path
import numpy as np
import pandas as pd
import plotly.express as px
from scipy.spatial import KDTree
def load_ldsc(ldsc_input_file):
"""Load spatial-LDSC results and append -log10(p)."""
ldsc = pd.read_csv(
ldsc_input_file,
compress... |
1a957de4832b157257bd7526baf6c0eb89d35efa21f236c29eebcf709aac8f48 | Python | 4,166 | 139 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
29d43de6d9708f1b9355ba2972d19279217895cc3ddb151f55768f956584633c | Python | 4,166 | 95 | #!/usr/bin/env python3
import argparse
from glob import glob
import sys
import numpy as np
import matplotlib.pyplot as plt
import pysam
import math
import pandas as pd
import haplotagging_stats
import os
import collections
import seaborn as sns
NUM_CONTIGS="num_contigs"
TOTAL_LEN="total_len"
HAPLOTYPE="haplotype"
HAPL... |
bf0b561747fa61a683e4f295b4c9246fc5240242eb111dedff8df8b9bbba5eb3 | Python | 4,167 | 126 | import sys
import numpy as np
import pandas as pd
from scipy.stats import norm as norm_rv
from utils import load_tsv, save_tsv
def aggregate(mean, variance, count, specificity=0.02, n_top=50):
assert (mean.index == variance.index).all()
assert (mean.index == count.index).all()
assert (mean.columns == v... |
37bcd640e8dd9b7a9e042e57d67d2948485a48697f367be9e4b94d9fb37efbf9 | Python | 4,169 | 130 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Tests for input range calibration."""
import random
from typing import Union
from copy import deepcopy
from pytest import mark
from torch import allclose, ra... |
dfb914b01896ac677dce8374b5e675d0c91c98d3942639546c4a0103e3a0403c | Python | 4,169 | 104 | from __future__ import annotations
import logging
import os
import numpy as np
import pandas as pd
import xgboost as xgb
from .. import settings
from ._base_algorithm import BaseAlgorithm
class XGboost(BaseAlgorithm):
"""
Class to compute XGboost classifier.
Parameters
----------
batch_key
... |
c2eecbfd2af25e33f7fd551462acc3836c9f98bf913c8f8316fecb11dd3985a5 | Python | 4,170 | 47 | import hail as hl
hl.init()
union_MT = hl.read_matrix_table("TE-shortvar-union.mt")
DRS_fams = ['162','179','181','188','212','237','240','241','245','1', '6', '7', '8', '12', '17', '18', '19', '20', '26', '30', '36', '43', '51', '52', '53', '54', '55', '57', '61', '62', '65', '67', '93', '98', '100', '102', '101', '... |
1c619bb7d893ef4c589e68820cc8d878af31dfa7f82a01b67955ef8383710500 | Python | 4,171 | 167 | from typing import Optional, List
from enum import Enum
from neuron_morphology.morphology import Morphology
from neuron_morphology.feature_extractor.marked_feature import marked
from neuron_morphology.feature_extractor.feature_specialization import FeatureSpecialization
from neuron_morphology.feature_extractor.mark im... |
d0825e274f2ee4763b1ed5be87653c7fc63b0ca5db75dc9f5a3df57c4c236e5d | Python | 4,172 | 106 | import utility
from types import SimpleNamespace
from loss import discriminator
import torch
import torch.nn as nn
import torch.nn.functional as F
class Adversarial(nn.Module):
def __init__(self, args, gan_type):
super(Adversarial, self).__init__()
self.gan_type = gan_type
self.gan_k = a... |
e38696236fcff24059113da9aac5e75e4dc544d1acb0eb11a1cfb59e1f7705a8 | Python | 4,172 | 209 | # flake8: noqa
# fmt: off
# __streaming_generator_define_start__
import ray
import time
@ray.remote
def task():
for i in range(5):
time.sleep(5)
yield i
# __streaming_generator_define_end__
# __streaming_generator_execute_start__
gen = task.remote()
# Blocks for 5 seconds.
ref = next(gen)
# ret... |
864c80b470a5376e5a894167f2d5ef7df99a1c1d9cd4c470379b19fde4c9cfe2 | Python | 4,174 | 112 | import argparse
import pickle
import lpips
import numpy as np
import torch
import lib.data_utils.data_util as du
import lib.dataset_config_parser.dataset_config_parser as dcp
from eval_fns.eval import Masked_MS_SSIM, \
apply_simple_masked_lpips, apply_masked_ms_ssim
from lib.data_utils.sta_metadata import compute... |
6483399b65eb7e57fe0c48c58216336663563e42b1fdb728606a0a407a3cec79 | Python | 4,176 | 111 | import torch
import logging
from torch import nn
from os.path import exists
from agent.data.entities.config import DEV_LABEL, MODELS_CACHE_PATH, NEW_ITEM_FILTER, NEW_LABEL
from agent.classifiers.utils.random_mgmt import set_random_seed
from agent.classifiers.evaluation.evaluation_mgmt import get_evaluation_measures
... |
cdba4d3ce644267fc5d2c9fe0d524c750c4e8b30de30a2f5941c109e939fed48 | Python | 4,177 | 84 | # -*- coding: utf-8 -*-
"""Load raw 3D SIM images, OTF, timestamps and save as .npz for reconstruction using sim3d_main.py.
This script is used to load raw 3D SIM images, OTF, timestamps and save as .npz for reconstruction using sim3d_main.py.
The raw 3D SIM images will be loaded, subtracted from the background intens... |
4fef1bc811ae847297be62cee53cbca56f1f92cda4012fc497a789312a926aa2 | Python | 4,180 | 108 | from typing import NamedTuple, Sequence
import copy as cp
class ReferenceLayerDepths(NamedTuple):
""" Reference (e.g. average across specimens and regions) depths of
cortical layer boundaries. Depths are given from pia. Units are not
specified, but the user should ensure they are consistent with other
... |
a01b9385c8b237851c5f4085f9a7bdcc0d16bb06ad2191d5bf64c84a9f2f221a | Python | 4,183 | 132 | # Copyright 2023 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
63789d343e8ff550271d5c99bfe6c9c869d83d0d78f52b38bf999c3ef01604c1 | Python | 4,184 | 118 | """
This module contains tests that run mozaik models and compare their output to a
saved reference.
"""
import numpy as np
import os
from mozaik.storage.queries import *
from mozaik.storage.datastore import PickledDataStore
from mozaik.tools.distribution_parametrization import PyNNDistribution
from parameters import ... |
45f084b360e891a1814b17714483faca819911c49f2e8331f25831fcd0908ebf | Python | 4,185 | 122 | import numpy as np
import pandas as pd
import pytest
from data_profiling import ProfileReport
@pytest.fixture
def html_profile() -> str:
size = 1000
time_steps = np.arange(size)
df = pd.DataFrame(
{
"ascending_sequence": time_steps,
"descending_sequence": time_steps[::-1]... |
6722182d5e20267aed3cd724eb7bdc929fc99a4bb841010ad86cb681f762bd3c | Python | 4,186 | 122 | import rdkit
from rdkit import Chem
from optparse import OptionParser
from rdkit import RDLogger
lg = RDLogger.logger()
lg.setLevel(4)
BOND_TYPE = [0, Chem.rdchem.BondType.SINGLE, Chem.rdchem.BondType.DOUBLE, Chem.rdchem.BondType.TRIPLE, Chem.rdchem.BondType.AROMATIC]
def copy_edit_mol(mol):
new_mol = Chem.RWMo... |
65b7cff4900ab11c04abeb4d641d7c5dabef97593d6e5339fd287756b7f7fbb9 | Python | 4,188 | 115 | #!/usr/bin/env python3
"""
Client script to send video to the Ray Serve API.
Usage:
python -m client.send_video --video s3://bucket/path/to/video.mp4
python -m client.send_video --video s3://bucket/video.mp4 --chunk-duration 5.0
python -m client.send_video --video s3://bucket/video.mp4 --token YOUR_TOKEN
"... |
d35817d412a293b13466c87dacfc2370c06c38cf39260518f602dd7672514805 | Python | 4,189 | 57 | from data_profiling.report.presentation.flavours.html.frequency_table import (
HTMLFrequencyTable,
)
from data_profiling.report.presentation.flavours.html.html import HTMLHTML
from data_profiling.report.presentation.flavours.html.image import HTMLImage
def test_html_frequency_table():
item = HTMLFrequencyTabl... |
f46b9e691e8bd93fd2b0519ede1b68d80ff9008e19cd4843068b3e1ab631ec13 | Python | 4,189 | 138 | import time
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from config import args
from dataloader import DataLoaderMasking
from models import GNN
from torch_geometric.nn import global_mean_pool
from util import MaskAtom
from datasets import MoleculeDataset
def compute_accuracy(pr... |
ef08e632f4fe6875098fdd1843d881841e1096a29b6a84bee8535682c914e3c5 | Python | 4,190 | 129 | """
a shortcut for predicting the context
"""
import numpy as np
NULL_RESPONSE = -1
# NULL_RESPONSE = None
class SimpleShortcut():
def __init__(self, input_dim, d, lr=.5, use_model=False):
'''d is the distance threshold that lead to narrow generalization gradient'''
self.input_dim = input_dim
... |
7cd789f8eb27514de826ceafe217b35c9f6db2b926e56e5bf2158ba02133616f | Python | 4,191 | 98 | from collections import defaultdict
from datetime import datetime
import pickle
from tqdm import tqdm
#
# def pre_user_cohort_rx(prescription_taken_by_patient, patient_take_prescription, min_patients):
# user_cohort_rx = defaultdict(dict)
#
# for drug, taken_by_patient in tqdm(prescription_taken_by_patient.it... |
ce9851cafa18f3779be50d9cf243e8202c0b41d583e7bb5f40778e067c648cd3 | Python | 4,191 | 121 | import os
from deepinterpolation.generator_collection import EphysGenerator
from deepinterpolation.trainor_collection import transfer_trainer
import datetime
import pathlib
if __name__ == '__main__':
# This is used for record-keeping
now = datetime.datetime.now()
run_uid = now.strftime("%Y_%m_%d_%H_%M")
... |
c0b1c4c777b675ba73826dbd71c976b3693b1615b6480baf8659b742c9e61b25 | Python | 4,192 | 117 | import requests
from .__config import base_url
from .__aux_funcs import process_response
def get_all_studies(keyword=None, direction="ASC", pageNumber=0, pageSize=10000000, projection="SUMMARY", sortBy=None):
"""
Get all studies. \n
:param keyword: Search keyword that applies to name and cancer type of the... |
a121199fe983abae2562566900be9d7709fa65d65c762f112e50cae0e1b3ad0a | Python | 4,196 | 164 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""API stubs for the AIHW Composer API."""
from collections import namedtuple
from typing import Dict
from aihwkit.cloud.client.session import ApiSession
End... |
d24db9f6b729a96c2f50498deec296e4a9ad67b196e05dd9108e6af7e5617327 | Python | 4,199 | 128 | import exputils as eu
import os
import IPython
from datetime import datetime
import ipywidgets
import base64
from IPython.display import Javascript, display
def create_new_cell(code='', where='below'):
"""Create a code cell in the IPython Notebook.
Parameters
code: unicode
Code to fill the new cod... |
3813f780cfc0f948a2a0624ab3197c62f195c5f3e9b766d56983a809d5610642 | Python | 4,200 | 158 | """OVAgent runtime helpers for workflow-driven analysis runs."""
from .run_store import AnalysisRun, RunStore
from .runtime import OmicVerseRuntime
from .workflow import WorkflowConfig, WorkflowDocument, load_workflow_document
from .protocol import AgentContext
from .prompt_builder import PromptBuilder, CODE_QUALITY_R... |
2bb6d1966adee588cf3c9684ea953c4015809f9b9d82f943077b5e6beae460f4 | Python | 4,201 | 140 | #!/usr/bin/env python
import argparse
import sys
import re
import json
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import os.path
from graph_qualdepth import plot_mapunmap
def parse_args( args=sys.argv ):
parser = argparse.ArgumentParser(
description='Graphs ... |
534feb3a0830e4e5fe82e5a4b71cf83c86e59bd381d4ff77d1c9daad0d825892 | Python | 4,201 | 119 |
import numpy
import abberior
import yaml
import os
from abberior import microscope
from .general import GeneralMicroscope
class AbberiorConfigurator:
"""
Configuration of an Abberior microscope.
This class is used to configure the microscope settings for a given measurement.
"""
def __init__(se... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.