sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
19f62dcf3e2769a62891f519b5209b2d586acdf8a252ce6dd554c588a0e0b7b4
Python
6,135
169
# Copyright 2018-2020 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or...
9e557a3b629ff4b62195d3b9733f049dac430f7d44e2c5b7fe9ff9b67fd030f8
Python
6,135
145
from src.workflow import WorkflowRepresentation, WorkFlowSpecs, WorkflowResults, WorkflowBuilder from src.test_config import pipe_config, model_config from sklearn.pipeline import Pipeline from sklearn.dummy import DummyRegressor import pandas as pd from pathlib import Path import tempfile import yaml import pytest ...
cccdf8f9796c2c05ea90fecae4a0daff4e814aff6f11ae0f323084ccb29a0b2c
Python
6,136
176
from typing import Any from src import config_handler import pandas as pd from pathlib import Path from src.paths import Paths LOCATION = Path(__file__).parent VALIDATION_FILE = Path(LOCATION,'resources','FreeSurferColorLut.txt') def read_rois(roi_file,validate=True): """ Read the roi file and return a dictionar...
bcac090aa5b894eb95f3416d039e178a746d2b8d9356a0daf4d9f48f61c883fd
Python
6,137
180
from datetime import datetime import numpy as np import torch import os import time import sys from sklearn.metrics import roc_auc_score from glob import glob class AverageMeter(object): def __init__(self): self.reset() def reset(self): self.val = 0 self.avg = 0 self.sum = 0 ...
6c51befd05069be8d4a372713a40677fd2fdc78604c9556a955244a0613e0474
Python
6,140
171
import torch import wandb import numpy as np from tqdm import tqdm from matplotlib import pyplot as plt from typing import Optional from twoandahalfdimensions.utils.config import DataViewAxis, Config def train_step(data, label, model, opt, loss_fn, settings, do_step=True): data = data.to(**settings) pred, at...
0be5b356d82857cb16108bb760436d9822e7b8bdfd93ef008c946726f5d6b88e
Python
6,141
178
import numpy as np import torch def scale(x, scaler): """ Scales the input data using the provided scaler. """ # Apply the scaling transformation to the NumPy array x_scaled = scaler.transform(x) return x_scaled def scale_with_gold_standard(x, column_means, column_stds): """ Scales ...
f6f3c8a3451476105a01b01555256ad0ef60d69a03f360e5e87f5dcf6d93f7d2
Python
6,141
178
"""Helper functions for saving stimulus features.""" import numpy as np import os from hard_coded_things import featuresets_dict from features import Features from textgrid import TextGrid def get_feature(featureset, features_object): model_function, model_kwargs = featureset[0] modeldata = getattr(features_...
ba60a649127f19f624206dd75f17f434351c741338baedbdfc912c3939720fab
Python
6,146
146
import torch import numpy import matplotlib.pyplot as plt import bionetwork import pandas import seaborn as sns def generatePerturbe(Yin, refFullRaw, level): nrKO = Yin.shape[1] inputKO = Yin.repeat(nrKO, 1) perturb = numpy.eye(nrKO) numpy.fill_diagonal(perturb, refFullRaw.flatten() * level) inputK...
b1d7b04b9e0025b51a131e9f98486f71ae84314d5b737dadc5cf9ea37bf4b7b2
Python
6,147
193
from datetime import timedelta import numpy as np import pytest import pandas as pd import pandas._testing as tm class TestIntervalArithmetic: def test_interval_add(self, closed): interval = pd.Interval(0, 1, closed=closed) expected = pd.Interval(1, 2, closed=closed) result = interval +...
73ddbc481854581fb1026da05090e8bb5191eec09f4e082da67e2f83c98f4527
Python
6,148
174
#! /usr/bin/env python ############################################################################## ## DendroPy Phylogenetic Computing Library. ## ## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder. ## All rights reserved. ## ## See "LICENSE.rst" for terms and conditions of usage. ## ## If you use this wo...
9ee0cba14e6a7c20fb9207503a045cbb4b7b265c2391cbd33aff28113668fa40
Python
6,149
219
# -*- coding: utf-8 -*- """ Created on Sun May 1 17:33:44 2022 @author: jeanbaptiste """ import os import json import pycromanager_tessie as pmt from pycromanager_tessie.acquisitions import experiment # Start platform: platform = pmt.microscope.platform.Platform(load_synchronizer=True) # Set LED ring platform.neop...
413d78be826190d57df1478fffcc393b03fc587e17420b04dcad386703f2aa0b
Python
6,154
136
""" Rerun single cells in BGLibPy (for extra reporting and access to parameters to be modified) authors: András Ecker, Sirio Bolaños Puchet; last update: 01.2023 """ import os import gc import time import logging import numpy as np import pandas as pd import bglibpy from assemblyfire.config import Config import asse...
06ab96798a8d7382036bba936b548c9d3d0a92ec5474764356b17d22d786b3e0
Python
6,159
185
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_drop(idx): dropped = idx.drop([("foo", "two"), ("qux", "one")]) index = pd.MultiIndex.from_tuples([("foo", "two"), ("qux", "one")]) dropped2 = idx.drop(index) expected = idx[[0, 2, 3, 5]] tm.assert_index_...
ab04a5b1236b150ec6380501a6727c376844875c82d0b75cf0027b6d397ec176
Python
6,159
168
# ------------------------------------------------------------------------------------------------------------------------------------- # Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet): # ----------------------------------------------------------------------------------------------...
7eec79082cf83ade7045b354e40dbd615891a4d6fd8c61c41c98b25f36ab55bd
Python
6,160
189
# coding: utf-8 import torch import torch.nn as nn import torch.nn.functional as F def initialize_weights(m): if isinstance(m, nn.Conv2d): nn.init.kaiming_normal_(m.weight.data, mode='fan_out') elif isinstance(m, nn.BatchNorm2d): m.weight.data.fill_(1) m.bias.data.zero_() elif isi...
1054e41fc6213c7dd2cc23c3690db666251cd4921b96e3ec4748ad341056154c
Python
6,161
201
# Copyright 2024 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agre...
2d8d31bbebdc544525c5bbe6e9a6a4c2dc9f7dbbec1ef8d87e49f46a48378918
Python
6,163
145
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: mbejtka """ import numpy as np import h5py as h5 import matplotlib.pyplot as plt from Fig2_traub_data_kcsd_column_figure import (prepare_electrodes, prepare_pots, do_kcsd) import kCSD2D_reconstruction_from_npx as npx from scipy.signal import filtfilt, butter ...
3f1e7f81840f9a41a19d64ed9150b82d9fe6aa80214117628ef2fdfe5f479d9b
Python
6,166
182
__all__ = ["GlycoPeptideData", "GlycoPeptideDataConverter", "GlycoPeptideDataBatch"] from typing import List, NamedTuple, Optional, Sequence, Union import dgl import torch import torch.nn.functional as F from torch.nn.utils.rnn import pad_sequence from ....chem.gpep.glycans import ( GlycanNode, Monosaccharid...
939f565bd735092da3c00bf4631a033486e2afd838c5085da7546dd0d1009e7c
Python
6,167
197
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_to_numpy(idx): result = idx.to_numpy() exp = idx.values tm.assert_numpy_array_equal(result, exp) def test_array_interface(idx): # https://github.com/pandas-dev/pandas/pull/60046 result = np.asarray(idx) ...
a92c6da7a4705438e0040ef65ae613619caf3eefbebe9ccad3638d472b4c5da9
Python
6,168
164
""" Onmt NMT Model base class definition """ import torch.nn as nn class BaseModel(nn.Module): """ Core trainable object in OpenNMT. Implements a trainable interface for a simple, generic encoder / decoder or decoder only model. """ def __init__(self, encoder, decoder): super(BaseModel, s...
96dd9602ed6e0b9a5e6170cd499caf7421768ee33171d15c76b4df0dcb7f59d4
Python
6,171
205
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
817d08a82960941f0f4256cbf681838aa091c2e1f7d9f9b7b7e44563fa2b68ca
Python
6,172
171
import importlib import operator import numpy as np import pytest from pandas.compat._optional import VERSIONS import pandas as pd import pandas._testing as tm from pandas.core.computation import ( check, expr, expressions, ) from pandas.core.computation.engines import ENGINES from pandas.util.version im...
4e35306a2a3aa058864ce1f2648f022a7969456fb50f1cb685339bf882ac2b53
Python
6,174
125
"""Prepare the real OrganAge example from the CC0 PRIDE deposit PAD000022. Run from the repository root: uv run --with openpyxl python tutorials/data/prepare_pad000022.py \ --source-dir /tmp/pad000022 --output-dir hf_static_data/repo """ import argparse import hashlib import json from pathlib import Path ...
16368ac8de653ae7ce857fa18597a5c9b40aae16fe002d591089cecc8a61edba
Python
6,175
188
# Copyright 2026 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agre...
2686aa4b108a7aab39db581c731a8ac7502d57515dd34a8b0cd74dfd9d5e8e5f
Python
6,177
180
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.tests.base.common import allow_na_ops def test_unique(index_or_series_obj): obj = index_or_series_obj obj = np.repeat(obj, range(1, len(obj) + 1)) result = obj.unique() # dict.fromkeys preserves the order ...
ecad109933d8d0e81087aecd04b232bb2ede361f71185fd290119a75df400a0a
Python
6,177
176
import reverb import tensorflow as tf from rl_toolkit.networks.models import DuelingDQN from rl_toolkit.utils import VariableContainer from ...core.process import Process class Server(Process): """ Learner ================= Attributes: env_name (str): the name of environment port (i...
73a82721f26c64ba036a997cb2826bdde3b4991c87d35d2d3eed4620cd0b093e
Python
6,178
151
import numpy as np class Chromatogram(): """ Representation of a chromatographic peak Contains the related peak object, the size and margin of the chromatogram and its dataframe as a numpy array. """ def __init__(self, peak, size, margin, dataframe): self.peak = peak self.size = ...
487801fa6ebf72fb66944c008b528c4b386d9654cac1d024e30e14d60cc2a4f9
Python
6,180
198
__all__ = ["NGlycan"] import functools from typing import Optional, Tuple from .glycans import GlycanNode NGlycanCore5 = Tuple[GlycanNode, GlycanNode, GlycanNode, GlycanNode, GlycanNode] NGlycanBranches = Tuple[GlycanNode, ...] SYMBOL_HEX = "H" SYMBOL_HEXNAC = "N" SYMBOL_FUC = "F" SYMBOLS_BISECTING = ("N", "X") ...
c3e4b4bcc374460cb46e52909de5fb7a8e811972b5b27beec86562a53f23b889
Python
6,180
140
"""Correctness tests for the GAE implementations (PyTorch loop and Triton kernel). The Triton tests require CUDA and an importable triton; they are skipped otherwise (e.g. on CPU-only CI). The PyTorch-path tests always run. """ import os import subprocess import sys import pytest import torch from rl_games.triton_c...
22ec187313be8f49e1f341b893956b07e7616ef132a0f6ba084d6e1a1d9f3da4
Python
6,181
140
"""DataFrame preprocessing must preserve sample identity and original values.""" import warnings import numpy as np import pandas as pd import pytest from pyaging.preprocess import df_to_adata, epicv2_probe_aggregation def test_dataframe_stays_on_host_when_cupy_is_available(monkeypatch): from types import Simp...
ea5cfa9ed12cd0292f44b254f8727cfcb2c891b8081d6822cc93f98d5e04f70f
Python
6,181
145
"""Defines DataSequence object.""" import numpy as np import itertools as itools from interpdata import sincinterp2D, gabor_xfm2D, lanczosinterp2D class DataSequence(object): """DataSequence class provides a nice interface for handling data that is both continuous and discretely chunked. For example, semanti...
148cbea60149601c3cef7681a82cb56394297f84f813a0e874f0d5850663557a
Python
6,182
194
#!/usr/bin/env python3 # -*- encoding: utf-8 # JN 2014-08-30 # convert ncs files to edf files # this converter does as of now (2014-08-31) # not follow all EDF+ rules, but is compatible with # EDF. In particular, no time channel is kept here # further work is required from __future__ import print_function, division i...
252d9f7dcf577bae443e122585d9fbeb9f9f686166d27a9e62713edcd859f8f2
Python
6,182
178
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 5 11:09:36 2023 @author: jinani This code is a working example of estimating the receptive fields of a V1 neuron recorded in cats for the fist pass-without any cropping. First part of the code loads the cell responses for natural images and ca...
a81d1362067dd5b558444d2aa7acc4ffddf4b9fd9eec7a8632722bc85091aa3f
Python
6,184
193
from __future__ import annotations import datetime as dt from typing import ( TYPE_CHECKING, Any, cast, ) import numpy as np from pandas.core.dtypes.dtypes import register_extension_dtype from pandas.api.extensions import ( ExtensionArray, ExtensionDtype, ) from pandas.api.types import pandas_dt...
2cf332fc5489b2a9905f998ab464d2e1d3ce8e42f5a2c5572ae9561d91381d75
Python
6,185
215
import os import pathlib import random import sys import unittest import anndata as an import numpy as np import pandas as pd import torch from torch.utils.data import * random.seed(42) from os.path import abspath, dirname, join sys.path.append(join(dirname(abspath(__file__)), "..", "src")) from data import * from ...
fe386395f244ff1ab19268cb0e98f2a0bfb69497f5c2d5421426886c39de242d
Python
6,186
159
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master...
59b46f9a11a10ed925dbc7b856207dc2e12b259ac69e22f59b7a752b0f9cb8b6
Python
6,192
226
import pandas as pd import numpy as np import itertools import random from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import MinMaxScaler from sklearn.metrics import mean_squared_error from sklearn.metrics import mean_absolute_error from...
38b47c837a9f3331df40a029dcb0a35325714c8b2aab6ce43b2604ceca4be730
Python
6,193
188
import numpy as np import torch import torch.nn.functional as F import sys from scipy.interpolate import LinearNDInterpolator, NearestNDInterpolator from scipy.spatial.qhull import QhullError class DataInterpolation: def __init__(self, device, num_channels, nx, ny, nz): self.__ny = ny self._fac_...
b3ad39953d432f5f7da71cc151fb3816d169afb78c22f81e13209ca00f01d576
Python
6,196
207
# coding: utf-8 """ class for channel table """ # JN 2014-12-16 from __future__ import division, print_function, absolute_import import logging logger = logging.getLogger(__name__) from PyQt5.QtCore import Qt, QAbstractTableModel, QModelIndex, QVariant NCOLS = 16 OBJECT, FNAME, POS_SP, NEG_SP, SORTED_SES, EXTR,\ S...
7365ac60421a6aeb7836807c2a7577d9eaf97895d7d27f43d2d6c86135ae6dc3
Python
6,200
131
import pandas as pd import numpy as np import scipy as sp from tqdm import tnrange, tqdm_notebook def label_trials(log_df, conds): whisker = log_df['block_type'] == 'Whisker' visual = log_df['block_type'] == 'Visual' correct = log_df['correct'] == 1 lick = log_df['response'] != 0 lick_right = log_df['...
ab4c6b8d9fa720409ad03a097bcbd84651366105f22a740ff4a7bcdd46009272
Python
6,200
135
"""Cardiac MR Fingerprinting signal model (EPG).""" from collections.abc import Sequence import torch from mrpro.operators.models.EPG import DelayBlock, EPGSequence, FispBlock, InversionBlock, Parameters, T2PrepBlock from mrpro.operators.SignalModel import SignalModel class CardiacFingerprinting(SignalModel[torch....
034272820a5e1f496fb5638f177fad52236e563cc28c2a64cea84cc119ccead2
Python
6,201
179
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 3 00:51:46 2023 @author: s205272 """ import numpy as np def normalize_mi_ma(x, mi, ma, clip=False, eps=1e-20, dtype=np.float32): if dtype is not None: x = x.astype(dtype,copy=False) mi = dtype(mi) if np.isscalar(mi) else mi...
923d0027880965a935988d32df441f039f37ba060c31dcb18f21211b693980d8
Python
6,201
140
import numpy as np import pytest from pandas.errors import Pandas4Warning from pandas.core.dtypes.dtypes import CategoricalDtype import pandas as pd import pandas._testing as tm class TestCategoricalDtypes: def test_categories_match_up_to_permutation(self): # test dtype comparisons between cats ...
debf900a24e3084525eec01779eebcdd57eb458187ece0684a487da3de2c3858
Python
6,201
163
# -*- coding: utf-8 -*- """ Created on Mon Jul 11 11:26:07 2022 @author: fm02 epoching is adapted from setareh10/semnet-project/sn_epoching.py """ import sys import numpy as np import pandas as pd import os import mne from importlib import reload path = "/home/fm02/Decoding_SDLD/SourceSpaceDecoding_SDvsLD" os.chdir...
3bbf2c847bd98ef3934d5f6e8426dafb5471967264572458708411839d61206f
Python
6,203
194
#### create branch- and depth-specific pcfg import re, sys, os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts')) import model MAX_ITER = 20 #### 0) read model from stdin mCr = model.Model('Cr') mCC = model.CondModel('CC') mCu = model.CondModel('Cu') mX = model.CondM...
4423cb7d26191469e06a3d70836c8099071564adce47ac90e3fe1f1a67981ee2
Python
6,203
166
import torch import numpy import matplotlib.pyplot as plt import time import bionetwork import plotting import pandas from scipy.stats import pearsonr import seaborn as sns from scipy.stats import pearsonr import saveSimulations #Load network networkList, nodeNames, modeOfAction = bionetwork.loadNetwork('data/KEGGnet-...
5cd3c10bfbdf368238f8450ab766a0df8b2eac6f25199ad34fd4db8c23ded79d
Python
6,203
187
# -*- coding: utf-8 -*- import torch import random import inspect import numpy as np from itertools import islice, repeat import os def check_path(path, exist_ok=False, log=print): """Check if `path` exists, makedirs if not else warning/IOError.""" if os.path.exists(path): if exist_ok: lo...
6f38445d71449f892c3b03f8ba7e06ff31fb35300ba16d7fceedeaaffa183906
Python
6,203
222
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ adapted from https://github.com/FNNDSC/pl-fetal-brain-assessment/blob/main/fetal_brain_assessment/resnet_architecture.py """ INPUT_SHAPE = (217, 178, 60) # Identity Block for ResNet def id_block(X, f): from keras.layers import ( Conv3D, BatchNo...
d7be1711660cbdfb8dd6f70b3342973adea6fbccf21810dbd511a069cb33da21
Python
6,203
198
"""Module for parallel processing of pdb files into structural info""" from argparse import ArgumentParser import logging import os import sys from time import time from typing import Tuple import h5py from hdf5plugin import LZ4 import numpy as np from progress.bar import Bar from pyrosetta.rosetta.core.pose import P...
8dc8add21555e756fc4bf3ddf6886a208d2461876eb1a59fe8de043a3aa64aed
Python
6,204
187
from __future__ import absolute_import from __future__ import print_function import tarfile import os import sys import shutil import hashlib from six.moves.urllib.request import urlopen from six.moves.urllib.error import URLError, HTTPError import requests from generic_utils import Progbar from modac_utils import g...
1f1c3349800c35a52dda44bbd470daa558bfa5f22c3a3ffe061e95b7064e138a
Python
6,206
142
#!/usr/bin/env python """ Given: 1. single cell UMI, BC file (ccs -> umi, bc) 2. collapse group.txt (ccs -> pbid) 3. SQANTI classification (pbid -> transcript, isoform, category) 4. optional ontarget file (pbid -> ontarget or not) Output a collated infor file that is: <ccs>, <pbid>, <transcript>, <ge...
f07939f4c9934f4bdeacca09f77b4f4763a7c7f8c66df32e63455374dee2edb2
Python
6,206
109
# Copyright 2019 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...
b0379fb8c9caf5b1aaecdd061f267771f804160d25f1d6a1250ace57a339ea29
Python
6,208
193
import requests from PIL import Image from neuronbridge.model import * class Client: def __init__(self, data_bucket="janelia-neuronbridge-data-prod", version="current"): """ Client constructor. When the client is created, it retrieves the configuration for the specified version. ...
76d90e98b30e252a0753ee6a93da193b22d7fe38fabb3a1f4aa7f81e104cc71c
Python
6,210
179
""" Create seaborn plot for discriminator predictions on real data Author: Rebecca Riley Date: 03/15/2023 """ import math import matplotlib.pyplot as plt import numpy as np import sys sys.path.insert(1, "../") from discriminator import OnePopModel from generator import Generator from global_vars impor...
6c41b22e5a74105debb61477fe75c402c66155d764f8f540f40c5e17600bd0f2
Python
6,211
202
""" Tests for the Skew and Kurt evaluation metrics. Verifies that: - Skewness and excess kurtosis are near 0 for standard-normal z-scores. - Skewness is positive for right-skewed z-scores. - Excess kurtosis is positive for heavy-tailed z-scores. - Both metrics handle NaN and Inf values gracefully. """ import numpy ...
5bf63421f50efeb09c43736f2d33c120d41187ac6b4c334057b6fac0b8765382
Python
6,212
150
from initialization.config import * import numpy as np import pandas as pd from typing import Optional, List from sklearn.preprocessing import MinMaxScaler, StandardScaler def scale_features( df: pd.DataFrame, factors: List[str], method: str = SCALING_METHOD, average_time_windows: bool = AVERAGE_TIM...
48a1432136cae0284c9677281c0c221a5a9be159b6a637f711972121ec623ca1
Python
6,213
149
# Copyright 2018-2025 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or...
8adb24149695759235722ae2d10d5c77270ea34f43c04f2f640588e440a99163
Python
6,215
137
from botocore.client import Config import ibm_boto3 from io import StringIO import types import os import pandas as pd from sqlalchemy import create_engine import sqlalchemy.orm as orm import sys import json sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.abspath(os....
628d95360846c9ef35e8d5817f7270b37934e4a01f21d611bdd50bf7148ad4f1
Python
6,218
147
''' Contains the clutter class ''' import warnings warnings.filterwarnings("ignore") import os from utils_mod import shlex_cmd class Clutter: ''' A class that contains all of the paramters for a single clutter image ''' def __init__(self, clutter_sample, composition_type='occlusion'): ''' ...
8117198fb06631dac21926f10e21c61910d8a1096e7ed6f19042f400632d482c
Python
6,218
151
"""Tests for filters.""" import pytest import torch from einops import repeat from mrpro.utils.filters import filter_separable, gaussian_filter, uniform_filter @pytest.fixture def data(): """Create a simple 3D tensor with a single voxel set to 1.0.""" data = torch.zeros(1, 1, 5, 5, 5) data[..., 2, 2, 2] ...
f28f9e5d59f75e02e754a091fe53520f79683fce171d3e8642cec700b791ddfa
Python
6,218
168
"""Public caller regressions run in subprocesses to bound native hangs.""" import os from pathlib import Path import signal import subprocess import sys import pytest SCRIPT = r''' import numpy as np import sys import threading import logging from concurrent.futures import ThreadPoolExecutor import MACS3.Signal.Call...
c69d7e5ba06f710fbb0afd363e383cac397efac1c49b276ab3d35539cc430b7f
Python
6,221
161
"""Session 22 — god-class drain, first pass: persistence verbs. The ``save_model`` / ``load_model`` / ``save_experiment`` / ``load_experiment`` verbs on ``Experiment`` no longer delegate to ``self._legacy``. They are now thin wrappers around the stateless helpers in ``pycaret.persistence``. These tests lock that contr...
d0ca66a5a8f34b784681d5fb81d6a526acd68a1699cdc6f66ad9a02331751ffe
Python
6,226
179
''' backcheck_publishedurl.py This program will backcheck publishedURL to neuronMetadata ''' import argparse from operator import attrgetter import sys from colorama import Fore, Style import jrc_common.jrc_common as JRC # Database MONGODB = 'neuronbridge' DATABASE = {} def terminate_program(msg=None): ''' ...
3fdfbb0d805b1df384bbf667ede010442668b4fde0cb6cfae621074577e10ba2
Python
6,227
146
import sys import re from storestate import Sign, StoreState, getUnkWord import numpy import scipy.sparse import collections import math ################################################################################ class IndexMap(dict): def __missing__ ( this, key ): this[key] = len(this) return this[key...
44f98c16943fa3e858d67c26cd9008634d16336256bf748dbda0dc8644c66b03
Python
6,227
103
#!/opt/local/bin/python2.7 import os from os import path import argparse import base.surfaces as surfaces import logging from base import loggingUtils from base.kernelFunctions import * from base.affineRegistration import * def main(): parser = argparse.ArgumentParser(description='runs surface matching registra...
315089cfe3102f3a9c8fb4be91eef0c070db1521270d31175268728feffd0c51
Python
6,228
134
# License: see [LICENSE, LICENSES/legged_gym/LICENSE] import os from datetime import datetime from typing import Tuple import torch import numpy as np from rsl_rl.env import VecEnv from rsl_rl.runners import OnPolicyRunner #, AMPOnPolicyRunner from legged_gym import LEGGED_GYM_ROOT_DIR, LEGGED_GYM_ENVS_DIR from .he...
f773a52233c414e80f900924248dae43fbe5a8a552e006bee95ca9bbb1d36203
Python
6,228
215
import h5py import numpy as np import xml.etree.ElementTree as etree from typing import Dict, List, Optional, Sequence, Tuple def load_file_T2(fname: str) -> Tuple: """ Load T2 fastmri file. Parameters: ----------- fname : str Path to the h5 fastmri file. Returns: -------...
9b461f150cb090b721906e05548f627ba7417dda0f9e9f40b65e86d07f978bde
Python
6,233
165
"""Public API and CLI regressions for #801, part of #757.""" import gzip from pathlib import Path import struct import subprocess import sys import pytest from conftest import macs3_env, no_core_dumps def run_probe(tmp_path, path, source): script = tmp_path / "probe.py" script.write_text(''' from pathlib i...
c3cd3adc3e7ac0e6f6866093f7619da091d86ce996ebb69167e9dc7abcb8f617
Python
6,233
275
import operator import pytest import pandas as pd import pandas._testing as tm @pytest.fixture def dtype(): """A fixture providing the ExtensionDtype to validate.""" raise NotImplementedError @pytest.fixture def data(): """ Length-10 array for this type. * data[0] and data[1] should both be n...
52ff16b43052e4b8d657c9f803643bb4ee9cae37b3654a151174f6d37e523318
Python
6,234
167
# Copyright 2018-2021 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or...
7f932c99323e76d020b69e9ce6d032d41c88a5d3de73c7d349d6a7e5ddc249d8
Python
6,244
139
"""Public compiled-track and CLI regressions for #802 (part of #757).""" from pathlib import Path import random import pytest from MACS3.Commands import callpeak_cmd, callvar_cmd from MACS3.Signal import FixWidthTrack, PairedEndTrack @pytest.mark.parametrize("command", [callpeak_cmd, callvar_cmd]) @pytest.mark.par...
071a903583df09f26ba6fe3162aeed20e5a09bbef8ade91cf7a97f6820f8d0f8
Python
6,248
231
"""Plot module for gradec.""" import math import os import matplotlib.pyplot as plt import numpy as np from matplotlib import colormaps from neuromaps.datasets import fetch_civet, fetch_fsaverage, fetch_fslr from surfplot import Plot from surfplot.utils import threshold from wordcloud import WordCloud from gradec.fe...
3f7b776a7b66702db884449d4026103bd7be3a35f2126fb765a5a1863bbc190b
Python
6,249
206
import os import numpy as np import matplotlib.pyplot as plt from src.models import NeuralKalmanFilter, KalmanFilter from src.utils import * plt.style.use('ggplot') device = "cpu" print(device) # hyper parameters seq_len = 1000 inf_iters = 20 inf_lr = 0.1 learn_lr = 1e-5 # create the dataset of the tracking prob...
889853dcb05ea03b14e1e4e38fe54bb265e6eb8d3d61f4c6be048321f742b906
Python
6,252
192
# Copyright 2018-2023 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or...
42d24495d38499e3353426ca425894e81d691780cd45b9c28228590c636bc1aa
Python
6,261
124
# Copyright (c) 2018-2023, NVIDIA Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of condit...
9dea04b837dbe66e11924750331c5490621ac1cf90d0a4a134fca805b35cf49d
Python
6,262
210
import math import numbers import random import numpy as np import torch from PIL import Image, ImageFilter from torchvision import transforms class Compose(object): def __init__(self, transforms): self.transforms = transforms def __call__(self, img, mask): assert img.size == mask.size ...
3d6e24814374c277d056c91799bc5ea6787f7e1c3f0208feaece26ce71ea019e
Python
6,263
177
import numpy as np import pytest from pandas._libs.tslibs import IncompatibleFrequency import pandas as pd import pandas._testing as tm @pytest.fixture def date_range_frame(): """ Fixture for DataFrame of ints with date_range index Columns are ['A', 'B']. """ N = 50 rng = pd.date_range("1/1...
1c988b9f1732d67f6061e4203196ea153da2b99db9fae8b890622a617691790b
Python
6,266
177
from collections import defaultdict import numpy as np import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize( "data, categories", [ (list("abcbca"), list("cab")), (pd.interval_range(0, 3).repeat(3), pd.interval_range(0, 3)), ], ids=["string", "interv...
b57872509a27d1068e1122f4819c72182e122585569d73c21b8905c6ed26f589
Python
6,269
160
import torch import numpy import matplotlib.pyplot as plt import bionetwork import pandas from scipy.stats import pearsonr import seaborn as sns import copy import matplotlib.patches as patches from matplotlib import cm from matplotlib.colors import ListedColormap def loadModel(refModel, fileName): #work around to...
1c1b067c4fbf8b5e84d16f238ce075c7035054e1ab39c5526622ff9b65947191
Python
6,271
186
import torch.nn as nn import torch import torch.nn.functional as F import numpy as np class MaskedCosineLoss(nn.Module): """Masked cosine loss between angles.""" def __init__(self): super().__init__() def forward(self, pred, tgt, mask): mask = mask.bool() p = torch.masked_select(...
ffebd9df844e70791678fd0fe2bf6021c3e4fec1233c9e12ac69f2cdcccda92e
Python
6,272
199
# coding: utf-8 import torch import torch.nn as nn import torch.nn.functional as F def initialize_weights(module): if isinstance(module, nn.Conv2d): nn.init.kaiming_normal_(module.weight.data, mode='fan_out') elif isinstance(module, nn.BatchNorm2d): module.weight.data.fill_(1) module....
c8e6aba4f43de25ed667c80e4970793f3e2acef2b67cca6b02939ba228cd8f7a
Python
6,274
210
# Copyright 2018-2025 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or...
5ae55bbad9fadb7e15001c8f455333b195fa5a52b00aae265a654d5ff83e5271
Python
6,275
157
import os, sys, re, torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np def read_dictionary(filename): d = {} with open(filename, 'r+') as f: for line in f: line = line.strip().split('\t') d[line[1]] = int(line[0]...
03e455bee4751fcd113770f97c2a078c13cfe78bcd1e0da817269f3fd37fea20
Python
6,280
174
import numpy as np, matplotlib.pyplot as plt, sys import pumpprobe as pp from scipy.optimize import lsq_linear plt.rc('xtick',labelsize=5) plt.rc('ytick',labelsize=5) unc31 = "--unc31" in sys.argv add_s = "_unc31" if unc31 else "" funa = pp.Funatlas(merge_bilateral=False,merge_dorsoventral=False,merge_numbered=False...
e2a3d104a160ba09720421c56a177dfae631ec113703c5e671ed5228c4b8dd4f
Python
6,282
175
import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import FloatingArray @pytest.mark.parametrize("box", [True, False], ids=["series", "array"]) def test_to_numpy(box, using_nan_is_na): con = pd.Series if box else pd.array # default (with or without miss...
6b8d5b5cf28a79940f337995930fab793f202b3f435b59fed2f1c89cc6a26ac3
Python
6,283
189
import numpy as np import scipy as sp import scipy.interpolate as interp try: from vtk import vtkPolyDataReader, VTK_ERROR gotVTK = True except ImportError: print('could not import VTK functions') gotVTK = False import os # General surface class class Grid: def __init__(self, gridPoints=None): ...
1eaf9dc4290810d839f2122c87a429fcb8d46e39c7a2116e1694d8e9fb04f0a6
Python
6,285
143
import subprocess from os import path as op from importlib import reload print(__doc__) # wrapper to run python script via qsub. Python3 fname_wrap = op.join('/', 'home', 'fm02', 'Desktop', 'MEG_EOS_scripts', 'Python2SLURM.sh') job_list = [ # # Neuromag Maxfilter # {'N': 'SemCat_TimeG...
b90028e863eaf71ccbbfca096bb060818aea750bba513e94a02bdfb2b5346bc4
Python
6,287
174
import numpy as np import pytest from pandas._libs import index as libindex import pandas as pd import pandas._testing as tm class TestGetSliceBounds: @pytest.mark.parametrize("side, expected", [("left", 4), ("right", 5)]) def test_get_slice_bounds_within(self, side, expected): index = pd.Index(list...
3669f7db111958a410e3ecc9615d0ca6defcdb865379551376b02a59b8481379
Python
6,296
214
#!/usr/bin/env python from __future__ import print_function, division import numpy as np import pandas as pd from rdkit import Chem from rdkit import rdBase from rdkit.Chem import AllChem from rdkit import DataStructs import rdkit.Chem.QED as QED from MCMG_utils import scripts as sascorer import pickle # from chemprop...
513004d7752d57e48cf63171144d3a0a15e5e31cef3dbf564c54d4ace4d19e01
Python
6,303
179
from datetime import datetime import zoneinfo import pytest from pandas.errors import NullFrequencyError import pandas as pd import pandas._testing as tm class TestDatetimeIndexShift: # ------------------------------------------------------------- # DatetimeIndex.shift is used in integer addition def ...
29029d983d70ffaf2a7bb91a1dfc61fcc8f8eb2269a85163eae3e21577f19813
Python
6,304
150
import torch import torch.nn as nn import numpy as np import rl_games.algos_torch.torch_ext as torch_ext class GeneralizedMovingStats(nn.Module): ''' Updates moving statistics with momentum ''' def __init__( self, insize, impl='mean_std', decay=0.99, max=1e5, eps=0.0, perclo=0.05, perc...
47bb1822e4aebbd4b416848bec53fc018601012800d1da90f8567df0fa0faa69
Python
6,306
186
from __future__ import print_function, absolute_import, division import json import numpy as np import os from PIL import Image, ImageDraw from collections import namedtuple data_folder = 'semantic_segmentation_images_annotations/Images_and_Supervisely_Annotations/' folder = 'json' folder_masks_anatomy_inst = 'mask_an...
9b9449e3e6c53f0fe6b4018e2eb2f15466f9a2c67e47c98b8ffc64a218281502
Python
6,307
159
# this module creates objects of the different models import tensorflow as tf from tensorflow.keras import models from tensorflow.keras import layers from tensorflow.keras.applications import ( VGG16, VGG19, Xception, ResNet50, ResNet50V2, ResNet101, ResNet101V2, ResNet152, ResNet152V2, EfficientNetB0, Eff...
6591247b0021bb7c70791e22bd6b7258314978f4a348dbcefc1daa65f25bd82c
Python
6,314
150
"""Diagnosis normalization and longitudinal (temporal) label correction. Ports the labeling logic from `Dataset_MRI.ipynb` / `Dataset_PET.ipynb` (see `docs/legacy-notebooks-inventory.md`), preserving its scientifically meaningful decisions: - The demented/not-demented regex classification, including treating "uncer...
a065de43a2d0ea4fb9a4072b387ed52b5872b21aae65c261f9d2a597c7332a5b
Python
6,316
182
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_reindex(idx): result, indexer = idx.reindex(list(idx[:4])) assert isinstance(result, pd.MultiIndex) assert result.names == ["first", "second"] assert [level.name for level in result.levels] == ["first", "second...
a448879edc625f6e219fa2e324cb3f9c7b34b05478064d564ae4b0eb8baa1e9b
Python
6,316
190
from __future__ import print_function, absolute_import, division import json import numpy as np import os from PIL import Image, ImageDraw from collections import namedtuple data_folder = 'semantic_segmentation_images_annotations/Images_and_Supervisely_Annotations/' folder = 'json' folder_masks_mix = 'mask_mix' folder...
eccf77a1e317d186a6793a95ba949ef5b48c976ed435d7c9c88ca5fdeea4b853
Python
6,317
119
# Copyright 2019 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...
e6e2d83e0ed1384d615213a426d43556650048ad45556ad52e5d3a35f226d514
Python
6,318
162
# Copyright 2026 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agre...
a96531cb54b3fdaf92fe668580163d9a9ac132c4d9a40f5b1784d8c9d0ff60b4
Python
6,322
196
import importlib import sys import torch import torch.nn as nn import windseer.utils as utils from .ModelBase import ModelBase class ModelStacked(ModelBase): ''' Experimental model consisting of multiple stacked models. ''' def __init__(self, **kwargs): super(ModelStacked, self).__init__()...
7012094b810e27c9f4f8e69944cf5f8948ed570f8bf569de6a21af9a2c6f8b67
Python
6,323
173
from datetime import datetime import numpy as np import pytest from pandas.errors import OutOfBoundsDatetime import pandas as pd import pandas._testing as tm class TestSeriesClip: def test_clip(self, datetime_series): val = datetime_series.median() assert datetime_series.clip(lower=val).min() ...