sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e0672d1999b47694d4cf35c4de319464483b9936a5e7923756a0f581a210393a | Python | 3,011 | 76 | """`--save_all_checkpoints` and `--keep_checkpoints`, through a real run.
The retention mechanism is pinned in
`tests/unit/test_checkpoint_retention_and_clipping.py`: `CheckpointIO.save`
deletes the previous file unless told to keep it. What that cannot say is whether
the flags reach it, and the two flags reach it dif... |
2a2017dac2afd24a344d0edd10395e63a6c403f7bffafcc159341f3814691e94 | Python | 3,014 | 90 | import sys
import os
def main(ref, mode, plumed, output, cv_files=None):
"""
ref : list of 2 str
Reference PDB structures
mode : str "compute" or "pull"
Whether to write CV calculation file or SMD pulling file
plumed : str
output : str
Name of PLUMED output file
cv_file... |
38a53e8e38ef0ecab06b1a16ea00a25553cabcf509e51804708d8be6bee224f8 | Python | 3,016 | 95 | import experiment as exp
import video_system
import schedule
class AsyncRecordingExperiment(exp.Experiment):
default_params = {
"record_groups": {},
"split_rec_every": 12 * 60 * 60,
"split_gap": 1,
}
def setup(self):
self.cancel_start_scheds = {}
self.cancel_stop_s... |
51be50f3ea71ae08a29ddb57a38ef1f0e5a070d75421f5b258cc9e68fa0ab490 | Python | 3,020 | 58 | # Copyright (c) 2019 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... |
24a042608b9f0949dc1489f959f87c0098b6c9e2370ab156f6269664cf97a532 | Python | 3,023 | 84 | """Extended tests for TanimotoSimilarity — multi-reference and edge cases."""
import numpy as np
import pytest
from reinvent_plugins.components.RDKit.comp_similarity import TanimotoSimilarity, Parameters
from tests.test_data import ASPIRIN, CELECOXIB, BENZENE
def _make_params(smiles_list, radius=3, use_counts=True,... |
a5b3d6ffe1dc9262fc54f539004b3f68ff0e17da67ca902873d14d00d47f0a61 | Python | 3,024 | 110 | # sys
import sys
import os
import dill
import configparser
from pathlib import Path
# sci
import numpy as np
import pandas as pd
# ephys
# own
from functions import *
from plotters import *
import sssio
# plotting
import matplotlib as mpl
import matplotlib.pyplot as plt
"""
#### ## ## ####
## ### ## ... |
4e7a35c4f9b44165511e3d67bba4de60d33b5eaf8cecdb9e949891959b7796f3 | Python | 3,026 | 88 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""gRPC interceptors module."""
import collections
import grpc
class _GenericClientInterceptor(
grpc.UnaryUnaryClientInterceptor,
grpc.UnaryStreamClientInterceptor,
grpc.StreamUnaryClientInterceptor,
grpc.StreamStreamCli... |
c5d9084b8353e99531ace1bffca1cfe6e5df5735c4db993429d418848031ff64 | Python | 3,026 | 88 | import numpy as np
import nibabel
import glob
import platform
import matplotlib.pyplot as plt
directory_split = "\\" if platform.system() == "Windows" else "/"
def calculate_scan(image_path, label_path):
voxel_spacing = nibabel.load(image_path).header.get_zooms()
label_volume = nibabel.load(label_path).g... |
703679d8922c7fe9b63ab6efdb016b7eb3a4375fc70f2a469ae45c8d6840b48f | Python | 3,028 | 94 | # ==============================================================================
# Copyright 2025 Technical University of Denmark
# Author: Nikolas Borrel-Jensen
#
# All Rights Reserved.
#
# Licensed under the MIT License.
# ==============================================================================
import h5py
from... |
9574f43c4d6b4c727804305d3e0de8b9486508a00cc7659a20c9b1cefb5da8df | Python | 3,028 | 76 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
import warnings
from typing import Any, Optional, Union, Dict, List, Callable
from nequip.data._nl import DEFAULT_NEIGHBORLIST_BACKEND
def handle_chemical_species_map(
chemical_species_to_atom_ty... |
100f0b5487c8fa950fd0e8f081a16682e98e52e3ecb93e39c1bc4d12d469fa8d | Python | 3,029 | 98 |
import os
import openpyxl
from collections import Counter
import re
import argparse
import sys
dirpath = 'Work/Onto/HBCP/ontologies/'
inputfile = 'MechanismOfAction/bcio_moa.xlsx'
externalfile = 'Upper Level BCIO/inputs/BCIO_External_Imports.xlsx'
external_tmp = []
external_list = []
id_list = []
label_list = []
ex... |
3320afd28f0a76e3ef54c32b9e082f23704bac2adb3439b32ffcbaf5f6ecbd03 | Python | 3,030 | 64 | import os
import argparse
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import pandas as pd
import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
from activation_models.generators import get_activation_models
from custom_model_tools.intrinsic_dim import ... |
69ce0140f6910e5a645373687a20154eb4b58a7519e8970b6e490a0b77f08bca | Python | 3,035 | 116 | """Create a Mol2Mol model from a list of SMILES strings"""
from __future__ import annotations
import time
import uuid
import csv
from reinvent.models import Mol2MolModel, meta_data
from reinvent.models.transformer.transformer import EncoderDecoder
from reinvent.models.transformer.core.vocabulary import Vocabulary, S... |
76c810429756df75d0fceb3e82604667b4cc1ce4b1015fce3524416e953936f0 | Python | 3,035 | 82 | import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.model_selection import StratifiedKFold
from utilityFunctions import *
# Session 1 = REST1_LR; Session 2 = REST2_LR
# Session 3 = REST1_RL; Session 4 = REST2_RL
ss_name = 'REST1_RL'
session = 'RL_S1'
path_to_dataset = 'PUBLIC_DATA_DI... |
f012bb145c90cc5885ee7bdc7d37c295b9bfdb0c8ad013edc894a9e9d987b0a4 | Python | 3,035 | 97 | from __future__ import print_function, division, absolute_import
import os
import numpy as np
from torch.utils.data import Dataset
from torchvision import transforms
from PIL import Image
import torchvision
import warnings
# Ignore warnings for cleaner output
warnings.filterwarnings("ignore")
class TrainDataset(Datas... |
a8cc4b4f7b3f1ad675eaad414127df440ade370459b6a041ee683775c5d6a4b9 | Python | 3,036 | 139 | import numpy as np
import matplotlib.pyplot as plt
def logistic0(x, L=1, k=1, xm=0):
"""
Logistic function for parameter optimization.
Parameters
----------
L: np.float32
Maximum value (defaults to 1).
k: np.float32
Controls the rate of the decay.
xm: np.float32
Poi... |
02d9aab9d0f087f4ebcc472f355cc9b87b74a3a95457cd251ba4b81690ab3756 | Python | 3,037 | 99 | import pandas as pd
import numpy as np
from itertools import combinations
from statsmodels.stats.multitest import multipletests
from scipy.stats import ttest_ind, mannwhitneyu
def getGroups(df, value_col, groupby_cols, agg_list):
"""
Group and aggregate a DataFrame, and return raw values for each group.
""... |
f02aac0d25186f123be2946a2fb595b411be29c7c54979c88acdc43a69958303 | Python | 3,037 | 94 | '''ResNet in PyTorch.
Reference:
He K, Zhang X, Ren S, Sun J. Deep residual learning for image recognition.
InProceedings of the IEEE conference on computer vision and pattern recognition 2016 (pp. 770-778).
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
def conv3x3(in_planes, out_planes, str... |
01b519f721c8571aaf6a08e7af28f8bcc2ad399d2365fd9f62c870885ee71414 | Python | 3,039 | 87 | import pytest
from chromadb.auth.utils import maybe_set_tenant_and_database
from chromadb.auth import UserIdentity
from chromadb.config import DEFAULT_DATABASE, DEFAULT_TENANT
from chromadb.errors import ChromaAuthError
@pytest.fixture
def user_identity() -> UserIdentity:
return UserIdentity(
user_id="te... |
043f2b8c5fea25d358ab727c4fb283b83bba470f606da9f1f593391f0d01eecf | Python | 3,040 | 122 | from abc import abstractmethod
from typing import List, Sequence, Optional, Tuple
from uuid import UUID
from chromadb.api.types import (
Embeddings,
Documents,
IDs,
Metadatas,
Metadata,
Where,
WhereDocument,
)
from chromadb.config import Component
class DB(Component):
@abstractmethod
... |
34a86c1e66bd48a9b60d114717676356fad0191b141357e83eb5c61fab6eb905 | Python | 3,041 | 79 | import gzip
from typing import List
from reinvent.chemistry import conversions
from reinvent.chemistry.standardization.filter_configuration import FilterConfiguration
from reinvent.chemistry.standardization.rdkit_standardizer import RDKitStandardizer
class FileReader:
def __init__(self, configuration: List[Filte... |
4371031bb7baf086c10798822c8127db0e91b1892a5f14824bb1f664a8cf81e3 | Python | 3,044 | 111 | import os
import cv2
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
class Lane:
def __init__(self, points=None, invalid_value=-2., metadata=None):
super(Lane, self).__init__()
self.curr_iter = 0
self.points = points
self.invalid_value = invalid_value
... |
48f9e5bef72d60c7ce4170bae1d5b15902f3de0b4d4106f8edb8f9f0d8cb9f3c | Python | 3,044 | 101 | import os
def overlap(x1,y1,x2,y2):
r = 0
if (y2 < x2 or y1 < x1):
raise Exception
elif (y1 <= y2 and y1 >= x2):
if (x1 > x2):
r = (x1,y1);
else:
r = (x2,y1)
elif (x1 <= y2 and x1 >= x2):
if (y1 < y2):
r = (x1,y1)
else:
... |
719a62d651d6d77251bc4924accc231aa049d69768ef0ab24d4a89fe1c8cb1b5 | Python | 3,044 | 93 | import os
import time
import hdf5storage
import numpy as np
import scipy.io as sio
from functions.dFC_funcs import *
os.environ["MKL_NUM_THREADS"] = "64"
os.environ["NUMEXPR_NUM_THREADS"] = "64"
os.environ["OMP_NUM_THREADS"] = "64"
print(
"################################# subject-level dFC assessment CODE start... |
eda85a2e12eaad2f060896d7ef6f11ccc4d97ae8db3d8e2176fcbf42720be1c5 | Python | 3,044 | 73 | import math
import numpy as np
import tensorflow as tf
from scipy.special import expit
def relu_moments(x, x_var):
relu_mean = 0.5 * x * (1.0 + tf.math.erf(x / (tf.sqrt(1e-8 + x_var) * math.sqrt(2.0)))) + \
tf.sqrt(0.5 * (1e-8 + x_var) / math.pi) * tf.exp(-0.5 * tf.pow(x, 2.0) / (1e-8 + x_var))
... |
9a443fecdbb637071247d51611f8d02b9313e3bd114fcce3ce275115bd9dffc0 | Python | 3,045 | 93 | import pandas as pd
import numpy as np
import sys
#prom_inter is the file from bedtools intersect, peaklist is the list of peaks, and out is the prefix of the output file
prom_inter = sys.argv[1]
peaklist = sys.argv[2]
out = sys.argv[3]
v = pd.read_csv(peaklist, sep = "\t", header = None)
v2 = pd.read_csv(pro... |
9bd08672edf14bcb8c38710f14ad57fbf670ec635733b0dcdaf31806abdcf92e | Python | 3,045 | 80 | """
Univariate Regression
=====================
This example simulates data according to a very simple sketch of brain
imaging data and applies a standard two-level univariate GLM to identify
significant voxels.
"""
#########################################################################
# Download pain dataset fro... |
615130d5de397f5c40afc44f18f5dba3f4921ad99cdaf132def2c3d30ce1ee78 | Python | 3,047 | 79 | # Author: Youzhi Luo (yzluo@tamu.edu)
# Updated by: Anmol Anand (aanand@tamu.edu)
from typing import Union, List, Optional, Tuple
import torch
from torch import Tensor
from torch_scatter import scatter
from torch_geometric.utils.num_nodes import maybe_num_nodes
from ..constants import *
def coalesce(
edge_index... |
8105efa2a03b125efc23a7612c011a469514dbc49d1813b111cc532e1ce11da9 | Python | 3,047 | 94 | """
Some custom metrics
"""
import functools
import multiprocessing
import logging
import numpy as np
from scipy import stats
import torch
from torch.utils.data import Dataset
def kl_from_empirical(
u: np.ndarray, v: np.ndarray, nbins: int = 100, pseudocount: bool = False
) -> float:
"""
Compute the KL ... |
91751308b6e600aa95b779ec805ce884be56f8288cbe11f20c4cd4b3a277f6d1 | Python | 3,049 | 78 | """
Downsample the input data by combining and averaging neighboring channels.
"""
import numpy as np
import matplotlib.pyplot as plt
import argparse
import os
import neo
from skimage import measure
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_str
from utils.neo_utils impor... |
7ba7ce58e21fbe02f4ea72e5691e73d82c954dbaa4f55f97b5efada6b60f6c9c | Python | 3,050 | 51 | #*----------------------------------------------------------------------------*
#* Copyright (C) 2024 ETH Zurich, Switzerland *
#* SPDX-License-Identifier: Apache-2.0 *
#* *
... |
ed28ac9bf0692c295969e7d0d3a5d166eb01a63e464ee3e75ba89b032eedcb10 | Python | 3,051 | 117 | import numpy as np
from torch.utils.data import DataLoader
import os, sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/..")
print(os.path.dirname(os.path.realpath(__file__)))
from model import *
from train import *
from tasks.seqDS import *
import torch
from utils import *
import matplotlib.pyplot a... |
b7d9526eb12d344f9fba790ca1940db1e217d8d906dc12102f205d616cf12b46 | Python | 3,052 | 96 | """The Poincare polydisk.
The Poincare polydisk is defined as a product manifold of the Hyperbolic space
of dimension 2. The Poincare polydisk has a product metric. The metric on each
space is the natural Poincare metric multiplied by a constant.
Lead author: Yann Cabanes.
References
----------
.. [JV2016] B. Jeuris... |
ff7d2ba4ad428a1979245f12371d7495e152f96e0b46dc1200cb1e01409d33cf | Python | 3,053 | 77 | """
Downsample the input data by combining and averaging neighboring channels.
"""
import numpy as np
import matplotlib.pyplot as plt
import argparse
import os
import neo
from skimage import measure
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_str
from utils.neo_utils impor... |
b2e68319edf831f3512e7e4cdf8d69d0fb8ad1de280dab3da170c5855a56c2b8 | Python | 3,054 | 102 |
import eelbrain as eel
import numpy as np
import scipy, pathlib, importlib, mne, time, os
from pyfftw.interfaces.scipy_fftpack import fft as fftw
from pyfftw.interfaces.scipy_fftpack import ifft as ifftw
def fit_ERP(y, x, t1=-0.01, t2=0.03, stdmul=5, gap=0.004, N=-1, verbose=True, weighted=True, divbystd=False):
... |
4fb7dd275d067dbb15c6e5fbc819b102de30dc329ff946b4fc331f0a1af6a466 | Python | 3,056 | 84 | import sys
import os
import numpy as np
import LFPy
import getMorphoSegments
import csv
from neuron import h, load_mechanisms
from scipy.stats import poisson
from math import ceil
import json
class cortical_neuron():
mechanismFolder = os.path.join(os.path.dirname(__file__),'mod_files')
def __init__(self,mFile... |
4dd0fbdb8cbd75778e515d6cd946f480ae48662ef22d257952c0cdfc21ba1874 | Python | 3,062 | 80 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 31 15:33:56 2020
@author: Tom
"""
import tensorflow as tf
import numpy as np
from sksurv.metrics import concordance_index_censored as cindex
import pandas as pd
class CIndexCallback(tf.keras.callbacks.Callback):
def __init__(self, image_flow_val, idx, followup, even... |
398001be5a9ddde36c9da3a860ba7fb9cf9381049d051415515827c901ef9130 | Python | 3,065 | 118 | """Notebook support code"""
import glob
from io import BytesIO
from tensorboard.backend.event_processing import event_accumulator
import seaborn as sns
import matplotlib.pyplot as plt
from PIL import Image
import pandas as pd
import mols2grid
sns.set(style="darkgrid")
def load_tb_data(wd, prefix="tb_"):
"""Loa... |
c2f74ad980752d2c919cfef01bb5c9af3cba8c9dfe1a00faa9c6fb9227e8e318 | Python | 3,067 | 101 | import pytest
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.hyperboloid import Hyperboloid
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.geometry.product_manifold import ProductManifold
from geomstats.geometry.siegel import Siegel
from geomstats.geometry.special_ort... |
985fe76f17452d7e2bf9b2cb3aadece7fae5b2a3e065b575cfcacabef00e4fff | Python | 3,068 | 78 | """
The Van der Pol Oscillator
==========================
Here, we will introduce the Van der Pol model, a widely studied non-linear oscillator model [1]_.
In its two-dimensional form, the Van der Pol oscillator is governed by the following non-linear ODEs:
.. math::
\\dot x &= z, \n
\\dot z &= \\mu (... |
de8ce626c531f5b908a1363d6d319dac65d449341ad37bd4736249b970bfaf9c | Python | 3,068 | 78 | """
The Van der Pol Oscillator
==========================
Here, we will introduce the Van der Pol model, a widely studied non-linear oscillator model [1]_.
In its two-dimensional form, the Van der Pol oscillator is governed by the following non-linear ODEs:
.. math::
\\dot x &= z, \n
\\dot z &= \\mu (... |
b0735ffaf1d897e1a9bd867f0ee030adc5238b574f4f881ff02c9089fe13d4a9 | Python | 3,070 | 84 | import os
import re
from datetime import datetime
from pathlib import Path
from typing import Optional, Tuple
import config
def get_last_checkpoint(experiment_path: Path) -> Optional[Path]:
checkpoints_root_dir = experiment_path / 'lightning_logs'
if not checkpoints_root_dir.exists():
return None
... |
a05b7039ef820fae7ec3c63a74c27218c792cef6af43fe5689d588792ba10d64 | Python | 3,073 | 80 | import numpy as np
from scipy.linalg import sqrtm
import torch
from .model import sample_z_categorical, sample_z_continuous
__author__ = "Zhijian Yang"
__copyright__ = "Copyright 2019-2020 The CBICA & SBIA Lab"
__credits__ = ["Zhijian Yang"]
__license__ = "See LICENSE file"
__version__ = "0.1.0"
__maintainer__ = "Zhij... |
0dea661ffd50c508abadc76328f17d341b804ab1c13873c14072c86eaefbffe2 | Python | 3,076 | 129 | #!/bin/env python3
"""Add meta data to REINVENT model files"""
import os
import sys
import uuid
import time
import logging
import argparse
from typing import TextIO
import torch
import xxhash
from reinvent.models import meta_data
from reinvent.models.meta_data import update_model_data, check_valid_hash
def setup_l... |
15b74d5e25be51dc6ae130b41696fe609e1fd367633ec32371bdaf8218eaae59 | Python | 3,078 | 129 | import os, sys
from PyQt5 import QtWidgets, QtGui
import matplotlib
import matplotlib.figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
# needed to import from SanPy which is one folder up
sys... |
a98cf22c2e3aadc1e8ef337d8811ec3a800ba09d5227aa92399675bb05c9fc22 | Python | 3,078 | 79 | """
Downsample the input data by combining and averaging neighboring channels.
"""
import numpy as np
import matplotlib.pyplot as plt
import argparse
from pathlib import Path
import os
import neo
from skimage import measure
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_path
... |
5fd5aefeae474320d1a4717a4594969f793813874172149170cdc7bce68caea0 | Python | 3,080 | 126 | from __future__ import annotations
__all__ = ["SampleBatch", "SmilesState"]
from dataclasses import dataclass
from enum import Enum
from typing import List, TYPE_CHECKING
import torch
import numpy as np
class SmilesState(Enum):
INVALID = 0
VALID = 1
DUPLICATE = 2
@dataclass
class BatchRow:
input: ... |
07a971550fd46e782fb6c21090eeec4d692065175a505eee51cca09240447d23 | Python | 3,081 | 90 | from chromadb.api.types import EmbeddingFunction, Space, Embeddings, Documents
from chromadb.utils.embedding_functions.schemas import validate_config_schema
from typing import List, Dict, Any
import numpy as np
class Text2VecEmbeddingFunction(EmbeddingFunction[Documents]):
"""
This class is used to generate e... |
962dbd63520b456f8e287d1606af1207a2a4fa99cae9b4a2ba32d4b90e953bf9 | Python | 3,082 | 112 | """Tests for compute_transform in reinvent/scoring/compute_scores.py."""
import numpy as np
import pytest
from reinvent.scoring.compute_scores import compute_transform
from reinvent.scoring.transforms import Sigmoid, ReverseSigmoid
from reinvent.scoring.transforms.sigmoids import Parameters as SigParams
from reinvent... |
82b3c96b4a1989c2f45f704043cb6533646f0f4380d71862186ac62a3071f2f2 | Python | 3,083 | 109 | import numpy as np
import torch
import torchvision.models as models
from torch.autograd import Variable
from torchvision import transforms
from numpy.linalg import norm
from PIL import Image
import os
import torch.nn.functional as F
from scipy import spatial
img_to_tensor = transforms.ToTensor()
ch_norm_mean = (0.5, ... |
f83626e158e8502710dc5da18cbf01d6d7bbec0978e06639b3ee6cc2a79cc522 | Python | 3,083 | 112 | """Quotient structure for a geodesic metric space."""
from abc import ABC
import geomstats.backend as gs
from geomstats.metric_geometry.point_set import PointSetMetric
class Aligner(ABC):
"""Bundle structure.
Parameters
----------
total_space : PointSet
Set with quotient structure.
alig... |
2fcffb091b58fe89b0f21830d95cb17e2bd51f58f904acbeb69796274c7fa799 | Python | 3,084 | 88 | import pytest
import unittest
import torch
import torch.utils.data as tud
from reinvent.models.transformer.core.dataset.dataset import Dataset
from reinvent.models.transformer.core.enums.sampling_mode_enum import SamplingModesEnum
from reinvent.models.transformer.core.vocabulary import SMILESTokenizer
from reinvent.r... |
4a1234103d661a51e14197d55392899ceb353c7f74e5a86f2884bdf452a64405 | Python | 3,084 | 74 | """The documentation site's directives, and whether the pages still name things that exist.
A full ``sphinx-build -W`` is the real gate and runs in CI. What is asserted here is the failure
that a docs build would only catch *after* someone renamed a table: every ``vdjdb-schema`` and
``vdjdb-vocabulary`` directive in t... |
6231058c56284df41d69fc680c9c4d056949c8a80aeb44c81ef8b082c8ab4450 | Python | 3,084 | 109 | import torch
from corgie import exceptions
from corgie.log import logger as corgie_logger
from corgie.layers import get_layer_types, str_to_layer_type
# TODO: DEFNITELY need a full blown cache.
STR_TO_BACKEND_DICT = {}
def str_to_backend(s):
global STR_TO_BACKEND_DICT
return STR_TO_BACKEND_DICT[s]
def g... |
78c2395ec151ef6983d0aa5437d3024bf03860d1e763ce8ae292efcab66a1e42 | Python | 3,085 | 97 | """Write out a TensorBoard report"""
from __future__ import annotations
__all__ = ["SamplingTBReporter"]
from collections import Counter
from typing import TYPE_CHECKING
import math
import numpy as np
from reinvent.runmodes.samplers.reports.common import common_report
from reinvent.runmodes.utils import make_grid_i... |
c421904de664a08b3411692ab6c20075fe50d2d49328484a1d95c1de3d62eaaa | Python | 3,088 | 79 | import networkx as nx
import numpy as np
import pickle as pkl
import scipy.sparse as sp
import sys
import pandas as pd
import torch
import anndata as ad
import scanpy as sc
def create_adjacency(feature="./data/Adult-Brain_Lake_dge.txt",preprocessing=True):
g = nx.read_edgelist('./data/adjacency_edgelist.txt',deli... |
1e5ee15323b7d781b2507cc64bbe501828c8e2d0394dc7e9376c438a9d8f0a85 | Python | 3,089 | 82 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 12 15:25:17 2018
@author: ngritti
"""
from csbdeep.models import CARE
# from deeprest.rawDataClass import rawData
# from deeprest.modelClass import modelRest
# from deeprest.timeLapseClass import sampleTimeLapse
import time, os, glob
# from keras i... |
bd063eeb61ed700b683a8f9b9aa5761fc6e6d96ea43bcdbbb59fbec673c76553 | Python | 3,089 | 98 | import itertools
import util as util
import numpy as np
import pandas as pd
from scipy.stats import spearmanr
from numpy import linalg as LA
##############################################################################
##############################################################################
"""
See https://git... |
5d5039b55ee7641f4951fdbcc65e7ef4be8e392be868aa709196a8d33db1ac88 | Python | 3,094 | 95 | # ==============================================================================
# Copyright 2025 Technical University of Denmark
# Author: Nikolas Borrel-Jensen
#
# All Rights Reserved.
#
# Licensed under the MIT License.
# ==============================================================================
import os
impor... |
d5e486705f86876a4eeba0311aea6e3d1cb9ea6070a8f90df956a1cda3b0f2fa | Python | 3,095 | 87 | from . import register_scheduler
from .base_scheduler import BaseLRScheduler
import argparse
import math
@register_scheduler("cosine")
class CosineScheduler(BaseLRScheduler):
"""
Cosine learning rate scheduler: https://arxiv.org/abs/1608.03983
"""
def __init__(self, opts, **kwargs) -> None:
i... |
bec9205e90ff5424d5637224421c98d7361b25202fd710c97e1b43f021402093 | Python | 3,098 | 82 | """stamp_correction.py: Module for general postprocessing operations of
annotations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
def combine_close_stamps(marks, fs, min_separation):
"""Combines contiguous marks that are too c... |
2aa9fdf8e903ab2e3939568f2c10a9dc7ede1920daa7a63da7d8761fac50b944 | Python | 3,099 | 83 |
'''
Example showing continuous hardware-timed analog input using nidaqmx-python and matplotlib
pinidaqmxegs.ai.hardwareContinuousVoltageWithCallBackNoPlot
Purpose
Shows how to do hardware-timed analog input using NI's nidaqmx-python package.
More details at https://github.com/ni/nidaqmx-python
This f... |
e2ea4d51abca2ac589e5d680e2394f622b3d217cc3b0fc7f020e87ae11c4b186 | Python | 3,104 | 92 | # ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Written by Bin Xiao (Bin.Xiao@microsoft.com)
# Modified by Ke Sun (sunk@mail.ustc.edu.cn)
# ------------------------------------------------------------------------------
from ... |
b56cc5f52c648c03e6a39918480596806b8fb12fcb75f8c3fa931950b4462270 | Python | 3,105 | 87 | import argparse
import numpy as np
import sys
import os
def check_file(expres):
checkset = set(["", "NA", "Na", "na", "nan", "null"])
for c in checkset:
loc = np.where(expres == c)
if loc[0].size:
expres[loc] = "0"
print(f"There is {c} in the 'gene expressio... |
8853b4e31c2adbc647dff11004ae84f300a3bc752befe0f231376c3ab7fd25f6 | Python | 3,107 | 105 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
import torch
from torch import nn, Tensor
from typing import Tuple, Optional
from .base_layer import BaseLayer
from .linear_layer import LinearLayer
from .dropout import Dropout
from ..misc.profiler import module_p... |
5c128f3ffe3449cde19a10c547c212754b8f1364c7cc2857829d2e31d89c2c02 | Python | 3,108 | 91 | """
Train FBPUNetReconstructor with data augmentation on 'lodopab'.
"""
import numpy as np
from dival import get_standard_dataset
from dival.measure import PSNR
from dival.reconstructors.fbpunet_reconstructor import FBPUNetReconstructor
from dival.datasets.fbp_dataset import (
generate_fbp_cache_files, get_cached_f... |
01e1d7d1191eae12107ad2bf24884c7262a615523dcb45b1dc8adef3019e1a14 | Python | 3,109 | 115 | from __future__ import print_function
import os
import argparse
import ANNarchy
import numpy as np
import pandas as pd
from time import time as t
plots_path = os.path.join("..", "..", "figures")
benchmark_path = os.path.join("..", "..", "benchmark")
if not os.path.isdir(benchmark_path):
os.makedirs(benchmark_pat... |
d8b1a5cad01a468822ce09c15e9eb0fdf8d5e910d52d494ee5c09bdf9b70fb0d | Python | 3,111 | 87 | # ==============================================================================
# Copyright 2025 Technical University of Denmark
# Author: Nikolas Borrel-Jensen
#
# All Rights Reserved.
#
# Licensed under the MIT License.
# ==============================================================================
import argparse
... |
95c125d70f278a62e92a2ee0698cd320ada24d31948a89b98e714e4c3e920b3f | Python | 3,112 | 108 | import random
import pytest
from geomstats.geometry.invariant_metric import (
InvariantMetric,
InvariantMetricMatrixExpODESolver,
)
from geomstats.geometry.poincare_ball import PoincareBall
from geomstats.geometry.special_orthogonal import SpecialOrthogonal
from geomstats.numerics.geodesic import ExpODESolver... |
9a1325d9a4f1747a6fc83253389be8e6c1f5b7fc2748071f66b5741f0014f147 | Python | 3,112 | 82 | """
Detrend the signal in each channel by order 0 (constant) or 1 (linear).
"""
import numpy as np
import scipy
import matplotlib.pyplot as plt
import argparse
import os
import warnings
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_int
CLI = argparse.ArgumentParser()
CLI.ad... |
3894a98faae422232557be622bc91086194c49732bc4e191a753e348fe958d26 | Python | 3,113 | 92 | #!/usr/bin/python3
import serial, time, threading, sys
arduino = serial.Serial('/dev/ttyUSB1',115200,timeout=0.1)
arduino.reset_input_buffer()
arduino.reset_output_buffer()
def readArduino(e):
while True:
data = arduino.readline()[:-2] ## the last bit gets rid of the new-line chars
if data:
... |
5fd8d999e114e6b2a0efe6b9ead0f2c1d289b0f1a6787c51ada4c7679d93e3c8 | Python | 3,113 | 86 | # Copyright 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging
from pathlib import Path
from openfl.callbacks.callback import Callback
from openfl.federated import Plan
from openfl.protocols import utils
from openfl.utilities.dataloading import initialize_minimal_dataloader
from openfl.utiliti... |
5ad1f0dc5229c796c28e77fbf252b278490a02de0d488e59ba58ac0a86051ef2 | Python | 3,120 | 112 | """Unit tests for the graphspace quotient space."""
import random
import pytest
from geomstats.metric_geometry.graph_space import (
ExhaustiveAligner,
FAQAligner,
GraphSpace,
PointToGeodesicAligner,
_GeodesicToPointAligner,
)
from geomstats.test.parametrizers import DataBasedParametrizer
from geo... |
c033d8ff947aafba45404145dbf94bfa34f00b0dd0bbd4ff544c0a82ea31d359 | Python | 3,122 | 106 | """Incremental frechet mean estimator."""
from sklearn.base import BaseEstimator
class IncrementalFrechetMean(BaseEstimator):
r"""Incremental Frechet Mean Estimator.
Incremental frechet mean estimator calculates sample frechet mean by
moving iteratively along the geodesic between current mean estimate
... |
7f5ae7c7e2a120f9303ee4b4395c130ac6b767c6a56c8830470d6523d3a2a31f | Python | 3,123 | 92 | from chromadb.api.types import Embeddings, Documents, EmbeddingFunction, Space
from chromadb.utils.embedding_functions.schemas import validate_config_schema
from typing import List, Dict, Any
import os
import numpy as np
class MistralEmbeddingFunction(EmbeddingFunction[Documents]):
def __init__(
self,
... |
572bbca1ab642644fed293c714df7b48dae56b1135f7551dee08c17300dcfc17 | Python | 3,125 | 109 | import warnings
import pandas as pd
from src.constants import (
AIS_LABEL,
DISTANCE_LABEL,
SECTION_LABEL,
SITE_LABEL,
TERMINAL_LABEL,
TIME_LABEL,
VOLTAGE_LABEL,
)
from src.data.files import get_file_path
from src.types import APCount
from tables import NaturalNameWarning
def _ap_series_to... |
eca57afe00212dc6833d25323aaab444d6a164728a692224b5a1a56b6366b06a | Python | 3,126 | 111 | # Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Federation Components Timeout tests module."""
import asyncio
import os
import pytest
import time
from openfl.utilities.fed_timer import fedtiming
from unittest import mock
@pytest.mark.parametrize(
'input,expected', [
... |
60814f9014a4cddc4d5fe156c0aea10ccaea4475c59a73f75a14d569eb6aa765 | Python | 3,129 | 115 | """Custom Nose-Hoover NVT thermostat based on ASE.
This code was originally written by Jonathan Mailoa based on these notes:
https://www2.ph.ed.ac.uk/~dmarendu/MVP/MVP03.pdf
It was then adapted by Simon Batzner to be used within ASE. Parts of the overall outline of the class are also based on the Langevin class ... |
3bbdb2aae3b3a8d763cb46f4e9777492cec2415384a4d229da1606dde658e7eb | Python | 3,135 | 79 | from typing import Optional, Sequence
import numpy as np
from monai.metrics.utils import get_mask_edges
from scipy.ndimage import distance_transform_edt
def distance_metrics(pred_mask, gt_mask):
mm_per_pixel = np.array([1.0, 1.0, 1.0])
edges_pred, edges_gt = get_mask_edges(pred_mask, gt_mask)
max_surfac... |
847cc88c464504090394d1a48417251eee01a3f8e9b1c451f87828823790fd68 | Python | 3,135 | 98 | # 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
#
# Un... |
d8439b023b41fccee429e4699158fd51529f501ea8b4c0ccb5c22ab2f273ca2b | Python | 3,135 | 83 | """
Detrend the signal in each channel by order 0 (constant) or 1 (linear).
"""
import numpy as np
import scipy
import matplotlib.pyplot as plt
import argparse
from pathlib import Path
import os
import warnings
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_int
CLI = argpars... |
8b26e266ef1438ef76b6bacf38963feab036643baa67632b25418546cbbec1d5 | Python | 3,139 | 85 | """
Offsets the signal in all channels by a fixed value.
"""
import argparse
from pathlib import Path
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_int, none_or_float, none_or_path
from utils.neo_utils import time_slice
CLI = argparse.Argumen... |
0bbc3f3716c50f5ce0ae496740feb3af9fc92c106da604fcc3d06fc834df7eee | Python | 3,140 | 85 | """
Offsets the signal in all channels by a fixed value.
"""
import argparse
from pathlib import Path
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_int, none_or_float, none_or_path
from utils.neo_utils import time_slice
CLI = argparse.Argumen... |
f5a3444da72aeb07af9d548a886488a4aaa5c819d2bb61b1e34053a08cd53958 | Python | 3,142 | 94 | """Reaction filter
This is primarily for Lib/Linkinvent and was previously directly in their
scoring methods in RL.
"""
__all__ = ["ReactionFilter"]
from dataclasses import dataclass
from typing import List
import numpy as np
from rdkit import Chem
from reinvent.chemistry.library_design import reaction_filters
from... |
66681a71b66bcd747a163d5ebe53636ae85cd3913c9422a46dd0ae4355001a17 | Python | 3,144 | 106 | """Script converting legacy param and json parameter files to hdf5.
This script downloads the legacy files directly from the GitHub repositories.
"""
# Author: George Dang <george_dang@brown.edu.com>
import os
import requests
import shutil
import tempfile
from pathlib import Path
from requests.exceptions import HTTPEr... |
96861ae80766192103579cf5b42534b020d9f28c7ddfff8df788094298c62c34 | Python | 3,147 | 108 |
from sleepy.gui.tagging.model.event import Event
from scipy.signal import find_peaks
import numpy as np
class IntervalEvent(Event):
def __init__(self, start, stop, dataSource, applicationSettings):
super().__init__(dataSource, applicationSettings)
self.interval = (start, stop)
@... |
26cd1d34d57bdff88506e53756be352d59df03cc4924af892720db0c3a80d67a | Python | 3,148 | 99 | """Visualization for Geometric Statistics."""
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # NOQA
import geomstats.backend as gs
class Ellipses:
r"""Class used to plot points on the manifold SPD(2).
Elements S of the manifold of 2D Symmetric Positive Definite matrices
can be... |
891e2ed79b10fc943b24b7c6b1fafaa0ab4f3ceda5b06a0cf2ac56cab2b0d136 | Python | 3,148 | 84 | from torch import nn
from torch.nn import Linear
class AE_encoder(nn.Module):
def __init__(self, ae_n_enc_1, ae_n_enc_2, ae_n_enc_3, n_inputs, n_z):
super(AE_encoder, self).__init__()
self.enc_1 = Linear(n_inputs, ae_n_enc_1)
self.enc_2 = Linear(ae_n_enc_1, ae_n_enc_2)
s... |
4172d0950d2f6f8bab6b7de1bda94be9907f98b63014ee76774455ba4e8c5011 | Python | 3,149 | 85 | # Generated by Django 4.1.1 on 2022-11-21 13:36
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('celsus', '0029_alter_project_associated_authors_and_more'... |
88e9dbdf5b201785415c1fd9b399ac1780cf4d90051bbe1282d630ab5316954b | Python | 3,149 | 85 | """
Offsets the signal in all channels by a fixed value.
"""
import argparse
from pathlib import Path
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_int, none_or_float, none_or_str
from utils.neo_utils import time_slice
CLI = argparse.Argument... |
0b237f3375a63764db24aa4c0f064a3a60e97539c97b6cba298d4a1db74405d1 | Python | 3,150 | 84 | """Frame validation shared by the data classes.
`BrainData.X`/`.Y` and `Adjacency.Y` accept the same range of tabular inputs
and store the same polars frame, so the ingress check lives here rather than
inside either class.
"""
from pathlib import Path
import numpy as np
import polars as pl
def _validate_frame(fram... |
48d270eafe1049fb216834d17e310f51d34829a96170468e28e46009a47fb482 | Python | 3,151 | 95 | """Tests for centralized SanPy filesystem paths."""
from pathlib import Path
from typing import Any
import pytest
from sanpy.sanpy_paths import SanPyPaths
def _make_template(bundled_dir: Path) -> Path:
"""Create a minimal bundled user-files template.
Args:
bundled_dir: Temporary bundled-resource d... |
5f396d42485b09eb3c70c90175aff55085f2e7d0521cfdf03682c0ef287afeb6 | Python | 3,151 | 82 | # Copyright 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import shutil
from pathlib import Path
import tests.end_to_end.utils.data_helper as data_helper
from tests.end_to_end.utils.tr_workspace import create_tr_workspace, create_tr_dws_workspace
@pytest.fixture(scope="function")
d... |
c3c9c3f296f12c5f7b6f7c9318147c3787c126993b038b4acdbe309e64c59436 | Python | 3,151 | 88 | import argparse
from . import register_scheduler
from .base_scheduler import BaseLRScheduler
@register_scheduler("polynomial")
class PolynomialScheduler(BaseLRScheduler):
"""
Polynomial LR scheduler
"""
def __init__(self, opts, **kwargs) -> None:
is_iter_based = getattr(opts, "scheduler.is_i... |
175e4dda374c5bcb0c426dd873a09850b53b6801bc19b8a1c341ad62f24dc805 | Python | 3,153 | 114 | from numba import njit, jit, objmode
from numba.experimental import jitclass
from numba import int32, int64, float32, float64, boolean
from numba import typed, types
from numba.types import pyobject
import numpy as np
from scipy.io import loadmat, savemat
spec = [
('nil', int32),
('lastElement', int32),
... |
9874438dd98e0cd170a0c6725c2f25532eae17d25293f49e2888a21012af90af | Python | 3,154 | 119 |
from PyQt5.QtWidgets import QCheckBox, QDoubleSpinBox, QSpinBox, QLineEdit, QPushButton, QHBoxLayout, QWidget, QColorDialog
from PyQt5.QtCore import Qt
class CustomQColorPicker(QWidget):
"""Custom widget displaying a QLineEdit and a colored button. The user can
choose a color or enter a hex-value.
... |
3070884a77bdceb605e6328d9530f4028f171599eb7e57b45ddc4aa3288988e3 | Python | 3,156 | 89 | """Riemannian and pseudo-Riemannian metrics for complex manifolds.
Lead author: Yann Cabanes.
"""
import geomstats.backend as gs
from geomstats.geometry.riemannian_metric import RiemannianMetric
from geomstats.vectorization import check_is_batch
class ComplexRiemannianMetric(RiemannianMetric):
r"""Class for Rie... |
f86c801c2554f99a5fb265a922c698cb14a852130f526173fd176abca885cd13 | Python | 3,157 | 87 | # 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 math
from fairseq import metrics, utils
from fairseq.criterions import FairseqCriterion, register_criterion
try:
from fairseq.mo... |
b01531b876ee4cf2ba6b57c2ce0b9bada36745800a1d31dd2f3c4e4cf1a8d573 | Python | 3,158 | 96 | import os
import importlib
import torch.nn
from utils import logger
import argparse
from .base_optim import BaseOptim
OPTIM_REGISTRY = {}
def register_optimizer(name: str):
def register_optimizer_class(cls):
if name in OPTIM_REGISTRY:
raise ValueError("Cannot register duplicate optimizer (... |
f0d203f34409241a903e69283d64c35434937a72cffd335333c25926f8ed277a | Python | 3,158 | 83 | """
Detrend the signal in each channel by order 0 (constant) or 1 (linear).
"""
import numpy as np
import scipy
import matplotlib.pyplot as plt
import argparse
import os
import warnings
from utils.io_utils import load_neo, write_neo, save_plot
from utils.parse import none_or_int
CLI = argparse.ArgumentParser()
CLI.ad... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.