sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
acc393df91b59f7f274bae736ea3e8c909c6db89039ccf8af3b148a69ce65e52 | Python | 2,718 | 72 | import numpy
from sklearn.kernel_approximation import RBFSampler
from NAB.nab.detectors.base import AnomalyDetector
class ExposeDetector(AnomalyDetector):
""" This detector is an implementation of The EXPoSE (EXPected Similarity
Estimation) algorithm as described in Markus Schneider, Wolfgang Ertel,
Fabio R... |
0508a35f635331d5e83d1375bca3ed0ee63c5929e56dd63131566827ae420de5 | Python | 2,719 | 73 | import torch
import numpy as np
from model_utils.decoders import FPNDecoder
from model_utils.decoders import UNetDecoder
from model_utils.segmentation import EncoderDecoder
from model_utils.segmentation.backbones import ResNetBackbone
def segmentation(models, stack, device, indexes, class_amount, window):
with ... |
207cb2643e8ccefb1e26352b2c321c36e0215444eb92deaa76cebb3ab0987529 | Python | 2,719 | 123 | from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
# ======================================================================
# Built-in MorphoGlia morphometric calculators
# ======================================================================
DEFAULT_CALCULATORS = (
... |
92390cc1e7ecad762ad0b9ca5e82ba00c524db7a284b7e0cc62771c1db1cac81 | Python | 2,719 | 93 | from PyQt5.QtWidgets import (QDockWidget,
QPushButton,
QApplication,
)
from PyQt5.QtCore import QTimer
from time import sleep
from wonambi import Wonambi
from .paths import (gui_file,
GUI_PATH,
... |
fc8e5e9043cf719b46b6db94d813a1edef79f182de735e953d2fec0760d390f0 | Python | 2,719 | 71 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 2 17:45:32 2021
@author: eshor
Class which defines the compartments object and related methods.
Class: Compartment : New compartment Methods: __int__ : Initializes compartment object set_ion_properties: define
intracellular ionic properties of the compartment (extracel... |
87ae1a4f550b7496d04912e329a0b7c46d557197c22506ded238a3ba04ae24b6 | Python | 2,720 | 68 | """Manually identify bad channels in the LEMON EEG data
NOTE: In LEMON EEG, we noticed that there can be a few bad channels that are difficult to
detect for some subjects. For these subjects, bad channels were first identified and then
manually dropped using the custom `detect_bad_channels_manual()` function during ... |
081f3ca7e0cfa8651ba42f18fb60d07d531802f834fd52a339b6de8c3784c328 | Python | 2,721 | 95 | """
Script for evaluating an object detection model using Tensorflow Object
Detection API.
This script expects a persistent dataset can be loaded with FiftyOne and that
said dataset has all necessary fields populated:
- groundtruth_loc_field_name
- groundtruth_img_labels_field_name
- prediction_field_name... |
7419a75e789ca09295266563d74a6d7c08d6c24502af6b0a919b1811d0a0be59 | Python | 2,722 | 69 | from basicsr.utils.registry import ARCH_REGISTRY
from torch import nn as nn
from torch.nn import functional as F
@ARCH_REGISTRY.register()
class SRVGGNetCompact(nn.Module):
"""A compact VGG-style network structure for super-resolution.
It is a compact network structure, which performs upsampling in the last ... |
d8aa5336bb81c72ad6911ff9e7e6db76fb876353ceedd9489e824ddc53d2ae2f | Python | 2,722 | 67 | """Helpers for distributing per-variable computations across jobs.
`_parallelize_with_joblib` is adapted from scirpy (BSD 3-clause).
"""
import math
from collections.abc import Iterable, Iterator
from contextlib import contextmanager
from typing import Any
import numba
import numpy as np
from joblib import Parallel
... |
dc9197cb856b2a4f6679ac64f67415bd56bb94cacca80596eb2b26ec252dd5e8 | Python | 2,722 | 60 | import torch
from nnunet.network_architecture.generic_UNet import Generic_UNet
from nnunet.network_architecture.initialization import InitWeights_He
from nnunet.training.network_training.nnUNet_variants.data_augmentation.nnUNetTrainerV2_insaneDA import \
nnUNetTrainerV2_insaneDA
from nnunet.utilities.nd_softma... |
5c3c4c4bc105eacd69c200df355d9a447712bcf04ab10d522b2341bec54ac22c | Python | 2,724 | 70 | """
OXASL - Quantification using Fabber
Includes partial volume correction
Copyright (c) 2008 University of Nottingham
"""
import numpy as np
from fsl.data.image import Image
from oxasl import mask, reg
from . import multistep_fit
def run(wsp):
# Basic non-PVC run
multistep_fit.run(wsp.sub("basil"))
... |
927338357354f1e788f2d195f6cc13c44e3f3e348704c3aff55043042a071917 | Python | 2,724 | 81 | ## Imports
import torch
import sys
import numpy as np
from src.script_util import create_model, create_gaussian_diffusion
from ConditionalNeuralField.scripts.train import trainer, ri
from basicutility import ReadInput as ri
## Setup
if torch.cuda.is_available():
dev = "cuda"
else:
dev = "cpu"
device = torc... |
b27e4422c56da12369325406f41edff2ceec0402718e918aead1be2995ea7208 | Python | 2,724 | 83 |
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.express as px
# Scores assigned by pathologists for three tasks (Artifact Detection, Artifact-free Preservation, Overall Usability)
## P1 MoE DCNNs
pathologist_1 = {
"Artifact Detection": [8, 9, ... |
fbbccaf5e3265f1416594d955dc644d735b249fd23c177d68929562c29c12869 | Python | 2,724 | 96 | import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import os
import matplotlib
import simulations as sim
import pickle
matplotlib.use('TkAgg')
rootdir = 'params/'
SNRs = [5, 7, 10, 15, 20, 25, 40, 100]
datapoints = [80, 90, 100, 110, 120, 130, 140, 150, 160]
Hcts = [0.3, 0.35, 0.4, 0.45, 0.5, 0.5... |
60ca6f5ebb86417aa7709b44c99b2189c8c421842141be592c7d9b0e9f0e33e9 | Python | 2,725 | 58 | # 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
#
# ht... |
8dbb81cc954e6c8952918343accfbaf8453fb736b0800cf95161a363170501c7 | Python | 2,726 | 60 | import random
from PIL import ImageDraw
from typing import Optional
from .shape import Shape, calculate_short_side
class Parallelogram(Shape):
def __init__(self, x: int, y: int, width: int, height: int,
offset: Optional[float] = None, flip: Optional[bool] = None):
super().__init__(x, y, w... |
14342ec0e8d91c5c0e7bcf2f63890cdbbb795b0d2978058596bf1eeab185a5f3 | Python | 2,728 | 76 | #!/usr/bin/env python
## updated 6/10/2020
import argparse
import subprocess
import os
import multiprocessing
import math
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--bfile", help = "plink binary file name") ## plink file path
parser.add_argument("--keep", help = "... |
1b024e159aeb2a602e0534f939443f4f77465cc70b604efb58024ecbd9e1bac3 | Python | 2,728 | 84 | import os
import sys
import math
import pprint
import pickle
from tqdm import tqdm
import numpy as np
import torch
from torchdrug import core, models, data, utils
from torchdrug.utils import comm
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from gearbind import dataset, layer, model, task, util
de... |
1ee73ba21df54fc72ebce70e74e8856f3134a62f22bfc744b9e082c6f3b19344 | Python | 2,728 | 73 | from __future__ import annotations
import re
import urllib.parse
from typing import Any
from wikibaseintegrator.datatypes.basedatatype import BaseDataType
from wikibaseintegrator.wbi_enums import WikibaseSnakType
class TabularData(BaseDataType):
"""
Implements the Wikibase data type 'tabular-dat... |
526cfd12cfbed4adbc22ae2f540e6f8e0e0d539d223cd3a968ecb74ae8a4d7fd | Python | 2,728 | 108 | """Parameter sets
-----------------
The dictionary ps_dicts defines parameter sets for overwriting the base
parameters.
"""
import numpy as np
local_sim_dict = {
'print_time': True}
### model-specific definitions ###
net_dict_mesocircuit_MAMV1 = {
'base_model': 'SvA2018',
'g': -11.,
'neuron_params'... |
9f97e7cb5ec8bbb23c7a19bb63f2d56ecc00982cc16604e101e2fd7cd664175f | Python | 2,728 | 90 | """Gradients of the univariate t distribution."""
import scipy.stats
import autograd.numpy as np
from autograd.extend import defvjp, primitive
from autograd.numpy.numpy_vjps import unbroadcast_f
from autograd.scipy.special import psi
pdf = primitive(scipy.stats.t.pdf)
cdf = primitive(scipy.stats.t.cdf)
logpdf = prim... |
f1781e68eec02f3945a8c296c118b3031542e1340c00482c62aae02bbefc51ca | Python | 2,728 | 82 | __author__ = 'martinez'
import pyseg as ps
import numpy as np
from unittest import TestCase
from pyseg.spatial.sparse import BiStat, PlotBi, gen_sin_points, gen_rand_in_mask
# ### Test variables
# Global
RES = 0.684 # nm/pixel
# Mask
MASK_R = 2000 # nm
SIZE = (200, 200, 1) # pixel
# Pattern 1 (Reference)
N_PST = 5... |
5731b03f8018f6a79ebbd351a7ab0bc3a14d9d0e5436909ec490f367cdfa6c24 | Python | 2,730 | 57 | from collections import OrderedDict
from pddlstream.algorithms.downward import make_action, make_parameters, make_domain
from pddlstream.language.constants import Not
from pddlstream.language.conversion import pddl_from_object, substitute_expression
from pddlstream.language.statistics import check_effort
from pddlstre... |
68a05701dfaf0b3e19d42d363d0c02907c8802b4a825373f6942dc86d531af82 | Python | 2,730 | 76 | import matplotlib
matplotlib.use("Agg")
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
import yaml, io
with open("./config/simul_study_config.yaml", 'r') as stream:
config= yaml.safe_load(stream)
config["default_path"]= str(config["default_path"])
config["split"]= float... |
14e4e00aaad4b3037eeaeacdf4a9f7fd3ec0e20b4f9c00e84bc079c0f59f45ec | Python | 2,731 | 77 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# 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 limitation the rights
# to use, copy, modify, merge,... |
fba7732650c7348c3ebf4805d4e163efc1cbadc6d6e1f0f42c5d13d175681146 | Python | 2,731 | 86 | # -*- coding: utf-8 -*-
from __future__ import annotations
import argparse
import os
from ast import literal_eval
from configparser import ConfigParser
from typing import Any, Dict, Optional, Sequence
import yaml
from omegaconf import OmegaConf
import supar
from supar.utils.fn import download
class Config(object)... |
25489fb28026901125480924bd041d6f094c52b13542153911befaa6d01a07f1 | Python | 2,732 | 76 | # A function to run batch-run qmod runs
import os
import pyclamp.gui.pgb as pgb
import pyclamp.qnp.qmod as qnp
from iofunc import *
from strfunc import *
DEFIPD = '/mnt/share/BQA/analyses/'
def qmods(_e = 1., _sres = 128, _vres = 64, _ares = 1, _nres = 32, _nmax = None, _ngeo = None, noprompt = 0, ipd = None, opd =... |
72cd6060b5d05c5cbfd12b33f6b9bc610b1cf804f5f9e95313e0a95c80818226 | Python | 2,732 | 78 | import csv
import pandas as pd
import numpy as np
from sklearn.preprocessing import OneHotEncoder
from config import DATA_DIR, DEBUG
RAW = [
{'name': "Mexico", 'labels': DATA_DIR + "raw/mexico_trainval.csv", 'dest': DATA_DIR + "raw/mexico_trainval_binned.csv"},
{'name': "Colombia", 'labels': DATA_DIR + "raw/c... |
8593a2500d5eb6c1e8a958e9cd2308d202d6d91a200869ab0c89ff4ba973a5d0 | Python | 2,732 | 76 | """
This script creates the visualizations for the supplementary analysis
To understand the thresholding, read https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Randomise/UserGuide
"""
import numpy as np
import glob
import nibabel as nib
from nilearn.plotting import plot_stat_map
import matplotlib.pyplot as plt
from matplotlib... |
9ac0119ee84b5652093638f70a161676c8d23e762868fcf5b2489ad90af31ddf | Python | 2,732 | 69 | import os
from pathlib import Path
import subprocess
import sys
import textwrap
import unittest
class TestVisualizerImports(unittest.TestCase):
def run_fresh(self, body):
root = Path(__file__).resolve().parents[2]
result = subprocess.run(
[sys.executable, '-c', textwrap.dedent(body)], ... |
10d7548d97367c1c153a0e3443e15c0178c2596175f0957a3d4c16fb871afd81 | Python | 2,733 | 74 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
11db1aa55d7673c66ecc5861951ad5bb5614830bfc93d229bbc0ee9c1d1aa7b3 | Python | 2,733 | 74 | """
Utility functions for training one epoch
and evaluating one epoch
"""
import torch
import torch.nn as nn
import math
from metrics import accuracy_TU as accuracy
"""
For GCNs
"""
def train_epoch_sparse(model, optimizer, device, data_loader, epoch):
model.train()
epoch_loss = 0
epoch_train_... |
3b51dc9d83797da7352690dd1b9dc86f7219e622f96f9ba22bde8375569e902f | Python | 2,733 | 94 | # pylint: disable=invalid-name, missing-function-docstring, no-member
""" LSTM model module """
from random import uniform, randint
import torch
from torch import nn
from omegaconf import OmegaConf, DictConfig
def get_model(cfg: DictConfig, model_cfg: DictConfig):
return LSTM(model_cfg)
def default_HPs(cfg: D... |
874005bc405baa06fcc53d89d64bd37391b2bcced014276b4df0d7bd0196335f | Python | 2,733 | 77 | import unittest
import numpy as np
import torch
from torcheeg.datasets.constants import (DEAP_ADJACENCY_MATRIX,
DEAP_CHANNEL_LIST,
DEAP_CHANNEL_LOCATION_DICT,
SEED_CHANNEL_LIST,
... |
951b8f15063188d9114480f8554de612e1cd993dd9144feda81f914bd01cfd08 | Python | 2,734 | 77 | import os
import shutil
import unittest
import mne
import numpy as np
from torcheeg import transforms
from torcheeg.datasets import FolderDataset
mne.set_log_level('CRITICAL')
class TestFolderDataset(unittest.TestCase):
def setUp(self):
if os.path.exists('./tmp_out/'):
shutil.rmtree('./tmp_o... |
b7d70a907f82cafe0230958f557c0ea33cfb24b39297475904fdfe66317f11cb | Python | 2,734 | 84 | from __future__ import annotations
import os
from pathlib import Path
from ase.build import bulk
from maggma.stores import MemoryStore
from quacc import change_settings
from quacc.recipes.emt.core import relax_job, static_job
from quacc.settings import QuaccSettings
FILE_DIR = Path(__file__).parent
def test_file(... |
d2cf63c72258eefd178da0ab3f5857e12da845faad988b205c4eda325159de29 | Python | 2,734 | 64 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Send a HPC job from python.
Although a better way to pipe command with subprocess, after python 3.7+, shbould be:
ps = subprocess.run(['ps', '-A'], check=True, capture_output=True)
processNames = subprocess.run(['grep', 'process_name'],
... |
ebd3cd8fd74f1ed21af6842ae4eb1d115d273bac40a7718b513a97adea538e19 | Python | 2,735 | 85 | # Copyright 2015 gRPC authors.
#
# 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 agreed to in writing... |
0b8fa5fa55be7c76865a738e0c6464af118c1b2dd3de61768f15b4bb1f2ca51f | Python | 2,736 | 82 | __author__ = 'martinez'
from pyorg import disperse_io
import numpy as np
from unittest import TestCase
from pyorg.spatial.sparse import BiStat, PlotBi, gen_sin_points, gen_rand_in_mask
# ### Test variables
# Global
RES = 0.684 # nm/pixel
# Mask
MASK_R = 2000 # nm
SIZE = (200, 200, 1) # pixel
# Pattern 1 (Reference... |
23ab9865f3315e80f1f3933be6bb137febd3bdbd635fc4e7c4c9ca43827cbdab | Python | 2,736 | 76 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
a2697275e4606af6ead37e37bfacbcbbdf20db394f2a0e609ffa22d8daf7f311 | Python | 2,736 | 77 | #
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# 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 limitation the rights
# to use, copy, modify, merge,... |
375bbae48b5d86457575ef000d34a84764d4b0c95f19930a560304dce3d9f0bf | Python | 2,737 | 112 | from __future__ import annotations
import pytest
dask = pytest.importorskip("dask")
pytest.importorskip("distributed")
from ase.build import bulk, molecule
from dask.distributed import get_client
from quacc.recipes.emt.core import relax_job, static_job # skipcq: PYL-C0412
from quacc.recipes.emt.slabs import bulk_t... |
4984775a85a83404c8fa871dfe142f7b6f9fa0ddd62f35b9f91094fba14777d5 | Python | 2,737 | 88 | import numpy as np
import xml.etree.ElementTree as ET
import json
bohr2ang = 0.5291772109
hartree2eV = 27.21138602
def save_band_json(lat, kpts, eig, efermi, plot_hsk_symbols):
'''
only supports non-spinful case
Arguments
---------
lat(3, 3): R_ij is the jth cartesian component of ith lattice vector
kp... |
96820404a5aaf1771343eee9141a3dfb25e9586a0429205b7cc4fb15f61d37e3 | Python | 2,737 | 104 | import numpy as np
from merlin.core import analysistask
'''This module contains dummy analysis tasks for running tests'''
class SimpleAnalysisTask(analysistask.AnalysisTask):
def __init__(self, dataSet, parameters=None, analysisName=None):
super().__init__(dataSet, parameters, analysisName)
def _r... |
bc1e5d9f7e23befdff640d889844aad991564bcf2585a47f6348a1a6f4f5c638 | Python | 2,737 | 71 | """The region-counting path warns when the annotation on disk looks corrupted
or outdated relative to the atlas CSV.
A healthy full-CCF annotation contains every leaf structure, so its max
parcellation index equals the CSV's. The float32 label-corruption bug dropped
that max (1327 -> 1276 in the wild) by zeroing/... |
2764656a3bcf797f9642ae54e97673029548759b229827ff7bc46daa9ef2bcde | Python | 2,738 | 83 | import time
import numpy as np
import pytest
from pupil_recording_interface.stream import BaseStream
class TestBaseStream:
def test_constructor(self, mock_device):
""""""
stream = BaseStream(mock_device)
assert stream.device is mock_device
assert stream.name == "mock_device"
... |
4c42c58193a87f796132668809558bf54ecf9615e8f4eb9fa246cc009e89d862 | Python | 2,738 | 92 | import collections
import logging
from typing import Generator, List, Optional, Sequence, Tuple
from pip._internal.utils.logging import indent_log
from .req_file import parse_requirements
from .req_install import InstallRequirement
from .req_set import RequirementSet
__all__ = [
"RequirementSet",
"InstallReq... |
82b4db1923ee91ab9ca3f9c7d3e315af43951844e367fb9b6b336a547e2c3e08 | Python | 2,738 | 89 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
bb440dabbde4ee44d71cfaab857070dfe0d03db71a78218c62fd1e053291072d | Python | 2,739 | 90 | from pathlib import Path
import pytest
import torch
from elasticai.creator.file_generation.on_disk_path import OnDiskPath
from elasticai.creator.nn.fixed_point.conv1d.layer import Conv1d
from elasticai.creator.testing.ghdl_simulation import GHDLSimulator
from elasticai.creator.testing.simulated_layer import Simulated... |
c53b297263fa37151e00b4082d9864a2bed76787a02a8d322d7833a24078e8f6 | Python | 2,739 | 108 | """Helper functions analysis
----------------------------
Helper function for deriving dependent analysis parameters from base parameter
dictionaries.
"""
import numpy as np
import copy
def derive_dependent_parameters(net_dict, sim_dict, base_ana_dict):
"""
Derives analysis parameters which depend on the n... |
68eed7d3240321e82f903033e0d6a788f30caf7024f9654f18f971d6f4945130 | Python | 2,740 | 71 | """Static API contracts checked by mypy; no calculations are executed."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
from typing import assert_type
from ase.atoms import Atoms
from ase.calculators.emt import EMT
from ase.md.md i... |
0f9de54d614e6473e47276cc0fb51e83aebf1c914d373361a5494c945eca201b | Python | 2,741 | 89 | import click
import numpy as np
import pandas as pd
import os
from sequence import SeqDreamChallange1D
from model import ResidualUnit1D_BN
import tensorflow as tf
from tensorflow.keras import Model, models, activations, layers
from tensorflow.keras.layers import Input, Conv1D, MaxPooling1D, Flatten, Dense, Dropout,... |
793340fc528739af44261111132d449c89f5b2eecd0c73a17f899ef61aa79d8e | Python | 2,741 | 103 | from baseline_aug_vgg import get_unet
from glob import glob
from cv2 import imread
from PIL import Image
from skimage.transform import resize
import numpy as np
from matplotlib import pyplot as plt
from skimage.morphology import label
from pycocotools import mask as maskUtils
from tqdm import tqdm
import os
import cv2
... |
7d53ab8e71211ac08bd3f0a6a7b0aa0059da147c57bcc58a2786918aa476c95f | Python | 2,741 | 63 | import os
#os.environ['KMP_DUPLICATE_LIB_OK']='True'
import matplotlib.pyplot as plt
import numpy as np
import torch
from torch.optim.optimizer import Optimizer, required
class LinOpGrad():
'''
Implements finite difference and its adjoint
'''
def __init__(self,ndims=2,index=None,bc = 'zeros',res=1... |
73fe9d8df00b64786c5c96a753c1d63ba86911baf2fa865e3b9dcdb1928bb96d | Python | 2,743 | 57 | # 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
#
# ht... |
e49d2eb79c81747ab4ef84c8cf115f0378f2127ed56d13d36ee562e254692ecc | Python | 2,743 | 71 | """
Created on Mon Oct 30 17:11:31 2023
@author: trianaa1
"""
import sys
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from nilearn import plotting
###############################################################################
# Change only!
pat... |
3c6e59bae74f897c16f1465417af59957a761aa4f1d5a4fb484a0234978239f1 | Python | 2,744 | 80 | import time
import numpy as np
from pydrake.systems.analysis import Simulator
from pydrake.trajectories import PiecewisePolynomial
from examples.drake.utils import get_configuration, user_input
def step_trajectories(diagram, diagram_context, plant_context, trajectories, time_step=0.001, teleport=False):
diagram... |
46bec74b97abba74cc842da898630d71a228030b77edebef40e91ab94aee5287 | Python | 2,744 | 85 | from collections import defaultdict
from downward.reports.scatter import ScatterPlotReport
from downward.reports.plot import PlotReport
EPSILON = 0.01
def get_relative_change(val1, val2):
"""
>>> get_relative_change(10, 0)
-999.0
>>> get_relative_change(10, 1)
-9.0
>>> get_relative_change(1... |
8cbda59081ef43b3a6c40fb1c60c02e87411e00db5fb2ed07181753cfa5b1135 | Python | 2,744 | 82 | # Node group ".MN_pivot_nucleic" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# Shared by several assets, which import it; not an asset itself.
# _build_group() is the source of truth: the docstring, __init__ and accessors are regene... |
94225019501e73ca5cd21d6bc92dd8a2cb9f6c2c9a9fb39c6b100c13ae24efa2 | Python | 2,744 | 115 | from __future__ import annotations
import pytest
ct = pytest.importorskip("covalent")
from quacc import flow, job, subflow
def test_covalent_decorators(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
@job
def add(a, b):
return a + b
@job
def mult(a, b):
return a * b
... |
a3fa3beb60431e2c5322f93cdf293906c6ea88c56e02091eb5b4a85f9b90493b | Python | 2,744 | 110 | import math
import meep as mp
def refl_planar(theta, kz_2d):
resolution = 100
dpml = 1.0
sx = 10
sx = 10 + 2 * dpml
cell_size = mp.Vector3(sx)
pml_layers = [mp.PML(dpml)]
fcen = 1.0
# plane of incidence is XZ
k = mp.Vector3(z=math.sin(theta)).scale(fcen)
sources = [
... |
943610a0566ae32271adf1244a93b6439d3c88473dc0969631f670facd92168a | Python | 2,745 | 95 | from os import environ
import pytest
import torch
from elasticai.creator.arithmetic import FxpParams
from elasticai.creator.nn import fixed_point as nn_creator
@pytest.mark.parametrize(
"total_bits, frac_bits, num_steps",
[
(4, 3, 4),
(6, 4, 32),
(8, 5, 64),
(10, 6, 16),
... |
88fc754635a47042cca606840fab5b33cf63704dcc89b685d15d49b52b430e7a | Python | 2,746 | 88 | ''' Modified by Mayank Kabra
From LEAP https://github.com/talmo/leap by Talmo Pereira
'''
import os
import numpy as np
import re
from time import time
import h5py
def versions(list_devices=False):
""" Prints system info and version strings for finicky libraries. """
import keras
import tensorflow as tf
... |
9fd833b02be1754186208c21bff6e7469554c3663fe3a70795fed1215c17c57f | Python | 2,746 | 89 | """Configuration file for the Sphinx documentation builder."""
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If... |
8cfe45e02e0a6d0903d883d29bda450383c28166b93324ea11667d6b75987812 | Python | 2,747 | 133 | import re
DELIMS = [
"=",
"-",
",",
"?",
"!",
";",
":",
"//",
"/",
"(",
")",
"[",
"]",
'"',
"&",
"' ",
" '",
". ",
]
HIGHLIGHTING_DELIMS = [
"=",
"-",
".",
",",
"?",
"!",
";",
":",
"//",
"/",
"(",
")... |
a4dcfef676068343c6fab3b0191d49e8e413a6a1f0f4452877b5f330c41fc296 | Python | 2,747 | 92 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import itertools
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
from downward.reports.compare import ComparativeReport
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterP... |
b2e482700003c922f8ee9d9c07dacf0e1497f17f575ce7898e776025a9e6aac3 | Python | 2,747 | 76 | import matplotlib
matplotlib.use("Agg")
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
from utilities.script_func import init, post, ScikitFeat_pre
import pickle
import logging
logging.info("")
def main():
import Models.models as Models
import Models.model_func as Model_F... |
fc2b3456510f62bdc6d6a5a810bafb011f518ef8adedf213bce9aeaf4e137b26 | Python | 2,747 | 100 | # Node group "Animate Fraction" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# Shared by several assets, which import it; not an asset itself.
# _build_group() is the source of truth: the docstring, __init__ and accessors are regener... |
23a35a0a5ee3ac2a7ebd19cde98530e6b6b86b425ebc12f9fd3d38bd18c7f319 | Python | 2,748 | 73 | import numpy as np
from sklearn import random_projection
from sklearn.decomposition import PCA
import random
class Node(object):
def __init__(self, data):
self.data = data
self.index = None
self.hyperplane = None
self.PCAmean = None
self.splitDi... |
9e3321228f70e102b6b499af5637699c228943992bbefe22db29625d23888b72 | Python | 2,748 | 89 | import pprint
import random
from pathlib import Path
import tiktoken
import tqdm
from openai import OpenAI
from pandas._typing import FilePath
from ord.utils import json_load, json_dump
_API_KEY = "YOUR_API_KEY"
Client = OpenAI(api_key=_API_KEY)
MODEL_NAME = "gpt-3.5-turbo-0125"
MAX_TOKENS = 3000
def print_models(... |
c9982fcd1938fea81be2e2181017d0f188d9896e855abc50f32905225f1f6e2e | Python | 2,748 | 86 | '''
Description:
Figure plotting for extrapolating multiple timepoints.
Author:
Jiaqi Zhang <jiaqi_zhang2@brown.edu>
'''
import numpy as np
from plotting import *
from plotting.__init__ import _removeTopRightBorders, _removeAllBorders
# ======================================================
model_colors_dic... |
d4a9bfe6d7630f4b484af4f4c6215b064d1cda56b449cb8399feafb4b05db571 | Python | 2,748 | 96 | # Node-group asset "Separate Polymers" (GeometryNodeTree), dumped by nodebpy.assets.dump_library.
# Rebuild the library with nodebpy.assets.build_library (nodebpy build).
# _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump.
from typing import TYPE_CHEC... |
f91d76600491dd37e538d33d3073172a45125966cace2c6fd8a140843a150c4e | Python | 2,748 | 96 | """
https://github.com/AllenInstitute/deepinterpolation/blob/master/deepinterpolation/generic.py
"""
import json
class JsonLoader:
"""
JsonLoader is used to load the data from all structured json files associated with the DeepInterpolation package.
"""
def __init__(self, path):
self.path = p... |
3ab870de4b9fe32afff9c164a49e2b4b992b2434b41413c5581a92f1faff89e8 | Python | 2,749 | 80 | import pytest
import shutil
import tempfile
import os
import numpy as np
from botocore import UNSIGNED
from botocore.client import Config
from google.auth.credentials import AnonymousCredentials
from merlin.util import dataportal
def local_data_portal():
tempPath = tempfile.mkdtemp()
with open(os.path.join(t... |
76bd6242415e8c5e307a0c1b2ffa8c92902aec45be26735eedffd6dee7ae6180 | Python | 2,749 | 76 | """Gradients of the normal distribution."""
import scipy.stats
import autograd.numpy as anp
from autograd.extend import defvjp, primitive
from autograd.numpy.numpy_vjps import unbroadcast_f
pdf = primitive(scipy.stats.norm.pdf)
cdf = primitive(scipy.stats.norm.cdf)
sf = primitive(scipy.stats.norm.sf)
logpdf = primit... |
7aebeabb3b81fed1d4dda6d4f9949b85058c21af238396becf9e6faba5838fb8 | Python | 2,749 | 64 | """HED data models: strings, tags, groups, inputs, queries, and definitions.
This module provides the core data structures used to represent, validate, and
transform HED-annotated data. A loaded :class:`~hed.schema.HedSchema` (from
``hed.schema``) is typically passed in when constructing these objects.
Typical usage
... |
b3ea80814106042950cd3e38e415b07ca94c53ca1aabdea0521a7b76e3faf46e | Python | 2,749 | 37 | """SNPF_SEROTONIN.py 2026-09-24. Pre-registration: 04-NOTES/PREREG-2026-09-24-SNPF-SEROTONIN.md"""
import re, numpy as np, pandas as pd
from scipy.stats import mannwhitneyu
R = 'D:/eucys'; L = []
def p(m=''): L.append(str(m)); print(m, flush=True)
a = pd.read_csv(f'{R}/02-DATA/flywire-annotations/Supplemental_file1_ne... |
39adbde97c0684cade8c52141ade0df83adcebb4c3890e4c4738adfb7943b4a1 | Python | 2,750 | 76 | import os
import pandas as pd
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
def walk_through_dir(dir_path):
"""walks though dir_path returning its content"""
for dirpath, dirnames, filenames in os.walk(dir_path):
print(f"There are {len(dirnames)} directories and {l... |
1cbecc102fc1e8a61df2f996fb205a418ebf4416287beef94d48c31d2eecabe6 | Python | 2,751 | 83 | """
Efficacy Score (ES) calculation per game session.
Requires: merged_data.pkl (output of preprocessing.py).
For each game session the Efficacy Score is defined as:
ES = mean(success_rate) / mean(response_time)
Response times are clipped to [0.3, 12] seconds before scoring.
Only the first session per participan... |
2326abce8e2c851886c1314a903c542a0a0ad104675c2ae6fff692a5b30867fc | Python | 2,751 | 86 | import os
import matplotlib.pyplot as plt
import numpy as np
import unittest
import pyntbci
class TestTopoPlot(unittest.TestCase):
def tearDown(self):
plt.close("all")
def test_input_values(self):
locfile = os.path.join(os.path.dirname(pyntbci.__file__), "capfiles", "biosemi64.loc")
... |
c1992ccc1c8feac7f517496ee873d4dfbcf6f89396063b8a0078c3f8cf31a8fe | Python | 2,751 | 124 | from __future__ import annotations
import pytest
jf = pytest.importorskip("jobflow")
from ase.build import bulk, molecule
from quacc import job
from quacc.recipes.emt.core import relax_job, static_job # skipcq: PYL-C0412
def test_tutorial1a(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
# Make an A... |
e487dd85aae95b909b4e9396a8087309c8dd7ce6d43b68db7f3027c30e06a56c | Python | 2,752 | 69 | import itertools
import torch
import torch.nn as nn
import nibabel as nib
from nipype.interfaces import fsl
from nipype.algorithms.misc import Gunzip
from nilearn import plotting, image
from nilearn.input_data import NiftiLabelsMasker
# Step 1: Extract different regions of fMRI using AAL atlas
def extract_regions(fmri... |
e05219c48262adacc3ab2eb3420c6613c8dc59fe46c092bf8908e7258c658716 | Python | 2,754 | 75 | import argparse
from matplotlib import pyplot as plt
import pytorch_lightning as L
import seaborn as sns
import sys
# local imports
sys.path.append("..")
from shapelearningtheory.datasets.multi_shape_dataset import MultiShapeDataModule
from helpers import format_table, train_and_validate, unpack_results, \
get_stan... |
34f6a03f5d5704479972635390dc8cf2ffceb2dee02324ce1adfba2ba0316414 | Python | 2,755 | 69 | #!/usr/bin/env python
# NB: This module include partly modified third-party code distributed under the
# license below.
##############################################################################
# The MIT License (MIT)
# Copyright (c) 2015 CGAT
# Permission is hereby granted, free of charge, to any person obtai... |
92efdc73616a0d540941e76f4ae8f403782a99339f2bfbe4b1bcdbc7cf98f577 | Python | 2,755 | 70 | import numpy as np
from scipy.stats import gamma, norm
import sys
from state_estimation import smc_c
import matplotlib.pyplot as plt
import sys
sys.path.append("../useful_functions/")
import useful_functions as uf
def get_smoothing_trajectory(actions, rewards, idx_blocks, choices, subj_idx, m_sample, apply_rep_bias, a... |
20bee3a412f68bc93af9f8a625171527f975f31e966104a83a9080e11de4a0d6 | Python | 2,756 | 94 | import os
import h5py
import numpy as np
from tifffile import imwrite
def createTIFF(f_vol_out: str, channel_names: list):
'''
args: f_vol_out -> path of the output volume (h5 file)
channel_names -> channel names in the volume
returns a numpy image array
'''
# make more modular (chang... |
a64829dbcc6351d8c78a5fc72b8d988f5956b2381b6bd04a8543d2487918805f | Python | 2,756 | 76 | import ntpath
from keras.optimizers import Adam
import keras.backend as K
import gc
import warnings
from src.gan import predict
warnings.filterwarnings('ignore')
from src.gan.model import fine_generator, coarse_generator
from src.gan_settings import GanSettings
from src.methods import Methods
warnings.filterwarnin... |
b8ebaa9dc7c5ef839b6f41387678ce18bea29db26cd1bc3d0a034469723f6eb7 | Python | 2,756 | 138 | #!/usr/bin/env python
# coding: utf-8
# ## Download tumor purity data
#
# The TCGA PanCanAtlas used [ABSOLUTE](https://doi.org/10.1038/nbt.2203) to calculate tumor purity and cell ploidy for samples with WES data. We'll use tumor purity values as a target variable/label for some of our multi-omics experiments.
# In[... |
d55228e5616a01eee98200bd3093f6eac5c4dee498c383f0b3a94c0ea2f96b5d | Python | 2,756 | 67 | import torch
import numpy as np
import time
from src.BSA_Phantoms.src_nn.network import Network
from src.BSA_Phantoms.src_nn.utilities import *
from torch.autograd import Variable
class NOEMRFReconstruction:
def __init__(self):
self.device = check_cuda()
self.dtype = torch.DoubleTensor
se... |
d7c73c024bf0489e85fa25df12da58d0eda36bc2d30b7719898f844305f2494d | Python | 2,756 | 112 | from __future__ import annotations
import pytest
dask = pytest.importorskip("dask")
pytest.importorskip("distributed")
from ase.build import bulk, molecule
from dask.distributed import get_client
from quacc.recipes.emt.core import relax_job, static_job # skipcq: PYL-C0412
from quacc.recipes.emt.slabs import bulk_t... |
59f4f064bea7258c6a910ab0a8e51c8a59aa42ac71f422a547c4bbef5cdb3d22 | Python | 2,757 | 74 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
5da54db2e464bfa3f21d09e5eb1f9c4200be5627e8695eab08b9b24d998bba19 | Python | 2,757 | 91 | import os
from argparse import FileType, ArgumentParser
import pandas as pd
import numpy as np
from Bio.PDB import PDBParser, MMCIFParser
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from tqdm import tqdm
parser = ArgumentParser()
parser.add_argument('--data_path', type=str, default='data/PDBBind_af2_al... |
7ed1d3f62d0161ac11c5541173103cc1d29ca47ddeab22cd17628f10bf541b6a | Python | 2,757 | 50 | # 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
#
# ht... |
8e056a83f4cfce7e270ab5b750c38a6e1bcca09d18e80fbacf83d4b921ec07bd | Python | 2,757 | 72 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# 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 applicab... |
d66f11f447335505ce36a979c428d6ce44fe9d266d3227d5ab05f1fdf9a5afc1 | Python | 2,757 | 90 | """Discoverability tooltips across the registration GUI tabs.
Each tab is constructed under offscreen Qt and a representative set of key
user-facing controls is checked for a non-empty tooltip. Construction is
guarded so a tab that can't build (e.g. missing optional deps) skips
gracefully rather than failing the ... |
b8aacaaf36fac31b937cd858cf7f7fb3517ea27fb79bfa0f399664de3e74a930 | Python | 2,758 | 103 | from collections import OrderedDict
from numpy import sum, zeros
from numpy.random import seed
from numpy.testing import assert_array_equal, assert_array_almost_equal
from pytest import raises
from wonambi.utils import create_data
from wonambi.trans import montage
from wonambi.trans.montage import compute_average_regr... |
aab5875ceb8c7c8e3e2af328d2350e96d0fd058a5acf1aa6bedb7c0c28b29efe | Python | 2,759 | 91 | # -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Interfaces to assorted Freesurfer utility programs.
"""
import os
import re
import shutil
from nipype import logging
from nipype.utils.filemanip import fname_presuffix, split_fil... |
c4868f189a4c7f6efb209509edfebe5be54bf001721dbc33ffc01032dded6ab6 | Python | 2,760 | 69 | #!/usr/bin/env python
#================================================================
# Copyright (C) 2023 Yufeng Liu (Braintell, Southeast University). All rights reserved.
#
# Filename : sdmatrix.py
# Author : Yufeng Liu
# Date : 2023-01-30
# Description :
#
#======================... |
fc68a29439722a37687f58f7c57661adfe8d463c65fa48279d1309f3d0035195 | Python | 2,760 | 121 | """Code for handling color names and RGB codes.
This module is part of Swampy, and used in Think Python and
Think Complexity, by Allen Downey.
http://greenteapress.com
Copyright 2013 Allen B. Downey.
Distributed under the GNU General Public License at gnu.org/licenses/gpl.html.
"""
import re
# the following is the... |
248175cafcd0da796b927c4d3cc081d593285df6665263d516e6e6ff81e30fdd | Python | 2,761 | 72 | #!/usr/bin/env python
# NB: This module include partly modified third-party code distributed under the
# license below.
##############################################################################
# The MIT License (MIT)
# Copyright (c) 2015 CGAT
# Permission is hereby granted, free of charge, to any person obtai... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.