sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
fa5dca0d24c5e49649732602128671ca267b80d9a9159d1ffb8be4e2f89b3999
Python
10,977
286
import shutil from pathlib import Path from unittest.mock import patch import holoviews as hv import pytest from guppy.frontend.visualization_dashboard import VisualizationDashboard from guppy.testing.api import step1, step2, step3, step4, step5 from guppy.utils.utils import parse_run_name from guppy_test_data import...
7a2849e99d172967419b4e81d9e3ad09e91ec21756e7bb323da3f70faf3b4d97
Python
10,979
300
"""Utilities related to layer/model functionality. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from .conv_utils import convert_kernel from .. import backend as K import numpy as np def count_params(weights): """Count the total number of scalars...
0b8144061227e69efa13d0511abc2f40c417ea5f351f0ec74b2bb18a91098964
Python
10,980
351
# -*- coding: utf-8 -*- # # burstiDAtor documentation build configuration file, created by # sphinx-quickstart on Sat Jul 19 14:34:56 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. #...
722ed11b77efd5e1213bce99cfc01b52caaeb1c0b6d1e84e2d255bcd33fd3cb9
Python
10,997
325
import numpy as np from scipy.special import expit import scipy from cogmodels.bayesian_base import BayesianModel from cogmodels.base import CogParam class PCModel(BayesianModel): """ Debate: single subject fit, with one paramter sets, and multiple PC models OR: one fit for all subjects, and multiple...
8ab7fe1f3f44f5ccb7f9f20f3032613d0d77683d6f490dcf87729b8529924e4b
Python
11,004
320
from __future__ import annotations import os import pickle from typing import TYPE_CHECKING, Literal, get_args import numpy as np import pytest from ase import Atoms from ase.io.trajectory import Trajectory from ase.md.npt import NPT from ase.md.nptberendsen import Inhomogeneous_NPTBerendsen from ase.md.nvtberendsen ...
79dee7e641b38f298faad00c84790df0854380de4b70c7cc52d378ad4a2e19f7
Python
11,009
259
import torch import numpy as np import time from collections import OrderedDict def copy_state(model): """ Given a PyTorch module `model`, makes a copy of the state onto the CPU. Parameters: ---------- model : torch.nn.Module PyTorch module from which to copy the state dictionary. Re...
9547561f07403a7e6cb9d41cbb9a29fd7d9f2dec093147c906dbbc145a35c30e
Python
11,012
243
import os import argparse import torch import torch.nn as nn import torchvision.transforms as transforms from torchvision.datasets import ImageFolder from torch.utils.data import DataLoader from torch.optim import Adam from torchvision.utils import save_image import numpy as np # Parse input arguments parser = argpars...
66b691e96d6975c518c9a49b9566335376cd3b9eeafc2e2b5d6a36c06fd9a47e
Python
11,024
323
""" Generate the lowest-level Cython bindings to HDF5. In order to translate HDF5 errors to exceptions, the raw HDF5 API is wrapped with Cython "error wrappers". These are cdef functions with the same names and signatures as their HDF5 equivalents, but implemented in the h5py.defs extension modul...
0b9fa4d5ea4cf1bfdb0f9784b4de63440544285ef4b7563083ab1391d71d4e76
Python
11,025
332
from typing import Dict, List, Optional, Tuple import torch from torch import nn, Tensor from torch.autograd import grad from torch_scatter import scatter_sum, scatter_mean from torch_geometric.data import Data from oa_reactdiff.model import EGNN from oa_reactdiff.model.core import GatedMLP from oa_reactdiff.utils i...
61d1045633baa498c65a12caf379a0304f86af90cff7d44e66d29c287e99fcf4
Python
11,026
299
import time import logging import threading import sqlite3 from medperf.comms.auth.interface import Auth from medperf.comms.auth.token_verifier import verify_token from medperf.exceptions import CommunicationError, AuthenticationError import requests import medperf.config as config from medperf.utils import log_respons...
bef8d542d4b73c425db9a16d013723cd67a5690a965479ee8917dfc4d4a32b23
Python
11,036
182
"""Emodel generalisation package.""" # Copyright (c) 2022 EPFL-BBP, All rights reserved. # # THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS'' # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCL...
c8229ca5a0ff21e68486328cb53e7ec864080231c669f08567dd3fbb16d53a57
Python
11,038
308
""" Author : Alexis Lebrun (PhD student) School : Université Laval (Qc, Canada) This module provides functions for a variety of utilities. """ import numpy as np from sklearn.model_selection import train_test_split import logging import pandas as pd from io import BytesIO from zipfile import ZipFile from urllib.reque...
0e701c3da96d9bd58111ff0041d79a499c517b331aff45ae5ebedf3492e145cc
Python
11,044
276
''' Trains only an MLP on PCA-dimensionality-reduced features. Author: Hanna M. Tolle Date: 2025-02-17 License: BSD 3-Clause ''' import sys sys.path.append('graphTRIP/') from sacred import Experiment from experiments.ingredients.data_ingredient import * from experiments.ingredients.mlp_ingredient import * import ...
53bcfd5dd8964d7487178d76690da0a61335e49385c087981c5fb9653b8c49a3
Python
11,044
203
""" In cases where a BOLD file exists but the corresponding events.tsv file is missing, there are several scenarios to consider: 1. Incomplete Behavioral Data with TEMP Files Available: TEMP files, which are trial-by-trial backups that don't rely on a final "save," may exist even if the behavioral data wasn't fully...
b5acf79c363188449e7c86e5b3d38a70bac55bc7516d54322b133f6696cfe12d
Python
11,044
322
import json from importlib.metadata import version from pathlib import Path import pytest from guppy.orchestration.save_parameters import ( read_artifact_provenance, save_parameters, ) # Derived provenance, recorded by the preprocessing steps rather than taken from the form. ARTIFACT_PROVENANCE_KEYS = { ...
18282d7577719b2264fbd2d6d276e0867b9f3b4cce4357e8f096339b94016629
Python
11,049
332
import torch import torch.nn as nn from typing import Tuple, Union, Optional from torch_sparse import SparseTensor import numpy as np class AdjToEdge: """ Convert adjacency matrix to edge indices and weights for graph decoders. Parameters ---------- threshold : float, optional ...
8b7953873740e687743cb9e71b6c7f2e957ce14ea4f17296ba3f1bc6604f3f45
Python
11,049
283
import numpy as np import os import subprocess import glob def train_val_test_split(files, nr_val_datasets, nr_train_datasets): """ Custom dataset split based on exclusion criteria. Parameters ---------- files : list of str List of file names. nr_val_datasets : int Number of d...
5f10a22daec4c5fb4b89f3217a03916ee95d2b3a27fa17053255ae615d8f7f24
Python
11,050
364
# 20180625 import importlib import pickle import mne import numpy as np import pandas as pd import h5py import os import re import sys import yaml import multiprocessing import gc #from scipy.io import loadmat from glob import glob from progressbar import Bar, ETA, Percentage, ProgressBar from joblib import Paralle...
29af5f88243b03d2e825dbe8d2841908cf32fba2de44ae68723888e46fd84d4a
Python
11,051
243
import matplotlib.pyplot as plt import sys, os, struct import pysam import numpy as np from statistics import median, stdev import pyarrow as pa import pyarrow.parquet as pq import time """ python /private/groups/brookslab/cafelton/fusions-code/pod5kmersignal/plotSignalInRegion.py chr13:52310695-52310705 can_m...
49c5bfeb07d81242d2794860af1fab50800617ec72580e3f60c70bf6435d4375
Python
11,055
251
# this file is used to evalaute the performance of the ev2gym environment with various stable baselines algorithms. from stable_baselines3 import PPO, A2C, DDPG, SAC, TD3, DQN from stable_baselines3.common.callbacks import BaseCallback from stable_baselines3.common.callbacks import EvalCallback from sb3_contrib import...
8c58e64a5d23938a89ad4fabdad602bb55bdf4424ab0e8238c893cee8cff2b01
Python
11,075
256
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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://w...
a1656cea56173b0f431bb8c16519fa5f6fd1eadf43cfb310ddd6b270c295de12
Python
11,078
300
import matplotlib.pyplot as plt import numpy as np import pandas as pd import scipy as sp import seaborn as sns from statsmodels.stats.anova import AnovaRM condition_map = { 'early_appetitive': 'Early', 'late_appetitive': 'Late', 'threat': 'Threat', 'post_threat': 'Post-threat' } def get_traces(sessi...
b7b79e5d1fc08fc3ffda358f330b3337c2cac0497b471712a264a2715b57a217
Python
11,078
344
"""Tests for Figures REST API endpoints.""" import pytest from helpers import ( MockSioServer, auth_header, create_test_room, create_test_user_in_db, ) from httpx import AsyncClient from sqlalchemy.ext.asyncio import AsyncSession from zndraw.exceptions import FigureNotFound from zndraw.models import R...
dbfc8026d6a1252644089d205c1bdc47a57b66c301be9ae2dfbee3eefafc79fd
Python
11,081
330
import glob import time import numpy as np import matplotlib.pyplot as plt from skimage import draw from random import shuffle import matplotlib.image as mpimg from torch.utils.data import Dataset import itertools import torch from inspect import currentframe, getframeinfo from PIL import Image class ...
d6471716881876eb977aa200c6c6c12511a91ad4263e22661c4ec9c60395491e
Python
11,085
352
""" 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 import torch from .atom_update_block import AtomUpdateBlock from .base_layers import Dense, ResidualLayer from .ef...
af16fe286df41ff3cd4b5d9777c83400566124954e39069825dc11ec5021099e
Python
11,087
262
#!/usr/bin/env python """ # Author: ChangXu # Created Time : Mon 23 Apr 2021 08:26:32 PM CST # File Name: STMAP_train.py # Description:` """ """ test: from cal_graph import graph import scanpy as sc from GCN import STMAP_model from STMAP_main import train data_path = "/home/xuchang/Project/STMAP/Human_br...
be460de771b7e41fab07ab49a3d6843a4f4ed1aec8bc07d7d02b1c9538e63d8d
Python
11,090
335
import json from pathlib import Path from typing import Any from schema_salad.utils import convert_to_dict from cwltool.context import LoadingContext from cwltool.load_tool import load_tool from cwltool.subgraph import get_step, get_subgraph from cwltool.workflow import Workflow, default_make_tool from .util import ...
05c28797a2f9f82e32374d8bdbbfc6032525f40b5e3723f0a445a9d240b5ba91
Python
11,092
309
from .mixin import scviMixin, adjMixin from .GODEVAE import GODEVAE_r from .utils_ODE import get_step_size import torch import torch.nn.functional as F from torch_geometric.data import Data import numpy as np from typing import List, Tuple, Optional from torchdiffeq import odeint class GODEVAE_Train...
a4b06b585cb100c01aca96e3e22801b6bb70aa6dd3cc3bc7d393f3b6129d72ad
Python
11,094
228
#!/usr/bin/env python2.7 import os, sys os.environ["OMP_NUM_THREADS"] = "1" os.environ["OPENBLAS_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["VECLIB_MAXIMUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" import argparse import chisel src = os.path.dirname(chisel.__file__) from ..Ut...
22c7a265238bb336235f45d6ea431d669986f425f928fef2958161006ef9c1a6
Python
11,099
221
import msgpack import psycopg2 import ujson from django.core.management.base import BaseCommand, CommandError from django.conf import settings from django.db import connection from catmaid.control.node import (_node_list_tuples_query, update_cache, Postgis2dNodeProvider, ORIENTATIONS, update_node_query_cache,...
b5b2cb1ce727233fa28ac58ff0b53e5596203e174fd113bf81c289495d130fc7
Python
11,117
280
# Linux/cgroup memory diagnostics used by the DuckDB exporter and report rules. # All functions are best-effort: they degrade to None/``unknown`` off Linux or when # the relevant /proc and /sys/fs/cgroup files are absent, and they never raise. import os.path import resource import sys from src.util import get_logger ...
b81a29f254cd66d4d15f007496b6128033d59b512c50e9804eac1755e8c48d36
Python
11,119
295
from medperf.comms.entity_resources import resources from medperf.exceptions import InvalidArgumentError, MedperfException from medperf.utils import remove_path, run_command, tmp_path_for_file_decryption from .utils import ( check_allowed_run_args, add_medperf_run_args, add_user_defined_run_args, add_me...
3e16d786ce2024a5244afe6c358a96093129bf05d3aef40cd86a56f9302a452b
Python
11,121
352
""" 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 torch from torch_geometric.nn import SchNet from torch_scatter import scatter from ocpmodels.common.registry import registry from ocp...
48f5c7a9dee5ee8025284c6c39589b408496cd6acbbde5457509ca542ce4d1a9
Python
11,123
309
#!/usr/bin/env python from __future__ import annotations import argparse import json import os import re import shutil import subprocess import sys from multiprocessing import Pool, cpu_count from time import time def call(args: list[str]) -> tuple[int, int, str, list[str]]: """Subprocess run wrapper.""" com...
c0dee7c00b18446c8a6ed99adcb176bec7ce84e8d26b9773f4a374117dcf337d
Python
11,126
339
""" classifier_builder.py - Build a random forest classification model from raw data. """ # imports from sklearn.ensemble import RandomForestClassifier from sklearn.feature_selection import SelectKBest from sklearn.model_selection import train_test_split, cross_val_score, KFold from sklearn.metrics import roc_curve, a...
d58db04d71bb5a4ac1e24bde7b1d2f8dbbc02b33be4343eb25ca7118f3e55b31
Python
11,132
183
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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://w...
3e99ebf3d090772a52252672ecb4379b0fc9c8f7c29b291d0898583c8afe2f98
Python
11,136
325
import argparse import os from collections import OrderedDict import nearl.data import numpy as np import nearl def parser(): parser = argparse.ArgumentParser(description="Featurize the misato trajectories") # Input and output settings parser.add_argument( "-f", "--pdbcodes", typ...
b1d1c611aa273ff6448d788c4c2ddc40e26e176009942d188f4e680fdf7654c6
Python
11,136
273
from __future__ import print_function, division import csv import functools import json import os import random import warnings import numpy as np import torch from pymatgen.core.structure import Structure from torch.utils.data import Dataset, DataLoader from torch.utils.data.dataloader import default_collate from to...
08e150a9a732aa02fb5fea2a1361d1ca2a480ded114b7bc4f553658ae308cb25
Python
11,139
279
#!/bin/env python # Author: Qiyuan Zhao (zhaoqy1996@gmail.com) import subprocess import os import time from ReactBench.utils.parsers import xyz_parse class PYGS...
1be27c99542696c097a3ef03b07eacdd9163f8bb9de83757aec0b1dccfe25ad0
Python
11,159
253
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np from matplotlib.lines import Line2D from glob import glob import scienceplots import matplotlib.gridspec as gridspec import scipy.stats as st from matplotlib.colors import LinearSegmentedColormap import matplotlib.colors as col...
4edea989f8c7f8ba894206980c4ebda10bf1395fe3438526562416dc28260807
Python
11,159
339
""" 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 torch from torch_geometric.nn import SchNet from torch_scatter import scatter from ocpmodels.common.registry import registry from ocp...
4777a850f2be0f0225fdb5375ebd8827988b7446ee50da1cf35dfc9d62745918
Python
11,160
337
# This file is part of h5py, a Python interface to the HDF5 library. # # http://www.h5py.org # # Copyright 2008-2013 Andrew Collette and contributors # # License: Standard 3-clause BSD; see "license.txt" for full license terms # and contributor agreement. """ Tests the h5py.File object. """ import h5py...
d1314d3a587d2e46d6139eb93940a9c0970cff48e34f0b595bbc5b2acc2b90c5
Python
11,160
367
from scipy import special, stats as sstats from sklearn.neighbors import KernelDensity import numpy as np from joblib import Parallel, delayed from scipy.spatial.distance import correlation from netneurotools import stats from neuromaps.stats import compare_images def compare_maps(src, trg, metric='pearsonr', ignore_z...
b140c3f78652dfb1ef7e7ae71d2a612e5df7974c6539bb886b06ffa37307ac6d
Python
11,164
318
import math import random from abc import ABC, abstractmethod from collections import defaultdict, namedtuple from dataclasses import dataclass, field from typing import Any, Set, Optional, Dict, List import keras import numpy as np from dante.obj_functions import ObjectiveFunction, BuiltInSyntheticFuncti...
069d7dec0f18a108037e98ab9bcb9af23e10df992ef98c8dccaecfee341b9a3c
Python
11,166
324
"""Utilities related to metrics.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from enum import Enum from .. import backend as K from . import losses_utils NEG_INF = -1e10 class Reduction(object): """Types of metrics reduction. Contains th...
c57a9929c55ac4e85d344a8432862ff4004b0b873c4535237b6460db654898df
Python
11,174
314
""" Caffe network visualization: draw the NetParameter protobuffer. .. note:: This requires pydot>=1.0.2, which is not included in requirements.txt since it requires graphviz and other prerequisites outside the scope of the Caffe. """ from caffe.proto import caffe_pb2 """ pydot is not supported under p...
0d2e9ed86c723b0890eb27e9cbb44b037ab097629b5bdd79f3ccba957c4a05c6
Python
11,182
291
import math from typing import Callable, Optional from torch.utils.data import Dataset import torch import numpy as np import os from scipy.linalg import eigh import tonic import torch.utils.data from torch.utils.data import DataLoader import pytorch_lightning as pl from datasets.utils.pad_tensors import PadTensors ...
6b75d6c94f35e822d2988950715d3eb4d09592af212f09b4e0c44161ca199295
Python
11,182
287
import numpy as np import pandas as pd import matplotlib.pyplot as plt import os, json import pickle from . import util def to_csv(df, path): """ https://stackoverflow.com/questions/50047237/how-to-preserve-dtypes-of-dataframes-when-using-to-csv """ # Prepend dtypes to the top of df df2 = df.copy(...
7393f440abf91d23c154a2feab8724977e6914fa0614ca39012b55f986fe56a5
Python
11,193
347
"""Test the 1.3 loop feature.""" import json from collections.abc import MutableMapping, MutableSequence from io import StringIO from cwltool.main import main from .util import get_data def test_validate_loop() -> None: """Affirm that a loop workflow validates with --enable-dev.""" params = [ "--en...
af09d258e9b5b0385637842f8e77956d7e1dda6df984497febee2fd535defcf8
Python
11,198
345
# Author: Huaxu Yu """ classifier_builder.py - Build a random forest classification model from raw data. """ # imports from sklearn.ensemble import RandomForestClassifier from sklearn.feature_selection import SelectKBest from sklearn.model_selection import train_test_split, cross_val_score, KFold from sklearn.metrics...
0c38b17934c8f091ae9e8a628ad7c737dfc959bbc78686727aae81b000aa2786
Python
11,203
347
import torch import torch.cuda import glob import os import pandas as pd import json from collections import * import random import diskcache from torch.utils.data import Dataset from torch.utils.data import DataLoader import numpy as np import cv2 import torchvision.transforms.functional as fn import Utils.config as ...
2df6b12baafa552a9e54ba2c895084f9c58a7b7ab0b5736aa7363feea530f7f1
Python
11,219
308
""" Qt dialog for manual labeling of an image Copyright (c) 2017 Polytechnique Montreal <www.neuro.polymtl.ca> License: see the file LICENSE """ import logging import sys import numpy as np from PyQt5 import QtCore, QtWidgets, QtGui from spinalcordtoolbox.gui import base from spinalcordtoolbox.gui import widgets fr...
c4a45757383e87172b4475edd3b32efbe3da1bccb9a36a859a94ca62f1e659a1
Python
11,225
187
import cv2 from create_dataset import * from utils import * from PDFN import PDFN from options import * from saver import Saver, resume from time import time from tqdm import tqdm from optimizer import Optimizer import datetime import torch.utils.data import torch timestamp = datetime.datetime.now().strftim...
ab4423e0571953c545bed05d151500750756b3af255ef625df25b66f41f7f02d
Python
11,227
361
""" 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 typing import Optional import torch from ocpmodels.common import gp_utils from ocpmodels.modules.scaling import ScaleFacto...
2da262e47f5a297944497562946ebf7fee29891d9ce402e4526b0c4237ce8a71
Python
11,230
256
"""Contract and mode-table tests for PyPhotometryRecordingExtractor.""" import json from pathlib import Path import numpy as np import pytest from guppy.extractors.pyphotometry_recording_extractor import ( PyPhotometryRecordingExtractor, ) from guppy_test_data import STUBBED_TESTING_DATA from .recording_extract...
6d63fb92476bdd4608c0b0bab797d68fd32e64ff44ecf0c9b4e8b844c4095279
Python
11,234
286
import re import pandas as pd from pathlib import Path import json import subprocess # Constants DATALAD_DIR = Path('/Users/h/Documents/projects_local/1076_spacetop') SCANNOTES_FNAME = Path('/Users/h/Documents/projects_local/cue_expectancy/resources/spacetop_scannotes/ST_Participants - scan_info_08-10-2022.csv') # Ta...
f319fcbb2a1de466a7ea67cbba78f1262e2aaa22a44573779e921c76f7004b75
Python
11,244
296
import concurrent.futures import sqlite3 from pathlib import Path import numpy as np import pandas as pd import torch from rdkit import Chem, DataStructs from rdkit.Chem import QED, rdFingerprintGenerator from torch_pca import PCA from tqdm import tqdm from DiastereomericResolutions.main.molecule_db import MoleculeDa...
566b1f321786cbf26acb297479e94a2f9d0df227e395b63a2683226bb164da87
Python
11,247
308
"""Reformat a CWL document and all its references to be a single stream.""" import copy import urllib from collections.abc import Callable, MutableMapping, MutableSequence from typing import Any, Optional, Union, cast from cwl_utils.types import CWLObjectType, CWLOutputType from ruamel.yaml.comments import CommentedM...
c216478175f68ca597c4b15e9b5bd808aacf723e73821fc0544acd9231eebc46
Python
11,248
305
"""Sequential model class. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import warnings import copy from . import network from .training import Model from .base_layer import Layer from .input_layer import Input from .input_layer import InputLayer fro...
5c792c892034472d3dfa98e94444f9feba3ca3d057829f0d5303ea81a78cffa6
Python
11,258
224
# Description: Implementation of the Local Optimal Linear Estimator (LOLE) algorithm. import numpy as np from sklearn.linear_model import MultiTaskLasso, LinearRegression, LogisticRegression from grid_cell.manifold_fitter import label_mesh from sklearn.metrics import mean_squared_error from grid_cell.util import permut...
9c55d9615528494c627216cf375feebacdba693248c870d6ca2302c8b8fafb4e
Python
11,265
359
import numpy as np from scipy.special import expit import scipy from cogmodels.base import CogParam from cogmodels.rl import RL_4p from cogmodels.utils import regularize PRECISION = 15 TOL = 1e-15 class Pearce_Hall(RL_4p): """ Adapted from Li et al. 2011: Q_{t+1} = Q_t + alpha * alpha_nu_t * rpe_t al...
5a5ec382b2298bb4da1611a87912b738c715356a754c2d39c0ff68bb65154040
Python
11,276
225
# -*- coding: utf-8 -*- # Generated by Django 1.9.13 on 2017-04-16 23:06 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(setting...
403c742eb3c0d634e9701345f410819af29d4132af572f4c9dfa1ca9eb900762
Python
11,279
312
"""TDD tests for analysis extensions. Tests for Distance, DihedralAngle, Properties1D, Properties2D. Calls extension.run(vis) directly against a real server to verify that analysis extensions create correct Plotly figures. """ import ase import numpy as np import plotly.graph_objects as go import pytest from zndraw ...
d4ff1e48d31529734a5124e734399bb67126fc03177cc6a2ac832bad45c60b13
Python
11,280
341
from itertools import product from typing import Any, Dict import numpy as np import pytest from hypothesis import given, note, settings, strategies import xgboost as xgb from xgboost import testing as tm from xgboost.testing.params import ( cat_parameter_strategy, exact_parameter_strategy, hist_cache_str...
247ff85dec7f202f1ed66e047ead948481b36ae35249cf962ba265a98b232365
Python
11,282
371
import torch import torch.cuda import glob import os from collections import namedtuple import pandas as pd import json from collections import * import random import diskcache from torch.utils.data import Dataset from torch.utils.data import DataLoader import numpy as np import cv2 import torchvision.transforms.functi...
aa5ce299fb3c5ac31190e9e2a63b06ea1df8ba633a18a61f903d0cd55aa8106f
Python
11,283
276
# -*- coding: utf-8 -*- import logging import os import re import functools from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait import selenium.webdriver.support.expected_conditions as EC fr...
8ddd8181a103b8194be771a077226fade4f443bef54d6c892c94efe310535cbd
Python
11,299
263
import numpy as np import pytest from guppy.analysis.z_score import compute_z_score, deltaFF, z_score_computation # ── deltaFF ─────────────────────────────────────────────────────────────────── def test_delta_ff_equal_signal_and_control_returns_zeros(): signal = np.array([1.0, 2.0, 3.0]) control = np.array...
9a7cf6a007727e1b6e14331e77ea250386d4cc50b91b38708f60a7fc84ebe451
Python
11,304
372
"""Test ephys model objects""" import os import tempfile import contextlib import pytest import numpy from bluepyopt import ephys sim = ephys.simulators.NrnSimulator() TESTDATA_DIR = os.path.join( os.path.dirname( os.path.abspath(__file__)), 'testdata') simple_morphology_path = os.path.join(TESTDAT...
8a70643d027e3d049cf70fb25864cb9989551851883937724101209a4a1839d1
Python
11,312
188
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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://w...
7040051fc65f21e327ea9096b3222bc3962b490c5c9b25a3c75d986dc00cb95a
Python
11,316
296
# Copyright (c) 2021 EleutherAI # This file is based on code by the authors denoted below and has been modified from its original version. # # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in complianc...
f012d43e05b3540c32cac66e4890d8d819a794df981a2846d2344283c8683a4d
Python
11,318
376
import os import sys import numpy as np import pathlib as pl import subprocess as sp from decimal import Decimal from scipy.stats import pearsonr from scipy import stats from scipy.interpolate import Akima1DInterpolator def smooth(a, window_size=5, window_type='hanning', axis=1): """ Smooth array by convolving...
7f17019d934e2e95f72440f5a1f983e40b76f01949631f7fc7369fc0a7c5b863
Python
11,319
259
print("It works!") import pandas as pd import scanpy as sc import numpy as np import os import json import anndata as ad import scipy import h5py ### reading the data that we want to apply the clock to adata = ad.read('./external_data/frohlich_control_lognorm_2024-12-19.h5ad', backed='r') with h5py.File("external_da...
bbe19d5110f8aec5df6a5a20bfd9bc9cdd4af236b46af08482c67a6a19b9f1db
Python
11,319
333
""" 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 import numpy as np import sympy as sym import torch from scipy import special as sp from scipy.optimize import brentq def Jn(r:...
c5e0fbb98eda876e2efc6897330cde86081a973874f40c8940c6be4b79ddff55
Python
11,322
269
# -*- coding: utf-8 -*- from collections import defaultdict from functools import partial from itertools import combinations, chain import json import math import networkx as nx from rest_framework.decorators import api_view from typing import Any, DefaultDict, Dict, Iterator, List, Optional, Set, Tuple, Union from ...
643cf0ff1301f67ec63ab0e2868d34023e626504a5a79ed49c3e4c2ecba7ebf4
Python
11,323
302
#!/usr/bin/env python # # Warp template and atlas to a given volume (DTI, MT, etc.). # # Copyright (c) 2013 Polytechnique Montreal <www.neuro.polymtl.ca> # License: see the file LICENSE import sys import os from typing import Sequence import spinalcordtoolbox.metadata from spinalcordtoolbox.reports.qc import generate...
d4f05c2aaa06d71d8f183163ae28068aebbcbadfe3445827ae4a366b21c9e57e
Python
11,323
289
# Cluster measurement. # Author: David Young, 2019 """Clustering measurements.""" import os import numpy as np import pandas as pd try: from sklearn import cluster from sklearn import neighbors except ImportError: cluster = None neighbors = None from magmap.cv import chunking, detector from magmap.se...
22a46482d2808454c44aa016b270186d6fdb96b08ee5ddc1a4638f4f3c11ac38
Python
11,334
398
"""Validate alignment of histological sections to structural reference volume.""" import os from multiprocessing import cpu_count from typing import Callable, Tuple import matplotlib.pyplot as plt import nibabel as nib import numpy as np import pandas as pd from brainbuilder.utils import utils from joblib import Paral...
9f39f115bbddb1cee5586230be72dc7903e2b7391b2a86b9973ce5d22bdea67a
Python
11,341
357
import torch import torch.nn as nn from nnunet_mednext.network_architecture.custom_modules.custom_networks.TransBTS.Transformer import TransformerModel from nnunet_mednext.network_architecture.custom_modules.custom_networks.TransBTS.PositionalEncoding import FixedPositionalEncoding,LearnedPositionalEncoding from nnunet...
2d227f3cf332301ce87e1a595e3fc1c6fe796189962fe9fbe5aeb3eec4c129f0
Python
11,344
300
# Extract faces from videos on nas and store them import os import platform import re import shutil import time import pandas as pd from pathlib import Path # from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip PATH_TO_NAS = Path('/nas/student/SimonPistrosch') if platform.system() == 'Linux' else Path('/...
44df7e2d86bb601678aced8a687c78c462b188b787922e2ae9e419b2531db310
Python
11,344
290
#%% # This script produces the results shown in Figure 1 in Wolff and Rademaker (2024) # It loads the simulation data obtained from Fig1_run_first_GFM_simulations.m and performs the decoding analysis # precomputed simulation data and decoding results are available at https://osf.io/bdf74/ import scipy.io as sio impor...
22b3a6b5bf2df0eb259cad8eb8925ee043720b7d3fcb21f965a5bc117b10bc51
Python
11,349
271
import logging import shutil from pathlib import Path from typing import Any import numpy as np import pandas as pd from guppy.extractors import BaseRecordingExtractor from guppy.extractors.detect_acquisition_formats import _classify_csv_file from guppy.utils._hdf5_io import write_hdf5 logger = logging.getLogger(__n...
cd00db27141e0180a525643a8a3c2bf09b7f3a87f43c400f8948c9172aa83c99
Python
11,349
270
#!/usr/bin/env python import argparse import os import sys import datetime from parse_config import parse_json_config, print_config from parse_gene_anno import parse_gff_tree from sc_longread import blocks_to_junctions, remove_similar_tr, get_gene_flat, get_gene_blocks, group_bam2isoform from gff3_to_fa import get_tra...
83149fe402e89e764cd8caa7db6b92d846be157ec4cab8c40ac8ab1d4607655d
Python
11,356
448
#!/usr/bin/env python # # Copyright 2009 Neal Norwitz All Rights Reserved. # Portions Copyright 2009 Google Inc. 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 # # ...
00efbd9a26ecfad00eace1bd3769d1b68196227754a3952e00a68223cfd15897
Python
11,360
254
from pytorch_lightning import LightningModule from pytorch_lightning.strategies import DeepSpeedStrategy from deepspeed.ops.adam import DeepSpeedCPUAdam, FusedAdam from transformers.optimization import AdamW, TYPE_TO_SCHEDULER_FUNCTION from torch.optim import Optimizer from torch.optim.lr_scheduler import _LRScheduler ...
be565b149701a61f02cbebc0e640ab0eb64a820a88abc9148ba2ea4ad2b037ca
Python
11,364
381
"""Genereal utils.""" import itertools import os from collections import deque from datetime import datetime from pathlib import Path from typing import Iterable, Optional import cv2 import cv2 as cv import numpy as np from numpy.typing import NDArray from omegaconf import OmegaConf from PIL import Image from soccertr...
fb3dee896eeb9fbd20a0aa5be2665c87c0086bc700849b612fd555e3713881e1
Python
11,366
310
#!/usr/bin/env python # coding=utf-8 # Copyright 2023 Statistics and Machine Learning Research Group at HKUST. All rights reserved. """A simple shell to inference the input data. """ from cmath import e from dataclasses import dataclass, field import logging import json import numpy as np import requests from PIL impor...
4b2348b541a576e78f86cdbe51f9531d26851341b07803400c418160d19443bd
Python
11,372
267
# SPDX-License-Identifier: Apache-2.0 # This file is cloned from microsoft/onnxruntime/tools/python and updated L57 by adding default dim value 1 # onnxruntime commit id: fdce4fa6af437b0b822958ab47b3b8f77f9e14ae import glob import os import shutil import numpy as np import onnx import onnx_test_data_utils from onnx ...
c1c2d766b90c0f5772e574b29b0516749fd9e3c1091eaf21429a2fd391ed43e1
Python
11,383
410
import pytest from kgx.graph.nx_graph import NxGraph from kgx.graph_operations import ( remove_singleton_nodes, fold_predicate, unfold_node_property, remap_edge_property, remap_node_property, remap_node_identifier, ) def get_graphs1(): """ Returns instances of defined graphs. """ ...
e6e5993522b7823e8b0b7cf3c973732e2119e0c2abc29cfd865cb2252f5b2ba8
Python
11,386
239
#!/usr/bin/env python # Import required modules from __future__ import print_function from future import standard_library standard_library.install_aliases() from builtins import str import os import argparse import subprocess import ICA_AROMA_functions as aromafunc import shutil # Change to script directory cwd = os....
fe402d6d65eb7172fef8eb42664548bcd746df4de1210c69b851ef755cf5e9ae
Python
11,389
238
import numpy as np from collections import Counter, defaultdict from time import time import re from glob import glob from sklearn.base import clone as CLONE import warnings from sklearn.exceptions import ConvergenceWarning import sklearn.metrics as metrics # Imputation from sklearn.experimental import enable_iterativ...
a9006e48e817a024f2cf1660f0fe0632f515df822d5f0d32a435c5df57ca3a06
Python
11,394
386
import os import json import tempfile import gzip from kgx.source import TrapiSource from kgx.transformer import Transformer from tests import RESOURCE_DIR, TARGET_DIR def test_read_trapi_json1(): """ Read from a JSON using TrapiSource. """ t = Transformer() s = TrapiSource(t) g = s.parse(os...
7a9ff920e585ce2da750f1388b143040bbc5c41e85792895d0a1ff2e5b5e1002
Python
11,396
250
# encoding=utf-8 import torch, math import torch.nn.functional as F def top_k_logits(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')): # This function has been mostly taken from huggingface conversational ai code at # https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with...
f89f96d591e651a9f4abb558332cc36919103ac7427330556b0804b20fe43da5
Python
11,399
270
# -*- coding: utf-8 -*- import json from datetime import datetime from catmaid.control.annotation import _annotate_entities from catmaid.control.annotation import create_annotation_query from .common import CatmaidApiTestCase class AnnotationsApiTests(CatmaidApiTestCase): def test_annotation_creation(self): ...
7881e7bbf98814905e12c8afea66c2b7c53ca808ca40d863195232501ff2c026
Python
11,400
319
from statistics import mean import numpy as np import math np.seterr(divide='ignore', invalid='ignore') def find_plane_equation(plane): """ Finds the plane equation of a plane :param plane: the plane to find the equation of :type plane: :any:`numpy.ndarray` :returns: the normal vector of the pla...
f1e93b60165794cf81843c906b264057cef0903dac920b585069cea935cff980
Python
11,400
317
from statistics import mean import numpy as np import math np.seterr(divide="ignore", invalid="ignore") def find_plane_equation(plane): """ Finds the plane equation of a plane :param plane: the plane to find the equation of :type plane: :any:`numpy.ndarray` :returns: the normal vector of the pla...
cb0f3d95d41ae70fb968a455d8eb1fd2d546c666e81d916012801940cd04baa8
Python
11,403
274
import pymonetdb import uuid from prov.model import ProvDocument from prov.dot import prov_to_dot import os import sys import json import argparse import re from provdbconnector import ProvDb from provdbconnector import Neo4jAdapter from neo4j import GraphDatabase # Environment variables for Neo4j credentials and con...
d9c74cc3e553929d60e9d2496ea8dcd57950b243375183d6413c111b48c2f5e7
Python
11,403
352
# tests/test_serve.py """Tests for JobManager auto-serve: claim loop, lifecycle wrapping, wait().""" import threading import uuid from typing import Any, ClassVar from unittest.mock import MagicMock from zndraw_joblib.client import ( Category, ClaimedTask, Extension, JobManager, ) from zndraw_joblib.e...
7ea9ac5720a950ccbfce6a6f99d372717c1b0f6adef00c4406be7d60d6b336a8
Python
11,411
393
#!/usr/bin/env python # coding=utf-8 # Copyright 2023 Statistics and Machine Learning Research Group at HKUST. All rights reserved. """A simple Multimodal chatbot implemented with lmflow APIs. """ import logging import json import time from PIL import Image from lmflow.pipeline.inferencer import Inferencer import num...
847c7777412235c16f0f9776574c0064e234aca5280f3f69e8c8cd4c4ea2acfd
Python
11,417
275
#!/bin/env python # Author: Qiyuan Zhao (zhaoqy1996@gmail.com) import os,sys from glob import glob import yaml import logging import time import pyjokes import multiprocessing as mp from logging.handlers import QueueHandler from joblib import Parallel, delayed # Add the parent directory to Python path to enable Reac...
6690b9b31233d4f8800ae0d45b959ff203deb5f1f90bf62cd36db24045a43d84
Python
11,425
285
# load Modules from PyQt5 import QtGui, QtWidgets, QtCore import pyqtgraph as pg import numpy as np import math from util.conf import cs_roi_params from util import colors from features.Feature import Feature from view.ImageView import ImageView from model.Object import Object class CellSelection(Feature): def _...