sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e278f28afa9b04711aa85722ea267d4255ffd93ccdfe10ebb4f5beda90c92b73 | Python | 9,054 | 379 | from pathlib import Path
N_ESMBLER = 5
TOPN_BRAVAIS = 2
TOPN_SPACEGROUP = 3
BATCHSIZE = 256
BRAVAIS_SPLIT_NAME = "Bravais"
LEARNER = f"{Path(__file__).parents[0]}/learner/"
BRAVAIS_MODELS_FOLDER = {
"metal" : "BravaisEsmMetal",
"oxide" : "BravaisEsmOxide",
"whole" : "BravaisEsmWhole",
}
BRAVAIS_ENSE... |
7e60d17b4b3f621b689f924f639a0b9bfd409a0fefbb748554c548ec3df09386 | Python | 9,057 | 205 | import numpy as np
import torch
import math
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
import random
def unit(x):
if x.size()[0]>0:
xnp=x.cpu().numpy()
maxx=torch.max(x)
#maxx=np.percentile(xnp, 99.5)
minx=torch.min(x)
marge=maxx-minx
... |
c67e04cdf75489b4ca47d481c4f4ceaac2502a507cfa4ae28c897b4c5adf353c | Python | 9,077 | 221 | #!/usr/bin/env python
__author__ = "Marc Steffen Seibel and Thomas Jochmann"
__email__ = "seibelsteffen@web.de"
"""
Calculate ICA decomposition and identify EOG and EKG independent components.
The selected components will be updated in `create_windows_ica.py` and then the artifacts are removed.
This script may ... |
57f5b715d6173b35a631d67e6cb2258428c4c13353a13dc3eea26133077f90ae | Python | 9,078 | 306 | from __future__ import annotations
import hashlib
import json
import urllib.error
import urllib.request
from pathlib import Path
from types import TracebackType
from typing import Self
import pytest
from datamonger import BUNDLED_REGISTRY, Registry, _registry, resolve_registry
from datamonger.errors import (
Reg... |
e8bc8e97d72121bc1b50ffabb0e2dbdb079753a0e5bfa627d0e3bff1345f4635 | Python | 9,081 | 252 | import numpy as np
import matplotlib.pyplot as plt
from somata.basic_models import StateSpaceModel as Ssm
from somata.basic_models import OscillatorModel as Osc
from somata.source_loc.source_loc_utils import simulate_oscillation
"""
##########################################################
Example script to visualiz... |
c7cdf39973e03956fe3dd994133e146aa243d4052929dac6ebef65b9bb856def | Python | 9,100 | 224 | import torch
import torch.nn as nn
import torch.nn.functional as F
class FastSal(nn.Module):
def __init__(self, pretrained=None):
super(FastSal, self).__init__()
self.context_path = VAMM_backbone(pretrained)
self.pyramid_pooling = PyramidPooling(128, 128)
self.prepare = nn.ModuleLi... |
d15e6091663d0aef57de953a225661d6d6de7f4c878a278af513e867e90db11d | Python | 9,116 | 231 | import json
import numbers
import random
from typing import Any
from typing import Dict
from typing import Optional
from typing import Set
from typing import Tuple
from typing import Union
import numpy as np
import torch
class BaseTransform:
"""
This class serves as the base class for all transforms.
I... |
ade4dd66bf7eef3a8988353ed6c48aff954bb8486d98865e117289036e3f8da9 | Python | 9,130 | 314 | import os
from itertools import combinations
import matplotlib as mpl
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
###################################################... |
7dfebb9763f031236f2772c2f9a5eaf76d67b5912b642081a3da637248db2cc9 | Python | 9,138 | 339 | # -*- coding: utf-8 -*-
import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from pysteps.blending.skill_scores import (
spatial_correlation,
lt_dependent_cor_nwp,
lt_dependent_cor_extrapolation,
clim_regr_values,
)
# Set the climatological correlations values
clim_cor... |
01be9ee490b7bacfd2d8f9e02208a6d0708dda48b421fa4a411a445df89b578b | Python | 9,152 | 286 | #!/usr/bin/python3
def trigamma(x):
"""`Tri-gamma function <https://en.wikipedia.org/wiki/Trigamma_function>`_ .
Parameters
------------
x: float or numpy.ndarray
Input value(s)
Returns
-----------
float or numpy.ndarray
"""
from scipy.special import polygamma
return polygamma(1, x)
def lcpm(reads,
... |
6bfdf9b0af18db75481e17c38a9ff4a134922de52ef3add3a5484a5fc2671013 | Python | 9,155 | 261 | """
MaskImage
=========
**MaskImage** hides certain portions of an image (based on previously
identified objects or a binary image) so they are ignored by subsequent
mask-respecting modules in the pipeline.
This module masks an image so you can use the mask downstream in the
pipeline. The masked image is based on the... |
15c039932feb4f669875a0ff87ad45b3f8234506fca4e9769b1ca6bb4584b5fa | Python | 9,179 | 234 | """Unit tests for the substructure pipeline on a small synthetic RVE.
A full Run() takes minutes and needs a solver export to feed the pipeline, so this builds the
10x10x10 voxel mesh the pipeline actually consumes (GrainID + phaseID cell data) directly and drives
packets -> blocks -> orientations on it. That covers b... |
952ed2bfa33818f7f4b09626dbf23ed59294b5eb23d71917cd1fa974d6200317 | Python | 9,199 | 277 | from __future__ import annotations
import hashlib
import json
import os
import subprocess
import sys
import threading
from datetime import timedelta
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
import pytest
from datamonger import cache_clean, cache_info
from datamonge... |
50b7adfe3c03afb582c4a27e468c8f997de961da54542c1875b7be4c5f25ffe1 | Python | 9,201 | 304 | from __future__ import absolute_import
import hashlib
import numpy as np
from scipy.ndimage import convolve1d
import scipy.stats
import unittest
import centriole.threshold as T
class TestThreshold(unittest.TestCase):
def test_01_00_nothing(self):
result = T.get_otsu_threshold(-np.ones((10, 10)))
de... |
1d13b1b2485eb7eb88754266cf5eb3ffba7daf499ff215aca9017283067c6a9d | Python | 9,202 | 226 | import os
import pathlib
import sys
from typing import Optional, Tuple, Union
import pandas as pd
from .handle_collisions import handle_collisions
def writeTrainingCSV(
inputDir: str,
channelsID: str,
labelID: str,
outputFile: str,
relativizePathsToOutput: Optional[bool] = False,
) -> None:
... |
a79e5229b67e157a356143ad4c84845b5015a6027d85ec1db00e8cdf5d6fd5c2 | Python | 9,207 | 238 | import glob
import os
import numpy as np
import cv2
import matplotlib.pyplot as plt
import copy
def load_files_in_directory(directory, t_interval=50):
# Load files: these include these have the following form
#
# idx.npy :
# t0_ns idx0
# t1_ns idx1
# ...
# tj_ns idxj
# ...
... |
0e63a1e4dc26429c291d6b34756fe421e57e844f0ecd604d6c3bd8a326cc2a18 | Python | 9,212 | 226 | #steroid is based on PyTorch and PyTorch-Lightning.
#import comet_ml
import torch
import torch.nn as nn
from torch import optim
from utils import get_logger, parse #device,
from torch.optim.lr_scheduler import ReduceLROnPlateau
import pandas as pd
from pytorch_lightning import Trainer, seed_everything
from pytorch_lig... |
b5984b2281e1a7d445fe37d6eccb917c1187f7752047324567e838f81bd8c9c0 | Python | 9,215 | 191 | """ Warmup-Stable-Decay (WSD) Scheduler
Warmup -> stable phase -> decay to lr_min over the final steps, w/ selectable stable and decay functions.
References:
MiniCPM (WSD): https://arxiv.org/abs/2404.06395
Scaling Laws and Compute-Optimal Training Beyond Fixed Training Durations (1-sqrt cooldown):
htt... |
cd3ebb44bc1d0da32c2bb3ef9283b5adf2df21ffb71a9b6dd346b11ccf3fd3a7 | Python | 9,225 | 307 | import numpy as np
import os
from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle
from tensorflow.keras import callbacks
from tensorflow.python.keras.callbacks import Callback
from lib.pinn import PINN
from lib.network import Network
import pandas as pd
import tensorflow as tf
from helper impo... |
73486cb35e099aab259953e7bcc07abe60731bf748c97436d2ac1e29b943b531 | Python | 9,231 | 171 | """ Classification loss factory
Hacked together by / Copyright 2026 Ross Wightman
"""
from typing import Optional, Sequence, Union
import torch
import torch.nn as nn
from .asymmetric_loss import AsymmetricLossMultiLabel, AsymmetricLossSingleLabel
from .binary_cross_entropy import BinaryCrossEntropy
from .cross_entro... |
dc1816729954857e1a40cd2a71c558b89986e1908520724525402e681cd61e61 | Python | 9,231 | 274 | """Public inspection and manual eviction for the private Python cache."""
from __future__ import annotations
import hashlib
import json
import os
import re
from collections.abc import Mapping
from contextlib import nullcontext
from dataclasses import replace
from datetime import UTC, datetime, timedelta
from pathlib ... |
ee0bd52e467e69021965b0f7eda6873d4b6ffa3f6a1dd9bce399532091f626ea | Python | 9,240 | 222 | import torch
import torch.nn as nn
class EncoderBlock(nn.Module):
'''UNet encoder block'''
def __init__(self, in_channels, out_channels, kernel_size=4, stride=2, padding=1):
super(EncoderBlock, self).__init__()
self.block = nn.Sequential(
nn.Conv2d(in_channels=i... |
20e754663dae48be70302c202c2b1e1186eb950d22a2c22da8a5c181095ba758 | Python | 9,245 | 310 | # coding:utf-8
import webbrowser
import wx.adv
from cellprofiler.gui.dialog import AboutDialogInfo
import cellprofiler.gui.help.content
import cellprofiler.gui.help.search
import cellprofiler.gui.htmldialog
import cellprofiler.gui.menu
class Menu(cellprofiler.gui.menu.Menu):
def __init__(self, frame):
s... |
c93af8d79ac928aa19d199e64aa282f2b5e8dc31409d7c7e0eaf0f8329c2d772 | Python | 9,258 | 339 | #!/usr/bin/env python3
import os
import sys
from itertools import combinations, product
import identification as ide
import numpy as np
import pandas as pd
import pkg_resources
from etspredict.pipelines.ioutils import IOManager
from etspredict.prepare_data import prepare_connectomes as pc
def load_subject_list(dat... |
4e71855a0df3aaa9d93e984f244bb70977d7683892270f9d994566ffd4394d3a | Python | 9,261 | 224 | import torch
import matplotlib; matplotlib.use('TkAgg') # noqa: E702
import matplotlib.pyplot as plt
import mne
import pickle
import numpy as np
from codetiming import Timer
from somata import OscillatorModel as Osc
from somata.source_loc import SourceLocModel as Src
from somata.source_loc.source_loc_utils import simu... |
489ddd78ba69185f6b220ca72426f7f953f20a4b017fb1e44a3f4f1a8d160ffb | Python | 9,269 | 203 | import datetime
import logging
from copy import deepcopy
from os import makedirs
from os.path import join, exists
from posixpath import abspath
import numpy as np
import pandas as pd
import yaml
import random
from sklearn.model_selection import StratifiedKFold
from data.data_access import Data
from model.model_factor... |
8dbb29501f652a9d5eb74e5ba5c8cfbe88476e63086729860616217ccf3822f9 | Python | 9,269 | 295 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# visual_coding_2p_analysis documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 9 22:26:36 2013.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are pre... |
c7759ed8d9112366d89dc25b857eb9048cf34a887132d40196f5646099b73224 | Python | 9,275 | 173 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 22 10:59:54 2018
@author: saskiad
"""
import numpy as np
import pandas as pd
import os, h5py
import core
def do_sweep_mean(x):
return x[28:35].mean()
def do_sweep_mean_shifted(x):
return x[30:40].mean()
class LocallySparseNoise:
def ... |
079df71e12ddde8d6cf2ed6b3b7f6c3f33d13df1f6a9734025f93e3f6bb8cd08 | Python | 9,279 | 322 | # These utils are for the setup.py, used *before* installing python libs, so only python vanilla can be used here
import os
import os.path as op
import traceback
from sys import platform as _platform
IS_LINUX = _platform == "linux" or _platform == "linux2"
IS_MAC = _platform == "darwin"
IS_WINDOWS = _platform == "win... |
a3c425d68bd06d7ee2be4c64ed7483c827beae71dc5acfd1581d651ef1531957 | Python | 9,281 | 303 | # -*- coding: utf-8 -*-
#
# mrHARDI documentation build configuration file.
# NOTE: This file has been edited manually from the auto-generated one from
# sphinx. Do NOT delete and re-generate. If any changes from sphinx are
# needed, generate a scratch one and merge by hand any new fields needed.
#
# This file is e... |
55a2cc3be0bc8779468c7d37aea502714199242d5b0136d02c8d7a9277f35cdb | Python | 9,284 | 285 | # -*- 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... |
dc1687d20231ca0a7bd8abf4543f0b2d88c6d952f4d3c8cf94ecd64a52be8107 | Python | 9,288 | 243 | # study: .sqlite3
# Metlin: True False
# NIST: True False
# LipidBLAST: False True
# decoy: True False
# HITS: 1
# output: .features
import sys
import time
import sqlite3
import subprocess
import mspepsearch
start_time = time.time()
__version__ = "0.4.0"
#
# Actual code begins here...
#
libraries = []
if NIST == ... |
41c1b7aa8a389c39a64e1a84160b7145cf4d17eac925c90876ffdd0ae293f409 | Python | 9,305 | 230 |
# 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.
# This free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License 2.... |
0573acb8dc0410aeadf710d0714ed019120ad2e5af47635759127d7788d288ad | Python | 9,314 | 295 | #! /usr/bin/python
#-*-coding: utf-8 -*-
import os
from keras.models import model_from_json
from pyBTK import btk
import numpy as np
from scipy import signal
from scipy.signal import argrelextrema
from numpy import matlib as mb
import numpy as np
from pathlib import Path
from google_drive_downloader import... |
77eb04bc1bf9e2593a3273590f2ebb66ddad6cc8fe05b761e32517c152c3439f | Python | 9,344 | 257 | # -*- 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... |
bfaed0ae8b22985c453e930c6a02dbb44aae8d600c2cbed81019fc550dfd6b6d | Python | 9,347 | 252 | import os, sys, argparse, time, random, math
import ot
import pandas as pd
import numpy as np
from sklearn.decomposition import PCA
from sklearn.model_selection import KFold, StratifiedKFold, train_test_split
from sklearn.cluster import KMeans, AgglomerativeClustering
import scipy.cluster.hierarchy as sch
from scipy ... |
996cbe9ee6737236c2ac23576be71c799e1189c465426fde8c666ed01c2b1ed1 | Python | 9,369 | 210 | from spektral.layers import GlobalSumPool,ECCConv
from spektral.data import BatchLoader
from sigma.GraphData import *
from tensorflow.keras.models import *
from tensorflow.keras import Model
from tensorflow.keras.layers import Dense, Input, concatenate
from tensorflow.keras.optimizers import Adam
from tensorflow.kera... |
c85cdb8e1d26d10e2886669fa4459c632bbecf1242fedb89b52555f71537e3e1 | Python | 9,372 | 210 | from spektral.layers import GlobalSumPool,ECCConv
from spektral.data import BatchLoader
from sigma.GraphData import *
from tensorflow.keras.models import *
from tensorflow.keras import Model
from tensorflow.keras.layers import Dense, Input, concatenate
from tensorflow.keras.optimizers import Adam
from tensorflow.kera... |
ddf7fad13e0390f45a5b6bc9ccd52fcfe671c8a95d1f907d75e0811fa53314b0 | Python | 9,372 | 243 | import math
from typing import Dict, Tuple
import h5py
import hdf5plugin
from numba import jit
import numpy as np
class EventSlicer:
def __init__(self, h5f: h5py.File):
self.h5f = h5f
self.events = dict()
for dset_str in ['p', 'x', 'y', 't']:
self.events[dset_str] = self.h5f[... |
a9686b6ee43e21b411bbf791fe04cbeae32f63b7f16dbb29609967158e80faea | Python | 9,374 | 299 | from contextlib import contextmanager
import json
import os
import os.path as osp
from setuptools import setup, Extension, find_packages
from setuptools.command.build_py import build_py
from setuptools.command.install import install
from setuptools.command.develop import develop
import site
import subprocess
import sys... |
11eac02dd5f36282ebe04bd96b11d022e356a69d124f322a540894cdd32977f1 | Python | 9,375 | 303 | """Utility functions for the extract module."""
from __future__ import division
import logging
import os
import os.path as op
import warnings
import numpy as np
import pandas as pd
import requests
with warnings.catch_warnings():
# Without python-Levenshtein, fuzzywuzzy warns on import that it uses difflib.
... |
bdf9170156f02611bb0dbb18291c49ae34cf5d6c1de4a244590ceaec707c992b | Python | 9,381 | 292 | #!/usr/bin/python3
def normcov(dc, c=True):
"""Normalizes each continuous covariate to 0 mean and unit variance.
Optionally introduces constant 1 covariate as intercept. Categorical covariates should be in binary/one-hot form, and will be left unchanged.
Parameters
----------
dc: numpy.ndarray(shape=(n_cov,n_c... |
142e802869c4b7dcc652b74cecab89cd77101d827133b969667a7c9f55b882ba | Python | 9,392 | 215 | import glob
from os.path import join, exists, dirname, basename
import os
import cv2
import torch
import numpy as np
from torch.utils.data import Dataset
import torch.nn.functional as f
import torchvision.transforms as transforms
from datasets.extract_data_tools.example_loader_ddd17 import load_files_in_directory, ext... |
a0d10c68b869d9f0d39971e313779d101b242681fc594fdcf05d421cc4f40708 | Python | 9,417 | 224 | # 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... |
03b88171f18fd97fa826fdb8f35c036c00dc8c9a3e0bc7100ef8b0963ed3b679 | Python | 9,423 | 393 | import base64
import io
import zlib
import numpy
import pytest
import skimage.data
import skimage.exposure
import cellprofiler_core.image
import cellprofiler_core.measurement
import cellprofiler_core.module
import cellprofiler_core.modules.injectimage
import cellprofiler.modules.rescaleintensity
import cellprofiler_c... |
ead8cd33582c359b1125b83a95787de5adf89b166b2edfbb0b3c2f8080b4c6b4 | Python | 9,430 | 229 | # 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... |
737a39856ad7edd9dcfcd1dba89fdb5bcd83efa07ffa1325e8a59ff1071484ce | Python | 9,432 | 174 | # -*- coding: utf-8 -*-
"""
molvs.normalize
~~~~~~~~~~~~~~~
This module contains tools for normalizing molecules using reaction SMARTS patterns.
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import logging
from rdkit import Chem
from rdkit.Chem imp... |
73f4d32c061a9f9573b401f1bbc890d795a8ec3437dd65792e3cc2b5fd3db507 | Python | 9,432 | 300 | from functools import partial
from torchvision.ops import DeformConv2d
from braincog.base.node.node import *
from braincog.base.connection.layer import *
from braincog.base.encoder.encoder import *
class BaseLinearModule(nn.Module):
"""
线性模块
:param in_features: 输入尺寸
:param out_features: 输出尺寸
:para... |
194d1bceb84ddb3d437b56dc9f4258fab20651adf8b3d7252120fbc357c61dd2 | Python | 9,437 | 264 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 7 16:25:01 2021
@author: filtsem
"""
from scipy.stats import ttest_rel, sem
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import MaxNLocator
# Configure the matplotlib figure style
FONT = "Times New Roman"
RC = {
'... |
0faf14c4d7e4eabac8a17b6e23f9623010fe010cfa54948d2e1cf45fad61e097 | Python | 9,442 | 305 | 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_with_hic = """
[hic]
fil... |
41b9f3241dd0d6f25377e373758b435fe7f848f1a55405e11a091bcb5a95a8f4 | Python | 9,448 | 210 | import numpy as np
import pandas as pd
import pyvista as pv
import sys
import logging
import tetgen
from dragen.utilities.InputInfo import RveInfo
from perlin_noise import PerlinNoise
class MeshingHelper:
def __init__(self, rve_shape: tuple = None, rve: pd.DataFrame = None, grains_df: pd.DataFrame = None):
... |
149e5d18a685da6b6a7976e82a92beef383834d7b84c8051133923c5d21fb763 | Python | 9,452 | 174 | """
This python script is for calculating VAT Combined blender combination
(1st layer: VAT general (with opacity set in parameters, blend mode normal), 2nd layer: VAT flat)
on multiple DEMs with multiple processes.
Parameters are:
input_dir_path (dir that contains GeoTIFFs of DEMs)
output_dir_path (dir where to... |
ddb99610a788844fb56968b2db2c86c551b815c6add16f083695f45a6380a723 | Python | 9,453 | 321 | import numpy as np
import matplotlib.pyplot as plt
import torch.nn as nn
import torch.optim as optim
import torch
import pdb
from torch.nn.utils import spectral_norm
import time
import math
import torch.nn.functional as F
def normal_init(m, mean, std) -> None:
if isinstance(m, (nn.Linear, nn.Conv2d)):
m.we... |
82744a0df96b785a70f28dd42fe440148fa0fdadbea51add6a3ed0f4e8747d41 | Python | 9,471 | 217 | from PIL import Image, ImageEnhance, ImageOps
import numpy as np
import random
# Non-random random
random.seed(0)
class BasicPolicy(object):
def __init__(self, mirror_ratio = 0, flip_ratio = 0, color_change_ratio = 0, is_full_set_colors = False, add_noise_peak = 0.0, erase_ratio = -1.0):
# Random color ch... |
0ce916dfc640401fdc72b2521263065e2faa91fedec55043c0396148abbee24b | Python | 9,493 | 154 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 5 15:58:38 2021
@author: filtsem
"""
from pathlib import Path
import numpy as np
import eelbrain
import re
import utils
import os
ANOVA_results_path = '/project/3027007.02/Scripts_for_publication/TRFs/Weights_ANOVA/Dutch_part1/'
language = 'F... |
c5c78557023d413c25624919688a77ab1baca0a8795848514bf55d244a03b1b4 | Python | 9,493 | 279 | from __future__ import absolute_import
from __future__ import division
import numpy as np
from centriole._np_compat import np_Inf, np_NaN
def otsu(data, min_threshold=None, max_threshold=None, bins=256):
"""Compute a threshold using Otsu's method
data - an array of intensity values between zero... |
eb33b6490e31ed6ebe3cb896855eb68cb4d6ca556a01b21f81ad57885a117513 | Python | 9,504 | 277 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on March 4th 2022
@author: Nikolai M Chapochnikov
This file is similar to act_odors_ORN_vs_con_ORN-LN,
but with the connections arising from the NNC instead of the real connections
from the data.
this uses the file 'NNC-W_act-all.hdf'
which is generated by ... |
ae118581adaadcafd993919a9a77efd0e238b1753410a33f78b895dc9a3713f4 | Python | 9,513 | 240 | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from Models.HVP import gycblock, residual_att
class ConvBlock(nn.Module):
def __init__(self, nIn, nOut, add=True):
super(ConvBlock, self).__init__()
self.conv = nn.Conv2d(nIn, nOut, 3, stride=1, padding=1, bias=F... |
55eea78094eb45790dd1e2cb9f6d3b25db06330ca4879403f57d5c728fe5856c | Python | 9,533 | 231 | import logging
import wx
LOGGER = logging.getLogger(__name__)
class ModuleSizer(wx.Sizer):
"""The module sizer uses the maximum best width of the setting
edit controls to compute the column widths, then it sets the text
controls to wrap within the remaining space, then it uses the best
height of eac... |
272e2e554f6f15f538140f87f15848440e8b65ac9c115a254c8046f79c133eb5 | Python | 9,534 | 325 | import pandas as pd
import os
import numpy as np
import xarray as xr
import pandas as pd
import matplotlib.pyplot as plt
from scipy.ndimage.filters import gaussian_filter
from allensdk.brain_observatory.ecephys.ecephys_project_cache import EcephysProjectCache
from allensdk.brain_observatory.ecephys.ecephys_session i... |
f15cccb5ecda80a964688eb1f942fb34f897208150d35e08c3d6adb02cbfe3ac | Python | 9,549 | 243 | import torch
from opacus import PrivacyEngine
import collections.abc as abc
from functools import partial
from torch.utils.data._utils.collate import default_collate
from typing import Union, Callable
import copy
from opacus.optimizers import DPOptimizer
from opacus.utils.uniform_sampler import (
DistributedUnifor... |
986f8039b51c99dd3274106478c685f4e010fe448129cd5890dfe0e0bc4c12a1 | Python | 9,551 | 215 | #!/usr/bin/env python3
"""
These functions are called by both ciftify_meants and ciftify_seed_corr.
"""
import os
import sys
import subprocess
import logging
import numpy as np
import ciftify.utils
import ciftify.niio
class NibInput:
def __init__(self, path):
self.path = ciftify.utils.check_input_readabl... |
ed902c3cd00cd5e0253571c8e841f3a15a4b4a7fdfbf9efd871abed430e13d66 | Python | 9,551 | 215 | import os
import copy
import random
import argparse
import torch
import numpy as np
import torch.nn.functional as F
from configs import config_from_file
from scipy.stats import pearsonr
# Plot
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
torch.multiprocessing.set_sharing_strategy('file_syste... |
5f870efe3b9152fefd417ecc61ffa188d8e9a306515f676b66890d9f1443e9c3 | Python | 9,554 | 266 | """
pysteps.extrapolation.semilagrangian
====================================
Implementation of the semi-Lagrangian method described in :cite:`GZ2002`.
.. autosummary::
:toctree: ../generated/
extrapolate
"""
import time
import warnings
import numpy as np
from scipy.ndimage import map_coordinates
def ex... |
7730de01fcfbbc1f0f7dbf85227adbb4d1e2c8e4939e579527465effe67e8e7e | Python | 9,559 | 241 | import numpy as np
from PIL import Image
import os
import io
import json
import glob
import h5py
from torchmeta.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchvision.datasets.utils import download_url
from torchmeta.datasets.utils import get_asset
class CUB(CombinationMetaDataset):
"""... |
bcd3eb90f16aae655325b349c1426800e2a2aba0ca1faba03d9d0012d03feb12 | Python | 9,560 | 252 | """Variable‑size Mixup / CutMix utilities for NaFlex data loaders.
This module provides:
* `mix_batch_variable_size` – pixel‑level Mixup/CutMix that operates on a
list of images whose spatial sizes differ, mixing only their central overlap
so no resizing is required.
* `pairwise_mixup_target` – builds soft‑label ... |
c89791c30672a57cc91a9116a59b38ee3b6209755125bc414b6badad7a92cc96 | Python | 9,561 | 269 | # -*- coding: utf-8 -*-
"""
pysteps.motion.farneback
========================
The Farneback dense optical flow module.
This module implements the interface to the local `Farneback`_ routine
available in OpenCV_.
.. _OpenCV: https://opencv.org/
.. _`Farneback`:\
https://docs.opencv.org/3.4/dc/d6b/group__video__t... |
ab025c4d9c1e80e57313e221f876156aa91ee68f125890e8138c8331274a8dba | Python | 9,565 | 281 | #!/usr/bin/env python3
from itertools import combinations
import numpy as np
import pandas as pd
from nilearn.connectome import ConnectivityMeasure
from sklearn.covariance import EmpiricalCovariance
from etspredict.timeseries import get_edge_timeseries
def ets_amplitudes(edge_timeseries):
"""Calculates co-fluc... |
2e17f0ae43e4122fe5f6403a2c7c3815304294725b6ceb2b5f86dd3768682448 | Python | 9,571 | 242 | # Copyright 2018 The TensorFlow Probability 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 o... |
7ab60c8aff328ad60dd84f127311e153a892dc04bacd6451213f381368e4c9f0 | Python | 9,581 | 220 | import time
import numpy as np
from datetime import timedelta
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
from PyQt5 import QtWidgets
from gui import Ui_MainWindow
from gui_settings import event_history_len, state_history_len, analog_history_dur
# Task_plotter -------------------------------------... |
6b1ff160e6e62944cb36e3219dc37afe8ad7ee6fcbe17aa2271d030375917b26 | Python | 9,584 | 285 | import pandas as pd
import numpy as np
import rdkit.Chem as Chem
from rdkit.Chem import AllChem
from spektral.data import Dataset,Graph
import pickle
import sigma.parameter as parameter
from tqdm import *
import time, random
import sys
def read_data(filename,):
'''
* Attributes
* ----------
* filename... |
a940f8d8966475f4fd00354516d11dd6ac8c7c342ea14697b3bee1b296d4e491 | Python | 9,584 | 211 | """
Author: Mingjian He <mh1@stanford.edu>
decimate module contains methods for decimated state-space model learning
"""
from somata.basic_models import StateSpaceModel as Ssm
from somata.exact_inference import run_em
import numpy as np
class DecimatedModel(object):
"""
DecimatedModel is an object class cre... |
e8c16197486b242a466bcc90f1b9ff164a3c8b8e23b0ccb8fd68eb4f0c27089a | Python | 9,589 | 230 | #!/usr/bin/env python
__author__ = "Marc Steffen Seibel and Thomas Jochmann"
__email__ = "seibelsteffen@web.de"
import os
os.environ['MNE_USE_NUMBA']='False'
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import mne
from collections import OrderedDict
from IPython.core.display import ... |
34c4ff5cec5518fdc6d3a2cc54358fe903301447173ddeb1e99ad17abe601b4e | Python | 9,592 | 302 | import torch
import torch.nn as nn
from torch.nn import Linear, Sequential, ReLU
from torch_geometric.nn import GINConv, TransformerConv
from torch_geometric.nn import global_mean_pool, global_add_pool, global_max_pool
class GIN(torch.nn.Module):
def __init__(self, num_features, num_targets, num_layers,... |
ace76c64f41106a8ba855169e476c84ccd15f9f9923ff35cc844ee6fd32ce832 | Python | 9,595 | 264 | from __future__ import absolute_import
import numpy as np
import scipy.ndimage as scind
from scipy.linalg import toeplitz
from .cpmorphology import fixup_scipy_ndimage_result as fix
def minimum(input, labels, index):
return fix(scind.minimum(input, labels, index))
def maximum(input, labels, index):
return ... |
7f1fa54f1722b3340019395c51725a49a23b04a733da3c5abb073b40b958d0f3 | Python | 9,598 | 236 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 7 18:23:18 2021
@author: Jing Li, Small steps make changes. dnt_seq@163.com
"""
from sklearn.manifold import TSNE
# from sklearn.datasets import load_iris
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
import seaborn as sns
import pand... |
b984ed2eb4203071ce88bd40c54f27a7e254d2e084ac6676ac6537020f335db7 | Python | 9,602 | 296 | import numpy as np
try:
from torch_geometric.data import DataLoader
except ImportError:
print('Warning: Error while trying to import torch_geometric.data.Dataloader')
from torch.utils.data import DataLoader as EuclideanDataLoader
class Datasets(object):
def __init__(self, train, val, test):
self.tr... |
b75cbb0ca8ffa046b3c90d09ec1552e9f71cb9aa55046843f19e267bb5f1e163 | Python | 9,603 | 301 | """This program provides query functionality for NIDM-Experiment files"""
from json import dumps
import os
import sys
import click
from click_option_group import RequiredMutuallyExclusiveOptionGroup, optgroup
import pandas as pd
from nidm.experiment.CDE import getCDEs
from nidm.experiment.Query import (
GetBrainVo... |
3d192e3bbad758e251526cd9d20bf6e334f004ec61903cfadd952d73a1a89c4b | Python | 9,610 | 246 | import os
import sys
import time
from serial import SerialException
from serial.tools import list_ports
# Add parent directory to path to allow imports.
top_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if not top_dir in sys.path: sys.path.insert(0, top_dir)
from com.pycboard import Pycb... |
6fb63530109ecfccf7046cdda00a4966f9d2f924fcb26b7f59e0c3f66a50fedc | Python | 9,619 | 248 | #!/usr/bin/env python3
"""
Creates pngs of standard surface and subcortical views from a nifti or cifti
input map.
Usage:
cifti_vis_map cifti-snaps [options] <map.dscalar.nii> <subject> <map-name>
cifti_vis_map cifti-subject [options] <map.dscalar.nii> <subject> <map-name>
cifti_vis_map nifti-snaps [option... |
311381a04b62391e757b192ef789f515d32026a4193550dcf76e17202b2291ff | Python | 9,625 | 280 | """ PyTorch LARS / LARC Optimizer
An implementation of LARS (SGD) + LARC in PyTorch
Based on:
* PyTorch SGD: https://github.com/pytorch/pytorch/blob/1.7/torch/optim/sgd.py#L100
* NVIDIA APEX LARC: https://github.com/NVIDIA/apex/blob/master/apex/parallel/LARC.py
Additional cleanup and modifications to properly su... |
59b6f59ca4457279a746da17bbd1825c480b4454ca9090f5d97a901551a7b64c | Python | 9,626 | 181 | """
Locates single-units in 3D anatomical space (relative to bregma coordinates).
@author: bartulem
"""
import os
import numpy as np
import pandas as pd
class ClusterLocator:
locator_dict = {'LH': {'bruno': {'alpha': 57.5,
'beta': 4.7,
'XY... |
f7455b841adc3d2cf08601e4d597445146de827f8a79812440ae1fb7a32d9ef2 | Python | 9,643 | 266 | """Base training task abstraction.
This module provides the base TrainingTask class that encapsulates a complete
forward pass including loss computation. Tasks return a dictionary with loss
components and outputs for logging.
"""
from contextlib import nullcontext
from typing import Any, Dict, Optional
import torch
i... |
28a62e99e1e1b6fe1f6c53eceda7a931422997602210acae2d06b776cbd1dd65 | Python | 9,649 | 231 | """treecheckboxdialog.py - tree checkbox dialog for selection of tree branches
"""
import wx
class TreeCheckboxDialog(wx.Dialog):
"""A dialog for "selecting" items on a tree by checking them"""
def __init__(self, parent, d, *args, **kwargs):
"""Initialize the dialog
d - dictionary represent... |
7a87287fc1b965b6b5792d0d2e87addbb785c18a84f2ba107340cbedebb71f62 | Python | 9,662 | 247 | from __future__ import annotations
import gzip
import hashlib
import importlib.util
import json
import shutil
from pathlib import Path
import pytest
from jsonschema import ValidationError
ROOT = Path(__file__).resolve().parents[3]
SPEC = importlib.util.spec_from_file_location(
"dm_bundle_registry", ROOT / "tools... |
d4e6bf9f0135ba75bcef08a9c2d2982d920bf7f499affe993f2d5a96dbbbae20 | Python | 9,688 | 257 | # -*- coding: utf-8 -*-
"""
Linear blending
===============
This tutorial shows how to construct a simple linear blending between a STEPS
ensemble nowcast and a Numerical Weather Prediction (NWP) rainfall forecast. The
used datasets are from the Bureau of Meteorology, Australia.
"""
import os
from datetime import da... |
a6954fc9c0a2c454c423d7ade2e8365d16d1ec288d5c610203cda2bc1de3f139 | Python | 9,706 | 291 | """Tests for bidsmri2nidm --per_subject mode."""
from __future__ import annotations
import json
from pathlib import Path
import subprocess
import sys
import pytest
from rdflib import RDF, Graph, Literal
from rdflib.namespace import Namespace
NIDM = Namespace("http://purl.org/nidash/nidm#")
BIDS = Namespace("http://bi... |
32c4754bd387cbde93230f3a9572fb155f7afac0e6c171d884e51bf94959917c | Python | 9,708 | 241 | from netCDF4 import Dataset
import pyvista as pv
import numpy as np
from dragen.utilities.InputInfo import RveInfo
class NetCDFWrapper:
def __init__(self, file_base, num_nodes, num_elems, num_blocks, num_node_sets=None):
Version = 2.0
file_path = RveInfo.store_path+'/'+file_base+'.e'
self._... |
64ec6d748a13edef4badb176cdb8bd94c4ad6d8dfa99298842f0d40d4f62e4e0 | Python | 9,710 | 206 | from . GenomeTrack import GenomeTrack
from . BedTrack import BedTrack
from .. readGtf import ReadGtf
from matplotlib import font_manager
from .. utilities import temp_file_from_intersect
import numpy as np
DEFAULT_BED_COLOR = '#1f78b4'
DISPLAY_BED_VALID = ['collapsed', 'triangles', 'interleaved', 'stacked', 'squares',... |
d5c6015599852c748799d48bc7bd6cfc704db9d2d50ef5624994d6b034c4f4ae | Python | 9,717 | 260 | """
Prepares data for rate-map analyses.
@author: Benjamin Adric Dunn
@modified: JingyiGF
"""
from .toolkits import *
def get_data(data, use_imu=False, max_num_spk=4):
# max_num_spk, THRESHOLD_FOR_MAX_NUMBER_OF_SPIKES_IN_INTERVAL
session_ts = data['session_ts']
tracking_ts = data['tracking_ts']
frame... |
572cf0b84723ba73b9770536f0d6326775e5a97b33cb5f1f193f0a77a27fd9b4 | Python | 9,722 | 251 | # -*- coding: utf-8 -*-
"""
Implementation of UNet with deep supervision and residual connections
"""
from GANDLF.models.seg_modules.DownsamplingModule import DownsamplingModule
from GANDLF.models.seg_modules.EncodingModule import EncodingModule
from GANDLF.models.seg_modules.DecodingModule import DecodingModule
from ... |
99f261f871b7ea0c8dead13ef196148f5fe0f4af45be5a81e65e4be7be8d6d32 | Python | 9,729 | 283 | # 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... |
c278cf4489603d8727ad27e142675230d2e0a79cb90e0cf30294be5a6b942a5c | Python | 9,751 | 289 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 20 22:39:20 2019
@author: nchapochnikov
Testing if sm_output_online gives the same results with the methods
inv, GD and CD
Starting with some random M and W matrices and some random x vectors
and see if it always converges to the same y.
You can... |
8aa572bed5ada001c25a40b86b66dc62a046492a23fd9f82539dabf3ce13a4e0 | Python | 9,757 | 273 | import os
import bpy
import bmesh
import numpy as np
import sys
sys.path.append("/home/harsh/anaconda3/lib/python3.7/site-packages")
from scipy.spatial import ConvexHull
from shapely.geometry import Polygon, LineString
def create_planes_along_centerline(centerline, obj):
#bpy.data.objects[0]
#centerline = bpy.data.... |
52af986084a05217aa294ef00d08d0d1baf734d921b5da006ac3590136b4f360 | Python | 9,770 | 226 | import shap
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pathlib import Path
import torch
from src.utils import utils
from slugify import slugify
import seaborn as sns
log = utils.get_logger(__name__)
def explain_samples(config, y_real, y_pred, indexes, shap_values, base_value, X, fea... |
5b2b650a374f9c00470ff2a839c0636864c9ce5821c9f6149addbd80c89d0934 | Python | 9,777 | 243 | # 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... |
be62c6c8de4224a96a77cc4410e8a915aded335719717e59e790bd8200f6902a | Python | 9,780 | 270 | """ Selective Kernel Networks (ResNet base)
Papers:
* `Selective Kernel Networks` - https://arxiv.org/abs/1903.06586
This was inspired by reading 'Compounding the Performance Improvements...' (https://arxiv.org/abs/2001.06268)
and a streamlined impl at https://github.com/clovaai/assembled-cnn but I ended up build... |
40e93147e1770d7b08a3e2af13c9482200d26b28fa399d8a3226f5177fe81de4 | Python | 9,784 | 240 | # -*- coding: utf-8 -*-
"""
pysteps.io.nowcast_importers
============================
Methods for importing nowcast files.
The methods in this module implement the following interface::
import_xxx(filename, optional arguments)
where xxx is the name (or abbreviation) of the file format and filename is the
name of ... |
a5caa8a3c64b077fff91f1944f20ab56fab7ed2b1753f669760a8ef3e0621a12 | Python | 9,788 | 253 | import matplotlib.pyplot as plt
import torch
import pandas as pd
from sklearn.manifold import TSNE
def strength_order_plot(data='qm7', save=True, n_sample=10, fontsize=28, m_start=2, average=False):
J_m, J_d = [], []
if data in ['qm7', 'qm8']: m_start += 1
if data in ['hamiltonian', 'newtonian']: n_sampl... |
aef03d77b9ae4adba43aae158a0f904effb3a7cef42e3b699a0c0cba4793bd33 | Python | 9,789 | 357 | # -*- coding: utf-8 -*-
import matplotlib as mpl
from matplotlib.testing.compare import compare_images
from tempfile import NamedTemporaryFile
import os.path
import pygenometracks.plotTracks
mpl.use('agg')
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"test_data")
browser_tracks ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.