sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
6dd812aa786950b51c89d723b60b55f79a45c466e1680ae40e0fc7f794891b39 | Python | 10,352 | 242 | """Write the substructure element sets, materials and sections for the Abaqus deck.
The deck DRAGen_RVE.inp already contains one `*Elset Set-<grain>` per grain. This module adds a
second, finer partition -- one material region per block (substructure) or per grain (everything
else) -- so each block can carry its own o... |
3427ff9a03ecbf276ca13092ac2c6cf4234efd9f27dbfa4b5ce0ab09e778faec | Python | 10,354 | 215 | import argparse
import json
import os
import gudhi
import gudhi.wasserstein
import numpy as np
from sklearn.manifold import MDS
from utils import get_dataset, timer
from barcodes_calculation import get_0_dim_barcodes
def get_mds(dissimilarity_matrix, is_euclidean=None, random_state=6):
if is_euclidean:
em... |
7d1722fef2fa871b51273665e002cdfb7e45c462369232232941b39a08ce949f | Python | 10,355 | 246 | import time
import scipy.io as scio
import torch
from braincog.base.node.node import *
from braincog.base.brainarea.BrainArea import *
import pandas as pd
import matplotlib.pyplot as plt
class brain_region(BrainArea):
def __init__(self, name, num_neuron, neuron_type_ratio, neuron_type_p, neuron_type_index, W):
... |
972cb5c89121620267235c8e943a426ee8fc3aa6bb9bbc6705b56e354273c558 | Python | 10,356 | 240 | import os
import re
import sys
import tqdm
import random
import jieba
import pickle
import joblib
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.nn.functional as F
from LAC import LAC
from transformers import BertTokenize... |
5e195fd32b5a44384270bb45d82fdc7500268507a042a5b846aeabe72529c69f | Python | 10,357 | 251 | #!/usr/bin/env python3
# Copyright 2019 Christian Henning
#
# 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 l... |
8858f71d6389e55f996b9e6d2fbd2fff674a185c17dbc1a0b79e506666545874 | Python | 10,357 | 273 | import torch
import torch.nn as nn
import torch.nn.functional as f
from torch.nn import init
class ConvLayer(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, activation='relu', norm=None):
super(ConvLayer, self).__init__()
bias = False if norm == 'BN' el... |
cb680248f3f254d12ab332f40f3e3bd6830cf88524c7c592eff25c1df4b38784 | Python | 10,365 | 385 | import weakref
from pathlib import Path
from typing import Any, Callable, Dict, List
import numpy as np
import pytest
from hypothesis import given, settings, strategies
from scipy.sparse import csr_matrix
import xgboost as xgb
from xgboost import testing as tm
from xgboost.core import SingleBatchInternalIter as Singl... |
16b30d2c8c42b5a307599f493bba56b685d34f57fc7950ee444c7dd74f00c368 | Python | 10,367 | 340 | # -*- coding: utf-8 -*-
"""
Modified from https://github.com/pytorch/vision.git
"""
import torchvision
import torch.nn as nn
import torch.nn.functional as F
from .modelBase import ModelBase
def create_torchvision_model(modelname, pretrained=True, num_classes=2, dimensions=2):
"""
Create a torchvision model ... |
1df481a9b653310e68e7a88835cc823d9764df4430c7ed0b772e9335e31886cb | Python | 10,370 | 173 | import os
import sys
import argparse
import torch
import numpy as np
from random import shuffle
from collections import OrderedDict
import dataloaders.base
from dataloaders.datasetGen import SplitGen, PermutedGen
import agents
def run(args):
if not os.path.exists('outputs'):
os.mkdir('outputs')
# Pre... |
d77f252c2b69ef68e7794d36ab8ea6c2b911f4cfbd22e0f2d1df1205a24e73f7 | Python | 10,379 | 290 | from jax import numpy as np
from matplotlib import pyplot as plt
from jax import jit, vmap, grad, pmap
from jax.experimental.ode import odeint
from jax import random
import numpy as onp
import matplotlib as mpl
from functools import partial
from tqdm import tqdm
from celluloid import Camera
s_ = onp.s_
tqdm = lambda _... |
2b412dffeee24f9ebfe3af7aa8555094a11bb54620038fda1fe337bd6a7677b1 | Python | 10,387 | 299 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any... |
af281d2e7ac4dc21e73a185be1a30cacaab700e1f84b81062ed434f84dc1ce8c | Python | 10,391 | 275 | """LIBSVM and SVMLight version 1 decoding."""
from __future__ import annotations
import bz2
import gzip
import math
import re
from array import array
from collections.abc import Mapping
from dataclasses import replace
from pathlib import Path
from typing import Literal, TextIO, cast
import numpy as np
from scipy imp... |
620f9b10fb8e750c42c1dc18f12b42bd769b7161eb465e80db680980bb32a5e5 | Python | 10,394 | 240 | """
Author: "Keitaro Yamashita, Garib N. Murshudov"
MRC Laboratory of Molecular Biology
This software is released under the
Mozilla Public License, version 2.0; see LICENSE.
"""
from __future__ import absolute_import, division, print_function, generators
import gemmi
import numpy
import json
import os
import argpa... |
aee94fb65c86f03675de31d5a13042f610fb64d592d109e4d5bc163d33671539 | Python | 10,400 | 250 | import numpy as np
from PIL import Image
import h5py
import json
import os
import io
import pickle
from torchmeta.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchvision.datasets.utils import download_file_from_google_drive
class TieredImagenet(CombinationMetaDataset):
"""
The Tiered... |
b2b28c3400b472aed0b1062f7b2f557184a182c2305835620bdb9ac126f0860f | Python | 10,406 | 232 | # TODO August 06 version
import os
import torch
from collections import OrderedDict
from abc import ABC, abstractmethod
from . import networks
class BaseModel(ABC):
"""This class is an abstract base class (ABC) for models.
To create a subclass, you need to implement the following five functions:
-- <_... |
8b8b0a9ed59e8b1a3f11cb0ed61dbede5607bd311609e2ad0a8807024b47ced3 | Python | 10,413 | 306 | from os import chmod
from os.path import exists
import nibabel as nib
import numpy as np
from GPUtil import GPUtil
from traitlets import Dict, Instance, Unicode, Bool, Enum
from traitlets.config.loader import ArgumentError, ConfigError
from mrHARDI.base.application import (mrHARDIBaseApplication,
... |
db251320b40759ad5c44edb31edf41cdea077c9ee6858aa44ddcbbb8899e788c | Python | 10,414 | 238 | """ Model / state_dict utils
Hacked together by / Copyright 2020 Ross Wightman
"""
import fnmatch
import torch
from torchvision.ops.misc import FrozenBatchNorm2d
from timm.layers import BatchNormAct2d, SyncBatchNormAct, FrozenBatchNormAct2d,\
freeze_batch_norm_2d, unfreeze_batch_norm_2d
from .model_ema import Mo... |
dff59aa74b58c696a02fc4434808fa1dae89a867d23720be3022c1835ca691ca | Python | 10,415 | 181 | #### Master Script 05h: Compile testing set performance results to calculate confidence intervals of baseline models for comparison ####
#
# Shubhayu Bhattacharyay
# University of Cambridge
# email address: sb2406@cam.ac.uk
#
### Contents:
# I. Initialisation
# II. Compile and save bootstrapped testing set performance ... |
e8197d301ddefe5e8e2115565d226e6367c793f4dde5d8d30f6133f5f206207f | Python | 10,417 | 276 | from __future__ import annotations
import os
import subprocess
from pathlib import Path
import pytest
import yaml
ROOT = Path(__file__).resolve().parents[3]
WORKFLOW = yaml.safe_load((ROOT / ".github/workflows/ci.yml").read_text())
DETECT = next(
step["run"]
for step in WORKFLOW["jobs"]["python-distribution-... |
0bf7d0b04df72d905af957f6e0154f1ce68f85c19d88f8fc136f7ecb7b2b5088 | Python | 10,446 | 232 | from pathlib import Path
from xml.etree.ElementInclude import include
import numpy as np
from sklearn.model_selection import GroupKFold, ShuffleSplit, StratifiedGroupKFold
from sklearn.utils import shuffle
class BaseDataset():
path_root_default = Path('')
default_series_trans = None
default_item_tran... |
584e838f4967b8aa668084341c5ad71fe03411049bca4444bad4730dfec01b62 | Python | 10,451 | 267 | """Helpers for plugins that offload their `run()` logic to a separate
process/environment via Appose (https://docs.apposed.org).
A plugin using this module ships:
- a lightweight frontend `Module` file, importable in the default
CellProfiler environment (only standard cellprofiler dependencies at module
level)
- a... |
c4089cb466073e4d261e7a307f759d2bd345d04aa690419d85541235972ee24d | Python | 10,464 | 288 | #!/usr/bin/env python3
import numpy as np
import pandas as pd
import os
import scanpy as sc
from scipy.stats import pearsonr
import networkx as nx
import time
from datetime import timedelta
import bambi as bmb
import arviz as az
from scipy import stats
import math
def checkGeneList(geneList, normCD, allOutput_df):
... |
d5e719df17a5d49dffb305fc2b619f7f62c69f89480e870a36a3c406b3ef7d14 | Python | 10,466 | 316 | """
pysteps.feature.tstorm
======================
Thunderstorm cell detection module, part of Thunderstorm Detection and Tracking (DATing)
This module was implemented following the procedures used in the TRT Thunderstorms
Radar Tracking algorithm (:cite:`TRT2004`) used operationally at MeteoSwiss.
Full documentation i... |
776d07d784335fb44f86af492c14629811be22e4a25ddb5f5f6802da1d9605da | Python | 10,468 | 434 | # -*- coding: utf-8 -*-
import matplotlib as mpl
mpl.use('agg')
from matplotlib.testing.compare import compare_images
from tempfile import NamedTemporaryFile
import os.path
import pygenometracks.plotTracks
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"test_data")
browser_tracks ... |
d6a02830c48036c5e9a253c96813a76270bc72105076437d00efcc459f6957b9 | Python | 10,469 | 190 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import sys, os
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import tensorflow_probability as tfp
from tensorflow.python.framework import constant_op
from tensorflow.python.fram... |
671c69ec71057427eb1be78d2f3295a3baa85a54a5793023ee77ac728ee311ed | Python | 10,478 | 222 | #### Master Script 6b: Calculate testing set predictions with dynamic tokens removed in parallel ####
#
# Shubhayu Bhattacharyay
# University of Cambridge
# email address: sb2406@cam.ac.uk
#
### Contents:
# I. Initialisation
# II. Calculate static-only testing set predictions based on provided bootstrapping resample ro... |
4c6520ad385a71e7cc0881e9dc0aad645c980a8dc1974af8cb6050ea15b8ec58 | Python | 10,482 | 250 | import time
import scipy.io as scio
import torch
from braincog.base.node.node import *
from braincog.base.brainarea.BrainArea import *
import pandas as pd
from numpy import genfromtxt
import matplotlib.pyplot as plt
class brain_region(BrainArea):
def __init__(self, name, num_neuron, neuron_type_ratio, neuron_type... |
d054c81fc2318d8dcd98682101ba417aff8a149faed372bc48bc42b6985328ee | Python | 10,482 | 350 | """Route requests with Flask."""
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime, timezone
from pathlib import Path
import numpy as np
import wtforms as wtf
from flask import (
Blueprint,
current_app,
jsonify,
redirect,
render_template,
reque... |
efb79a50e7fc95b1755cf1e2b9de947b76aeaa70933fa87027ef79bd4e70af71 | Python | 10,485 | 285 | import pickle
import torch
from .base import BayesianSpikingModel
from ..decoding import BayesianDecoder
from ..kernels import KernelValues
from ..masks import shift_mask
from ..utils.time import get_dt
class GLM(BayesianSpikingModel, BayesianDecoder):
def __init__(self, b, kappa, eta, noise='poisson'):
... |
8300c0aff4a737797c27616e276581f353f11471cfb2f8ffc824952cc7b18d72 | Python | 10,486 | 279 | """ ResNeSt Models
Papers:
* `ResNeSt: Split-Attention Networks` - https://arxiv.org/abs/2004.08955
Adapted from original PyTorch impl w/ weights at https://github.com/zhanghang1989/ResNeSt by Hang Zhang
Modified for torchscript compat, and consistency with timm by Ross Wightman
"""
from typing import Optional, ... |
dfeffbcdc8c026242c60d4cdc885fd32c84c777a283cf4f6914d7ef2a59c4f67 | Python | 10,529 | 266 | """
Smooth
======
**Smooth** smooths (i.e., blurs) images.
This module allows you to smooth (blur) images, which can be helpful to
remove small artifacts. Note that smoothing can be a time-consuming process.
|
============ ============ ===============
Supports 2D? Supports 3D? Respects masks?
============ =========... |
526da2e1cfbfc0f2d8db5f1e656c0556f9104a8fc678ddc37171bac3cf0a6cd6 | Python | 10,530 | 302 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any... |
620a5cf6844a7f6ab420cc8edd4af0d5fea50148860cdd82b5a18291f3ef6e01 | Python | 10,531 | 342 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any... |
85272f303f4fc61814e28abebb1c93bf6d548bc361264f1fd462ec6f8d5f9f97 | Python | 10,543 | 286 | """ Non-Local Attention Pooling Layers
A collection of global pooling layers that go beyond simple avg/max pooling.
LSEPool - LogSumExp pooling, a smooth approximation between avg and max pooling
SimPool - Attention-based pooling from 'Keep It SimPool' (ICCV 2023)
Based on implementations from:
* LSE Pooling: custom... |
7384a24be355e3a57949a306047204e7110692fc1cab4edc7aeacd7f7f40973d | Python | 10,545 | 225 | from cellprofiler_core.preferences import (
ABSOLUTE_FOLDER_NAME,
DEFAULT_INPUT_SUBFOLDER_NAME,
DEFAULT_OUTPUT_SUBFOLDER_NAME,
)
from cellprofiler_core.utilities.image import image_resource
DEFINITION_OBJECT = """\
In CellProfiler, we use the term *object* as a generic term to refer to
an identified featur... |
1fdd8ac7348f7d64ac73a67606aea1d148c9a9ae58dc3b201880f76cfab9920f | Python | 10,560 | 233 | """
Implementation of the Brunel 2000 network:
sparsely connected network of identical LIF neurons (Model A).
"""
# This file is part of the exercise code repository accompanying
# the book: Neuronal Dynamics (see http://neuronaldynamics.epfl.ch)
# located at http://github.com/EPFL-LCN/neuronaldynamics-exercises.
# T... |
666a03516ef8e1ee776d4e5323a692ac558b021e9ff2c50e9415e64d45bd756c | Python | 10,562 | 354 | import os
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from baycomp import two_on_single
from etspredict.prediction.scoring_utils import compare_propabilites
###############################################################################
# paths to re... |
1af53b5d57b05a1832d8df59330cc12a21740b6c19edb8eb877a53b7d4ebfc0b | Python | 10,571 | 304 | """Test models"""
import unittest
from afidsvalidator import model
from afidsvalidator.model import HumanFiducialSet
# pylint: disable=missing-function-docstring
# pylint: disable=missing-class-docstring
class TestHumanFiducialSet(unittest.TestCase):
def test_empty_afids(self):
test_afids = model.Human... |
58b110d49392ecb236ca517a917a1f57b80e03c147ddd273b8c111360991d7ca | Python | 10,578 | 263 | import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
import torch_scatter
from gvp.atom3d import _NUM_RESIDUE_TYPES
class E_GCL(nn.Module):
"""
E(n) Equivariant Convolutional Layer
"""
def __init__(self, input_nf, output_nf, hidden_nf, edges_in_d=0, act_fn=nn.SiLU(), ... |
baebd470ba22e440318886f41e65f42e34e2d3dd74a4a7fb253028c01182a549 | Python | 10,598 | 389 | #!/usr/bin/env python3
import os
from itertools import combinations
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
##############################################################################
# Constants
dataset = "hcp_aging"
parcellation = "schaefe... |
51880b1d9cfaae1da77fe9dc7a15021a3530d0498745445c628c8e24c02b4e6b | Python | 10,609 | 335 | # This file is part of pyunicorn.
# Copyright (C) 2008--2026 Jonathan F. Donges and pyunicorn authors
# URL: <https://www.pik-potsdam.de/members/donges/software-2/software>
# License: BSD (3-clause)
#
# Please acknowledge and cite the use of this software and its authors
# when results are used in publications or publi... |
7a4867c6c47f00706931f64415a0ac1ba98b7a39ee92a4ccabfe7ac52f2c266a | Python | 10,620 | 263 | import argparse
import os
import warnings
from pathlib import Path
import pandas as pd
import pytorch_lightning as pl
import torch
import wandb
import yaml
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import CSVLogger, WandbLogger
from sklearn.model_selection import Stratified... |
e84c760ac92b7ee712b7ff55827a8d675ad3c4a4f0b0ecc4376bf4d0969c7648 | Python | 10,644 | 277 | # noqa W605
from typing import Optional
import torch
from einops import rearrange
from torch import einsum, nn
from src.models.tabular.pytorch_tabular.repository.models import common
class Residual(nn.Module):
def __init__(self, fn):
super().__init__()
self.fn = fn
def forward(self, x, **kw... |
0be8300db00dabf050cde1cec58981e6e6bcf463d7e587161ed57254d8665980 | Python | 10,646 | 264 | import argparse
import os
import warnings
from pathlib import Path
import pandas as pd
import pytorch_lightning as pl
import torch
import wandb
import yaml
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import CSVLogger, WandbLogger
from sklearn.model_selection import Stratified... |
c024128a1c7e2a55ebc5e33a7c94c585ae1e960cd032b39b08445ea30f05c5a5 | Python | 10,659 | 290 | """ MLP module w/ dropout and configurable activation layer
Hacked together by / Copyright 2020 Ross Wightman
"""
from functools import partial
from typing import Optional, Type, Union, Tuple
from torch import nn as nn
from .grn import GlobalResponseNorm
from .helpers import to_2tuple
class Mlp(nn.Module):
"""... |
b2007951fd379ad505332dd7e86a8d3489a194a0567d91ec271fe904ea5718eb | Python | 10,680 | 299 | """
DisplayScatterPlot
==================
**DisplayScatterPlot** plots the values for two measurements.
A scatter plot displays the relationship between two measurements (that
is, features) as a collection of points. If there are too many data
points on the plot, you should consider using **DisplayDensityPlot**
inste... |
b82d8d34f42cfe66b7d00b659e2d17df7da0747801f8908ad0cae8b4b65775f5 | Python | 10,687 | 244 | # TODO Sep 08 version
import numpy as np
from collections import OrderedDict
import scipy.signal
from util import util
from skimage.exposure import match_histograms
from skimage import exposure
import data
import torch
class Assemble_Dice():
def __init__(self, opt):
dataset_class = data.find_dataset_using_... |
2895cf3f04d9107e638d35d2b5151b2be46a41062f80a7849bd581e3e1208bee | Python | 10,690 | 277 | import matplotlib.pyplot as plt
import numpy as np
from ..globalFunctions import morphology_v2 as mphv2
from .utils import convert_strtosec, convert_strtoseclist, convert_strtoseg
colorkeyval = {'soma': 'tab:red', 'axon': 'tomato', 'apical trunk': 'tab:blue', 'apical trunk ext': 'royalblue',
'apical tu... |
62142caaea0a5d53b113fe950fbc34b3d025731a4ca8177e3751e387c5674b32 | Python | 10,697 | 365 | import os
import re
import wx
import wx.html
from cellprofiler_core.preferences import get_plugin_directory
from cellprofiler_core.utilities.core.modules import (
instantiate_module,
get_module_names,
)
import cellprofiler.gui
import cellprofiler.gui.help.content
import cellprofiler.gui.html.utils
import cell... |
2c9f7ae4a4b6da1ab2647f67a1ebf3bc4d5b103babc6362978f4921af7148397 | Python | 10,700 | 242 | """ Adafactor Optimizer
Lifted from https://github.com/pytorch/fairseq/blob/master/fairseq/optim/adafactor.py
Modified by Ross Wightman to fix some issues with factorization dims for non nn.Linear layers
Original header/copyright below.
"""
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is l... |
6c91550bf322f4526f69d1bd1e6e72ca29d891f1eb9b3c1ad8c92643e0e2e375 | Python | 10,708 | 251 | """Tests for timm.layers.drop module (DropBlock, DropPath)."""
import torch
import pytest
from timm.layers.drop import drop_block_2d, DropBlock2d, drop_path, DropPath
class TestDropBlock2d:
"""Test drop_block_2d function and DropBlock2d module."""
def test_drop_block_2d_output_shape(self):
"""Test t... |
f822f5679f0645fcebe8413baca3ba7526c708c93437e04a51eb677c2d9f3883 | Python | 10,709 | 223 | import glob
import json
import os
import sys
import time
import warnings
from typing import Literal
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from matplotlib import cm
from scipy import integrate
import Functions.globalFunctions.ExtracellularField as EcF
from Analyses.SDC.tools import VTA... |
f5fb5d5e7160f3c52628db82414a49127f30c0906c84a4279044b0176db0faec | Python | 10,715 | 380 | from __future__ import division
import re
from cached_property import cached_property
import numpy as np
from numpy import pi as PI
import numpy_groupies as npg
import scipy.ndimage as ndi
class FormFeatureExtraction(object):
def __init__(self, segmentation):
self.segmentation = segmentation
def ge... |
473052f8aef8e5cc616e58df81bd1fd16342539a72c509461e27c2e09397d254 | Python | 10,717 | 306 | import math
import pandas
import numpy
import os
from pepars.utils import DNA
from pepars.fileio import csv_wrapper
from pepars.utils import Sequence_Trie
from pepars.analysis import DNA as DNA_analysis
from ..workspace import Workspace as ws
from ..workspace import Database as db
class Sequence_Library:
# Loa... |
c9fd92960c05e5a81abe34be40c98feb783806b554ddb254a2089df983e302ff | Python | 10,726 | 264 | # Pytorch Tabular
# Author: Manu Joseph <manujoseph@gmail.com>
# For license information, see LICENSE.TXT
"""Feature Tokenizer Transformer Model"""
import logging
import math
from collections import OrderedDict
from typing import Dict
import pandas as pd
import pytorch_lightning as pl
import torch
import torch.nn as n... |
d13b4f282c657e0a3533697d1dd25de8e0a6e1e86802ba4a4e4b919d6a7d7d0d | Python | 10,727 | 247 | # coding:utf-8
from cellprofiler_core.preferences import (
ABSOLUTE_FOLDER_NAME,
DEFAULT_INPUT_SUBFOLDER_NAME,
DEFAULT_OUTPUT_SUBFOLDER_NAME,
)
import cellprofiler.gui.help.content
DEFINITION_OBJECT = """\
In CellProfiler, we use the term *object* as a generic term to refer to
an identified feature in an... |
02ec811ffbd87a9cd667d45e3300cca2c3341a0d974d6087dadd732942fce009 | Python | 10,748 | 271 | """ Image to Patch Hybird Embedding Layer
Hacked together by / Copyright 2020 Ross Wightman
"""
import logging
import math
from typing import List, Optional, Tuple, Union
import torch
from torch import nn as nn
import torch.nn.functional as F
from .format import Format, nchw_to
from .helpers import get_device_dtype,... |
6521d02ab6a033e865ee003ae215e69a5b7e70d333d65deed1d7f6c36849b6eb | Python | 10,753 | 249 | import numpy as np
import time
import nengo
import sys, os
sys.path.insert(1, os.path.dirname(os.getcwd()))
#os.chdir("..")
import sspslam
import argparse
# Parse command line arguments
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--backend", default="... |
c1fb5ad1eda748d68bb2bd8def10f90cfd03debfd91a36326a9d8a33034cb409 | Python | 10,763 | 343 | #!/usr/bin/env python3
# --------------------------------------------------------------------------- #
import os
import random
import string
import time
from datetime import datetime
def id_generator(size=10, chars=string.ascii_uppercase + string.digits):
return "".join(random.choice(chars) for _ in range(size)... |
8b852405f65bd0d47ca683c8ccb8aa577226c20465f2595b48f7d82d3fa6b1e0 | Python | 10,767 | 324 | #!/usr/bin/python3
def pc1(d):
"""Computes top principal component.
Parameters
------------
d: numpy.ndarray(shape=(n1,n2))
Returns
----------
numpy.ndarray(shape=(n2,))
"""
import numpy as np
from sklearn.decomposition import TruncatedSVD
# Normalize data
t1 = d.T
t1 = t1 - t1.mean(axis=0)
t1 = t1 /... |
4e74d9c85686732664583eaef0401fcc29c9f3c00b67ad2e539abc259ba32d8f | Python | 10,772 | 280 | # coding=utf-8
# Copyright 2020 The SimCLR 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... |
062bdb597ce2424eeb00f82a038f0aec5eb08e18537b4eea058337165a0e0c96 | Python | 10,779 | 310 | import time
from copy import copy
from os.path import exists, join
from pathlib import Path
import nibabel as nib
import numpy as np
from traitlets import Bool, Dict, Integer, Unicode
from traitlets.config import ArgumentError
from traitlets.config.loader import ConfigError
from mrHARDI.base.application import (Choic... |
ea24f7a6f8ae31488c7810f6c9e17145beff831c179a289dcd03b8b216e8ba35 | Python | 10,792 | 255 | """Build the JupyterLite site that runs the gallery examples in the browser.
jupyterlite_sphinx builds the site and sphinx-gallery adds the example notebooks to it.
This extension adds the rest:
- the kernel environment from ``jupyterlite/environment.yml``, byte-compiled so the
browser doesn't compile every module ... |
33eddbb033864c1574ec9a5c9132e437494b68faa1483233dde480412611eec0 | Python | 10,799 | 251 | # -- coding: utf-8 --
"""
pysteps.verification.interface
==============================
Interface for the verification module.
.. autosummary::
:toctree: ../generated/
get_method
"""
def get_method(name, type="deterministic"):
"""
Return a callable function for the method corresponding to the given... |
2102c1e6ef5eb0a78abe3472e8a06e7afb6e96da03ce263a2eee9c56e7f38c1c | Python | 10,800 | 257 | # This file is part of pyunicorn.
# Copyright (C) 2008--2026 Jonathan F. Donges and pyunicorn authors
# URL: <https://www.pik-potsdam.de/members/donges/software-2/software>
# License: BSD (3-clause)
#
# Please acknowledge and cite the use of this software and its authors
# when results are used in publications or publi... |
52647787c2e696d30ed431cb6d52c4d565c588b26c3f51a31bb8a8136b884d58 | Python | 10,807 | 324 | import os
import sys
from os import path
from glob import glob
import numpy as np
import SimpleITK as sitk
from sklearn.model_selection import KFold
from helpers import *
from dual_attention_unet import build_dual_attention_unet
from config import *
from dbx import download_and_extract
def train(
... |
277d56036f8242e74010373220f7abec8ec4801ca7d88616526d2517fcb9262d | Python | 10,840 | 223 | from centriole import cpmorphology
import numpy
import scipy
from typing import Annotated, Optional, Union, Tuple
from cellprofiler_library.modules import threshold
from cellprofiler_library.functions.object_processing import (
separate_neighboring_objects,
filter_on_border,
filter_on_size
)
from pydantic i... |
0a1b0151468cd067d3ee7a225746265f04a4d0662a0c504d204b213a05360140 | Python | 10,843 | 272 | from array import array
import pyb
from . import hardware as hw
# Constants used to indicate special event types:
timer_evt = const(-1) # Timer generated event.
hw_timed_evt = const(-2) # Timer event set by hardware object.
goto_evt = const(-3) # timed_goto_state event.
print_evt = const(-4) # User... |
15d90a05c1011a8bd4ad43ab6c478e5861214ab4c67e5c3dd5d3c2a3bda6b2e0 | Python | 10,869 | 257 | """Token-based distillation training task for models with distillation heads."""
import logging
from typing import Any, Dict, Optional, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.utils import unwrap_model
from .classification import resolve_classification_loss
from .distillati... |
d1f02cc833836ad7a1cdc6553ffb13cae41710fe25ef5d4583fc51f4d6c35311 | Python | 10,871 | 292 | # This file is part of pyunicorn.
# Copyright (C) 2008--2026 Jonathan F. Donges and pyunicorn authors
# URL: <https://www.pik-potsdam.de/members/donges/software-2/software>
# License: BSD (3-clause)
#
# Please acknowledge and cite the use of this software and its authors
# when results are used in publications or publi... |
c8cd76eebba572a71a5a1ded9948b93ddd55563da19731900bfb9e88fd4ff11a | Python | 10,876 | 270 | import datetime
import os
import sys
import logging
from logging.handlers import TimedRotatingFileHandler
import math
import time
import matplotlib.pyplot as plt
from dragen.main2D import DataTask2D
from dragen.main3D import DataTask3D
from dragen.utilities.Helpers import HelperFunctions
from dragen.utilities.InputIn... |
767d08fc4631970402a318901032fb19fe53d71da6f9bd10d3f7e514d219dfd9 | Python | 10,882 | 341 | """
Functions to create 2D patterns.
Note, in the hopfield model, we define patterns as vectors. To make
the exercise more visual, we use 2D patterns (N by N ndarrays).
"""
# This file is part of the exercise code repository accompanying
# the book: Neuronal Dynamics (see http://neuronaldynamics.epfl.ch)
# located at ... |
aec3199719af866b47e761dbf68020de386c1bdb34acb627afe36176b74bfe2a | Python | 10,885 | 232 | import PyDSTool
import numpy as np
import pickle
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter,ScalarFormatter
import matplotlib as mpl
from matplotlib.lines import Line2D
'''
Nr of molecules vs time, for fast ants, fig 5 in the paper
08.11.23
GCG
'''
params = {'axes.labelsize': 8,
... |
6f63f3d377e169c1a3942b4f85cacb2684afb2f815d447a1b8cabbb581767d16 | Python | 10,891 | 310 | import re as r
from collections import OrderedDict
from datetime import datetime, timezone
from pathlib import Path
def add_enable_when(condition: str):
"""
Parses condition string and returns the enablewhen json
"""
enable_when = []
behave = "None"
condition = condition.replace("\n", "")
... |
d23e60b8d985976eee21805314024362617f3b7b0064a3080e49c16d955f463d | Python | 10,894 | 310 | #--------------------------2 Choice-DNMTP----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# DNMTP task which is started on 12/08/2019 this is only operates two hole i.e 2 and 4 and this is simplest task in DNMT
# One of the five_poke LEDs turns on randomly (cu... |
89a37a95ed351ff6b026df40d2356ef95e2139ddbd32a0fe45a7c7e675d0ef19 | Python | 10,899 | 212 | import random
from dgl import save_graphs, load_graphs
import numpy as np
import os
from torch.utils.data import Dataset
from src.utils.io import pmap_multi
from src.utils.protein_utils import preprocess_unbound_bound, protein_to_graph_unbound_bound, UniformRotation_Translation
import pickle
from biopandas.pdb import... |
4dc4969389ec3624e4cf6646d84372d072bef3fd4a6298045f9acd88df7cdae8 | Python | 10,934 | 318 | """
DisplayPlatemap
===============
**DisplayPlatemap** displays a desired measurement in a plate map view.
**DisplayPlatemap** is a tool for browsing image-based data laid out on
multi-well plates common to high-throughput biological screens. The
display window for this module shows a plate map with each well
color-... |
99454861ca65c8f484e6480104816c740d4a9c7efb0f5ec8ff0f289ffee90a14 | Python | 10,941 | 317 | # -*- coding: utf-8 -*-
"""
pysteps.decorators
==================
Decorators used to define reusable building blocks that can change or extend
the behavior of some functions in pysteps.
.. autosummary::
:toctree: ../generated/
postprocess_import
check_input_frames
prepare_interpolator
memoize
"""... |
605f24dd6db8c2e8f04cef2310b6ae451aae11ea31aaf3c997e6ef6e09ca5e69 | Python | 10,944 | 360 | # -*- coding: utf-8 -*-
import matplotlib as mpl
mpl.use('agg')
from matplotlib.testing.compare import compare_images
from tempfile import NamedTemporaryFile
import os.path
import pygenometracks.plotTracks
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"test_data")
browser_tracks... |
fae0c1c89186fe990973f4e9d6c7e401b407cb828a65480bcb4d6d5beee01e2c | Python | 10,945 | 206 | """empty message
Revision ID: d0a243e71ea2
Revises: eef891c5c783
Create Date: 2019-11-15 12:59:10.755762
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "d0a243e71ea2"
down_revision = "eef891c5c783"
branch_labels = None
depends_on = None
def upgrade():
# ... |
2299bb4e51d1c7e374b78f7b091990243c4a4fcce06cc9ea531d4298eb7e65b3 | Python | 10,947 | 341 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 8 14:33:12 2021
@author: obernauer
"""
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
from numpy import linalg as LA
import pywt
from tqdm import tqdm
from green import Green
def wannier(x: np.float64, y: np.float64,... |
7fb485bf7d0bc77cc2cd38f7042756cba0886b2f59e65dd22a7405d96b645a90 | Python | 10,967 | 277 | import numpy as np
from scipy import ndimage
from .dataset import Datasets, Dataset
# CONSTANT WHERE TO FIND THE DATA
from config import ENDOSTROKE_DIR
import SimpleITK as sitk
import os
import pandas as pd
import os
from .dataset import Datasets, Dataset, GraphDataset
import torch
from torch_geometric.data import (Da... |
40be9bbf54e89db55d8adbfbbae3af11752ad5794228fa4846b9f75c68c32907 | Python | 10,974 | 216 | import os
import time
import numpy as np
import nibabel as nib
import json
import warnings
from scipy.stats import zscore
from os.path import join as pjoin
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LassoCV
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing imp... |
8a70cf4a636af01dfa3420dcb74b6f670e127cb0f000d6f054a432b45654a8ff | Python | 10,977 | 222 | # Pytorch Tabular
# Author: Manu Joseph <manujoseph@gmail.com>
# For license information, see LICENSE.TXT
"""AutomaticFeatureInteraction Config"""
from dataclasses import dataclass, field
from typing import Optional
from src.models.tabular.pytorch_tabular.repository.config import ModelConfig
@dataclass
class TabTran... |
7c2adc4dc722467fba7e916d1d8bdfd683d700e6e3baa4775907a3cf977446b0 | Python | 10,980 | 296 | """
Author: "Keitaro Yamashita, Garib N. Murshudov"
MRC Laboratory of Molecular Biology
This software is released under the
Mozilla Public License, version 2.0; see LICENSE.
"""
from __future__ import absolute_import, division, print_function, generators
import numpy
import copy
eps_l = 1.0e-5
def gen... |
8eddcd9b75950e159d2e7d047d141c16ee468ef954f961e2a97f8e896ebb8e5b | Python | 10,985 | 143 | from typing import Any, Iterable, Optional, Union, Annotated, get_origin, get_args, Sequence, Tuple
from pydantic import Field, AfterValidator
import numpy as np
import numpy.typing as npt
from numpy.typing import NDArray
class CellProfilerInputValidationError(ValueError):
def __init__(self, message: str):
... |
f64133984e0858ce0f4698da4f52769349322830cd37a172275abd53d740e15b | Python | 10,991 | 350 | import tensorflow as tf
from tensorflow.keras.layers import LSTM, Dense, GRU
from tensorflow.keras.models import Sequential
import tensorflow_probability as tfp
tfd = tfp.distributions
tfpl = tfp.layers
class DynamicGaussianNetworkFactorized(tf.keras.Model):
"""TODO: Logic"""
def __init__(self, meta):
... |
df12396a423639a59a7715719297ea2ae0ab31afbc3243d99f658b717d601eb4 | Python | 11,008 | 374 | import os, types, sys
import numpy as np
import re
import itertools
#from matplotlib.pylab import *
SLUG_RE = re.compile(r'[\s\-\\\/\?]+')
def slugify(val):
l = val.lower()
return SLUG_RE.sub('_', l)
def read_simple_mapfile(filename, default_value=""):
d = {}
fp = open(filename, 'r')
for line... |
fd8212bc35589895fa0a6934c45e645890ff0671cfdd7a5c3558ded491804c23 | Python | 11,010 | 314 | import argparse
import os
import datetime
import json
import torch
import torch.nn as nn
from types_ import *
from torchvision import transforms
from torch.utils.data import DataLoader
from torch.optim import Adam
# Torchgan Imports
import torchgan
from torchgan.models import *
from torchgan.losses import *
from torc... |
61d8c6b8bf964b3b1e6afc09fd8784aa52b9bd05bef7ad1a697dab467792ace3 | Python | 11,011 | 198 | #### Master Script 5g: Calculate metrics for test set performance in baseline model for comparison ####
#
# Shubhayu Bhattacharyay
# University of Cambridge
# email address: sb2406@cam.ac.uk
#
### Contents:
# I. Initialisation
# II. Calculate testing set calibration and discrimination metrics based on provided bootstra... |
cfddbb5d2200fdc4e05916b49421a543956d7898413f453c8b7d8020344db1c6 | Python | 11,012 | 268 | import h5py
from unnatural_movie_analysis import unnatural_movie_analysis
from natural_movie_analysis import natural_movie_analysis
import os
import numpy as np
import sys
from gabor_wavelet_preprocessing_linquad import gabor_wavelet_preprocessing_linquad
from threshgrad import threshold_grad_desc_cv, lsq, dotde... |
ce385f607b2bd93dff3c6f1cb5ced4a982085fbd0d3f2614fbcb627cda9a3827 | Python | 11,015 | 272 | """
CombineObjects
==============
**CombineObjects** allows you to combine two object sets into a single object set.
This moduled is geared towards situations where a set of objects was identified
using multiple instances of an Identify module, typically to account for large
variability in size or intensity. Using th... |
1977fbd8fcc8c6e6249358f88a0607bb752c109344db16360a4b127db0af7944 | Python | 11,075 | 244 | #--------------------------5-CSRTT Protocol----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# Task file for 5-CSRTT task which can be used for training stages 1-5, and all challanges, by adjusting task variables as described below.
# One of the five_poke LEDs t... |
20dbf14843c1555641d0e616ab87682226dd9bedc15eafce13d0ab8112490b65 | Python | 11,075 | 244 | #--------------------------5-CSRTT Protocol----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# Task file for 5-CSRTT task which can be used for training stages 1-5, and all challanges, by adjusting task variables as described below.
# One of the five_poke LEDs t... |
298e5fa0c7caf3c2d955975ddd25b5ff3c2a83d642d70a421705c34669546956 | Python | 11,075 | 244 | #--------------------------5-CSRTT Protocol----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# Task file for 5-CSRTT task which can be used for training stages 1-5, and all challanges, by adjusting task variables as described below.
# One of the five_poke LEDs t... |
d1e5cd764175ea83b934ade70cfcb826f22fe597b5802589682fc2842fa0032b | Python | 11,075 | 244 | #--------------------------5-CSRTT Protocol----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# Task file for 5-CSRTT task which can be used for training stages 1-5, and all challanges, by adjusting task variables as described below.
# One of the five_poke LEDs t... |
f1f4aae4568be00e3238d48575cacebeb19bf6c0b99483a19d03e109f896f2b9 | Python | 11,075 | 244 | #--------------------------5-CSRTT Protocol----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# Task file for 5-CSRTT task which can be used for training stages 1-5, and all challanges, by adjusting task variables as described below.
# One of the five_poke LEDs t... |
fcb8d9da74460e68d9eb0148c40b1ecf8b470f07c5c293ccf691c13b03487a1b | Python | 11,075 | 244 | #--------------------------5-CSRTT Protocol----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# Task file for 5-CSRTT task which can be used for training stages 1-5, and all challanges, by adjusting task variables as described below.
# One of the five_poke LEDs t... |
48cee92b39422438aa6e6f979dbffedd088b937c4b7dc8c37f4e6e71891a5392 | Python | 11,076 | 244 | #--------------------------5-CSRTT Protocol----------------------
# important note:- Do not change any print stings if you intended to use pyOS5 GUI
# Task file for 5-CSRTT task which can be used for training stages 1-5, and all challanges, by adjusting task variables as described below.
# One of the five_poke LEDs t... |
bfd829ed0c537bfd1bcf60f0eefb1e0e939b2a1b0fd73cf521c24227bee44229 | Python | 11,076 | 283 | # -*- coding: utf-8 -*-
import datetime
import numpy as np
import pytest
from pysteps import blending, motion, utils
# fmt: off
pca_enkf_arg_values = [
# Standard setting
(20,30,0,-60,False,False,5,5,0.05,0.01,"ssft","masked_enkf",True,None,1.0,"ensemble",False,False,0,False),
# Smooth radar mask
(2... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.