sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
70d372734dc233ccc9e254c4c68bc3149a63b35997d09d2f9303bcf46c7a5378 | Python | 7,281 | 192 | ####################################################################################################
# Copyright (c) 2023 - 2024 Marwan Abdellah < abdellah.marwan@gmail.com >
# Copyright (c) 1994 - Michael Holst and Zeyun Yu
#
# This file is part of OMesh, the OptimizationMesh library.
#
# This program is free software... |
89958d84f8e24ffe31e30af467e8bb7aa8babfe9b60e95e28d00bd391179162d | Python | 7,285 | 247 | import os
import pickle
import warnings
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader, TensorDataset
warnings.filterwarnings("ignore")
class PatchEmbedding(nn.Module):
def __init__(self, embed_dim: int, num_heads: int, qkv_... |
ab7c34430b5172792875018eeb6423a6e3ba71ed3567542cef19803dde11bfec | Python | 7,285 | 210 | import numpy as np
import tensorflow as tf
# Set target dtype
TARGET_DTYPE = tf.float32
def get_angles(pos, i, d_model):
angle_rates = 1 / np.power(10000, (2 * (i // 2)) / np.float32(d_model))
return pos * angle_rates
def positional_encoding_1d(position, d_model):
angle_rads = get_angles(
np.ar... |
807f47ccf2032c6528678688347ae42b2414c4b3e399d6e69a9b12eee83f502c | Python | 7,288 | 196 | """
Module for filtering raw signal data using different filtering methods.
This module contains functions to apply Butterworth and Elliptic filters, both bandpass
and highpass, to raw signal data. It supports filtering data for individual channels and
allows for specification of filter order and cutoff frequencies.
... |
a4a7f264c0af37de4e7d8476b3f03262cd2c8e39d0ef547effd5c0949a910c19 | Python | 7,288 | 173 | import matplotlib.pyplot as plt
import pickle
import numpy as np
import os
import pandas as pd
from util import *
from sklearn.metrics import auc, accuracy_score, confusion_matrix, roc_auc_score, roc_curve, precision_recall_curve, PrecisionRecallDisplay
from sklearn import svm
# define a function to calculate precisi... |
273c49cec6b71b9b3d106108c5957cde7b0170e4477ebabd816b68c58619af3d | Python | 7,290 | 263 | import numpy as np
import matplotlib.pyplot as plt
import settings
import os
from scipy.stats import mannwhitneyu
# Example function to determine total based on file count
def compute_total_from_files(files_path):
total = 0
files_path = os.path.join(settings.loc, "summary", "ideal")
# Counts only files th... |
c2ecd29d4dcb3715232f04cbc56714b38383af0beeb4fb019aad94ed3f0a6173 | Python | 7,293 | 209 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 17 15:56:57 2023
@author: gagan
"""
from identification import regret
import os
from itertools import product
import pickle as pkl
from glob import glob
import numpy as np
import matplotlib.pyplot as plt
OUTPUT_PATH = './results_new'
keys = [(0,0),(1, 0),(1, 100),(1, 2... |
b530e35b9d3034e288726fda8032832faf4b5918e5750d63b4079a675fbde03f | Python | 7,294 | 210 | """Repo-owned workflow contract for OVAgent analysis runs."""
from __future__ import annotations
from dataclasses import asdict, dataclass, field
import hashlib
import logging
import re
from pathlib import Path
from typing import Any, Optional
logger = logging.getLogger(__name__)
ALLOWED_WORKFLOW_DOMAINS = {"data-... |
1040c7035023a42a2fd1303cb1215b4182d43b6c795299ea4678fef6147e0b2e | Python | 7,297 | 151 | # 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... |
5eb97954bd217386b79cdc828b3c7ec88f3c206ba24f1c2ef02553a9d6754b3d | Python | 7,297 | 170 | ####################################################################################################
# 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... |
7ad845cb6def35fc43ff963cfea36aa9533d13bba39ab144024302b378dc5fa5 | Python | 7,298 | 154 | import code
# code.interact(local=dict(globals(), **locals()))
import csv
import argparse
import os
import random
from tqdm import tqdm
import subprocess
from util import print_args_info
def parse_args():
parser = argparse.ArgumentParser(description="Script to reformat any summary statistics by defining column(s)... |
b87eba1f557b319994e6f90d948b34271a3f120b64e67aef43ca473a78a1c514 | Python | 7,301 | 174 | from typing import List
import numpy as np
import pandas as pd
from scipy.spatial import distance
from sklearn.neighbors import KDTree
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
from .logging import logger_manager as lm
from .utils import color_difference_rgb, s... |
a55f816c1eb910db1a638d81b3806f74244cf60a728404ed436fc23bbdaa83c1 | Python | 7,302 | 229 | from __future__ import annotations
import importlib
import logging
from pathlib import Path
from typing import (
IO,
Any,
Callable,
Iterable,
Optional,
Protocol,
Sequence,
Tuple,
Type,
TypeVar,
Union,
cast,
)
from omegaconf import DictConfig, OmegaConf
from omegaconf.ba... |
e410a6d7b450faa678e84922eabfef59905350938898563deddea512291c737a | Python | 7,302 | 220 | import os
import yaml
import glob
import pandas as pd
from typing import List
from pathlib import Path
with open(Path(__file__).parents[2] / "config.yaml") as f:
config = yaml.safe_load(f)
# TODO: represent as enum class
nyumets_modalities = {
'T1_pre': 'T1',
'T1_post': 'CT1', # spin-echo
'T2': 'T2'... |
523ffff2702163965a8c81a94b50d5675eafcebdb7b295d418f780b49b0f22ac | Python | 7,307 | 195 | import torch
import torchvision
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
if torch.cuda.is_available():
dev = "cuda"
else:
dev = "cpu"
device = torch.device(dev)
transform = transforms.Compose([transforms.ToTensor(), tra... |
b54b78c154b776f67bfd90e6577ebbdb431edc5f0388f30a0b6945edff2c021a | Python | 7,307 | 214 | import numpy as np
import pytest
import torch
import cebra.attribution._jacobian
import cebra.attribution.jacobian_attribution as jacobian_attribution
from cebra.attribution import attribution_models
from cebra.models import Model
class DummyModel(Model):
def __init__(self):
super().__init__(num_input=1... |
83470ea62d15655f6e53cded26148c212de67d94734279594c4c98852aea4d59 | Python | 7,310 | 162 | import matplotlib.pyplot as plt
import pickle
import numpy as np
import os
from util import *
from sklearn.metrics import auc, accuracy_score, confusion_matrix, roc_auc_score, roc_curve, precision_recall_curve, PrecisionRecallDisplay
from sklearn import svm
# define a function to calculate precision, recall, F1 score... |
e748440094f902b31c7dabdc256296f760e1b552919b43a1a1b5b17ec393ecee | Python | 7,314 | 153 | import sys
import numpy as np
from numba import njit
from spiking_readout.utils import mean_firing_time_loss, wta_class_inhibition
# NOTE: @njit is not efficient here
# but removing it alter results
@njit
def __stdp_simplified(weight, in_spks, t_post, ap, am, w_min, w_max, max_time, soft_bound, ignore_silent):
#... |
6f52aa492876b5d6b3d3276cae49b3c7534f6ac136bb0080e7cae839f85eef5e | Python | 7,315 | 156 | import torch
import torchvision
from torchvision import datasets, transforms
def get_transforms(dataset):
transform_train = None
transform_test = None
if dataset == 'cifar10':
transform_train = transforms.Compose([
transforms.RandomCrop(32, padding=4),
transforms.RandomHori... |
7147585fdda6b1119ad99fe3191fae04ca8a3813cd1448509a5ed2aa9da9cfea | Python | 7,315 | 219 | from __future__ import annotations
import warnings
import numpy as np
import pandas as pd
import plotly.graph_objects as go
from pandas.api.types import is_numeric_dtype
SUGGESTIVE_LINE_LABEL = "suggestive line"
GENOMEWIDE_LINE_LABEL = "genomewide line"
def _get_hover_text(dataframe, snpname=None, genename=None, a... |
e1f3217dc6601eba620c97be395579e9a4e58165046925c70678f915f2aaff6f | Python | 7,316 | 229 | __version__ = "0.15.0.dev0"
from .configuration_utils import ConfigMixin
from .utils import (
OptionalDependencyNotAvailable,
is_flax_available,
is_inflect_available,
is_k_diffusion_available,
is_k_diffusion_version,
is_librosa_available,
is_note_seq_available,
is_onnx_available,
is... |
fcb77f2002122aa837a61da90b6192076a371104e437ffb704be3738f169466c | Python | 7,322 | 139 | import tensorflow as tf
import logging
tf.get_logger().setLevel(logging.ERROR)
from tensorflow.keras.optimizers import Adam
from IsoNet.models.unet.data_sequence import prepare_dataseq
from IsoNet.models.unet.model import Unet
import numpy as np
from tensorflow.keras.models import load_model
def train3D_continue(outF... |
1a3acad0b9bf5b6f83f7ef4c11bdd26bf5b5e556cd77ccc6c229b06b2df64015 | Python | 7,327 | 191 | """
Credit: https://github.com/soniamartinot/3D-ConvLSTMs-for-Monte-Carlo/blob/master/convlstm3D.py
"""
import torch.nn as nn
import torch
class ConvLSTM3DCell(nn.Module):
def __init__(self, input_dim, hidden_dim, kernel_size, bias, keep_in_memory=False):
"""
Initialize ConvLSTM cell.
Pa... |
9ec571d3e2c5907d4658590daceb92840ba4010e219511e6180a5484a65036c3 | Python | 7,330 | 195 | import torch
import torch.nn as nn
from torchvision import models
import torch.nn.functional as F
class DeepCorn(nn.Module):
def __init__(self, input_channels=3):
super(DeepCorn, self).__init__()
# Backbone (Truncated VGG-16)
self.backbone_conv1 = nn.Sequential(
# Conv-3-64
... |
69d42b969e2128b8a428e2896780a68ae1563525e4a35a4225416969feadc087 | Python | 7,331 | 182 | import logging
import os
from enum import Enum
from typing import TYPE_CHECKING, Dict, Iterator, List, Optional, Tuple
from ray.data._internal.object_extensions.arrow import raise_on_pickle_object_columns
from ray.data._internal.util import _check_import
from ray.data.block import BlockMetadata
from ray.data.datasourc... |
e66a143248a24f4b5d12ee13586a26da2ddb8e514eddd4dfac9d25fc329b1619 | Python | 7,331 | 195 | # Copyright (c) MONAI Consortium
# 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, so... |
660883789d980ab07d07d1da31e4b760853ceeb7b86b1c29845722462e743652 | Python | 7,332 | 190 | """GPU-accelerated drop-ins for a few ``scipy.stats`` primitives that
omicverse hits in tight loops.
Public surface:
* :func:`rankdata` — batched, descending / ascending ranks with
average-tie handling, signature-compatible with
``scipy.stats.rankdata(..., axis=..., method='average')``. Bit-for-bit
matches scip... |
414ee135f22093357ac7da7729bcf1b6eecae28467ac6c899b22dd14c95f6d5e | Python | 7,333 | 197 | import re
import sys
from unittest.mock import patch
import pytest
from ray._common.ray_option_utils import (
Option,
_check_deprecate_placement_group,
_counting_option,
_resource_option,
_validate_resource_quantity,
_validate_resources,
update_options,
validate_actor_options,
vali... |
be63892ee66e3cc029a0a94d1d5ae37e3055a3685f926527d6290de603cd54ac | Python | 7,335 | 228 | """
This file serves as a documentation example and CI test for VLM batch inference with images.
Structure:
1. Infrastructure setup: Dataset compatibility patches, dependency handling
2. Docs example (between __vlm_image_example_start/end__): Embedded in Sphinx docs via literalinclude
3. Test validation and cleanup
""... |
e3039238c17c4635348f20c0000294aad1c7319ab32c8d28ed4ac504a8678e86 | Python | 7,335 | 202 | from pathlib import Path
from typing import Literal
import math
import pickle
import json
import matplotlib.pyplot as plt
import argparse
import logging
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.utils import ModelEma
from timm.loss import Label... |
ef31f0f9d9d7f4b2082d16fccd9b8c6481a1cf6120a4477859fee58553a3a941 | Python | 7,335 | 187 | from __future__ import annotations
import logging
import os
import joblib
import numpy as np
import pandas as pd
import scanpy as sc
from pynndescent import PyNNDescentTransformer
from scvi.model import SCVI
from sklearn.neighbors import KNeighborsClassifier
from sklearn.pipeline import make_pipeline
from .. import ... |
c9623b4e43d07ebe69f0bcdd1146b693ee892f2f085bd4a61c292ef062a81402 | Python | 7,337 | 192 | # 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.
from __future__ import absolute_import, division, print_function
import os
import numpy as np
import joblib
from sklearn.preprocessing import (
StandardScaler,... |
1fa93f180e123736b059717969c7317830fa37095e6c14ce23e92d7a10c205cc | Python | 7,340 | 277 | # -*- coding: utf-8 -*-
### -------------- IMPORTS -------------- ###
import numpy as np
from numba import jit
from scipy import signal
### ------------------------------------- ###
def chunk_array(start, stop, div):
"""
Get array to read labchart in chunks.
Parameters
----------
start : int... |
901bb8f5d5b6c31d0ce3efaf82b5e07c1ed28da7a355f3daea8087241851a434 | Python | 7,342 | 253 | #!/usr/bin/env python
# coding: utf-8
# ## Restriction Spectrum Imaging
# Richard Watts, Yale University, August 2020-April 2023
#
# Based on
# <UL>
# <LI>White et al, Probing Tissue Microstructure With Restriction Spectrum Imaging: Histological and Theoretical Validation. HBM 2013 34:327-346
# <LI>Hagler et al... |
17cdf704cbe65ce27fccafd07393046988ef79e55a9dc6eefbc45bb86b230f56 | Python | 7,344 | 256 | import os.path as op
import os
from fsub_extractor.utils.system_utils import *
def anat_to_gmwmi(
anat, outdir, subject, threshold=0, fivett=None, space_label="FS", overwrite=True
):
"""Creates a gray-matter-white-matter-interface (GMWMI) from a T1w or FreeSurfer image
If a T1w image is passed (not recomm... |
89fd9f087998fbdd9490b2b472a82768eef68314246327ba2177ea5270c52167 | Python | 7,344 | 212 | import glob
import os
import subprocess
import time
import exputils
import numpy as np
def start_slurm_experiments(directory=None, start_scripts='*.slurm', is_parallel=True, verbose=False, post_start_wait_time=0):
return start_experiments(directory=directory,
start_scripts=start_scrip... |
f3218d647c92e32281b956080c234138530d1534d29d3a2590a7162b2123df30 | Python | 7,344 | 207 | #!/bin/python
#------------------- Description & Notes --------------------#
#------------------- Dependencies ---------------------------#
# Standard imports
import argparse
import sys
from pathlib import Path
# Third-party imports
import numpy as np
import pandas as pd
import pyspark.sql.functions as F
import pys... |
9daf4e52d4c7f84629f15809079f33504a3b747006e9a4d71d58fa2edefb199d | Python | 7,346 | 215 | from __future__ import annotations
from typing import Optional, Union
from numbers import Number
from numpy.typing import ArrayLike
import numpy as np
import jax
import jax.numpy as jnp
from quspin.basis import spin_basis_general
from ..symmetry import Symmetry, Identity
from ..utils import ints_to_array, arra... |
f71e1d14ac82729e9cf8472bdaf80cc9b77bb470f10c9800d6eb55dfed132bb2 | Python | 7,353 | 225 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import csv
import json
import os
import random
import sys
from itertools import product
NAME = "memberships"
def read_rules(name):
rules = []
with open(os.path.join(sys.argv[1], f"{name}.csv")) as f:
reader = csv.DictReader(f)
... |
2b2a30529ef76cd0c46f52d474e500f5d11c19e9e4fed536f6b1950c8a558238 | Python | 7,354 | 198 | """Essential checks for spike placement, screen boundaries and run metadata."""
import json
import numpy as np
import pytest
import yaml
from mozaik.tools.experanto_merge import merge_experanto_shards
def _yaml(path, value):
path.write_text(yaml.safe_dump(value))
def _read_yaml(path):
return yaml.load(
... |
4719e81801ca971bf26a8037ebc9c1e62bddbd06e961f673240c7fad26054fa9 | Python | 7,354 | 181 | import matplotlib.pyplot as plt
import sys
import numpy as np
import os
import pickle
# from Step_7_util import *
from sklearn.metrics import accuracy_score, confusion_matrix, roc_auc_score, roc_curve, precision_recall_curve, average_precision_score
def print_topl_statistics(y_true, y_pred, topl_csv):
# Prints th... |
c0fd69f98e968e63b27ed3501d7f2bc86add6fc0322cbe1ae85aacec0bdc493a | Python | 7,354 | 229 | import math
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
def get_inplanes():
return [64, 128, 256, 512]
def conv3x3x3(in_planes, out_planes, stride=1):
return nn.Conv3d(in_planes,
out_planes,
kernel... |
98193fae52971f3fc83083e6e2f9181905b7325c3621ad67abd728a3099de92c | Python | 7,356 | 166 | '''
Plots user specified exp number, plane, ROI, time frame (in sec), with each stimuli shaded with user specified colors (at the 3rd column of the Stimulus.csv)
Make sure stimulus names don't include ","
'''
import Utility_working as Utility #custom-made utility file, contains lengthy functions
from constant impo... |
1071c996c577caf08ce7e72386375a203d64a9b569297fba2596e402e7f0af53 | Python | 7,358 | 245 | # flake8: noqa
# __single_sample_begin__
from ray import serve
from ray.serve.handle import DeploymentHandle
@serve.deployment
class Model:
def __call__(self, single_sample: int) -> int:
return single_sample * 2
handle: DeploymentHandle = serve.run(Model.bind())
assert handle.remote(1).result() == 2
# _... |
e27577d53ae124a332d00213c1a2fe810170dfd3152468969f9e33536a54181d | Python | 7,364 | 169 | ####################################################################################################
# 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... |
1ee428f6cd4d020a8ebdb0d4e0914eb0c1363b5abafefc9d4685dabe69b3a0b5 | Python | 7,368 | 192 | import argparse
import os
import torch
import time
import pickle
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
from easydict import EasyDict as edict
from scipy.signal import butter, filtfilt
import sys
sys.path.append('.')
from NeuroMotion.MSKlib.MSKpose import MSKModel
from NeuroMotion.MN... |
c801ac6d012d33bfbb9d20e00c8b25523abec42a2b1b71646143470b99a87229 | Python | 7,368 | 195 | import os
from collections import defaultdict
from typing import Dict, List, Optional, Tuple
import torch
import torch.utils.data as data
import numpy as np
import scanpy as sc
from numpy import array
import subprocess
import os
from tqdm import tqdm
import warnings
warnings.filterwarnings("ignore")
from .gene_emb... |
28bf7d4b8d9db21d7e72d90a578d33ab34700f860e711e07b7f3ed1ab362b166 | Python | 7,369 | 249 | #!/usr/bin/env python3
# /// script
# requires-python = ">=3.9"
# dependencies = []
# ///
"""
Build Ray manylinux wheels locally using raymake.
"""
from __future__ import annotations
import argparse
import os
import shutil
import subprocess
import sys
from dataclasses import dataclass
from datetime import datetime
fro... |
11948df574a8c1d542e840a312ff813ea792c30bf54d5c97ba8f4133a5dd6da0 | Python | 7,372 | 198 | r"""Binding-pocket detection & druggability for :mod:`omicverse.mol`.
Backed by **rust-fpocket** (``fpocket-rs``) — a pip-installable Rust port
of fpocket's Voronoi / alpha-sphere pocket detection and its calibrated
druggability score. fpocket is the only native dependency in the
``ov.mol`` stack with no PyPI wheel, h... |
5e5fbea12fc9eb3a71f16852a0028de055e2d126bbd300ad0e7388284a6ada1e | Python | 7,372 | 246 | """Fake multinode docker monitoring script.
This script is the "docker compose server" for the fake_multinode
provider using Docker compose. It should be started before running
`RAY_FAKE_CLUSTER=1 ray up <cluster_config>`.
This script reads the volume directory from a supplied fake multinode
docker cluster config fil... |
e8bdbcf4cdd76ee0cf690b2c04f7682483ecae77b136332bbcd60d0e7e18651c | Python | 7,372 | 235 | """Stimulus response functions with caching using xarray."""
from __future__ import annotations
import pprint
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Union
import numpy as np
import flyvis
from flyvis.connectome import ReceptiveFields
from flyvis.datasets.moving_bar im... |
51e6295cc6a4d2de053d81a830f363744861cdef96d455b3bbce5c03ebfe617b | Python | 7,373 | 235 | # built-in dependencies
import os
import io
from typing import Generator, IO, List, Optional, Union, Tuple, cast, Any
import hashlib
import base64
from pathlib import Path
# 3rd party dependencies
import requests # type: ignore[import-untyped]
import numpy as np
from numpy.typing import NDArray
import cv2
from werkze... |
f233187c99966db10dfb29d66a1591a5161584deea63660a129bb3e2a6eb9e07 | Python | 7,373 | 232 | """
Tests for tedana.utils
"""
import random
from os.path import dirname
from os.path import join as pjoin
import nibabel as nib
import numpy as np
import pytest
from tedana import io, utils
rs = np.random.RandomState(1234)
datadir = pjoin(dirname(__file__), "data")
fnames = [pjoin(datadir, "echo{}.nii.gz".format(n... |
da2ece01f35e1d9295643ff954e902e3e243579f40a81c60c6bccfa382da4502 | Python | 7,378 | 147 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Python version: 3.10.9
pandas version: 1.5.0
"""
#%% Modules
import pandas as pd
import warnings
from pathlib import Path
warnings.filterwarnings("ignore")
#%% Functions
def retain_quantile(data, percentile=0.9):
percentile_val = data[3].quantile(percentile)
... |
e2134a5fc2c2c4435734a3876dd13726a96c9250bc3fb7ae6634625981684497 | Python | 7,378 | 222 | import logging
import os
from pfrl.experiments.evaluator import Evaluator, save_agent
from pfrl.utils.ask_yes_no import ask_yes_no
def save_agent_replay_buffer(agent, t, outdir, suffix="", logger=None):
logger = logger or logging.getLogger(__name__)
filename = os.path.join(outdir, "{}{}.replay.pkl".format(t,... |
0729fa0782e33fc5d0b11912ae37c5614d2299cc6f398d66dd10b84cd10b1390 | Python | 7,379 | 210 | # Modified from https://github.com/open-mmlab/mmdetection/tree/3.x/
import argparse
import json
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
def cal_train_time(log_dicts, args):
for i, log_dict in enumerate(log_dicts):
print(f'{"-" * 5}Analy... |
1860e5c7fd8e6f8640da94f91b6194103ffa06e20505259ea8c68b9a30a05b58 | Python | 7,380 | 198 | ####################################################################################################
# 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... |
f33aebbd905e827ea405aa3d34cf60ce6c9b88063ce583eb5c6d205874b3ba97 | Python | 7,380 | 186 | # config_manager.py
import json
import os
from pathlib import Path
from typing import Dict, Iterable, List, Tuple
class ConfigManager:
"""Utility helpers for reading and writing the Streamlit agent configuration."""
CONFIG_PATH = Path(__file__).resolve().parent / "config.json"
DEFAULT_PACKAGES: List[Dic... |
f057a31dc40884c7d91bfb2d7ae069f722fb95b475636954b9de5d3496bab3ac | Python | 7,382 | 186 | import torch
from .. import nn
from .. import model
import numpy as np
from icecream import ic
from monai.networks.nets.swin_unetr import SwinUNETR
from typing import Any
class ImagingModelWrapper(torch.nn.Module):
def __init__(
self,
arch: str = 'ViTAutoEnc',
tgt_modalities: di... |
7cdd1bbec52835876b60cc904202ee938d926d907b82e97fffeb819bc22fbf1f | Python | 7,383 | 218 | import os
import sys
import time
import datetime
import pandas as pd
import seaborn as sns
from itertools import product
import matplotlib.pyplot as plt
from argparse import ArgumentParser
from typing import List, Generator
from abc import ABC, abstractmethod
from ml4h.defines import StorageType
from contextlib import ... |
e82fddc6a03175747e1d4fb2a09cc8d30b80d660a3e9de4dab3005cfd79aa62b | Python | 7,386 | 182 | import tensorflow as tf
import tensorflow_addons as tfa
import numpy as np
import wandb
from os import path
from utils.evaluation import *
def check_filepath_naming(filepath):
"""
Check and modify the file path to avoid overwriting existing files.
If the specified file path exists, a number is appended ... |
36f7486c036895eb3c45a10f6ebec0d69ec93b1c29b09b083f3c1c65c491dfa3 | Python | 7,388 | 181 | """End-to-end bulk RNA-seq pipeline: SRA download -> QC -> alignment -> quantification."""
from __future__ import annotations
import os
from typing import Dict, List, Optional, Sequence, Tuple, Union
import pandas as pd
from .._registry import register_function
from .prefetch import prefetch
from .fq_dump import fq... |
36e3d3d263cbacb058ac30da1322ec7c2e80abb4903829b7877da0b90167d1b6 | Python | 7,389 | 298 | """
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 re
from enum import Enum
from shutil import which
from typing import TYPE_CHECKING, Optional
fr... |
014788892c21eccd7fdc939985079175898d7ba1e9fc90531598643b8ae88c95 | Python | 7,390 | 221 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module
class Discriminator(nn.Module):
def __init__(self, n_h):
super(Discriminator, self).__init__()
self.f_k = nn.Bilinear(n_h, n_h, 1)
... |
86c1eb26e80ab5ba2d03817dfe126a22df02840c5d544539995d8438d4af613e | Python | 7,390 | 200 | """Tests for regressor.py
Only contains tests that are specific for regressor subclasses.
"""
from functools import partial
import numpy as np
import pytest
from sklearn.base import clone
from skorch.tests.conftest import INFERENCE_METHODS
class TestNeuralNetRegressor:
@pytest.fixture(scope='module')
def... |
d99e96059f0ee4e3dbe08016167a9290cc1644a07ce7425c80e70997601c75c1 | Python | 7,391 | 52 | #%%
features = ['his_NACCREAS', 'his_NACCREFR', 'his_BIRTHMO', 'his_BIRTHYR', 'his_HISPANIC', 'his_HISPOR', 'his_RACE', 'his_RACESEC', 'his_RACETER', 'his_PRIMLANG', 'his_EDUC', 'his_MARISTAT', 'his_LIVSIT', 'his_INDEPEND', 'his_RESIDENC', 'his_HANDED', 'his_NACCAGE', 'his_NACCNIHR', 'his_NACCFAM', 'his_NACCMOM', 'his_... |
322ca1e6625d041f774e88a00866f4b0318d1bc75dcfbba08b98cff15a3158ab | Python | 7,392 | 211 | import os
import re
import json
import numpy as np
from numpyencoder import NumpyEncoder
from sphinx.util import docstrings
import imageio
PARAMETERS_REGEX = re.compile(".*Parameters.*")
OTHER_PARAMETER_REGEX = re.compile(".*Other\ [pP]arameters\ *\n-{15}-+")
PARAMETER_REGEX = re.compile(
"\s*(?P<name>[^:\s]+)\s*\... |
77c90a145a0f78b3d0396d6a9ce2622984b3602271be3c2b3a25123ef1b2b061 | Python | 7,393 | 183 | import numpy as np
from matplotlib import pyplot as plt
import time
from pysted import base, utils, microscopes
from pysted import exp_data_gen as dg
"""
This script will go over the basics of pySTED for simulation of confocal and STED acquisitions
on simulated samples.
In order to simulate an acquisition, we need a... |
476e08341f5a79b36c4ca0558179b46600175ae48ce8562c942af46fc6a7e9ab | Python | 7,394 | 179 | """SecAct / CytoSig signature matrices: on-demand download, cache and grouping.
The SecAct signature (7,919 genes x 1,170 secreted proteins, ~80 MB gzipped)
is too large for the omicverse wheel. It is fetched once from the authors'
GitHub repository at a pinned commit, checked against a SHA-256 digest and
cached. The ... |
0dec163d31b3d862c143ec3c55e4f809124044cce5b1e0ba8996bdc6df95ecd5 | Python | 7,396 | 209 | import numpy as np
from mmcv.transforms import to_tensor
from mmcv.transforms.base import BaseTransform
from mmengine.structures import InstanceData, PixelData
from numpy import ndarray
from torch import Tensor
from lqit.common.structures import DataSample
from lqit.registry import TRANSFORMS
try:
from mmdet.stru... |
af8b4d4e67f19e89141fa631d2ec394765c8b345f8575041f2801ab8cfe91398 | Python | 7,397 | 240 | # 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... |
e5862557fe6d1b0b44b99da53b1a707140d9767002315e2a27262d141f47e7b5 | Python | 7,398 | 216 | import re
import requests
from nir.ir import __all_ir as primitives
# Delete Input, Output, and NIRGraph from the list of primitives
primitives = [p for p in primitives if p not in ["Input", "Output", "NIRGraph"]]
# Fetch raw converter file from GitHub
GITHUB_RAW_URLS = [
# (LibraryName, Direction, URL, functio... |
fbaa67760d386d47832a0390a22b03a30917f87f005a4a5cce3b54b0464adac1 | Python | 7,400 | 228 | import argparse
import os
from transformers.trainer_utils import SchedulerType
from transformers.models.auto.configuration_auto import MODEL_NAMES_MAPPING
from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES
# You should update this to your particular problem to have better documentation of `mo... |
70dfa2f10f5c4aa13fba66df73f9274dff95c0c0f555ab9393d4abb33a868b12 | Python | 7,406 | 185 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 20 09:49:07 2020
@author: sam
"""
import skvideo
from tools.radialShape import *
from scipy.interpolate import splprep, splev
import pickle
import os
from skimage.filters import threshold_otsu, threshold_yen
import time
from tqdm import tqdm
from ... |
bf8bc9c8a238de119c63f916d22c04466da96719e28cb4e76ea263a401546e7c | Python | 7,406 | 213 | #------------------------------------------------------------------------------
# Libraries
#------------------------------------------------------------------------------
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
# from .base_model import BaseBackbone
from... |
14af5f0350aee48f174c7bd36d1cd3b2402d5b8b76f5ad414a1bb7039b0f70d7 | Python | 7,407 | 243 | """
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 pytest
import torch
from torch import nn
from fairchem.core.common import distutils
from fairch... |
b539a8472bcdd3823e1e7b101bb8611b5a38a4b4bb9cbd8c8f6323020d17ab29 | Python | 7,407 | 209 | """fasterq-dump wrapper for SRA -> FASTQ conversion."""
from __future__ import annotations
import os
import time
from pathlib import Path
from typing import Dict, List, Optional, Sequence, Tuple, Union
from .._registry import register_function
from ._cli_utils import (
build_env,
ensure_dir,
find_sra_file... |
7ed01eec12cdeff16d9d97f158270e1d15960cbd674c5b01459eba75af724fdc | Python | 7,408 | 154 | import os
import cv2
import math
import time
import torch
import torch.distributed as dist
import numpy as np
import random
import argparse
from model.RIFE import Model
from dataset import *
from torch.utils.data import DataLoader, Dataset
from torch.utils.tensorboard import SummaryWriter
from torch.utils.data.dist... |
d2d31854946b23ee6f1fa58baf9d5d173bec8be705763ec9162951db08d88ed6 | Python | 7,412 | 232 | from typing import Dict, List, Optional, Tuple
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import networkx as nx
from scipy.stats import chi2
from omicverse.external.scTenifold.plotting._dim_reduction import *
def plot_network_graph(network: np.ndarray,
... |
869bfdb46f3f859b3cd079355c71b4b760fc7579909c19b0b9f6f34932c29b28 | Python | 7,414 | 194 | import abc
import torch
import torch.nn as nn
from typing import Union, List, Sequence, Iterator, Dict
class VQVAEBase(nn.Module, metaclass=abc.ABCMeta):
@abc.abstractmethod
def forward(self, images: torch.Tensor) -> Dict[str, List[torch.Tensor]]:
raise NotImplementedError
@abc.abstractmethod
... |
9d87d5797b921b255ce1abccee0e738073e5064aa766717671fdfb426504aae5 | Python | 7,414 | 229 | import shutil
from copy import deepcopy
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pytest
import torch
from datamate import Directory, Namespace
from flyvis import results_dir
from flyvis.datasets.datasets import SequenceDataset
from flyvis.network.ensemble ... |
426ac78a60995ee3f88471bbf1d64fcd58cea01456b272c6e56d5b6e559abd5f | Python | 7,415 | 203 | from Bio import SeqIO
import random
import os
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
SEQ_LENGTH="800"
QUATER_SEQ_LEN = int(SEQ_LENGTH) // 4
EACH_JUNC_PER_LOCUS = 500
MIN_JUNC = 200
MAX_JUNC = 20000
THRESHOLD = "100"
hg38_ref = "../../../Dataset/hg38_p12_ucsc.no_alts.no_fixs.fa"
out... |
74f5c7a5e45ad1ec2a063e59e0209f8fc5484ddb6e07e31d9f3423fbabcc508d | Python | 7,415 | 209 | ####################################################################################################
# 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... |
5acc05bc407eb4de691045365479b827b4f313ff99a556a675c95854700eee92 | Python | 7,416 | 210 | import torch
import torch.nn as nn
from typing import Tuple
class DenseBlock(nn.Module):
def __init__(
self, in_channels: int, hidden_channels: int, out_channels: int, count: int,
):
super().__init__()
self.relu = nn.ReLU(inplace=True)
# First iteration takes different nu... |
725c14a5adcf967b61f63d2dd66761f6ccaba044b2624c4510ffd16fec96bc52 | Python | 7,419 | 179 | # -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals, absolute_import, division
import numpy as np
from collections import namedtuple
from ..utils.tf import keras_import, K
Model = keras_import('models', 'Model')
Input, Conv3D, MaxPooling3D, UpSampling3D, Lambda, Multiply = keras_import('la... |
b8cf52dc3006ec4977d4881cb4c265718dd352da6c64ce854880181bae96435f | Python | 7,420 | 229 | """
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
from typing import TYPE_CHECKING
import numpy as np
import torch
from ase import Atoms
if TYPE_CHECKI... |
007b338517c8104ba7281c91606e5d69cc1be04b2e92e2e1ea5e28dce303e381 | Python | 7,421 | 183 | import numpy as np
import pytest
import tensorflow as tf
from ml4h.metrics import dice, per_class_dice
SIMPLE_LABELS = {'background': 0, 'foreground': 1}
THREE_LABELS = {'background': 0, 'class_a': 1, 'class_b': 2}
MULTI_LABELS = {'background': 0, 'class_a': 1, 'class_b': 2, 'class_c': 3}
H, W = 4, 4
def make_one... |
bc263ca4fcebabeed631fad9a716917a4c5f6c161e1346622ed9d15e5b57a5e7 | Python | 7,421 | 182 | ####################################################################################################
# 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... |
46ccfe6950fc4cd8e7819860e933645b1cb74307cbace7d5ee981b49f11197ab | Python | 7,423 | 244 | import os
import time
import cv2
import numpy as np
import PIL.Image
import io
from torch2trt import torch2trt
from torch2trt import TRTModule
import torch
from torchvision import transforms
from DeepLabv3_modified_addBN import custom_net
def load_weight(model,weightpath):
print('=> loading checkpoint {0}'... |
c5bbdc68b0d24a64c7e0041fb0d4dca48777d2a8b2b7fa9c72e4d74d1e7efdb7 | Python | 7,425 | 212 | #
# 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... |
e08593f19846f2629cfd2cd76c02126ee6fbb5cf5f318858667d8a962285a33a | Python | 7,426 | 196 | import numpy as np
from scipy.fft import fft2, ifft2, fftshift
import copy
import matplotlib as mpl
from scipy.io import loadmat
import h5py
import hdf5storage
import matplotlib.colors
import os
def gencmap():
"""
Get behavioral map colormap as a matplotlib colormap instance.
:return: Matplotlib colormap i... |
e198aadcbda10f23035ad0a7b117713697c28be8c0672c217007e4290b7d1ab3 | Python | 7,428 | 195 | import torch
from torch import nn
from opt import get_opts
import os
import glob
import imageio
import numpy as np
import cv2
from einops import rearrange
# data
from torch.utils.data import DataLoader
from datasets import dataset_dict
from datasets.points_utils import axisangle_to_R, get_points
# models
from models.... |
b2750c661ae991973672af1755543f32ebe5c89774c006e817e8f0689f563717 | Python | 7,429 | 236 | from datetime import datetime
import json
import os
import re
def check_and_mkdir(path):
dirname = os.path.dirname(path)
if not os.path.exists(dirname):
os.makedirs(dirname)
print('make dir:', dirname)
else:
print(dirname, 'exists, no change made')
def str_to_datetime(... |
b9ef44daf7d184bf632f22674f0cecf728b5ea0ba4bc71742d052f2917c351bd | Python | 7,429 | 189 | """Standalone autosummary stub generation for the public API reference.
The API-doc consistency check (``ci/ray_ci/doc``) reads autosummary stub
``.rst`` files that are generated from the directives in :data:`AUTOGEN_FILES`
-- for example the per-class method tables that the hand-written API pages
``.. include::``. Hi... |
d09e5c7c9b56e5142ede9ffea8c329f40d8bebcf00655709f286d24da769843c | Python | 7,430 | 225 | import numpy as np
import torch
from torch import nn
from torch.functional import F
from torch.optim import Adam
from torch_geometric.nn import MetaLayer, MessagePassing
from torch.nn import Sequential as Seq, Linear as Lin, ReLU, Softplus
from torch.autograd import Variable, grad
class InwNGN(MessagePassing):
d... |
88dbdab2594948e89d176d6874b5dba3af7b5044e2be0bbe03f58f8ba6c1fa71 | Python | 7,439 | 228 | import argparse
import os
import sys
import torch
sys.path.append(".")
import matplotlib.pyplot as plt
import numpy as np
from easydict import EasyDict as edict
from BioMime.models.generator import Generator
from BioMime.utils.basics import update_config, load_generator
from BioMime.utils.plot_functions import plot_m... |
4fee2e9bac7736469fd21910ddb5ee8245f652d423e0c20251adb2f96c5b89a5 | Python | 7,440 | 225 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import typing as T
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from einops import rearrange, repeat
... |
b77b128e1dd4e0f535ed96ad64c73e09d4f60a9045fd732b5141ce51c9ec106e | Python | 7,440 | 186 | from __future__ import annotations
from pathlib import Path
from typing import Callable, Iterable
import numpy as np
import pandas as pd
TIME_GRID = np.round(np.arange(6.0, 30.0 + 0.01, 0.01), 2)
MZ_GRID = np.arange(50, 600, 1)
EXPECTED_SHAPE = (TIME_GRID.size, MZ_GRID.size)
DEFAULT_PRECISION = 3
Loader = Callable[... |
1b3976d301e3af72dd94af90b5fb282eb93c02f305df2e1252a0ae1b0a526a3c | Python | 7,443 | 207 | # -*- coding: utf-8 -*-
# language=rst
"""
***********
Interactive
***********
The `interactive` submodule provides methods to handle user-interactivity such
as mouse clicking, keyboard pressing, or timer based events. This submodule is
named `vtkplotlib.interactive` but also goes by the alias `vtkplotlib.i... |
d9a6adb4918ce224598317dd4ae8cf7152ca253f170d97c5eb9d583b1fcdfc5a | Python | 7,443 | 210 | """Organize the calculation of statistics for each series in this DataFrame."""
from datetime import datetime
from typing import Any, Dict, Optional, Union
import pandas as pd
from tqdm.auto import tqdm
from visions import VisionsTypeset
from data_profiling.config import Settings
from data_profiling.model import Base... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.