sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
15b0af15edb20a0b9e33126c50282aa7b3a860425cea9bf48156b5f18baf2c01 | Python | 2,615 | 58 | """The adaptive LR controller needs an unbiased Gaussian KL in every dtype."""
import pytest
import torch
from rl_games.algos_torch.torch_ext import policy_kl
@pytest.mark.parametrize('dtype', [torch.float32, torch.float64, torch.float16, torch.bfloat16])
@pytest.mark.parametrize('sigma', [0.2, 0.01, 0.001])
def te... |
d8c0b1664ed6f73f8c37aa02fe9d91048d7d41a82572d7f396efef6e970df611 | Python | 2,616 | 76 | import numpy as np
import torch
from progres.chainsaw.src.domain_assignment.sparse_lowrank import greedy_V
class BaseAssigner:
def __call__(self, y_pred, uncertainty=False):
assert y_pred.ndim == 2
if torch.is_tensor(y_pred):
y_pred = y_pred.detach().cpu().numpy()
return self.... |
c92ede5294c235882f49bc88576b2e4ae005f39207a29ab914da030b4b138a2e | Python | 2,617 | 92 | from math import floor
class Config():
def __init__(self) -> None:
self.defaultConfig()
pass
def defaultConfig(self,):
self.displayINFO()
self.subINFO()
self.expINFO()
self.connectINFO()
self.tkinterINFO()
pass
def sub... |
4c35e9eb97f1b380564b18928606fb0d097bfc22ed70e773344ddd072723e302 | Python | 2,620 | 73 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 100
px = 1 / plt.rcParams['figure.dpi'] # pixel in inches
fig_size = (700*px, 500*px)
label_fontsize = 1200*px
fig_size = (700*px, 600*px)
legend_fontsize = 1200*px
xy_label_fontsize = 1200*px
tick_fontsize = 1200*px
t... |
ed02e0bff36c3ef1dfdc258a1b8b75126e57d961ba9dc9e40a3fa36c05a94773 | Python | 2,620 | 65 | # Copyright 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 agre... |
7b2b1125fb84d9ff01e69077f1ca1e6847be21683e26e9c4d6e6f20e0914cc3e | Python | 2,621 | 90 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 30 09:27:48 2023
@author: nrq2
"""
import scenicplus
import scanpy
import pycisTopic
## 1. Initialize cisTopic object
from pycisTopic.cistopic_class import *
from pycisTopic.utils import *
from pycisTopic.lda_models import CistopicLDAModel
import p... |
09fd08e7a4ebc5e153f8254e72912627ebf700ed9577d2107b3114c0404bb1e0 | Python | 2,624 | 91 | """
optimization.py
Created February 17, 2021
Methods related to optimization.
"""
from typing import Callable, List, Optional, Tuple, Union
from ecgdigitize.image import GrayscaleImage
def otsuThreshold(image: GrayscaleImage) -> float:
"""
A Threshold Selection Method from Gray-Level Histograms - Nobuyuki... |
932f2ece5e07d0e7804d35adfee7f841d4e99608c088ed543877f54ff1cf5b8d | Python | 2,624 | 59 | from pkg_resources import resource_filename
import jieba
import msgpack
import gzip
DICT_FILENAME = resource_filename('wordfreq', 'data/jieba_zh.txt')
ORIG_DICT_FILENAME = resource_filename('wordfreq', 'data/jieba_zh_orig.txt')
SIMP_MAP_FILENAME = resource_filename('wordfreq', 'data/_chinese_mapping.msgpack.gz')
SIMPL... |
aae339e87483bb155da217191e4cc5e3bc0e3e007e981d7e14a5e0d64bafaa7f | Python | 2,626 | 74 | """
.. module:: image_manager
:platform: Linux, Windows
:synopsis: Manager for handling image data (volumes and masks)
.. moduleauthor:: Fredrik Nysjo
"""
import image_utils
import image_nifti
import image_dicom
import numpy as np
class ImageManager:
def __init__(self):
self.volume = None
... |
98ec438fdba74a4aa84adfa6e9576e8bab7a59d2835d1e7345d34bfc7178b85b | Python | 2,627 | 56 | # -*- coding: utf-8 -*-
"""
Expectation-maximization brain segmentation
NOTE: if no graphical interface, needs xvfb-run
"""
import os
import time
from app.utils import get_exitcode_stdout_stderr, end_execution, wrap_string
import logging
logger = logging.getLogger(__name__)
def EMsegment(im_t1_path, output_path, sli... |
a77ce594b8eeef838d79ee832ea5839ae27e2e32482eb9f2172ecb733466c68e | Python | 2,628 | 81 | #!/usr/bin/env python
import os, sys
from Bio.SeqRecord import SeqRecord
class LazyFastqReader:
"""
Like LazyFastaReader except works with fastq!
"""
def __init__(self, fastq_filename):
self.f = open(fastq_filename)
self.d = {}
while 1:
line = self.f.readline()
... |
d1d146e825b73290785f78e517e916d77e658611fff6d67cbc3144b98d279390 | Python | 2,628 | 74 | #! /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... |
1ec5dd197bbdb0d82f88be4068236e6f77ead7a00ce8452147142e1bcc4cfd89 | Python | 2,630 | 69 | import importlib.resources
from PyQt6 import uic, QtCore, QtWidgets
class AnalysisView(QtWidgets.QWidget):
filter_changed = QtCore.pyqtSignal(dict)
plot_changed = QtCore.pyqtSignal(dict)
slot_changed = QtCore.pyqtSignal(dict)
pipeline_changed = QtCore.pyqtSignal(dict)
def __init__(self, *args, *... |
5dff1344878a9e2a91ae161aa82b834a5eb8bc0403eed1ef9f59424b1f56fbe7 | Python | 2,630 | 90 | import numpy as np
import pandas as pd
import torch
from torch.utils.data import (
Dataset,
DataLoader
)
def set_binary_labels(labels):
threshold_10 = labels.quantile(0.1)
threshold_90 = labels.quantile(0.9)
# adas > q90
y_adas_q90 = (labels['ADAS_ADASTS14'] > threshold_90['ADAS_ADASTS14'... |
0a4ee7cc7c2ecc2774ea909ab906a9481f07775ec3fdeaf8e8e71f12c9ba602f | Python | 2,632 | 76 | import pytest
from pathlib import Path
import numpy as np
import torch
from kilosort import io
data_shape = (1000, 10)
def make_bfile_with_dtype(dtype, fill, directory, device):
# Create memmap, write to file, close the file again.
N, C = fill.shape
path = directory / 'temp_memmap.bin'
try:
... |
0a4e42c9f87d680d0887b3bb4613e92a72726372ffe9de8562a28c515d24ea15 | Python | 2,633 | 75 | import os
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
import argparse
DATA_PATH = os.path.join(os.path.dirname(__file__), '../../', 'data')
def load_and_preprocess_default_data():
lincs1000_genes = pd.read_csv(os.path.join(DATA_PATH, 'lincs1000.tsv'), sep='\t')
... |
7f9dce0956972b97d6ccf94a278ebd1f441310454a593f5d6b364a9484a86490 | Python | 2,633 | 73 | """Test the train CLI command argument parsing."""
import argparse
import pytest
from lightning_pose.cli.commands.train import get_parser
class TestGetParser:
"""Test the get_parser function."""
def test_returns_argument_parser(self):
"""Returns an ArgumentParser instance."""
assert isinst... |
ac9bf7fcf70806927fb2e4868133a9af5451c2169a2f6491fa703b52d9525796 | Python | 2,636 | 85 | """
Three Gaussians spread along the diagonal of a six-dimensional hypercube.
This coding style for the integrand is more complicated than slow.py but
leads to run times that are 20x shorter because the integrand is expressed
in terms of numpy arrays and whole-array operations, thereby greatly reducing
the overhead f... |
2b9fcfdd1000e8d3922bbec72afc56c7a19eddfe42bfc57c34e8c70fe52554de | Python | 2,639 | 78 | import operator
import numpy as np
import pytest
from pandas.core.dtypes.missing import isna
import pandas._testing as tm
from pandas.core.ops.array_ops import (
comparison_op,
na_logical_op,
)
def test_na_logical_op_2d():
left = np.arange(8).reshape(4, 2)
right = left.astype(object)
right[0, 0... |
993e3ee2863e209af245d0c4878e2c0dda7dafb7d6a52ddc33a606d19708b9f6 | Python | 2,640 | 65 | from botocore.client import Config
import ibm_boto3
import types
import os
import sys
import pdb
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from app import create_app
from utils import upload_director... |
c482b3e196aacb5a5b71dd5b88680562f62f1d93af1d9558d5222585a0b741cf | Python | 2,641 | 70 | import sys, pandas as pd, matplotlib.pyplot as plt, seaborn as sns
# Load data
df = pd.read_csv(sys.stdin, sep=', ')
# Preprocess
df.rename(columns={'lmeargs': 'link', 'signif': 'p', 'estimate': 'beta', 't value': 't'}, inplace=True)
df['agg'] = ''
df.ix[df.effect.str.endswith('Sum'), 'agg'] = 'Sum'
df.ix[df.effect.... |
f58b1745d01039006a751c2d13cac3ddb98aa31cbb6ebc108baefe0b1ce62e03 | Python | 2,641 | 79 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 8 22:05:33 2023
@author: hklumpe
"""
import numpy as np
import glob
import os
import json
username='hklumpe'
dcc_repo_path = f"/projectnb/dunlop/{username}/deepcellcontrol/"
#%% Smaller training set sizes
rng = np.random.default_rng(103122)
tr... |
1dd57ec70b16b3b92fab0676b25a666134b8563658e6816be582bf3103e77c36 | Python | 2,645 | 70 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
7c6bbbb4f37a3db4e4289af16e37483633452ed8fb912bf11c5ec2daa54b3490 | Python | 2,645 | 70 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
ae0ab67eecd1015bf4fdbf2d006f3a8784a5fffcc7a7a087ede44c8718960f81 | Python | 2,645 | 70 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
d965f3ada0c2e64481551b5034435122a6ac0c7f9ea2c705376615a952a76ac5 | Python | 2,646 | 114 | """Decompose a Run into per-Trial work units.
Phase 0-v2: a ``compare`` Run isn't one engine call anymore. The
orchestrator pre-creates N Trial rows (one per algorithm) + N Jobs
(``kind="trial"``); workers pull them in parallel and run
``create_model`` independently. This module owns the "which model ids
should we fan... |
92ec26642e9f91cc98648310d4522f15a5ab2e571b01a56d73140ee2ee663114 | Python | 2,647 | 70 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
399a9ff4f0d76f6937d59f6328ca45e193c8786beda086bb678ee72cbad66344 | Python | 2,648 | 96 |
import pandas as pd
from joblib import Parallel, delayed
from rdkit.Chem import Crippen, QED
from rdkit.Chem import Descriptors, rdMolDescriptors
from rdkit import Chem
from onmt.sascorer.sascorer import calculateScore
import pandas as pd
def condition_convert(con_df):
con_df['logP'][con_df['logP'] < 5] = 1
... |
ad9cad064ae79eab3870e5b486f5dc9f0db74276aa6c4dd26d2dff348715e85b | Python | 2,648 | 72 | #!/usr/bin/env python
import torch
from torch.utils.data import DataLoader
import pickle
from rdkit import Chem
from tqdm import tqdm
import data_struct as ds
from data_struct import MolData, Vocabulary
from data_struct import Variable, decrease_learning_rate
from model import RNN
import sys
def Transfer(restore_from ... |
b0c8c144cc472ba1bc9bcdedf8213303c6bb791d39c1af85e3bc65f138e15614 | Python | 2,648 | 71 | import numpy as np
import pytest
from pandas.compat import HAS_PYARROW
from pandas.core.dtypes.cast import find_common_type
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize(
"to_concat_dtypes, result_dtype",
[
# same types
([("pyarrow", pd.NA), ("pyarrow", pd.NA)], ... |
18557e675c22ce7c86c9b161d913d6ac0541fd6d32141979c2c633c458d403e9 | Python | 2,650 | 64 | """ Introduction
--------------------
This package provides tools for estimating multidimensional
integrals numerically using an enhanced version of
the adaptive Monte Carlo |vegas| algorithm (G. P. Lepage,
J. Comput. Phys. 27(1978) 192).
A |vegas| code generally involves two objects, one representing
the integrand... |
26477f6474d5519a326b2a66ff78e7da46b97c9c44c931eff317bccb7b42d976 | Python | 2,650 | 63 | import numpy as np, sys
import pumpprobe as pp
req_folder = None
req_ds = None
ds_tags = None
ds_exclude_tags = None
enforce_stim_crosscheck = "--enforce-stim-crosscheck" in sys.argv
fname = "/projects/LEIFER/francesco/funatlas_list.txt"
for s in sys.argv:
sa = s.split(":")
if sa[0] == "--ds-list": fname=sa[1]... |
9c7f440665578f881ddf8e5ebf0834406fd9c16d5c4c27981a8dce222a740529 | Python | 2,651 | 81 | #
# naming.py -- Michael Pun -- January 2021
# Conventions and functions for naming the following types of data files:
# - spherical projections of residue neighborhoods
# - training logs from equivariant neural networks
# - equivariant neural network weights
#
import copy
def get_id_from_params(args,ignore_params,... |
850fd85325d2af9015bc82ce9572aa2a0e5790d6dd0171b9b52b74e68113d734 | Python | 2,652 | 126 | # 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... |
f70f7221566ffb7e2b79cb42e1946c605b217772b1e64bb84936018e9ffa8041 | Python | 2,652 | 102 | # -*- coding: utf-8 -*-
import numpy as np
import pytest
import emcee
try:
from scipy import stats
except ImportError:
stats = None
__all__ = ["_test_normal", "_test_uniform"]
def normal_log_prob_blobs(params):
return -0.5 * np.sum(params**2), params
def normal_log_prob(params):
return -0.5 * n... |
f3727104b8ae2df8a1ab36e307d55fe710de47dc5f706aa05fb6589b1dc6a53a | Python | 2,653 | 97 | import pytest
import pandas as pd
import pandas._testing as tm
from pandas.arrays import IntervalArray
@pytest.mark.parametrize(
"kwargs",
[
{"start": 0, "periods": 4},
{"start": 1, "periods": 5},
{"start": 5, "end": 10, "closed": "left"},
],
)
def test_interval_array_equal(kwargs... |
2d59a1ef8cc05711548c488e56e28b7a7ef9d25bc49a0854883d76da659f68b1 | Python | 2,654 | 90 | # JN 2015-06-06 refactoring
from __future__ import print_function, division, absolute_import
import os
from PyQt5.QtWidgets import (QDialog, QDialogButtonBox,
QListWidget, QVBoxLayout, QLabel)
from .. import get_relevant_folders, get_time_files
POS_FNAME = 'do_manual_pos.txt'
NEG_FNAME = 'do_manual_neg.txt'
cl... |
5507b321e2641765fa1d1b2dc798c9378acda1d9acee6d87cea1ddff88bc54c7 | Python | 2,654 | 78 | import os
from pathlib import Path
import tensorflow as tf
from protein_holography.network import hnn
from protein_holography.network import clebsch
def load_network_from_weights(saved_network):
# parameters of the network
# parameters commented out were only necessary to load the data or for training
... |
d177c18894bb62e820e3b93e1fcad87c5fd6c05f46cc3537c795a9a2fded6d5e | Python | 2,654 | 75 | #!/usr/bin/env python
import os
import argparse
import pandas as pd
parser = argparse.ArgumentParser(description="Parameters for summarizing results")
parser.add_argument(
"--gene_demulti",
help="Folder containing output files of genetic demultiplexing pipeline",
default=None,
)
parser.add_argument(
"-... |
28265370a06112e0af6e4474e67382a35d7ce9b10c90437183c2a0cbeac90db9 | Python | 2,655 | 80 | __all__ = ["GlycoSpectralAngleLoss"]
from typing import Dict, cast
import torch
from torch.nn.modules.loss import _Loss
from ...util.math import spectral_angle
from ..common.data import GlycoPeptideDataBatch
from .data import (
GlycoPeptideMS2DataBatch,
GlycoPeptideMS2Output,
adjust_fragment_intensity_b... |
4a7dc741de10d037f08e8e1fea1392468b8bd9ed1a430ec4c6be12de20601053 | Python | 2,656 | 50 | """
Template for processing pipeline. Should contain a run() generic function to run the processing, as well as a proc2metric
function in order to gather the generated outputs and combine them into a matrix. The template provides the metrics as
a table to bypass processing.
Remember to add new processing modules to the... |
2c837da5ff8a4b21e42cc9c30cc5e223dff771c5cd0917577279aa83fc8d871a | Python | 2,658 | 76 | # MIT License
#
# Copyright (c) 2020 Gabriel Nogueira (Talendar)
# Copyright (c) 2023 Martin Kubovcik
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without ... |
d87be981b2058284b4ee3ad8ae61fc874eda78df2e03f7e74449115d82897d1c | Python | 2,658 | 67 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 23 08:26:03 2022
@author: danielkerschensteiner
"""
import numpy as np
import pandas as pd
import tkinter as tk
import glob
import os
def collect_columns(path_name, ind_col, target_col):
files = glob.glob(path_name +'/**/*.csv', recursiv... |
e2c1c42b798fcfc191e43d16452df7d1b7d25301bd3a30ad03333f2f469e6f2f | Python | 2,658 | 57 | from rl_games.common import object_factory
import rl_games.algos_torch
from rl_games.algos_torch import network_builder
from rl_games.algos_torch import models
NETWORK_REGISTRY = {}
MODEL_REGISTRY = {}
def register_network(name, target_class):
NETWORK_REGISTRY[name] = lambda **kwargs: target_class()
def register... |
bf6cc806f63eac8d3c7da359892ef15076bd0ee10226c1ecffcf44b224511957 | Python | 2,660 | 73 | #!/usr/bin/env python
version = "v0.1.0.20220610"
import os,os.path,sys,re
from argparse import ArgumentParser
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../core'))
import myc
import time
if __name__ == '__main__':
#Parameters to be input.
parser=ArgumentParser(description="RNA... |
efc1813430c8123c7bccc2e57efe0fcf58d4ef5dde0b484f8a994effce339481 | Python | 2,660 | 75 | #!/usr/bin/env python
import argparse
import torch
from torch.utils.data import DataLoader
from rdkit import Chem
from rdkit import rdBase
from tqdm import tqdm
from MCMG_utils.data_structs import MolData, Vocabulary
from models.model_rnn import RNN
from MCMG_utils.utils import decrease_learning_rate
rdBase.DisableL... |
6a1144a3c624c751b7120524f8fc936753afff67f5a2961021fe12ae1c9fdf53 | Python | 2,661 | 99 | import time
import gymnasium
import numpy as np
from dm_control.utils import rewards
from gymnasium import spaces
class HumanoidRobot(gymnasium.Env):
metadata = {"tasks": ["stand", "walk"], "render_modes": ["human", "rgb_array"]}
def __init__(self, render_mode=None, port="/dev/ttyACM0"):
self.render... |
36e9fede389616ae1ae39da1c0c3f0dee56501990f83a1684ee78a60b22d39cd | Python | 2,662 | 55 | import pandas as pd
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
import sys
import argparse
import os
import gc
from utils import create_pytorch_geometric_graph_data_list_from_smiles_and_labels, init_weights, KFoldGen, JSONLogger
import pickle
from sklearn.model_selection im... |
94cd24ad77bb15d8855b68e704d4ec12f51bf40928b3d018b1a9b03f07986057 | Python | 2,662 | 89 | """Stateless persistence helpers for PyCaret 4.0.
`save_model(pipeline, path)` and `load_model(path)` are the stateless,
top-level utilities for persisting fitted sklearn Pipelines. They're
equivalent to `joblib.dump` / `joblib.load` with a thin PyCaret metadata
header so loaded artifacts can be routed back to the rig... |
ff32386d47c1e6b8edd39714567f329a1856cdae6ce3bda799d3f3419b21c4cb | Python | 2,663 | 78 | import torch
from torch import nn
import copy
from ..mlp import MLP
from ..convs import MGNTransformerConv
from ..basis import GaussianRandomFourierFeatures
# Typing
from torch import Tensor
from typing import List, Optional, Tuple
class Encoder(nn.Module):
def __init__(self, init_node_dim, init_edge_dim, dim):... |
619c9d92b52eb2d67b4cf15067b4648d73b336e9b2229578511e5e3930ba1984 | Python | 2,664 | 73 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
88f726324d1c3575b6a4b7342f6e067a84a4cc2dee723fa8b204a02388376019 | Python | 2,664 | 99 | """This script produces a figure axis scaling options."""
import os
import matplotlib.pyplot as plt
import mne
import numpy as np
import osl
import sails
import lemon_plotting
from glm_config import cfg
from lemon_support import get_eeg_data
#%% ----------------------------------------------------------
# Prep
fba... |
bac1546a1bc62f76d093cf3e51da2a186f0f95ec6c40a563037ea87e6c6b4690 | Python | 2,664 | 70 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
56d614a74b5e0cceaa4fdf1f7dfe3d5d50df2b461bbf5aedf999f8174a896c56 | Python | 2,665 | 41 | import os
from argparse import ArgumentParser
def get_args():
parser = ArgumentParser(description="PyTorch deep learning models for document classification")
parser.add_argument('--no-cuda', action='store_false', dest='cuda')
parser.add_argument('--gpu', type=int, default=0)
parser.add_argument('--cu... |
de6c06094e09190a32515638ce043a5a2c89b6d8dd88f83b08cdbe9a71101c13 | Python | 2,665 | 85 | # -*- coding: utf-8 -*-
"""
morphological operations
"""
import numpy as np
from skimage import morphology
from scipy.ndimage import binary_dilation, binary_erosion
import logging
logger = logging.getLogger(__name__)
def fill_holes_2D(mask,minsize=[]):
out = np.copy(mask); out = out>0
if not minsize:
... |
cec317176d9658f6280af5411c48853c5552c6de6125112f35081eed9f71a2e3 | Python | 2,666 | 94 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# ----------------------------------------------------------------------------------------------... |
7c599a47d70fe31d8c10bceb63b312934fa7fe8aac501ee09878476bee3a6926 | Python | 2,667 | 79 | import importlib.resources
from PyQt6 import uic, QtCore, QtWidgets
class BulkList(QtWidgets.QWidget):
def __init__(self, parent, title=None, items=None, *args, **kwargs):
"""A checkable list with bulk (de-)selection button"""
super(BulkList, self).__init__(parent=parent, *args, **kwargs)
... |
82b6bde21aee5a28c3a4c21a52eb9b51e30e6e161d0990d91da9cdf7df7ec23c | Python | 2,668 | 105 | from pathlib import Path
import pytest
@pytest.fixture
def xml_data_path():
"""
Returns a Path object to the XML example directory.
Examples
--------
>>> def test_read_xml(xml_data_path):
... pd.read_xml(xml_data_path / "file.xsl")
"""
return Path(__file__).parent.parent / "data"... |
dc605a1d3d0898b2f196b386c4731f6e3d7509ac863bb70f40f80c6f6d7bc72c | Python | 2,668 | 67 | import matplotlib.pyplot as plt, matplotlib.pylab as pylab, numpy as np
from mpl_toolkits.mplot3d import Axes3D
from .files import read_data
# Graphic's format
pylab.rcParams['axes.labelsize'] = 9
pylab.rcParams['xtick.labelsize'] = 9
pylab.rcParams['ytick.labelsize'] = 9
pylab.rcParams['legend.fontsize'] = 9
pylab.rc... |
dcf10831e8d8b37e3c092dfeb0f3606f92426a4cedc720548adb84b495610252 | Python | 2,668 | 94 | """JWT access + refresh token helpers.
Access tokens are stateless JWTs with a short TTL (default 60 min). Refresh
tokens are random strings whose SHA-256 hash is stored in the ``sessions``
table; the client holds the plaintext. On refresh, the server looks up the
row by hash and issues a new access token.
Revocation... |
55472b1f61cf83a289629da76bd29731c1fa556d9d02663969097a5426e8ef6c | Python | 2,670 | 84 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Setup and metavariables for PDbb2.
Vinding, M. C., Eriksson, A., Low, C. M. T., Waldthaler, J., Ferreira, D., Ingvar, M., Svenningsson, P., & Lundqvist, D. (2021). Different features of the cortical sensorimotor rhythms are uniquely linked to the severity of specific ... |
7bb162e410510f2d3a0f83170add52edd56a8bd35a571f2eba68f6273a7bc06a | Python | 2,671 | 70 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
9693f208a0ab5b9b4aca817ad02833342c8aa4a40f296de01e6bfbf0fc93f55d | Python | 2,671 | 98 | import tensorflow as tf
import os
import nibabel as nib
import numpy as np
import random
import re
from skimage.transform import resize
from const import *
def int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=[value]))
def int64_list_feature(value):
return tf.train.Feature... |
20112e1fbb31747555d9aaed9a5eefe98710b7bcd4d47c27c022f8e46de0bb81 | Python | 2,672 | 75 | ##############################################################################
## ##
## This file is part of ModelBlocks. Copyright 2009, ModelBlocks developers. ##
## ##
#... |
7542c81b7e5cc8545c1adcf2b886ca719523a8313ced33fb44e4323530b8d4cb | Python | 2,672 | 82 | __all__ = ["GlycoPeptideReportParserBase", "GlycoPeptideReportSpectrumParserBase"]
import abc
from typing import Iterable, Optional, Union
import pandas as pd
from ....specio.spec import MassSpectrum
from ...pep.parser.abs import PeptideReportParserBase
from ..filter import GlycoPeptideSpectrumFilter
from ..spec imp... |
2da15b081f03af257aea6d1576ddc89aa488dc2715fc4930940fe9de89343171 | Python | 2,673 | 86 | import os
import cv2
import random
from glob import glob
import numpy as np
import processing.plastegy_net as pn
root_path = ''
data_Path = root_path + 'korsneset_mai2022/'
img_paths = glob(data_Path + '*/*.bmp')
img_paths.sort()
img_paths = img_paths[::-1]
lice_path = root_path + 'neural_net/training_data/lice'
ot... |
69d517bc4cee8a9aa0eb970502ec467e719a5753082ad93bbcbbada7e55875a1 | Python | 2,673 | 85 | """Test nimare.annotate.gclda (GCLDA)."""
import nibabel as nib
import numpy as np
import pandas as pd
import pytest
from nimare import annotate, decode
def test_gclda_symmetric(testdata_laird):
"""A smoke test for GCLDA with symmetric regions."""
counts_df = annotate.text.generate_counts(
testdata_l... |
17de6f00968c9f307b882c3a907c1cd8234fc970bdf1ebf2261f5dd6ee9f0e89 | Python | 2,674 | 63 | """Value clipping must compare predictions and targets in one coordinate system."""
import copy
from types import SimpleNamespace
import pytest
import torch
from rl_games.algos_torch.running_mean_std import RunningMeanStd
from rl_games.common.a2c_common import ContinuousA2CBase, DiscreteA2CBase
from rl_games.common.... |
1e89fd1baf5043f60e7dca04a2f4cc879d8c9bf3a95dfa227dcf28ad1fc420bb | Python | 2,675 | 69 | import os
import pysam
def generate_plot():
cmd = "java -cp ./utils/gepard/Gepard_altered.jar org.gepard.client.cmdline.CommandLine -seq {} {} -matrix ./utils/gepard/edna.mat -outfile {} -silent -word {} -zoom {}"
def fetch_ref_seq(ref_file, chrom, start, end):
return ref_file.fetch(chrom, start, end + 1)
... |
aa5ed56fbfae6e4cf7e601c61b894598164f6eaa39c2a9d9c2fb3bf9b82c339d | Python | 2,676 | 88 | #!/usr/bin/env python3
#
# Copyright 2017 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... |
b2b090f95c70bf5a574831c959571592ebf3e60e9055c9d71dcbbdb54024544a | Python | 2,677 | 83 | ###############################################################################
# This script visualizes the brain visualization and meta-analysis data in #
# brain surface plots. #
# ... |
593c8ce3723d72aeb11860f0244c8c685ef12dd36a5a3b5b106ba8248c3317d0 | Python | 2,679 | 84 | #-----------------------------------------------------------------------------
# Ion Feature
#-----------------------------------------------------------------------------
import os
import DXGB.get_pdbinfo as get_pdbinfo
from DXGB.get_pdbinfo import *
import numpy as np
import sys
def get_Ions(fn,lig,pro,infile):
... |
bf1655ba6c003c3f90ba1e65d9002980cfed3d12f4bfe88a829f473601113ed7 | Python | 2,680 | 58 | from Common import loggingUtils
from Common.kernelFunctions import *
from Surfaces import surfaceMatching, surfaces, surfaceTimeSeries as match
#import secondOrderMatching as match
def compute(Atrophy=False):
if Atrophy:
pass
else:
pass
#outputDir = '/Users/younes/Development/Results/bio... |
f70703d899ae834231fb7303be7cee2be9b88042d71f1fef85dd153d6fbbc7e1 | Python | 2,680 | 92 | from AnalysisProcess.BasicAnalysisProcess import BasicAnalysisProcess
import numpy as np
from psychopy import core
import pickle
import os
class TestingProcess(BasicAnalysisProcess):
def __init__(self):
self.algorithm = None
self.state = None
self.cacheData = None
self.... |
0063c85ccd4a62a9f1121ef54f6b1c33b9d7355f6ad1c5319d2c1e95d73e6cca | Python | 2,681 | 73 | """Tests for merge-proposition filesystem persistence."""
import json
from pytest import raises
from .._proposition_io import (
PropositionSourceChangedError,
file_sha256,
load_proposition_documents,
read_json_mapping,
write_json_atomic,
write_review_document,
)
def test_load_optional_propo... |
73c8a62b59ea37ee90c4af982cd3a944b1e6569ff8eaaa850a63d29892612962 | Python | 2,684 | 68 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 23 08:26:03 2022
@author: danielkerschensteiner
"""
import numpy as np
import pandas as pd
import tkinter as tk
import tkinter.filedialog
import glob
import os
def collect_columns(path_name, ind_col, target_col):
files = glob.glob(path_n... |
1cd4bf0ceec2ab04b00c891903bbe882b44a675296d89b0df2126d19eab55506 | Python | 2,685 | 66 | # coding=utf-8
from __future__ import annotations
import logging
import os.path
import time
import numpy as np
from SCTrack import reclassification
from SCTrack.utils import mask_tif_to_json
def start_track(fannotation: str | dict, fout, basename, track_range=None, fimage=None, fbf=None,
export_vi... |
ec9cfadbd5236f49610f390a525e330ecc265c14ecd2e3bfc6c28ffb39da7057 | Python | 2,686 | 88 | import argparse
import pandas as pd
def get_args():
"""
Get arguments from command line with argparse.
"""
parser = argparse.ArgumentParser(
prog='Convert-JGI-Coverages.py',
description="""Convert JGI depth files.""")
parser.add_argument("-i", "--in_jgi",
req... |
245e417f797a6e3be537dacb20f54b34406e7b9708c41d5e1e15e0683c2aabe0 | Python | 2,687 | 77 | import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from sklearn.metrics import auc
def plot_confmat(matrix, saveas=None, title=None):
fig, ax = plt.subplots(figsize=[5, 5])
# build the plot
sns.set(font_scale=2)
sns.heatmap(matrix, annot=True, annot_kws=... |
48db9576ad6bab618f713fa0fdec406adb41c89f38afe36076a600bae9f7acaa | Python | 2,687 | 83 | import numpy as np
import pytest
import pandas as pd
@pytest.fixture
def interval():
return pd.Interval(0, 1)
class TestInterval:
def test_properties(self, interval):
assert interval.closed == "right"
assert interval.left == 0
assert interval.right == 1
assert interval.mid =... |
a654ada64113861db9edc507622487bb3f3ec537cb68829a1f83355e2bd14a11 | Python | 2,687 | 90 | """
detection.py
Created May 23, 2021
Converts a color image to binary mask of the lead's curve.
"""
import cv2
import numpy as np
from .. import common, otsu, vision
from ..image import BinaryImage, ColorImage
from ..grid import frequency as grid_frequency
def otsuDetection(image: ColorImage, useBlur: bool = False... |
68c7a127ffcdfe864000341d6970b1159e4bc1a9d3fbbe57908b99524a36e9b1 | Python | 2,688 | 77 | # 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... |
f018ee9b5bc76ffe207a2a9a16baca5f933d75a3ba88c6e6412f1206b364b1e2 | Python | 2,688 | 62 | #!/usr/bin/env python3
"""Runs clang-tidy only on the lines changed since <base-ref> (no dependency on clang-tidy-diff.py).
usage: clang-tidy-changed.py [--fix] <base-ref> <compile-db-dir>
Raw clang-tidy output goes to stdout.
"""
import json, os, re, subprocess, sys
from concurrent.futures import ThreadPoolExecutor
... |
a569fe3db44a6d65d795b9a8d0a5edc4d178105bce5c11dcb5f5b7a4f58046ad | Python | 2,689 | 70 | """Conventional order parameter featurization
Reference: https://freud.readthedocs.io/en/latest/modules/order.html
"""
import torch
from torch_geometric.utils import scatter
from e3nn import o3
def steinhardt(l, edge_index, edge_vec, num_nodes, p=1, second_shell_avg=True):
# Compute q_lm
i, j = edge_index
... |
1c39af60531958f9f3c29b39b9b5f65c751ffbc1157a5fdd4dc637e21ed85e7f | Python | 2,690 | 102 | from io import StringIO
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
pytest.importorskip("tabulate")
def test_keyword_deprecation():
# GH 57280
msg = (
"Starting with pandas version 4.0 all arguments of to_markdown "
"except for th... |
11f2d78f66e9cc911be797649b4bde2b8178e4b301e3588818887c003a8a7e9b | Python | 2,692 | 61 | """
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5608695/
AdaBoost Dagan-Wiener
"""
from sklearn.ensemble import AdaBoostClassifier
from sklearn.metrics import roc_curve
from sklearn.metrics import auc
from sklearn.metrics import confusion_matrix
import numpy as np
import pandas as pd
import os
from rdkit import Chem
f... |
36c9e54aeb0d786fdc7841c2a5082bc202417421a554639b9b82577b66e03e65 | Python | 2,694 | 88 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestSeriesDiff:
def test_diff_series_requires_integer(self):
series = pd.Series(np.random.default_rng(2).standard_normal(2))
with pytest.raises(ValueError, match="periods must be an integer"):
seri... |
f490a2d2c87d1bda5980a925784f795346b6a680b093813b5821683aba8d0d59 | Python | 2,694 | 61 | import numpy as np
from defs import *
from values import *
# compute electro-convective-diffusive fluxes
def compute_ecd_fluxes (cell,jvol):
# function return values
jsol = np.zeros([NS,NC,NC])
delmu = np.zeros([NS,NC,NC])
convective_flux = np.zeros([NS,NC,NC])
electro_flux = np.zeros([NS,NC,NC])... |
aa3ea56b0497004e051da2d999a2bd2f0b136fbf35d40640c0c3e7038668b468 | Python | 2,695 | 70 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
c1dc33ef1d6b0f556605ae24ea436fd40eb3519ff3148631e74ef7457e358d6c | Python | 2,695 | 86 | import importlib.resources
from PyQt6 import uic, QtCore, QtWidgets
from ... import pipeline
class MatrixPlot(QtWidgets.QWidget):
active_toggled = QtCore.pyqtSignal()
option_action = QtCore.pyqtSignal(str)
modify_clicked = QtCore.pyqtSignal(str)
def __init__(self, identifier=None, state=None, *args... |
e2e66ac137c900875f9e637be8841e6fb808295ddbe42b84725353aaf5ba6593 | Python | 2,695 | 71 | #Run and save results of sweeps over eps, eta for 1 fields.
#Date written and executed: 2022-10-20
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
# this particular script fills in some missing simulations with eta = 8.
import numpy as np
fro... |
4d2bc9d210386ca359352e0ab45b8d037b132364228a30addbe1e1a253159073 | Python | 2,696 | 77 | """Endomorph Operators."""
from __future__ import annotations
from abc import abstractmethod
from typing import cast
import torch
from typing_extensions import Any, TypeVar, TypeVarTuple, Unpack, overload
import mrpro.operators
from mrpro.operators.Operator import Operator
from mrpro.utils.typing import endomorph
... |
ec9e062bad2cf13ac4e78b7ef5a670b61e3c2e016fa66a43e46a67b159a19549 | Python | 2,697 | 102 | from io import StringIO
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
pytest.importorskip("tabulate")
def test_keyword_deprecation():
# GH 57280
msg = (
"Starting with pandas version 4.0 all arguments of Series.to_markdown "
"except... |
fe6f99af29a092469d459dc497a63d2560a5ef6353056889b5adc33506697484 | Python | 2,697 | 66 | import os
import nibabel as nib
import numpy as np
from esFCM import Segment
from esFCM.utils import read_image_with_info, add_noise_to_image
noise = [0, 20, 40]
biase = [0, 5, 10]
def run_experiment(info_image, mask_image):
for noise_perc in noise:
noise_perc = noise_perc / 100
for bias_ratio in ... |
2d2259750560f872e85021168fbc3b65ebfb869a93d07b2d9ffb4cd9fb0150d6 | Python | 2,698 | 74 | """Tests for the nimare.diagnostics module."""
import os.path as op
import pytest
from nilearn.input_data import NiftiLabelsMasker
from nimare.diagnostics import Jackknife
from nimare.meta import cbma, ibma
from nimare.tests.utils import get_test_data_path
@pytest.mark.parametrize(
"estimator,meta_type,n_sample... |
c37bdf16076a5bf12d89fe1ea824f04593a5b0e884c74c0dc520953133e43662 | Python | 2,699 | 92 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Do MNE on resting MEG state data.
Vinding, M. C., Eriksson, A., Low, C. M. T., Waldthaler, J., Ferreira, D., Ingvar, M., Svenningsson, P., & Lundqvist, D. (2021). Different features of the cortical sensorimotor rhythms are uniquely linked to the severity of specific s... |
114f0f4af6ea442271b1166854a83a9f740bff286c6576ba05e98a2a073b8939 | Python | 2,700 | 86 | import matplotlib
import matplotlib.pyplot as plt
from pcntoolkit.util.plotter import _plot_qq
from test.fixtures.plotter_fixtures import create_test_data_with_z
# Use non-interactive backend so no display is needed.
matplotlib.use("Agg")
def test_001_plot_qq_two_figures_in_subplot():
"""_plot_qq should return ... |
676e3958b442d4000622b13a142a9bf596dbea3c3b7c3114fefc2d14dd707427 | Python | 2,700 | 69 | from sklearn.metrics import mean_squared_error as MSE
from sklearn.metrics import r2_score
import numpy as np
import matplotlib.pyplot as plt
import random
import time
import argparse
from . import xgboost_preprocess
from xgboost import XGBRegressor
class Tree:
#constructor
def __init__(self, args, default_dat... |
870614ee5e165c99757ea5d8d60f715980112ae5093d6f77614044622337a5a5 | Python | 2,700 | 97 | import numpy as np
import pytest
import pandas as pd
@pytest.fixture
def datetime_frame() -> pd.DataFrame:
"""
Fixture for DataFrame of floats with DatetimeIndex
Columns are ['A', 'B', 'C', 'D']
"""
return pd.DataFrame(
np.random.default_rng(2).standard_normal((10, 4)),
columns=p... |
fb24ebd02c621e54fcc5842aaaba2fabf86f1362d2574c3ae205a5e32838136d | Python | 2,700 | 94 | __all__ = ["PredictorBase"]
import abc
import math
from logging import Logger
from typing import (
Generic,
Iterable,
List,
Optional,
Sized,
TypeVar,
Union,
)
import torch
from ...util.config import Configurable
from ...util.collections.dict import chain_item_typed
from ...util.collectio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.