sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
844d20189d6ff6f6eda511019bfd1729ba31611f2d3f61558bc0db7a7542d2b2 | Python | 6,391 | 152 | """
The GOOD-ZINC dataset. Adapted from `ZINC database
<https://pubs.acs.org/doi/abs/10.1021/acs.jcim.5b00559>`_.
"""
import os
import os.path as osp
import gdown
import torch
from munch import Munch
from torch_geometric.data import InMemoryDataset, extract_zip
class GOODZINC(InMemoryDataset):
r"""
The GOOD-... |
f122c620a9ea4320bc264d167010d4b2c830cf9eaeaddcf1e413d59b3cf4c547 | Python | 6,392 | 174 | import numpy as np
import pandas as pd
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from utils.hand.model import (BothHandCNN, BothHandFullConnected,
BothHandLRchannelGRU, BothHandTransformer,
HandConvNet, HandConvNet_o,
... |
a521f2c159c36a701fca113c749da16942794723d273cbde4c9bd8c0e3db018f | Python | 6,393 | 191 | from typing import Optional
import torch
import numpy as np
def single(
data: torch.Tensor,
time: int,
dt: float = 1.0,
sparsity: float = 0.5,
device="cpu",
**kwargs
) -> torch.Tensor:
# language=rst
"""
Generates timing based single-spike encoding. Spike occurs earlier if the
... |
e45013472df21ac3a896d081f601712a7efb0a37d5e4dfe94d21f18a824e00f4 | Python | 6,395 | 151 | """w
Detect trigger times (i.e., state transition / local wavefronts onsets)
by finding crossing of a set phase-value in the channel signals.
"""
import argparse
import neo
import numpy as np
import quantities as pq
from scipy.signal import hilbert
from scipy.stats import zscore
import matplotlib.pyplot as plt
import... |
a86323c5fcc8a17a0aa412f8e7f3bc2a7b9b1a668c4dea10d1ec5b1fa1dead9c | Python | 6,396 | 206 | """Visualization for Geometric Statistics."""
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # NOQA
import geomstats.backend as gs
from geomstats.geometry.hypersphere import Hypersphere
S1 = Hypersphere(dim=1)
S2 = Hypersphere(dim=2)
AX_SCALE = 1.2
class Circle:
"""Class used to draw... |
5352f0ff9e033cb3f49c474e567c215f39f07937a0f9a9cc05f9383bdffb1ed3 | Python | 6,397 | 141 | from pathlib import Path
import tensorflow as tf
if tf.__version__[0] == "2":
tf = tf.compat.v1
from common.augmentation import tf_specaugment
class BatchGenerator:
def __init__(self,
tf_records_folder,
is_training,
partition,
are_test_labe... |
2a204dac61cc57136a2450a170cff6094ef300bf84197c3d1b4cc1fe9b0a2c9b | Python | 6,398 | 216 | """
field_parser.py
parser for field data
"""
from __future__ import print_function
import os
import struct
import numpy as np
def parse_field_all(fn):
"""
parse internal field, extract data to numpy.array
:param fn: file name
:return: numpy array of internal field and boundary
... |
913420492ff6186d6876329d4268d7bf52691d8f4d611e826de205ee5dd4a228 | Python | 6,401 | 155 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
import contextlib
import pathlib
import requests
from tqdm.auto import tqdm
from nequip.model.utils import _EAGER_MODEL_KEY
from nequip.model.saved_models import ModelFromPackage, ModelFromCheckpoint
... |
1356f1771ebb7e07cd1cd56223182ba4748a92c0282057b79f6e33e1a68b549d | Python | 6,404 | 167 | import os
import sys
import logging
import shutil
import re
from string import ascii_lowercase
import contextlib
import inspect
from pathlib import Path
sys.path.append(str(Path(inspect.getfile(lambda: None))))
from pipeline.utils.snakefile import get_setting, set_setting, get_config
from pipeline.utils.snakefile impo... |
3ec56c7e442f3b58e1ebd83159c3e02e550fe875276e73738c52ae264961576f | Python | 6,405 | 189 | """
Short script to convert a PDB file with coordinates to a list of residues.
This is coutesy of ESM,
Please note that this is _NOT_ compatible with the protein diffusion main conda environment and must
use a different environment. To set up this environment, do the following:
mamba create -n inverse -c conda-forge ... |
b315130b71da534c4ddc9b7eadc2efb9e294931a12399db06385e40b165b7863 | Python | 6,405 | 174 | import geomstats.backend as gs
from geomstats.geometry._hyperbolic import _Hyperbolic
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.hyperboloid import Hyperboloid
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.geometry.poincare_ball import PoincareBall
from geomstats.... |
f62e3e363a3fb3163fe0a1bacf34e005282150c906f749c1e52cb7f621035a23 | Python | 6,408 | 164 | """
Create frames showing the input data on the spatial grid for each time step.
"""
import os
import sys
import argparse
import matplotlib.pyplot as plt
import numpy as np
from utils.io_utils import load_neo, save_plot
from utils.neo_utils import analogsignal_to_imagesequence
from utils.parse import none_or_str, none... |
c31d17749d00a4ece72e92d0aefb1b6bc66f76cfe59aa0be35240692ac49e01d | Python | 6,410 | 186 | #!/usr/bin/env python3
"""Preload Chroma's default ONNX embedding model for CI."""
from __future__ import annotations
import hashlib
import os
import tarfile
import time
import urllib.error
import urllib.request
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Optional
MODEL_NAME ... |
e24b96ab3dedab7fbda1b695eacea943b7b5e75d2d840ff658097feece4e9a5a | Python | 6,411 | 160 | '''
Utilities for initiliazing, training and testing a network
for the problem of Image Recognition.
'''
import copy
import torch
import torch.nn as nn
import torch.optim as optim
def decimate(tensor, m):
'''
Decimate a tensor by a factor 'm', i.e. downsample by keeping every
'm'th value. This is used whe... |
4384959be60f3db3e9411e859d0baff5ae107a3c368ee7c8a4354275fe2c815a | Python | 6,417 | 178 | # Copyright (c) 2021 PaddlePaddle Authors. 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 appli... |
fc74eec1f50b75a18de136dd09b613b52953194374de34d730a7bee4122ce6e7 | Python | 6,418 | 175 | import random
import re
from datetime import datetime
from pathlib import Path
from typing import Optional, Tuple, Union
import numpy as np
import pandas as pd
import psutil
from data.dataset import MrSliceDataset
from data.utils import plot_img_and_target
from matplotlib import pyplot as plt
from torch.utils.data imp... |
f28128c3c30779a4144cbe4b8763e5921fd1aef85b74dd6df910f56ce960c639 | Python | 6,419 | 131 | """
Izhikevich Neuron Mean-Field Model
==================================
Here, we will introduce the Izhikevich population mean-field model, which has been derived from a population of
all-to-all coupled Izhikevich neurons (see [1]_ for an introduction to the Izhikevich neuron model) in [2]_.
The model equations are ... |
9ac0e48903c662d2cbe4918fda3820919e8d3d5463369a5e4ee39709f911388f | Python | 6,424 | 160 | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... |
de427f36ffe28f1733e3622e1f7966132539e135528dfd05eea146a9322267d8 | Python | 6,427 | 155 | """The profile has to add up. Nothing tested that, and it did not.
``motifs.tcrnet.background.*`` is timed inside ``motifs.tcrnet.enrichment``, so every row summed gave
a motif total of 268.7 s over a step that took 198 s and understated every ``share`` by 36 % - the
same ``share`` that ``tests/release/test_build_timi... |
e06ce9aef3194a94951bbae9d8e63371f6cdfbbe7530ef376b72a6c04994f9cc | Python | 6,432 | 178 | """
Select a region of interest (ROI) by thresholding the intensity signal.
"""
import numpy as np
import matplotlib.pyplot as plt
from skimage import measure
import shapely.geometry as geo
import argparse
from pathlib import Path
import neo
import os
from utils.io_utils import load_neo, write_neo, save_plot
from util... |
bc62bf05c0f373b7348d02a313fafeaa2c4cf419d613c15e1f5be5eeda1f3df7 | Python | 6,438 | 230 | import numpy as np
import SimpleITK as sitk
import nrrd
import os
import funcs.visualize as visualize
from funcs.utils import timeit, NumpyEncoder
import json
import sys
import glob
import pickle
def get_template_header():
with open("funcs/template_header.pkl", "rb") as f:
header = pickle.load(f)
ret... |
850e96de04196607c6f58be69bcf6379482507102e3e60901c438a170eae4e94 | Python | 6,442 | 201 | import json
from pathlib import Path
import ase.io
import numpy as np
import pytest
from ase.atoms import Atoms
from tests.helpers import run_mace_train
pytestmark = [pytest.mark.network]
def _make_small_real_head_dataset(tmp_path: Path):
"""Create a tiny synthetic dataset for a non-pt head (e.g., DFT)."""
... |
5295b81635c854c7c8bd1785cf47c97b27d0ff7ef150ab4610035742a9ba0cc6 | Python | 6,444 | 174 | import argparse
import math
from utils import logger
import numpy as np
from . import register_scheduler
from .base_scheduler import BaseLRScheduler
SUPPORTED_LAST_CYCLES = ["cosine", "linear"]
@register_scheduler("cyclic")
class CyclicLRScheduler(BaseLRScheduler):
"""
Cyclic LR: https://arxiv.org/abs/1811.... |
c293966e42892d69be8819269f9b46a6d9ad1521b3a8c1dc797bc3263c68f9e2 | Python | 6,444 | 165 | import os
import sys
sys.path.append(
os.path.abspath("/hwfssz5/ST_BIOINTEL/P20Z10200N0039/06.groups/01.Bio_info_algorithm/renyating/project/SGAE"))
import torch
import torch.nn.functional as F
from torch import nn
from torch.nn import Parameter
from .AE import AE
from .GAE import IGAE
from .readout i... |
9bd65f4618b68fdd92ba8b75fd5002b9b85aa55a6372e9455dc8ce1278abcb8c | Python | 6,445 | 171 | from PymoNNto import *
from PymoNNto.NetworkCore.Behavior import *
import math
import numpy as np
#np.tile(src.x, (1, dst.size)).reshape(dst.size, src.size)
def vec_to_mat(vec, repeat_count):
return np.tile(vec, (1, repeat_count)).reshape(repeat_count, vec.shape[0])
#np.tile(dst.x, (1, src.size)).reshape(src.size... |
1a79940776209371a1481d0705f04a7058919ff40eeaebf68250506ce2a8bcb2 | Python | 6,446 | 174 | import argparse
import os
import torch
import numpy as np
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import WandbLogger
from pytorch_lightning.callbacks.early_stopping import EarlyStopping
from pathlib import Path
# Imports from this project
fr... |
23652153f050c64259adb88403b130b27fe7d1f5e3ea927101c01c73dbcb8fb6 | Python | 6,448 | 172 | import pandas as pd
import numpy as np
import config
def include_fct_2021(model_folder_name):
return 'brats21' in model_folder_name.lower() or 'Brats2021Train' in model_folder_name or \
'brats2021' in model_folder_name.lower()
def include_fct_same(model_folder_name):
return 'sameexp' in model_folde... |
9fd9012907f8a60a321f4b086fa93261031d903ce10afc0672f431b50e298a8d | Python | 6,448 | 119 | """The MHC dictionary: one row per distinct MHC call in the database, and its hierarchy.
Restriction is a hierarchy, and a question about it picks a level. "Is this motif HLA-A2-restricted,
A-locus-restricted, or just class I?" is three claims, so the corpus carries three MHC token families
(``m:``, ``ml:``, ``mc:``) ... |
a60fb52447102f60c995e01a82b781ffa360a8517206c35b95131fd6f0021718 | Python | 6,448 | 203 | import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
from torch.optim.lr_scheduler import StepLR,MultiStepLR
import math
import torch.nn.functional as F
from torch.utils import data
from sklearn.model_selection import train_test_split
from torch.utils.data import Dataset
from preproces... |
ac2ceb44d8415ff9d91ed25c2565822d3d9bee6feb0cd58fc46ba606a0953cc2 | Python | 6,448 | 185 | import warnings
import numpy as np
import xarray as xr
from numpy.testing import assert_raises, assert_allclose
from sklearn.linear_model import LinearRegression
from gemmr.data import load_outcomes
from gemmr.sample_size.linear_model import *
from gemmr.sample_size.linear_model import do_fit_lm, _check_pxy, \
_... |
1a85eabb0312d761665bc2bf6a24e2cd9f748dc5f4dd6deeb6ad39b9409650bf | Python | 6,449 | 224 | import geomstats.backend as gs
from geomstats.algebra_utils import from_vector_to_diagonal_matrix
from geomstats.test.data import TestData
class LocalizationLinearTestData(TestData):
def propagate_test_data(self):
time_step = 0.5
acc = 2.0
data = [
dict(
state=g... |
834e9924e29d1286209d4dccdc777e072d392832b5df89ae22e9378059368baa | Python | 6,454 | 210 | # /// script
# requires-python = ">=3.11"
# dependencies = [
# "marimo",
# "nltools>=0.6.0",
# ]
# ///
# Similarity and distance — marimo notebook. Source of truth for the docs page; rendered to the docs page by scripts/marimo_to_zensical.py.
import marimo
__generated_with = "0.24.0"
app = marimo.App(width="m... |
31f1365e8e59c75ff519ca7843ab11f849e8d8eb36eca4c4549210d7af36706e | Python | 6,457 | 122 | # %%
import os
import sys
import math
import numpy as np
import time
import h5py
import pyfftw
from scipy import signal
from scipy import special
from scipy.io import savemat, loadmat
import multiprocessing as mp
from suns.PreProcessing.preprocessing_functions import preprocess_complete
from suns.PostProcessing.par3 ... |
a7e341680260548246e47c8a5762815b0f508aa6b773eaff8f8d953f09e65d4a | Python | 6,466 | 127 | #!/usr/bin/env python3
import tensorflow as tf
def VDSR(input_shape, filters=64, kernel_initializer='he_normal'):
"""VDSR model architecture (Very Deep Super-Resolution Neural Network).
- 'he_normal' weights initializer
- 64 filters per layer
- 20 convolutional layers
- parametric rectifying linea... |
490799743724a9bed81170be316d22b7fe5b645fb06ab7a50b69377cb9b44567 | Python | 6,470 | 150 | import copy
from typing import Optional, List
import torch
import torch.nn.functional as F
from torch import nn, Tensor
from einops import rearrange
class TransformerDecoder(nn.Module):
def __init__(self, decoder_layer, num_layers, norm=None, return_intermediate=False):
super().__init__()
... |
944a1ae9e8d909e558a7d9090f93a19db1e9b185606655bde072671cfb1c847b | Python | 6,471 | 184 | from typing import Union, Optional, List, Dict, Tuple, Any, Callable
import pandas as pd
import numpy as np
import statsmodels
def statsmodels_fitting_result_dataframe(
res,
alpha: float = 0.05,
accessor: Callable[[np.array], np.array] = np.exp,
) -> pd.DataFrame:
"""Create category and item colum... |
effb3dc01185174d58d186cda332a08ccd16ca548445e54cfc08a4591d4d8992 | Python | 6,471 | 210 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 12 15:25:17 2018
@author: ngritti
"""
import time, os, glob
from tqdm import tqdm
import numpy as np
from skimage.io import imread
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import rc
rc('font', size=12)
rc('font', family='A... |
c9013c84af79bc60cfca7025781fef8d124ac26a6fef5ca23ce59b891ba5a93f | Python | 6,479 | 142 | # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... |
62ae55f4b3c6c815fb41bea1bda24878aebeb79a97471096a4e0278da3222227 | Python | 6,483 | 129 | import tensorflow as tf
import tensorflow.keras.backend as K
def get_loss(pred_train,
model_configuration,
y_pred_names,
other_outputs,
pos_weights):
global_pooling = model_configuration["global_pooling"]
if "loss_type" in model_configuration.keys():
... |
18ce787c1dad336db188ec4c8cc8c8fc7cd47ed2502da751421a778ce18ae69d | Python | 6,486 | 201 | from typing import List
import logging
from rdkit.Chem import AllChem, MolToSmiles
from rdkit.Chem import SaltRemover
from rdkit.Chem import rdmolops
from rdkit.Chem.rdmolfiles import MolFromSmarts, MolFromSmiles
from rdkit.Chem.rdmolops import RemoveHs
from reinvent.chemistry.standardization.filter_types_enum import... |
5e376c49c3ba77f7de0b071530f6a7157efad2f9402c343e10c0ca0d7eaf48c0 | Python | 6,487 | 200 | """Test single-recording export and local Dandiset construction."""
from __future__ import annotations
from datetime import datetime
from pathlib import Path
from types import SimpleNamespace
from zoneinfo import ZoneInfo
import numpy as np
from pynwb import NWBHDF5IO
from export_sanpy_banalysis_to_nwb import (
... |
5be0bb6e49f97548bd78a44d20f501e53028757b540af9d26243d37dba07688d | Python | 6,492 | 204 | __description__ = \
"""
Base class for allowing connections between arduino and PyCmdMessenger instances
via USB.
"""
__author__ = "Michael J. Harms"
__date__ = "2016-05-30"
import serial, time
class ArduinoBoard:
"""
Class for connecting to an Arduino board over USB using PyCmdMessenger.
The board hold... |
725d007bea05d1d560112acba6d3788708a427ac983d028631ebb52d615f6d5f | Python | 6,492 | 159 | import logging
import torch
from fairseq.models.speech_to_text.s2t_transformer import (
S2TTransformerEncoder,
S2TTransformerModel,
Conv1dSubsampler,
base_architecture as transformer_base_architecture,
)
from fairseq.data.data_utils import lengths_to_padding_mask
from fairseq.modules.conformer_layer imp... |
717910c736c01c70a5bf29ba792e9b61aae6c3f2eaae3be8f36cc63dfa6b6d0a | Python | 6,494 | 203 | import torch
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from typing import List, Tuple, Optional
def plot_weights_movie(ws: np.ndarray, sample_every: int = 1) -> None:
# language=rst
"""
Create and plot movie of weights.
:param ws: Array of shape ``[n... |
8acd511be47e49bdabd76f1ff7a7d20e6ab23f90784472e4f13532789995a12c | Python | 6,494 | 187 | from torch import Tensor
import cv2
import numpy as np
import copy
from typing import Optional, List, Union, Tuple
from torchvision.transforms import Resize
import matplotlib.pyplot as plt
from utils.color_map import Colormap
from utils import logger
# -------- cam -------------
from torchvision import models
import... |
47d15785b3987beb7e8e16f59bb80caa2e967f936b15e6c4e9a88a08927072a1 | Python | 6,495 | 175 | # Copyright (c) 2023 PaddlePaddle Authors. 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 appli... |
8f2f9e2103fb0cec2cc642f116b807877d1f637cd99fa8285823fcb9765e09a4 | Python | 6,497 | 222 | # Copyright (c) 2020 PaddlePaddle Authors. 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 appli... |
b67a52297ad16104a05d0f87cb2d06a1bf4a51aedb7dabd107d4cedc8583d411 | Python | 6,498 | 128 | #!/usr/bin/env python3
import tensorflow as tf
def VDSR(input_shape, filters=64, kernel_initializer='he_normal'):
"""VDSR model architecture (Very Deep Super-Resolution Neural Network).
- 'he_normal' weights initializer
- 64 filters per layer
- 20 convolutional layers
- parametric rectifying linea... |
1de4cc11b54a1d3a3709d030b0d61b9ab682ccd15e04e53eb68f59ea1af2102e | Python | 6,499 | 154 | import argparse
from sklearn import svm
from sklearn.model_selection import KFold
from sklearn.metrics import precision_recall_curve, roc_curve, auc
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
import joblib
# Calculate and update the best metrics, fold index and results... |
4108d18688af43f6cec611866b162d3fb201da1f0bb29fa2e30e06639a42bce1 | Python | 6,500 | 120 | import io
import click
import pandas as pd
from uniprotparser.betaparser import UniprotParser, UniprotSequence
from sequal.sequence import Sequence
def lambda_function_for_diann_ptm_single_site(row: pd.Series, modified_seq_col: str, entry_col: str, fasta_df: pd.DataFrame, modification_of_interests: str) -> pd.Series:
... |
25c94b2d6ff295e8f6128e7787425f26d391a8939e66306130afd66f764aecb6 | Python | 6,508 | 200 | # Copyright (c) 2021 PaddlePaddle Authors. 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
#
# Un... |
978b1780ed3d595a490f56959cbd674f03dc1427cf9371e723539adddf76b4c2 | Python | 6,513 | 161 | import sys
import requests
import cv2
import random
import time
import numpy as np
import tensorrt as trt
from cuda import cudart
from pathlib import Path
from collections import OrderedDict, namedtuple
def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=True, scaleup=True, stride=32):
# Resize an... |
f3fde99da46eea4ecf8b8759e019c1c23c9ada03f002c3ec38a8b46adfe1e12a | Python | 6,513 | 201 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 12 15:25:17 2018
@author: ngritti
"""
import time, os, glob
from tqdm import tqdm
import numpy as np
from skimage.io import imread
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
from skimage.metrics import structural_simil... |
1aaf0cec57ef7a8d43fbcfcaf8c77f6a89d85540f8bd11470a5fdb9187ff64f7 | Python | 6,514 | 187 | from qtpy.QtCore import Qt, Signal # type: ignore[reportPrivateImportUsage]
from qtpy.QtGui import QColor
from qtpy.QtWidgets import (
QHBoxLayout,
QInputDialog,
QLabel,
QScrollArea,
QToolButton,
QVBoxLayout,
QWidget,
)
from idtrackerai.GUI_tools import AddBtn, RemoveBtn, WrappedLabel
Sel... |
fbef13b7ca80da07f98209c043cb361d84062ba40e2dc30e68729c851b859ab4 | Python | 6,529 | 194 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
import torch
from torchmetrics import Metric
from nequip.utils.global_dtype import _GLOBAL_DTYPE
from typing import Callable
class _MeanX(Metric):
"""Hidden base class for mean statistics.
Co... |
5952ebc0ece50913d2959521f1e962c950ed430c893a85c962aa5f360dccd778 | Python | 6,530 | 176 | # Copyright (c) 2022 PaddlePaddle Authors. 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
#
# Un... |
9997a7db54d73064d4a2716e3deada325f525b468256576ce2bcc8366cb870d7 | Python | 6,532 | 181 | #!/usr/bin/env python3
"""
Convert SPDX JSON output from Trivy to Excel format with enhanced reporting
"""
import json
import pandas as pd
from pathlib import Path
import sys
def determine_origin(pkg_info: dict) -> str:
"""
Enhanced origin detection with comprehensive pattern matching
Args:
pkg_... |
1df8c6d99b00b3ef944107ca414b5d706bc5b5262d9999c710e31341410b59c9 | Python | 6,536 | 205 | import torch
import torch.nn as nn
import os
import sys
file_dir = os.path.dirname(__file__)
sys.path.append(file_dir)
from RNN_cells import *
class RNN(nn.Module):
def __init__(self, params):
"""
Initializes a continuous time recurrent neural network model
Args:
params: pytho... |
c3bacbad129ad7b2f7dcec1d819d7217cb6ccc3b11cdfed9d872a65698b10419 | Python | 6,539 | 157 | # Author: Youzhi Luo (yzluo@tamu.edu)
# Updated by: Anmol Anand (aanand@tamu.edu)
import torch
import torch.nn as nn
from torch_scatter import scatter
from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GINConv
from dig.auggraph.method.GraphAug.constants import *
class GEMBConv(torch.n... |
520f4aed84320c98abf34bdcb8859fa6512b83aabad5fa589dd32d978c8e2750 | Python | 6,544 | 164 | '''
Example showing hardware-timed continuous analog output using a callback function
function pynidaqmx.ao.hardwareContinuousVoltageCallback
Purpose
Demonstrates how to do hardware-timed continuous analog output using a callback function.
This means we will not use sample regeneration. i.e. the buffer contents... |
74550b7cefee195174adcbf46d372d4338316830220db2d9f6aa712442777921 | Python | 6,544 | 205 | import click
import torch
from corgie import scheduling
from corgie.log import logger as corgie_logger
from corgie.data_backends import pass_data_backend
from corgie.layers import get_layer_types, DEFAULT_LAYER_TYPE, str_to_layer_type
from corgie.boundingcube import get_bcube_from_coords
from corgie import argparsers
... |
b7282471e68b1faf6327ad979a17817a9f239cc56530dc952db7246e6a15df3f | Python | 6,549 | 188 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
from typing import List, Tuple
import numpy as np
import pathlib
import pytest
import tempfile
import os
from ase.atoms import Atoms
from ase.build import molecule, bulk
from ase.calculators.singlepoin... |
fdf95eb3d158a35a198c6a76c293294ee13d7704f2652234a750b0f3ecaf9998 | Python | 6,549 | 197 | #!/usr/bin/python3
# -*- coding:utf8 -*-
"""
# @Auther: AcDrogen
# @Email: Nothing
# @File: figWalk
# @Time: 14:15
# @Version: V1.0
"""
# -----------------------
import os
import time
from fairseq.models.transformer import BaseFunc
import sys
import dgl
# 同构图框架
class buildHomo(BaseFunc):
def __init__(self, args)... |
1521b6cb7c9922509756ca766af6203b61215c41a8e82b88ff4f8f1f81742641 | Python | 6,556 | 177 | """The final error table, per head, and `--skip_evaluate_heads`.
`create_error_table` is what a training prints at the end, and multihead is the
normal case, so a row per loader is the product rather than a detail. Nothing
covered it: the only test that reached this function at all compared a
single-head table's numbe... |
866d4d34f96b6db370a711ebd238e134a4068526449da019e1f0d3004da3f0c2 | Python | 6,557 | 160 | """Build the plain-``MACE`` parity anchor by direct instantiation.
This anchor is deliberately *not* produced by ``mace_run_train``, and that is
not a matter of convenience. ``--model MACE`` returns a ``ScaleShiftMACE``
with ``atomic_inter_scale=args.std`` and the shift zeroed
(``mace/tools/model_script_utils.py:279-2... |
615e736b679f939b11ba882cef12d99abfeb34c826d04d757b4bd7f3731c93d9 | Python | 6,560 | 210 | from __future__ import division
import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from paddle import ParamAttr
from paddle.nn import Conv2D, MaxPool2D
from ppdet.core.workspace import register, serializable
from ..shape_spec import ShapeSpec
__all__ = ['VGG']
VGG_cfg = {16: [2, 2, 3, 3, 3], 19: [... |
7e76555ec8709f1ba6b05b6dc77f1a9f34cfc1125e7925b9ebeaed41e42ace2e | Python | 6,560 | 154 | import argparse
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import KFold
from sklearn.metrics import precision_recall_curve, roc_curve, auc
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
import joblib
# Calculate and update the best met... |
a6b36ddcbb9265af00c5f9e95bbdf3559083329331dab044a44d66ccbd5ef882 | Python | 6,563 | 194 | import matplotlib.pyplot as plt
import numpy as np
from tqdm import tqdm
def set_white_plot(ax):
ax.spines['bottom'].set_color('white')
ax.spines['top'].set_color('white')
ax.spines['right'].set_color('white')
ax.spines['left'].set_color('white')
ax.xaxis.label.set_color('white')
ax.yaxis.label... |
4bc429847eb6f7b6161593fd90e3c996bc3fd65fa698a5910e546dec1e343c39 | Python | 6,567 | 135 | import os.path as osp
import numpy as np
from tqdm import tqdm
import torch
from sklearn.utils import shuffle
from torch_geometric.data import InMemoryDataset, download_url
from torch_geometric.data import Data, DataLoader
class QM93D(InMemoryDataset):
r"""
A `Pytorch Geometric <https://pytorch-geometric... |
3371295953b648ddfe3131384678f191758de922375dd50594402ba9ec911d60 | Python | 6,570 | 187 | import argparse
import os
import torch
import numpy as np
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import WandbLogger
from pytorch_lightning.callbacks.early_stopping import EarlyStopping
from pathlib import Path
# Imports from this project
fr... |
17bfc72f268b034cd7c384680872960d3cc241d2ee78ed4a64e585345e2157d9 | Python | 6,572 | 169 | import eelbrain as eel
import numpy as np
import scipy, pathlib, importlib, mne, time, os
def load_eeg(eegfile, ch='Cz', refs=['EXG1', 'EXG2']):
'''
load EDF, rereference and find Erg start time
eegfile: path to .bdf file
refc: list of reference channels
'''
print('LOADING', eegfile.stem)
... |
67533f470f87e8a527d2019a1b7392d74cb14f86c2d7d51097179969e2547d9e | Python | 6,572 | 208 | import os
import torch
import argparse
import matplotlib.pyplot as plt
from torchvision import transforms
from time import time as t
from tqdm import tqdm
from bindsnet.datasets import MNIST
from bindsnet.encoding import PoissonEncoder
from bindsnet.network import Network
from bindsnet.learning import PostPre
from bi... |
06ddc9fe38d455153d538f1af524c5f5ec92f3e8a4827182f1fc21c78a8ce204 | Python | 6,573 | 171 | import cv2
import math
import numpy as np
from preprocess_ops import get_affine_transform
class HRNetPostProcess(object):
def __init__(self, use_dark=True):
self.use_dark = use_dark
def flip_back(self, output_flipped, matched_parts):
assert output_flipped.ndim == 4,\
'output_f... |
db39f177fc47add5e721b4537cf3869e5ea4019952d80672616d699cf0c1a526 | Python | 6,575 | 183 | # Copyright 2020-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging
import json
import re
import tests.end_to_end.utils.defaults as defaults
import tests.end_to_end.utils.interruption_helper as intr_helper
import tests.end_to_end.utils.ssh_helper as ssh
log = logging.getLogger(__name__)
def... |
e640e07e40bcdba29cd4257bacd9ef2a18218d7cf39407ed5a73aba98bc5cbda | Python | 6,580 | 220 | """The 3D Heisenberg group.
Lead author: Morten Pedersen.
"""
import geomstats.backend as gs
from geomstats.geometry.base import VectorSpace
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.lie_group import LieGroup
from geomstats.geometry.symmetric_matrices import SymmetricMatrices
class ... |
03213fa238cb3e53e5fa811748b54e771a5593d3d5fb5f8cb94d571ab3789f80 | Python | 6,584 | 226 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 1 16:21:13 2022
@author: kilgoretrout
"""
from typing import Tuple
import torch
import torch.nn as nn
from torch.nn.functional import conv2d
import matplotlib
matplotlib.use('Agg')
def gaussian(window_size, sigma):
def gauss_fcn(x):
... |
2b00d767fb4c040739ed8db21ced9a90fd76a10b588c10bc71beb70e04091be1 | Python | 6,584 | 172 | import argparse
import json
import os
# import pdb
import numpy as np
import pandas as pd
from utils.hand.api import (ffmpeg4format, hand_parameters, # hand_pos_inference,
model_pred_severity, mp_kpts_generator,
mp_kpts_preprocessing)
from utils.hand.keypoints i... |
6540257e83c854ad083b0ba455478e6429b01e623ad0d0f4aa337be479284e95 | Python | 6,592 | 246 | # Description: Helper functions for handling, modifying and filtering images.
import numpy as np
import numpy, os
from skimage import io
def RescaleImgs(imgs):
"""
Linear rescale over all images in imgs to the range [0,1] so the values of 0.0 and 1.0 exist in the image-list.
Parameters:
---... |
8a0ade24a32fc105e9f4b21d77915e369669983cc4d12551d1e80d3e67145d14 | Python | 6,593 | 144 | import torch
from torch.utils.data import DataLoader, TensorDataset
import pandas as pd
from sklearn.metrics import confusion_matrix, classification_report, precision_recall_fscore_support
from modelClasses import *
from utilityFunctions import *
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
models_sessions_list = ['LR_S1'... |
17d616bddb8fc3782ba5ca8aa6d063908290cef1eceb5123b70fe6d3cdb083a9 | Python | 6,600 | 125 | """
File containing PauliNet-inspired embedding Layer.
"""
import jax.numpy as jnp
import numpy as np
import haiku as hk
from deeperwin.configuration import (
EmbeddingConfigDeepErwin1,
MLPConfig,
)
from deeperwin.model.definitions import *
from deeperwin.model.mlp import MLP
class PauliNetEmbedding(hk.Modul... |
e938fe21486f29571922042a309767fe41f29e942082e6e5a8213f0c03bafab4 | Python | 6,606 | 157 | #### group_mean_binfile_parcellation.py
# Copyright (C) 2010 R. Cameron Craddock (cameron.craddock@gmail.com)
#
# This script is a part of the pyClusterROI python toolbox for the spatially
# constrained clustering of fMRI data. It performs group level normalized
# clustering of connectivity matrices. This is one of two... |
5a679db2bdb01c4464ea4932baa2269f2dc54fec82e9fb90382b2c275360b6ac | Python | 6,608 | 166 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
import numpy as np
import torch
from . import AtomicDataDict, _key_registry
from typing import Dict
def from_dict(data: Dict) -> AtomicDataDict.Type:
"""Convert a dict of data into correct dtypes... |
df3017c48186b2273501feb2b7d3af0a348eeb7807d5242aba25be70fcad2475 | Python | 6,614 | 218 | # -*- coding: utf-8 -*-
import os
import argparse
import logging
from data_functions import seriate_x, read_ms_tree
from scipy.spatial.distance import pdist, squareform
import glob
import networkx as nx
import itertools
import numpy as np
import random
import matplotlib.pyplot as plt
# return the first and last inde... |
2916e52a95ee78df92b0bc0b396fd5075a8fbf9ae401f8069f9d913aaedd0686 | Python | 6,616 | 158 | # This function is taken with minor modiifcations from Pat Walter's "Useful RDKit Utilities"
# https://github.com/PatWalters/useful_rdkit_utils, available under the MIT License, copied below
# particularly https://github.com/PatWalters/useful_rdkit_utils/blob/master/useful_rdkit_utils/ring_systems.py
# commit version c... |
df62d8c5432e20e45d58f938d06f3ff2fc9d4a487f8675059b5666496a050677 | Python | 6,619 | 170 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Adam optimizer module."""
from typing import Dict, Optional, Tuple
import numpy as np
from openfl.utilities.optimizers.numpy.base_optimizer import Optimizer
class NumPyAdam(Optimizer):
"""Adam optimizer implementation.
Impl... |
03fa66fe65dc6242df54decf15b130e8b2e915295ac2927259200ccb0bbbb21e | Python | 6,620 | 204 | """General filesystem and runtime utilities for SanPy."""
import os
import importlib
from typing import List, Union
import uuid
import numpy as np
from sanpy.sanpyLogger import get_logger
logger = get_logger(__name__)
# External Python extensions are intentionally disabled until the runtime
# extension architectu... |
a3b397119c560fe1b6d899beb2f3cea25f4718823e546bb75cc2292f00329ac1 | Python | 6,621 | 219 | # NOTE: This is designed for nnU-Net <v2.*
# V2 changed some things around, so this script would need to be updated to work with v2
import json
from pathlib import Path
import click
import numpy as np
from SimpleITK import ReadImage, WriteImage, GetArrayFromImage
from sklearn.model_selection import train_test_split
f... |
bdba388b178153f3e7d8e5d4195a5eab7435f138291de13e519f8e13e18f5c0e | Python | 6,623 | 207 | # -*- coding: utf-8 -*-
import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import logging
import argparse
import os
import torch
import h5py
import sys
sys.path.insert(0, os.path.join(os.getcwd(), 'src/models'))
from layers import NestedUNet, NestedUNetV2
from data_loaders ... |
ef3fbb6621b671fb0916b9f76f2b9414731b46eb1968432076f26368e2db331c | Python | 6,625 | 155 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
import torch
from nequip.data import AtomicDataDict
from nequip.utils.aoti_metadata import NEQUIP_CUSTOM_OPS_LIBS_KEY
from ._graph_mixin import GraphModuleMixin
from typing import List, Dict, Any, Opt... |
9012e314bacfb6bbdc6af21552251b54b2db34c2fb20ac480af2289e59c81bae | Python | 6,626 | 211 | from qtpy.QtCore import QRectF, Qt
from qtpy.QtGui import QColor, QColorConstants, QPainter, QPaintEvent, QPalette
from qtpy.QtWidgets import QWidget
class BlobInfoWidget(QWidget):
"""Bar plot of the areas of the blobs detected in the current frame."""
def __init__(self):
super().__init__()
s... |
d9da9e39ab3cbb7045825c4f48f2d5015b61983b68a95ee243cb95d9af29b912 | Python | 6,626 | 193 | """
Model class.
"""
from typing import List, Tuple
import torch
import torch.nn as tnn
from reinvent.models import meta_data
from reinvent.models.model_mode_enum import ModelModeEnum
from reinvent.models.libinvent.models.decorator import Decorator
class DecoratorModel:
_model_type = "Libinvent"
_version =... |
4baa7dfc575292a31420a113b5dd9b61cac12992ddc2d60b4a23ccfa9cd197fa | Python | 6,628 | 168 | import numpy as np
import pandas as pd
import torch
try: # Handling API difference between pytorch 1.1 and 1.2
from torch.utils.data.dataloader import default_collate
except ImportError:
from torch.utils.data._utils.collate import default_collate
from common.dataframe_dataset import DataFrameDataset
from torc... |
ed2620606f7ccc52b9bb3c00b0eb1a358bea47ceaf2c75daf50bbb092fe01fd1 | Python | 6,630 | 200 | #!/usr/bin/env python3
"""
Population SNF
"""
import logging
import math
from dataclasses import dataclass, asdict
from typing import Optional, Callable
from pysam import VariantFile
try:
from edlib import align
except ImportError:
align: Optional[Callable] = None
from sniffles.config import SnifflesConfig
# ... |
4926d9a3e21987ce33da6b6064d0e58cd8f92fa16a548dede2ee92677fd8b450 | Python | 6,633 | 211 | import sys
import os
from pathlib import Path
import dill
import numpy as np
import neo
import quantities as pq
import logging
"""
## ####### ###### ###### #### ## ## ######
## ## ## ## ## ## ## ## ### ## ## ##
## ## ## ## ## ## #### ## ... |
7f9466f5c105d2b2cdce76937e34e6d868693197d0d4e5b221b838142c238026 | Python | 6,633 | 195 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 9 09:43:40 2021
@author: nicol
"""
import glob, os, tqdm
import pandas as pd
import numpy as np
import xml.etree.ElementTree as ET
# import matplotlib.pyplot as plt
# from matplotlib import animation
tgmm_folders = [
os.path.join('..','..','pescoids','timelapse','... |
897d1c916f0db0d09c3827446dfcddd4a9c2b34a07d3545c9164a7e4e7398d1f | Python | 6,636 | 228 | import random
import pytest
import geomstats.backend as gs
from geomstats.geometry.discrete_curves import (
DiscreteCurvesStartingAtOrigin,
ElasticMetric,
)
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.hyperboloid import Hyperboloid
from geomstats.geometry.hypersphere import Hype... |
cd57847d5a26a4f8fffe2024190f9b1b8f6c886a8a68fe4c940154e7ecda25b5 | Python | 6,638 | 158 | """The one-training-step gradient golden.
This closes the training-numerics gap: the loss-decrease smoke test and the
committed final-error table both stay green while `d(loss)/d(theta)` is wrong
by an amount comparable to initialisation noise, because they only ever look
at where training ended up. A committed single... |
7935df79b74d90c9aafe74b3b1edfe43c32d2a474fbeb335968bbeecda3ec585 | Python | 6,639 | 172 | """
Create frames showing the input data on the spatial grid for each time step.
"""
import os
import sys
import argparse
import matplotlib.pyplot as plt
import numpy as np
from utils.io_utils import load_neo, save_plot
from utils.neo_utils import analogsignal_to_imagesequence
from utils.parse import none_or_str, none... |
eb4e455275c42edd5b3ea04621e9eff6b3397e3871a32ed782b9435b873febe2 | Python | 6,641 | 187 |
import string
from pathlib import Path
import imageio.v2 as imageio
import matplotlib.pyplot as plt
import numpy as np
import ppafm.ml.AuxMap as aux
import ppafm.ocl.field as FFcl
import ppafm.ocl.oclUtils as oclu
import ppafm.ocl.relax as oclr
import torch
from matplotlib import cm
from ppafm.ml.Generator import Inv... |
b96849877b228586b1eb6aa6be036b1be4c853ba6e6e5a8cb062d36cfcbbcd9e | Python | 6,646 | 190 | import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# from shapely.ops import polygonize,unary_union
from shapely.geometry import MultiPoint, Point, Polygon
from scipy.spatial import Voronoi
def voronoi_finite_polygons_2d(vor, radius=None):
"""
adapted from https://stackoverflow.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.