sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
3aac652220359b54461efd2b6c15c57d13bdbf9235073a15184be095c43f91e8 | Python | 7,125 | 205 | # 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, sof... |
74c399e1d0b2e618e781ee23f4298b73492fe9a3168fd718d515b3f3d1418762 | Python | 7,125 | 154 | import numpy as np
import pandas as pd
import torch
from .do_obo_parser import OBOReader as DO_Reader
import os
dirname = os.path.dirname(__file__)
class DataSplitter:
def __init__(self, kg_path=''):
self.kg, self.nodes, self.edges = self.load_kg(kg_path)
self.edge_index = torch.LongTensor(s... |
b227831263aea9e144bf0664a331fbfb6ef17231afa852317e6cfad10b93c4de | Python | 7,125 | 173 | from typing import Union, List, Optional, Iterable, Sequence, Dict
import warnings
from matplotlib.axes import Axes
import numpy as np
import pandas as pd
from scipy.sparse import issparse
import matplotlib.pyplot as plt
import seaborn as sns
from anndata import AnnData
from ._single import embedding
def embedding_mu... |
5466cf5788277f872200c36dc80c74c505e1d0a38bc330e45026adbe3f4afe15 | Python | 7,127 | 150 | # This script is used to debug the network defined in CNN_penalty_Network.py
import CNN_penalty_Network as CNN_pen
import numpy as np
import scipy.io as sio
import sklearn.model_selection as MS
import tensorflow as tf
import datetime
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import h5p... |
1b1164d18d789351a33abdfdb17ab02b18ca51e738483b13b4abb79df2096ba3 | Python | 7,133 | 241 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""aihwkit example 25: Simple correlation detection with analog optimizers."""
# pylint: disable=invalid-name, too-many-locals, too-many-statements
from typing ... |
be6b1f6851cbd5372c1f0dff77df05cbc3ff29b85b887b53ed939f8809b93126 | Python | 7,136 | 121 | # --------------------------------------------------------
# Swin Transformer
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ze Liu
# --------------------------------------------------------
from .swin_transformer import SwinTransformer
from .swin_transformer_v2 ... |
dbfdd90ddae88f79a78936b45a9ed15361cefcae0cf695baeb248bfa3635adf1 | Python | 7,136 | 198 | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.cuda.amp as amp
from typing import Tuple
class VectorQuantizerEMA(nn.Module):
"""
Vector Quantization module using Exponential Moving Average (EMA) to learn the codebook parameters [1].
Args:
dimensions: number of s... |
fe3e9ae3a8c0602c857ca49ebb42ef488e7c600452da1fbf4ebd02b79b16e7e2 | Python | 7,136 | 176 | import numpy as np
import mpl_scatter_density # noqa, side-effect on import
import matplotlib.pyplot as plt
from matplotlib.colors import SymLogNorm
from matplotlib.lines import Line2D
from lib5c.util.plotting import plotter
@plotter
def plot_ma(data, sig_idx, loop_idx=None, names=None, s=-1, nonloop_s=None,
... |
feb9221cd46fdf66f9284d6e88e02e9b54726f2d247e5dbcd3288e4e4bffbdeb | Python | 7,141 | 151 | """Real public single-extracellular-vesicle (single-EV) proteomic datasets.
Each loader downloads a dataset asset from the ``omicverse-data`` GitHub
release (``single-ev-v1``) on first use, caches it under ``dir``, and
returns it ready for the ``ov.single.ev`` single-EV proteomics workflow
(EV QC, normalisation, EV-su... |
0ae4031939f7a07b15f1dba30a9e4ff7c0365ef71fc8eb5a2b0370020fde1380 | Python | 7,143 | 146 | import numpy as np
def check_is_in(TestArray, ParentArray):
"""
Test to se if a row in TestArray is in ParrentArray
Arguments:
TestArray -- ndarray (N, 2)
ParentArray -- ndArray(M, 2)
Returns:
IsIn -- ndarray (N) dtype - bool
"""
IsIn = (TestArray[:, None] == Parent... |
d46eca1eb410e4127e17293e999607e59fb92f38d896bb93e4e885428b73044b | Python | 7,143 | 147 | import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152
os.environ["CUDA_VISIBLE_DEVICES"] = ""
import pandas as pd
import numpy as np
from utils import oneHot
from sklearn.model_selection import train_test_split
from scipy.stats import pearsonr
import tensorflow as tf
from tensorflow.keras.models i... |
b3451e8fab33dbfbb8194bce3f007403b00d3aced08751650310e726f15fc7c0 | Python | 7,144 | 202 | # coding=utf-8
# Copyright 2023 HuggingFace 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 ag... |
d92b82b7cb4c60007793fb15c31ff50ac0ed75c5b5fd0db20a460e2355fb679f | Python | 7,144 | 151 | import argparse
import io
import requests
import torch
from omegaconf import OmegaConf
from diffusers import AutoencoderKL
from diffusers.pipelines.stable_diffusion.convert_from_ckpt import (
assign_to_checkpoint,
conv_attn_to_linear,
create_vae_diffusers_config,
renew_vae_attention_paths,
renew_v... |
7e1470ea8d72b98fe24e1113f2b0c63fdb0287f0342134dc7d72f927e30dff51 | Python | 7,145 | 232 | """
DataCollect module for OmicVerse - Comprehensive bioinformatics data collection.
This module provides access to 29+ biological databases with seamless OmicVerse integration,
including proteins, genomics, expression, and pathway data.
Key Features:
- 29 API clients for major biological databases
- Unified data for... |
af4cb4e236e1ff6d5f814052c0484099b76c950edd92e37df48cf03998e18a6a | Python | 7,145 | 219 | from typing import Dict, List, Set
import click
from ci.ray_ci.utils import ci_init, logger
from ray_release.configs.global_config import get_global_config
from ray_release.result import ResultStatus
from ray_release.test import Test
from ray_release.test_automation.ci_state_machine import CITestStateMachine
# The ... |
bc07bc3f60b76a99f72f8b39c50d0c265a7ef04bf3186be2ac0079a483723be6 | Python | 7,146 | 207 | # mypy: ignore-errors
from dataclasses import asdict
from typing import Any, Callable, Dict, List, Type, Union
import numpy as np
import pandas as pd
from visions import VisionsBaseType, VisionsTypeset
from data_profiling.config import Settings
from data_profiling.model import BaseDescription
from data_pr... |
c0a58ff98184f3b9738fa922fa965d3af04bd6635e953c83ca2dcb12316551f8 | Python | 7,147 | 232 | """A simple speech classifer AND autoencoder
"""
from __future__ import print_function
import pyaudio
import wave
import numpy
import numpy as np
import pymouse
import pygame
import math
# pygame.init()
# pygame.mixer.init(frequency=22050, size=-16, channels=1, buffer=4096)
pygame.mixer.init(frequency=8000, size=-16, ... |
91ed4cfc0bb4a9df55ba332afc19e2a004e672737c882a6582cb5a02f3978d06 | Python | 7,149 | 135 | import torch
import logging
from torch.utils.data import TensorDataset
from sklearn.model_selection import train_test_split
from scipy.special import softmax
from agent.data.sql.sql_mgmt import get_connection, select_fields_where, update_non_text_field, update_text_field
from agent.classifiers.data.lstm_dataset_mgmt ... |
d8e1aa6a44e07589a52568b4da91afdb0fcff5039eaccfe96eccb1f89653797c | Python | 7,149 | 196 | import gc
import random as rnd
import cv2
import tkinter as tk
from tkinter import ttk
from tkinter import *
from PIL import ImageTk as itk
from PIL import Image
from tkinter import filedialog as fd
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
from mp... |
ea90358d9864accd29a92db5f2444385382cfb419273d976b25a0386edb21846 | Python | 7,152 | 243 | import io
import cv2
import efficientnet.tfkeras as efn
import tensorflow as tf
import numpy as np
from PIL import Image
from PIL import ImageEnhance
from pillow_heif import register_heif_opener
from typing import Union
def resize_byratio(image):
"""This function takes a Pillow Image object and will resize the i... |
020762b52086c9df8e391427e20711b3aadd993b78bdeb5a30adf69abaf705a3 | Python | 7,153 | 145 | #!/usr/bin/env python
from __future__ import print_function
import argparse
import glob
import os
import subprocess
import sys
import bam_stats
CHR = "c"
START = "s"
END = "e"
DESC = "d"
def parse_args():
parser = argparse.ArgumentParser("Split BAM by region")
parser.add_argument('--input_bam_glob', '-i', ... |
07e72af87116bdd93ba594bbf33e3ea84e7cb1059763f3b2e9b009300e4743db | Python | 7,157 | 195 | from typing import Dict, List, Optional
import argparse
from pathlib import Path
import numpy as np
import pandas as pd
from omicverse.external.scTenifold.data._sim import *
def adobo_score(X: pd.DataFrame,
genes: List[str],
n_bins: int = 25,
n_ctrl: int = 50,
... |
75e4437197deedb0f3a5fdb71209d48f85cf60dfcc020a4b6050880b4c454a56 | Python | 7,158 | 224 | import numpy as np
import pdb
import matplotlib.pyplot as plt
from scipy.stats import gaussian_kde
from data_assimilation.true_solution import TrueSolution
from data_assimilation.oracle import ObjectStorageClientWrapper
def plot_state_variable(
x_vec: np.ndarray,
state_mean: np.ndarray,
state_std: np.ndar... |
171cf547d4d48606eea549a1984eb84ff1648001da5c7afdab0c6921a7af1217 | Python | 7,160 | 263 | import subprocess
import numpy as np
import av
import os
import datetime
import cv2
import logging
def count_frames(file_name):
if os.path.exists(file_name):
try:
with av.open(file_name, "r") as reader:
return reader.streams.video[0].frames
except Exception as e:
... |
3c0767c44337c504d291888b9fdc678d06000756cd0da0951abf30326a2b07f8 | Python | 7,160 | 191 | # built-in
import os
import argparse
# third party libraries
import matplotlib.pyplot as plt
import numpy as np
from mlproj_manager.plots_and_summaries.plotting_functions import line_plot_with_error_bars, lighten_color
def get_max_over_bins(np_array, bin_size: int):
"""
Gets the max over windows of size bin_... |
9387df4f013def6d8596ed7c7cc86b08bd368c6b8f553fbae31051a1c8d76a44 | Python | 7,163 | 190 | import logging
from agent.data.sql.sql_mgmt import get_connection, select_fields_where
from agent.data.sql.sql_mgmt import update_text_field, update_non_text_field
from agent.classifiers.evaluation.evaluation_mgmt import get_evaluation_measures
from agent.data.entities.config import ITEMS_TABLE, SENTENCES_TABLE
ITEM_... |
dfc007e0dc26c2de86532eaab4671536bc3638a6dee277f5e8251947f073943e | Python | 7,163 | 206 | """
Utility functions for monocle2_py.
Implements calABCs, calILRs, and other helper functions.
"""
import numpy as np
import pandas as pd
from scipy import sparse
def cal_ABCs(adata, branch_point=1, branch_states=None, branch_labels=None,
trend_formula="~sm.ns(Pseudotime, df=3)*Branch",
r... |
3cfe07e54a4f2be7898d262760dc310c143d043c0d6132f9afcc853d7e89ed19 | Python | 7,165 | 204 | """Functions for prediction"""
import argparse
import logging
from pathlib import Path
import numpy as np
import pandas as pd
from lefshift import constants, utils
from lefshift.application_utils import validate_column
from lefshift.model import FluorineModel
def add_predict_subparser(subparsers):
"""Add predic... |
a0cc100debb95005dbde8ecb34b998c2f3e84ef538666e0a18230cfdf644facb | Python | 7,166 | 207 | #!/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
import haplotagging_stats
import os
import collections
REF_LINEWIDTH=2
LINEWIDTH=1
REF_ALPHA=1.0
ALPHA=.33
MALE_SAMPLES=[
"HG002",
"HG005",
"HG0... |
d33480e6d7b78735fdd92aab0e1f33cef26877cd2251d76d87d7ee2cd3337326 | Python | 7,166 | 188 | #!/usr/bin/env python3
"""Plotting genes on the UMAP basis or the gene-gene graph."""
import os
import re
import gc
import logging
import numpy as np
import pandas as pd
import scanpy as sc # Need for genes' logFC vs. a covariate
# Plotting:
from matplotlib import pyplot as plt
from matplotlib.colors import Normalize... |
47f06824eb8fc1af5ed624c6ee2710eb088fa040cc9b563820c9f8fd4313f84e | Python | 7,169 | 226 | import pickle
import os
import pandas as pd
import requests
import matplotlib.pyplot as plt
import networkx as nx
from .comparison import *
from ..._registry import register_function
# bcolors
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC... |
8f9aca4bd3050d5a1be6865e9053148289ed18491795a8c1651d370a4ac4b220 | Python | 7,170 | 189 | import inspect
import logging
import threading
from inspect import Parameter
from typing import Any, Dict, List, Tuple
from ray._private.inspect_util import is_cython
# Logger for this module. It should be configured at the entry point
# into the program using Ray. Ray provides a default configuration at
# entry/init... |
8c70e9fcf7336c5099142a52eaaadc27cb6d67814cd980055e5da82d95147501 | Python | 7,171 | 169 | import glob
import logging
import math
import os
from typing import Dict, List, Optional, Tuple
from ray._private.accelerators.accelerator import AcceleratorManager
from ray._private.ray_constants import env_bool
logger = logging.getLogger(__name__)
# Visibility env var for Mobilint NPUs. The qb Runtime native libra... |
16d2319c4a3fe0a858c62e788392c043f43ee1bc0ae8e945553b7c6889664fe9 | Python | 7,172 | 228 | #!/usr/bin/env python3
import json
from argparse import ArgumentParser
from datetime import datetime
from pathlib import Path
from typing import Any, Dict
import pandas as pd
import torch
import torch.nn.functional as F
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import OneHotEncod... |
1c30716923e1530aa8b3d0b861cdec16e4b661773bd6c11537d92d030effa7c8 | Python | 7,172 | 211 | """
Make a movie out of a shotgun VAE projection and an audio file.
Reduce speed by 50%:
::
ffmpeg -i out.mp4 -filter_complex "[0:v]setpts=PTS/0.5[v];[0:a]atempo=0.5[a]" -map "[v]" -map "[a]" -strict -2 out.mp4
TO DO
-----
* Check whether ffmpeg is installed.
"""
__date__ = "November 2019 - November 2020"
import... |
40c85dc6257202a9032adf4f2d4f81023e6d071055b3c7ed8987cdfb9c4663e3 | Python | 7,172 | 172 | # 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... |
059d565f0681ad38871949ae7b530c50cb020413ceafe8ac4c461c9936456895 | Python | 7,174 | 188 | # -*- coding: utf-8 -*-
"""
@author: Valeria Fascianelli, 2023
"""
import pickle
from matplotlib import pyplot as plt
import numpy as np
from sklearn.preprocessing import PolynomialFeatures
import statsmodels.api as sm
import random
def get_linear_regression_rnn(nSubSamples,trials_id,rt_cond,indep_variables):
... |
2e8c817e0c32a4f4e76cca609cea4ef3340b08f764a58f395dc05034b3f2bd8b | Python | 7,175 | 228 | #!usr/bin/python
"""Experiments for co-expression v2."""
# -------------------------------------------------------------
# Compute co-expression modules within python scanpy framework,
# Using data loader + modules + graph handlers
# Created: 12/01/21
# -------------------------------------------------------------
impo... |
32b9617da97a2e688918e5f4eb6f438eae8d6a771bb3496e4a13d79fc11884b1 | Python | 7,175 | 174 | import os
import sys
from ray._private.ray_constants import ( # noqa F401
AGENT_PROCESS_TYPE_DASHBOARD_AGENT,
AGENT_PROCESS_TYPE_RUNTIME_ENV_AGENT,
AUTOSCALER_RESOURCE_REQUEST_CHANNEL,
DEFAULT_OBJECT_STORE_MEMORY_PROPORTION,
LABELS_ENVIRONMENT_VARIABLE,
LOGGER_FORMAT,
RESOURCES_ENVIRONMENT... |
68a341d3a65bba449f1c38b70a7bf7b06a7c2e5fe4e34dafd3a8077d25abbb7f | Python | 7,175 | 236 | import time
import numpy as np
from scipy.sparse import issparse, csr_matrix
from scipy.sparse.csgraph import connected_components
from scipy.sparse.linalg import eigsh
from scipy.stats import entropy
from sklearn.decomposition import PCA
from sklearn.utils.extmath import randomized_svd
from typing import List, Tuple... |
949bf1a0bee2167d791fe7851da3359666586d600cd7af1666d05a8c21e8bab8 | Python | 7,175 | 186 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 8 18:37:21 2022
@author: pbolan
"""
import numpy as np
from os import path, makedirs
import sys
import glob
import pandas as pd
import nibabel as nib
import matplotlib.pyplot as plt
from skimage import filters
from skimage.metrics import structur... |
050eb73659e4a78a8b85ff81e210727c8d05caba45a08751a01eae9121ebb02c | Python | 7,180 | 180 | import os
import time
from subprocess import call
import numpy as np
import pandas as pd
import seaborn as sns
from scipy import stats
import seaborn as sns
import matplotlib.pyplot as plt
import scipy as sc
from matplotlib.colors import ListedColormap
import scipy.sparse as sparse
import importlib
import copy
import ... |
427ee8a3b3a406190ccdebce94298016aecd1c4dd2a4dc35be92459d62a77433 | Python | 7,181 | 148 | import torch
import torch.nn as nn
import numpy as np
import scanpy as sc
import anndata as ad
from torch.optim.lr_scheduler import _LRScheduler, ReduceLROnPlateau
from tqdm import tqdm
from copy import deepcopy
from ..utils.eval import downstream_eval, aggregate_eval_results
from ..utils.data import XDict, Transcripto... |
b6aa4063a9ed8889d1e16e01ee820645ed1edcc8e31bba8ae76f057c4b3f7970 | Python | 7,181 | 221 | from typing import List, Dict, Any
import json
from django.contrib.postgres.aggregates import ArrayAgg
from django.core.cache import cache
from django.db import models
from django.db.models import F
class Organism(models.Model):
ncbi_taxon = models.IntegerField(unique=True)
common_name = models.CharField(max... |
6e437f2334e32371e19d6036723b624049da587072c2928dbf581687cfa4c449 | Python | 7,182 | 240 | """
This file serves as a documentation example and CI test for VLM batch inference with videos.
Structure:
1. Infrastructure setup: Dataset compatibility patches, dependency handling
2. Docs example (between __vlm_video_example_start/end__): Embedded in Sphinx docs via literalinclude
3. Test validation and cleanup
""... |
b45ca4501fa2e42d63d27ac6457989a8be2d30108e3b801c23ea09686eda36a7 | Python | 7,182 | 191 | import torch
import torchvision.transforms as transforms
import torchvision.datasets as datasets
from spikingjelly.clock_driven import functional
from spikingjelly.clock_driven import surrogate as surrogate_sj
from modules import neuron, surrogate
from models import spiking_resnet
from utils import Bar, AverageMeter, a... |
b0c81ed55b1a71c76ae67d438d47980009acab036dd94aa375fb2d1a0ecc5135 | Python | 7,183 | 237 |
import numpy as np
import torch
from data_assimilation.pytorch.forward_model import BaseForwardModel
from data_assimilation.pytorch.model_error import BaseModelError
from data_assimilation.pytorch.observation_operator import BaseObservationOperator
import pdb
import matplotlib.pyplot as plt
import torch.nn as nn
clas... |
b5e51704bb9ce9dce156d9f973aa97b8c3ef951f6fb979bb6686844f56416cf8 | Python | 7,184 | 244 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 17 10:33:41 2023
@author: gagan
"""
import numpy as np
from data_loader import get_data, zscore, create_dataset_windows, get_tt
import cmlreaders as cml
from glob import glob
from config import ROOTDIR
import os
from tqdm import tqdm
from utils import get_pval, get_pval_... |
05f10c33c9421aac442709efe1e3fcc8b3ef4ed473115bc367715166852849c6 | Python | 7,185 | 232 | import os
import sys
import time
import pytest
from ray.autoscaler.v2.schema import (
AutoscalerInstance,
ClusterStatus,
IPPRGroupSpec,
IPPRStatus,
)
from ray.core.generated.autoscaler_pb2 import NodeState, NodeStatus
from ray.core.generated.instance_manager_pb2 import Instance
def test_cluster_stat... |
0179c1c59a47a9594906d20b9315b2a29b03734f9337f205fd796fa091c3fdeb | Python | 7,188 | 237 | """
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 os
import numpy as np
import pytest
from ase import build, db
from ase.calculators.singlepoint ... |
33fe5a3042f1890fe37285742278c2bb5677a5990d70458e04733e3dfb716b47 | Python | 7,188 | 190 | from __future__ import annotations
from functools import partial
from typing import Sequence, Optional, Union, Tuple
import numpy as np
import jax
import jax.numpy as jnp
from quspin.basis import spin_basis_general
from ..global_defs import get_sites, get_default_dtype, is_default_cpl
def _get_perm(generato... |
21414ab7ffdc35ed698862d4aad4c74043666acca67b63cbfb38d8e89284cdc5 | Python | 7,189 | 222 | import argparse
import importlib
import os
import warnings
from argparse import Namespace
from typing import Dict, Tuple, Union
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.models as models
from torch.utils.data import DataLoader, Dataset, WeightedRandomSampler
from .auxiliaries i... |
dce23304967094127ecea12e4de60662628fc56817b15658e5d9becb8c194318 | Python | 7,189 | 134 | import numpy as np
from scipy import sparse
import time
from PostProcessing.evaluate import GetPerformance_Jaccard_2
def refine_seperate(masks_final_2, times_final, cons=1, thresh_mask=0.5, ThreshJ=0.5):
'''Refine segmented neurons by requiring them to be active for "cons" consecutive frames.
The output ... |
f091a0f4ac0d5c54dafb02d3d7e1195a9f589096e9759e2b7c61b60c64289156 | Python | 7,194 | 239 | import sys
import os
import numpy as np
from sklearn.neighbors import NearestNeighbors
from sklearn.neural_network import MLPRegressor
import matplotlib.pyplot as plt
from utils import (
load_tsv, load_pickle, save_pickle, load_image, save_image,
read_lines)
from image import smoothen
class NearestN... |
d9eb1ee216a4a4eaaee483c7ed15779dc981488a36b3134b323dda46edee5bf9 | Python | 7,195 | 181 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Build synthetic datasets representing a T2 mapping series (10 evenly spaced TEs) using
imagenet images as the true T2 and S0 maps
S(TE) = S0 * exp(-TE/T2)
@author: pbolan
"""
import numpy as np
import matplotlib.pyplot as plt
from os import path, getcwd, makedirs... |
4fded47f4ca789c60ab08fbec0c21769035906f4ff56f5fc9843c9e08d8614a7 | Python | 7,196 | 234 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 5 16:18:59 2023
@author: Leyang Xue
"""
import sys
import numpy as np
from multiprocessing import Pool
import datetime
# Add package path
packagepath = '../kcorePercolation' # Manually specify the path to your script
sys.path.append(packagepath)
from utils import kco... |
1f2c3335eb6239856ab6f501829f5772a2feaafb56612e999621313992cee9f4 | Python | 7,198 | 198 | import exputils as eu
import numpy as np
from tabulate import tabulate as original_tabulate
def tabulate_meanstd(data=None, config=None, **kwargs):
"""
Plots a table over several datasource.
:param data:
:param config:
tabulate: Parameters for the tabulate function that plots the table.
... |
f68647b842a2580632f210d3a2af054bfb23dc87b80df3cb2b79328558247b68 | Python | 7,199 | 137 | """Row-level difference between two harness runs: which ground-truth peaks flipped between exact / partly right / missed, which false positives appeared or
vanished, per set, and the trace stage of each flipped peak in both runs.
Usage (from the repo root):
python tests/harness_diff.py base.json new.json [--sets G... |
7760da557a2d196191966b66ef3328f3a95f2a5c6f6ab78a6b0d33d5049a45a0 | Python | 7,200 | 204 | """
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 argparse
import os
import numpy as np
import torch
from fairchem.core.calculate.ase_calculato... |
bd7207b787d7d213179e5ef029674b412656a3751ae47ae380bc7b3613affce1 | Python | 7,202 | 259 | """Mouse Phenome Database API client."""
from typing import Dict, List, Optional, Any
import requests
from .base import BaseAPIClient
class MPDClient(BaseAPIClient):
"""Client for Mouse Phenome Database API."""
def __init__(self):
super().__init__(
base_url="https://phenome.jax.org",... |
cb2248d6b6760f996b52495c403fa534a7e24d8356e6e21e5c43eef7e68fcdd8 | Python | 7,204 | 192 | import os
import sys
import pandas as pd
import numpy as np
import pcntoolkit as ptk
from matplotlib import pyplot as plt
import seaborn as sns
#%% Set globals
scriptsdir = '/project_cephfs/3022017.02/projects/hansav/Run7_f/scripts/'
datadir = '/project_cephfs/3022017.02/projects/hansav/Run7_f/data/'
Zdir = '/proje... |
b448d1a34aa708a90ae492490b4357e74c3832f4c99923de56b43379af4cf9d3 | Python | 7,207 | 163 | import matplotlib.pyplot as plt
import pickle
import numpy as np
import os
# from Step_7_util import *
from sklearn.metrics import accuracy_score, confusion_matrix, roc_auc_score, roc_curve, precision_recall_curve
import seaborn as sns
def main():
splam_v2_j_shuffle_pred_prob = []
splam_v2_j_shuffle_label_pro... |
9b2c294974cf7c50e414a0e08478ef49d287dd60be11c54f1f2e6e2a9d3f3ea3 | Python | 7,208 | 220 | from typing import List, Optional, Union
import cv2
import numpy as np
from mmcv.transforms import BaseTransform
from numpy import ndarray
from lqit.registry import TRANSFORMS
@TRANSFORMS.register_module()
class GetEdgeGTFromImage(BaseTransform):
"""Get the edge from image, and set it into results dict.
Re... |
24d885fa2ead67ec766c41f9aeef4b5865f27ef2dfbfc106f8a6d19bc49bb712 | Python | 7,211 | 192 | ##Vanilla alive dead model
import pandas as pd
import comet_ml
import numpy as np
import os
import pytorch_lightning as pl
import rasterio
from skimage import io
import torch
import torch.nn.functional as F
from torch.utils.data import Dataset
from torchvision import models, transforms
from torchvision.datasets import ... |
087b80e8ec67d1f09a0c7ce47ebd7dc8e594796379998623f44bdc588b445422 | Python | 7,212 | 164 | import argparse
import pickle
from typing import List
import numpy as np
import torch
from lib.data_utils.matched_cells_struct import OrderedMatchedCellsStruct
import lib.dataset_config_parser.dataset_config_parser as dcp
from lib.dataset_config_parser.dataset_config_parser import read_config_file
import lib.data_uti... |
f99a0e431d348a1e375b4d08d290b73c5e859f1d8fc3efbb73601bd9516e5db4 | Python | 7,212 | 181 | import tensorflow as tf
from utils.nn import linearND, linear
from mol_graph import atom_fdim as adim, bond_fdim as bdim, max_nb, smiles2graph_list as _s2g
from models import *
from ioutils import *
import math, sys, random
from collections import Counter
from optparse import OptionParser
from functools import partial
... |
dd0a296fa0c3ddb0b90312a465a0eed0db725791531af58e0600cc56cfd2a015 | Python | 7,213 | 157 | dataset_dict={}
dataset='7_Cryo_aw_f'
dataset_dict[dataset]={}
dataset_dict[dataset]['rabies_out']=f'/scratch/m/mchakrav/desgab/data_preprocess/multicenter/rabies_{dataset}_20221024'
dataset_dict[dataset]['local_threads']=20
dataset_dict[dataset]['group_spec']='*'
dataset='7_Cryo_med_f1'
dataset_dict[dataset]={}
datas... |
21aa2995aaa48af84ab521427fabdfadaebc380c31ac850eac38d8059fcfbc39 | Python | 7,214 | 277 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 30 09:37:00 2023
@author: ju-bar
Functions related to the 1d quantum harmonic oscillator (QHO)
This code is part of the 'emilys' repository
https://github.com/ju-bar/emilys
published under the GNU General Publishing License, version 3
"""
import emilys.optics.econst as ... |
5c95e5d1ad71789351922f5f7fc884db90ac0da02f64708518cccf31e9eb1224 | Python | 7,217 | 121 | from tests.objects import test_node, test_tree
from neuron_morphology.validation import bits_validation as bv
from neuron_morphology.validation.result import InvalidMorphology
from tests.validation.validation_test_case import ValidationTestCase
from neuron_morphology.constants import *
import unittest
from mock import ... |
0b536ff4520600f39404f0a743aa54ce65fa5f818e630a5b6c5dc7bad30ca2a9 | Python | 7,218 | 238 | import numpy as np
import pytest
import torch
from torch import nn
import sinabs.layers as sl
from sinabs.activation import MembraneReset, SingleSpike
from sinabs.from_torch import from_model
class CNN(nn.Sequential):
def __init__(self):
super().__init__(
nn.Conv2d(1, 16, kernel_size=(3, 3), ... |
4cc4c7d6f519163195909d9930d3b6682eaa311dca6b5679bbd6596756ed292a | Python | 7,219 | 196 | """Methods for storing and retrieving annotations within notebooks."""
import abc
import datetime
from typing import Optional, Union
from google.cloud import bigquery
from google.cloud.bigquery import magics as bqmagics
import pandas as pd
class AnnotationStorage(abc.ABC):
"""Base class for annotation storage.
... |
7ac4306c2cc04585dca830b86576fd7fc4b86d8b652d935aac7458ecb4fa4c33 | Python | 7,220 | 192 | import torch
import torch.nn as nn
from collections import OrderedDict
from utils.kfac_utils import fetch_mat_weights
# from utils.common_utils import (tensor_to_list, PresetLRScheduler)
from utils.prune_utils import (filter_indices,
filter_indices_ni,
get_t... |
23ef947430dac2cd168426926dd439df68bc27234bd778c83f4ac90bbb9c60c8 | Python | 7,225 | 206 | import os
import re
import pickle
import numpy as np
import pandas as pd
from collections import defaultdict
import tensorflow.compat.v1 as tf
_PFAM_GAP_CHARACTER = '-'
AMINO_ACID_VOCABULARY = [
'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'P', 'Q', 'R',
'S', 'T', 'V', 'W', 'Y'
]
def residues_... |
3ed7bd19a72a99e69f70724c5dd38536604ddd895b50ee3f824bcc6e942473bd | Python | 7,228 | 208 | """
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 json
import logging
import time
from monty.dev import requires
try:
from ray import serve
... |
1995763d01ea34a46a471c1d97e9386d13487db5768f9090e1f5e0d32d64215b | Python | 7,231 | 190 | import mozaik
from mozaik.storage.datastore import PickledDataStore
from neo.core.segment import Segment
from mozaik.storage.neo_neurotools_wrapper import (
MozaikSegment,
PickledDataStoreNeoWrapper,
)
from parameters import ParameterSet
import numpy
import pickle
import re
import os
logger = mozaik.getMozaikL... |
07a737fe4bd5fdeb1c148afd85db3fc9dc519df92e79da70c7aa20fc89fc5d21 | Python | 7,232 | 187 | # biolgca is a Python package for simulating different kinds of lattice-gas
# cellular automata (LGCA) in the biological context.
# Copyright (C) 2018-2022 Technische Universität Dresden, Germany.
# The full license notice is found in the file lgca/__init__.py.
"""
Interaction functions and helper functions for LGCA w... |
67c1fc997f7163f784312e1517a82e7d5c2f8a526f3006cf99b04d3cb0e37e4e | Python | 7,232 | 182 | # Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import json
from http import HTTPStatus
from typing import Literal
import pytest
from cvat_sdk.api_client import models
from cvat_sdk.api_client.api_client import ApiClient, Endpoint
from cvat_sdk.core.hel... |
659333f7d52b111ad5f38d2eb20be0c4c22cd21c351cf22d35e292c06f7203ed | Python | 7,233 | 159 | ####################################################################################################
# Copyright (c) 2023, 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 free softw... |
f9d7297c481ff1cbf6e12c9d0eee34e260a5c0f438798510dcf43aaf825e5f8c | Python | 7,233 | 266 | import tempfile
import inspect
import sys
import numpy as np
import nir
from tests import mock_affine, mock_conv
ALL_NODES = []
for name, obj in inspect.getmembers(sys.modules["nir.ir"]):
if inspect.isclass(obj) and obj.__module__ == "nir.ir":
ALL_NODES.append(obj)
def assert_equivalence(ir: nir.NIRGra... |
b5579b439b0e30342dc4ab5d139112fcfe4ed91b00baf3ad3ec3390e4ee6243d | Python | 7,234 | 211 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import glob
import os
import os.path as osp
import shutil
import subprocess
import time
import torch
from mmengine.config import Config
from mmengine.fileio import dump
from mmengine.utils import mkdir_or_exist, scandir
def process_checkpoint(in_file, o... |
ee21cb9de053904b44fc344c47b4d7d46262e77bd6830cc80aab559e5b3e16f4 | Python | 7,238 | 176 | import math
import torch
from torch import nn
# from torch.nn import TransformerEncoderLayer, TransformerEncoder
# from torch_cluster import knn_graph, radius_graph
# from torch_geometric.nn import MetaLayer, voxel_grid, global_max_pool, max_pool, avg_pool
# import torch.nn.functional as F
# from torch_geo... |
b36f51007ac504869e0fd57c07ee2047a7dd1106b9ba5577a46a422b721ece9c | Python | 7,240 | 184 | from sklearn.preprocessing import MinMaxScaler
from sklearn.neighbors import NearestNeighbors
from .init_pca import init_pca
from .pps import pps
from .learning_s import learning_s
from .learning_l import learning_l
from .opt_scale import opt_scale
from .clle import clle
import numpy as np
from scipy import sp... |
43f732fc3a76f7062439ee618cbe34183938d2a82aa1746da3622d023e2a9395 | Python | 7,242 | 192 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 01 Nov 2022
@author: Saad Idrees, Joel Zylberberg's Lab, York University
idrees.sa@gmail.com
This script demonstrates how to use the adaptive-conv layer.
Cell 1 generates training and validation data
Cell 2 trains a model with adaptive-conv as the input lay... |
f8b7d8feaede5fc6c6ac1a2fad515c6a351747ec097331e8430efd3849e3c797 | Python | 7,245 | 220 | import time
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from config import args
from models import GNN, AutoEncoder, SchNet, VariationalAutoEncoder
from torch_geometric.data import DataLoader
from torch_geometric.nn import global_mean_pool
from tqdm... |
39765e1a80d677718b2207152a4e114391aaa5d254ffa9065f1c0c34aaf13159 | Python | 7,248 | 216 | __doc__ = """Calculate tetranucleotide frequency from a FASTA file.
Usage:
>>> with open('/path/to/contigs.fna') as filehandle
... tnfs, contignames, lengths = read_contigs(filehandle)
"""
import os as _os
import numpy as _np
import vamb.vambtools as _vambtools
from collections.abc import Iterable, Sequence
from ... |
415941d52c85c02ebc1edc7f8727ed59df20ad0c391d295e01ebb7812f8fdf0a | Python | 7,249 | 197 | # -*- 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.
#... |
f505f01d2d7ac0bb94d4a163f4186203bb2ce78fa74c161f26ab53ede8c69b4c | Python | 7,249 | 129 | import math
from projectmetis.python.utils.formatting import DictionaryFormatter
from projectmetis.python.utils.proto_messages_factory import MetisProtoMessages, ModelProtoMessages
class KerasProtoFactory:
class CompletedLearningTaskProtoMessage(object):
def __init__(self,
model,
... |
68b75ba4a6403ea740d6b9ea5fa314bbada182610f982b1741be5876f560c2f6 | Python | 7,255 | 164 | import logging
import warnings
import graphviz
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.tree import export_graphviz
from sklearn.feature_selection import SelectFromModel
from treeinterpreter import treeinterpreter as ti
from ag... |
d773de35738b7defc7c48c277930b2853f54644be62d24292b422ba51d69ee61 | Python | 7,255 | 179 | from torch_pgn.train.train import train
from torch_pgn.train.evaluate_model import evaluate
from torch_pgn.train.train_utils import parse_loss, make_save_directories, save_checkpoint, load_checkpoint
from torch_pgn.models.model import PGNNetwork
from torch_pgn.evaluate.plot_utils import plot_correlation
from torch.uti... |
47a86bef9387d3f2bf51af69413262a74af2434abc15dde3d4502c20acda730f | Python | 7,256 | 212 | # plot_hist.py --- Plot 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 published by
# the Free Softwa... |
ee78ff2dd6fca63e754733c301ed890a8110ff2dc47302116aa5c58dd0852589 | Python | 7,258 | 220 | import argparse
import time
from itertools import repeat
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from models import GNN
from torch_geometric.data import DataLoader
from torch_geometric.nn import global_mean_pool
from datasets import MoleculeDataset_graphcl
class graphcl(nn.... |
9e6dc5f6df02ff318d28c534dcb30dab4195bde343ef540e2a90196cfe8c75bc | Python | 7,262 | 250 | from typing import Optional, List, Union, Dict, Any
from statistics import mean
from collections import defaultdict
from functools import partial
from neuron_morphology.morphology import Morphology
from neuron_morphology.constants import SOMA
from neuron_morphology.feature_extractor.marked_feature import marked
from n... |
77144304cc75bcba0945f84fdeae74883b8aa62944aa8c27a89630754b4f7ba9 | Python | 7,263 | 267 | from __future__ import annotations
import json
import logging
import os
from pathlib import Path
import networkx as nx
import numpy as np
import pandas as pd
from anndata import AnnData
from scipy.sparse import csr_matrix
def get_minified_adata(
adata,
) -> AnnData:
"""Return a minified AnnData.
Parame... |
7b3cf627f571ad35204e16510f1d1293cd122cab2a6bcd816d2612c062e91112 | Python | 7,267 | 224 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from pfrl.action_value import (
DiscreteActionValue,
DistributionalDiscreteActionValue,
QuadraticActionValue,
)
from pfrl.functions.lower_triangular_matrix import lower_triangular_matrix
from pfrl.initializers import init... |
5628311fa80feaef52eef817b43b00717cb9b88c8982d8d146027a67379cb57f | Python | 7,268 | 200 | from imports import *
from mock import mock_open, call
import yaml
from StringIO import StringIO
from ngs_mapper import config
class Base(common.BaseClass):
modulepath = 'ngs_mapper.config'
def setUp(self):
super(Base,self).setUp()
self.config = {
'NGSDATA': self.tempdir,
... |
700f9dfd960dcafce527a31ebb13514099b0b368d9791e65e606f0e597c9a388 | Python | 7,268 | 214 | import numpy as np
import pandas as pd
import torch
import torch.nn.functional as F
from torch.utils.data import Dataset
from ._starfysh import LOGGER
#---------------------------
# Single Sample dataloader
#---------------------------
class VisiumDataset(Dataset):
"""
Loading a single preprocessed ST AnnDa... |
2eb33a525ffe2b94a873876f13feba039ff9562c0090358c47170b14e35edcf4 | Python | 7,270 | 175 | #!/usr/bin/env python
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0,'TIANA')
from argparse import ArgumentParser
import argparse
package_dir = os.path.dirname(os.path.abspath(__file__))
import shutil
from TIANA.training import train
from TIANA.edge_weights import Edg... |
ed22d2893f89807b7f191482aafa631693cb5c33836bfee8342f7d168d97cd9c | Python | 7,273 | 188 | import os
import json
import h5py
import pandas as pd
from numpy import copy
RESULTS_DIR = './results'
SAVED_DIR = './example networks'
def make_directories_if_needed(directory):
if not os.path.exists(directory):
os.makedirs(directory)
pass
def check_if_file_exists(file_name, run_name, directory):
... |
b1ecfc5914b8a0a52643442e8f8dbb5e8851dea3218db67da6b70ca52ef1a301 | Python | 7,275 | 205 | #Code to train Resnet18 model for Tumor Segmentation
# Load libraries
import torch
from torch import nn
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.models import DenseNet
import PIL
import matplotlib.pyplot as plt
import cv2
import numpy as np
import sys, glob
import tim... |
579d12b456aaf0d69a0274e13e90cdf2e041ce19cfad14ae699f2b94d527eb8e | Python | 7,279 | 183 | from Dataload_eeg import *
import torch
import torch.nn as nn
from Fusion.VIT_audio.Transformer_audio import Trainer_uni
#from tensorflow.keras.models import Model
from torch.nn.utils import weight_norm
# Define the EEGNet model
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.par... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.