sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
bf3ae1e7ca60759aa0080557e7dd4d4fa0be51f6022cccfd07207e6c179d5e75 | Python | 3,910 | 96 | from loguru import logger
import argparse
import os
import re
import glob
import shutil
import subprocess as sp
from tempfile import TemporaryDirectory
from contextlib import contextmanager
# YAML imports
try:
import yaml # PyYAML
loader = yaml.load
except ImportError:
try:
import ruamel_yaml as ya... |
3caf508cf3420f86af53c189df9b56deb02551903455fc5011ba72e0dc919ec0 | Python | 3,911 | 114 | ##
# \file outlier_rejector.py
# \brief Class to identify and reject outliers.
#
# \author Michael Ebner (michael.ebner.14@ucl.ac.uk)
# \date Jan 2019
#
import os
import scipy
import numpy as np
import SimpleITK as sitk
import matplotlib.pyplot as plt
import pysitk.python_helper as ph
import pysitk.sim... |
a484c8d4e7e738d7b588816e14b2236c4d2ba8caba4e8bbd2b606e2e91db364f | Python | 3,911 | 113 | # -*- coding: utf-8 -*-
from typing import Iterable, Union
import torch
from supar.config import Config
from supar.models.dep.biaffine.transform import CoNLL
from supar.models.sdp.biaffine.parser import BiaffineSemanticDependencyParser
from supar.models.sdp.vi.model import VISemanticDependencyModel
from supar.utils.l... |
a973b2b04fdeba863208d690f5f36eb673d50fa545953a0a93d4d9719f8737a8 | Python | 3,911 | 123 | # Node-group asset "Select Res ID" (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_CHECKING... |
3a7a493b7e31c406979027e5fbf258022ae763ae80310a4d65dd75b48c6cd864 | Python | 3,912 | 119 | import ctypes
from ctypes import c_int, c_char_p, create_string_buffer
from pycparser import c_parser, c_ast, parse_file
import re
import sys
C_TO_CTYPES = {
'void': None,
'int': ctypes.c_int,
'char': ctypes.c_char,
'char*': ctypes.c_char_p,
'bool': ctypes.c_bool,
'double': ctypes.c_double,
... |
7acbe3ef393b807c581b15fd1189bdae282a2a6d0fef2a92e7678e330a49ea25 | Python | 3,912 | 113 | # --------------------------------------------------------
# Based on BEiT, timm, DINO and DeiT code bases
# https://github.com/microsoft/unilm/tree/master/beit
# https://github.com/rwightman/pytorch-image-models/tree/master/timm
# https://github.com/facebookresearch/deit
# https://github.com/facebookresearch/dino
# --... |
bcaadd0cf8bf091b714b7f215e63ad16b7973754f833954a4ad2c14ecd407ac5 | Python | 3,912 | 100 | import os
import numpy as np
import torch
from learn import *
from networks import *
from loss import *
from train_helper import *
import time
import pickle
import json
def run(
patient_id,
data,
device,
patient_dir,
params,
):
"""
learning a patient
freeze_epoch... |
89ea7bb316bc33b785e524852ca458fd1703d99789d5e4b146b54c670ba1a68b | Python | 3,913 | 130 | import json
from pathlib import Path
import numpy as np
import yaml
import matplotlib.pyplot as plt
import click
from collections import OrderedDict
from segm.utils.lines import Lines
def plot_logs(logs, x_key, y_key, size, vmin, vmax, epochs):
m = np.inf
M = -np.inf
domains = []
lines = []
y_key... |
055c8ea633a6e6a578421a2ee2cd5ae0677c02173a5c430019b7a925f8c512c7 | Python | 3,914 | 111 | """
oxasl.gui.analysis_tab.py
Copyright (c) 2008 University of Nottingham
"""
import os
from oxasl.gui.widgets import TabPage, OptionError
class AslAnalysis(TabPage):
"""
Tab page containing model fitting and analysis options
"""
def __init__(self, parent, idx, n):
TabPage.__init__(self, par... |
099e56f692746302b4e249fafdda7e2e8e5d47957b0f80b60c1a99a7a1a72107 | Python | 3,914 | 130 | import cocotb
import pytest
from cocotb.triggers import Timer
from torch import asarray
from elasticai.creator.arithmetic import FxpArithmetic, FxpParams
from elasticai.creator.nn.fixed_point import PReLU
from elasticai.creator.testing import CocotbTestFixture, eai_testbench
from elasticai.creator_plugins.act_func.uti... |
b1bd0cd951876e22d82fac8fa6bd5756bdf670413193c43778cfbe2e285f806b | Python | 3,914 | 134 | # Node-group asset "Sample Nearest Atoms" (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_C... |
c3b7b1f4c1ea2dc6f4c7d8f4dd6e2ca870cf42f98ba57fc582eb2ac226c1e0e6 | Python | 3,914 | 106 | import cv2
import numpy as np
import os
import pandas as pd
import torch
from torch.utils.data import Dataset
from torchvision import transforms
from src.utils import map_to_score_grid, score_to_class
from src.dataloaders.transforms import *
from constants import (SCORE_COLUMNS,
CLASSIFICATION_... |
50a2b749a2190763c274a4884b4827bccb4b47d2495fad8cf9f649bb73a55b28 | Python | 3,915 | 106 | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights R... |
b5eeeab5ee487b9a447ac107ec9e12829cfdad16c489f9c13c708356bcba4641 | Python | 3,915 | 106 | # regtools/tests/test_ccf_section_browse_export.py
import os
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
import json
import numpy as np
import pytest
pytest.importorskip("PySide6")
import nibabel as nib
import tifffile
from PySide6.QtWidgets import QApplication
from regtools.ccf_boundary_editor.... |
d710696837092ec1f6112781accdf1239ad8a3e4824b7e8dc40403f197c35d8e | Python | 3,917 | 117 | import graph_tool as gt
from graph_tool.topology import subgraph_isomorphism
def extract_circular_subgraph_vertices_and_edges(mol, center_atom_index, radius):
V = {center_atom_index}
E = set({})
for r in range(radius):
for current_atom_index in V:
current_neighb... |
f775820ae0e2b21b4b95d351c332cebc2ca29d11e6c3f33f2f73a5b4059b9e1a | Python | 3,919 | 132 | # Copyright (C) 2024 by mao jiashun and wang jianming
# Copying and distribution is allowed under AGPLv3 license
import os
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence
from torch.autograd import Variable
import numpy as np
import sys
sys.path.append(r'/home/jmwang/WorkSpace/G... |
38d0a6cc99003a32459d17dd15e21790675d193643ad5d5ac1c77e97337e14cc | Python | 3,921 | 139 | #!/bin/env python3
'''
Define a Feynman diagram
'''
import pdlfeynman as fy
import pdlfeynman.particle as fyp
import pdlfeynman.reaction as fyr
import yaml
def determine_particle(node:fy.diagram.Node, key:str='products') -> fyp.Particle|None:
match node.nodetype:
case fy.diagram.NodeType.PARTICLE:
... |
7c59b0adb69efb27ffac0993d0441745c69aa4dde9cbe006c3abba27ace75caf | Python | 3,921 | 146 | """Core recipes for Gaussian."""
from __future__ import annotations
from typing import TYPE_CHECKING
import psutil
from quacc import job
from quacc.recipes.gaussian._base import run_and_summarize
if TYPE_CHECKING:
from ase.atoms import Atoms
from quacc.types import Filenames, SourceDirectory, cclibSchema
... |
a4ba453d6ee8c0f464410fdda8b772b17dab8f5be061d0cab83fb8cefbc59bcd | Python | 3,921 | 114 | from __future__ import annotations
from typing import NamedTuple
import flax.linen as nn
import jax.numpy as jnp
import numpyro.distributions as dist
from ._base_components import FlaxDecoder, FlaxEncoder
class LossOutput(NamedTuple):
"""``reconstruction_loss`` and ``kl_local`` are per cell, ``loss`` is the sc... |
ad46db6a8a3a19325910ac99194d4dfab8e601fa98badb0562ee25453812b594 | Python | 3,921 | 103 | import glob
import main_config as conf
class DataHandler:
def __init__(self, offline_dir: str = conf.OFFLINE_DATA_DIR, online_dir: str = conf.ONLINE_DATA_DIR,
pp_offline_dir: str = conf.PP_OFFL_DATA_DIR, pp_online_dir: str = conf.PP_ONL_DATA_DIR):
self.offline_dir = offline_dir
... |
cbb06f327c8f7a026c261e84292a4599cbe6fb8afbdf2fa9163470071834e32d | Python | 3,921 | 96 | """
Archived copy of the original (pre-CG) Laplacian matrix builder.
Only laplacianA3D is kept - it is used by the LGMRES-vs-CG comparison
tests in test_lgmres_vs_cg.py to verify that the optimised solver
produces equivalent results.
"""
import numpy as np
import scipy
import gc
def laplacianA3D(shape,... |
e9a2183546369a1f4d04cf5f25cca718470a2b7991beb3fcd643b970dda956aa | Python | 3,921 | 106 | # -*- coding: utf-8 -*-
from collections import defaultdict
from matplotlib import ticker
from downward.reports.scatter import ScatterPlotReport
from downward.reports.plot import PlotReport, Matplotlib, MatplotlibPlot
# TODO: handle outliers
# TODO: this is mostly copied from ScatterMatplotlib (scatter.py)
class ... |
f720a567f37be80c8804280bc0a369a28bc33b377c887031d4f3b9076018913b | Python | 3,921 | 106 | # -*- coding: utf-8 -*-
from collections import defaultdict
from matplotlib import ticker
from downward.reports.scatter import ScatterPlotReport
from downward.reports.plot import PlotReport, Matplotlib, MatplotlibPlot
# TODO: handle outliers
# TODO: this is mostly copied from ScatterMatplotlib (scatter.py)
class ... |
6671aa65cf5715a1292615d368f87ca457f4e7c52f9c7f8ce4a7d8814f5f66c0 | Python | 3,922 | 107 | """
"Test" is a loose term...
This outputs the grids and strips as they are interpreted from VOX_coords mother.
Meant to be used to visualize which bipolar pairs will be made.
Run with:
python test_vox_mother_converter <subject>
"""
"""
from voxcoords_to_fs import *
"""
from vox_mother_converter import *
from cal... |
8ceff40e0f527db2be61c68db98f61334bb1e969a48447c653d42b033e909f61 | Python | 3,922 | 102 | import os
import numpy as np
import torch
from learn import *
from networks import *
from loss import *
from data import *
import math
import copy
def run(LR, input_size, output_sizes, hidden_sizes, Epoch, k, K, seed, batch_size_label):
train_split('Copy of virtual_biop(5000+5000).csv', k, K, seed)
train_labe... |
a1b147d1b4d6b14bfd4fb39c3b59b97ab8bdf3b1c8db77f00ac1e18d9e8f93b8 | Python | 3,922 | 92 | """Design shell: rail nav + expanded (non-collapsible) sections."""
import json
import os
from regtools.registration.report import build_html_report
def _meta(p):
with open(p, "w", encoding="utf-8") as fh:
json.dump(
{
"atlas": "allen_ccf_25um",
"... |
d4aa8bba5dfc5ccd39f1e72c9b68ba8435ec7d38639ab3b9b7ea1210060918fb | Python | 3,923 | 132 | """Configure tests."""
import mne
import numpy as np
import pytest
from mne.datasets import eegbci
@pytest.fixture(scope="session")
def montage():
"""Fixture for standard EEG montage."""
montage_kind = "standard_1020"
montage = mne.channels.make_standard_montage(montage_kind)
return montage
@pytest.... |
2d93205de12bfb7e894e889c337e945168345faefc5156c4f6012f4492df1065 | Python | 3,924 | 120 | # Node-group asset "Group Pick First" (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_CHECK... |
31ed5533c1d07a23059b0abf92cb50309cb7dac3031e7e26d2af0092a053c51e | Python | 3,924 | 109 | # -*- coding: utf-8 -*-
import lib.spectgr
import lib.spectgrList
import lib.tensores as tensores
from keras.utils import to_categorical
import pandas as pd
import os
# main(carpetaModelos,carpetaTensoresTest,carpetaResultados,numClases,numMFCCs,numChannels,numEspectros)
def main(tensoresTest,datosTest,carpetaModelos,... |
d00de972ae8ae6720a54dec20ff0829d8927dac4a41c797b2e655fdff28b90cd | Python | 3,924 | 106 | # Node-group asset "Set Geometry Volume" (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_CH... |
014bc7938ec776e78fa686f87b8a9c6dfa87ea4f6a99f6a16c9c801c56903ad2 | Python | 3,925 | 152 | import math
from scipy.optimize import minimize_scalar, ridder
import meep as mp
from meep import mpb
def print_heading(h):
stars = "*" * 10
print("{0} {1} {0}".format(stars, h))
# Our First Band Structure
print_heading("Square lattice of rods in air")
num_bands = 8
k_points = [
mp.Vector3(), # Gam... |
0f383fd109e218e840a189b03c77d5457b80e835511caa0926bbf504b3d0e718 | Python | 3,925 | 118 | """
Tests class Contingency
# Author: Vladan Lucic
# $Id: test_cluster.py 1520 2019-03-11 17:00:20Z vladan $
"""
__version__ = "$Revision$"
import warnings
import unittest
import numpy as np
import numpy.testing as np_test
import scipy as sp
import pandas as pd
from pyto.clustering.contingency import Contingency
... |
21efd5b746bd705b7c63b4ff2c9a7d240a210af0ee70076c8358e6a840aec8aa | Python | 3,925 | 121 | from sklearn.datasets import make_classification
from sklearn.model_selection import cross_val_score
from sklearn.ensemble import RandomForestClassifier as RFC
from sklearn.svm import SVC
from bayes_opt import BayesianOptimization
from colorama import Fore
def get_data():
"""Synthetic binary classification datase... |
aa7524eb1d58d389e18df8719a4b197dd0b88729ae5b224709f0b4389809248c | Python | 3,925 | 91 | import numpy as np
from ..constants import bohr2ang
from .misc import atom_number2name
class Structure:
'''
Attributes:
---------
rprim(3, 3): R_ij is the jth cartesian component of ith lattice vector, in bohr
gprim(3, 3): G_ij is the jth cartesian component of ith primitive reciprocal lattice ve... |
d3c12c7571aab6ca25c4e8a3702229ef840a414369b59d5ad706ecfe2fa91bf1 | Python | 3,926 | 123 | import os
import sys
_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
if _ROOT not in sys.path:
sys.path.insert(0, _ROOT)
from installer import steps
def _recording_runner(calls, returncode=0, stderr=""):
"""A fake runner capturing argv; returns (returncode, st... |
47a20debf9a1b0c04a71a2d3a3fe734814d56c71a640feaa0eed52914cf063c4 | Python | 3,927 | 98 | from pathlib import Path
from typing import List, Tuple
from sitetack.app.alphabet import Alphabet
from sitetack.app.sequence import Sequence
class Fasta:
""" For reading fasta files. """
@staticmethod
def read_sequences_from_file(fasta_file: Path) -> List[Sequence]:
"""
Read a fasta file... |
71458c8e46a0f3575a4deeffb68ee51e467a185fe5b12fe23d4f437f4f3e7fd6 | Python | 3,927 | 100 | from importlib.util import find_spec
import numpy as np
import numpy.testing as npt
import pytest
if find_spec("pydeseq2") is None:
pytestmark = pytest.mark.skip(reason="pydeseq2 not available")
if find_spec("formulaic_contrasts") is None or find_spec("formulaic") is None:
pytestmark = pytest.mark.skip(reaso... |
30fa39c9ad6db9575c87d9f408edf492f5cc2609fb3bd557b13c1f313d1f7a3e | Python | 3,928 | 87 | import os
import numpy as np
import pandas as pd
from nilearn.image import mean_img
from nilearn.plotting import plot_glass_brain, plot_stat_map
from nilearn.glm.first_level import FirstLevelModel
path = "/m/cs/scratch/networks-pm/protocol/data/pilot_iii/fmri/sub-01"
savepath = "/m/cs/scratch/networks-pm/pilot/sub-01... |
541e970f3f8b0f5060f1a136f1cb8e4bd8b084ab366d5076f13f9b673c7f20d8 | Python | 3,928 | 109 | # 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... |
a8e9ba837e5f9fad009229e8ec468b11b6108e5ffc7d0a3069c5f3d7c099c296 | Python | 3,928 | 93 | from typing import Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
def entropy(predictions: torch.Tensor, reduction='none') -> torch.Tensor:
r"""Entropy of prediction.
The definition is:
.. math::
entropy(p) = - \sum_{c=1}^C p_c \log p_c
where C is number of class... |
831635a3e9f7d5966dcdfec028be63adcc451b98c065e9628fc37162b218c398 | Python | 3,930 | 126 | # A demo of gradients through scipy.integrate.odeint,
# estimating the dynamics of a system given a trajectory.
import itertools
import matplotlib.pyplot as plt
import numpy as npo
import autograd.numpy as np
import autograd.numpy.random as npr
from autograd import grad
from autograd.builtins import tuple
from auto... |
a86944071e7c637c529224d3526ee1b9d2a440827185d38f615388db6b876da7 | Python | 3,931 | 101 | #!/usr/bin/env python3
"""
Check if the spec_tests directory structure is properly set up for local testing.
This script verifies that the required directories and files exist.
"""
import os
def check_directory(path, description):
"""Check if a directory exists and list its contents."""
print(f"\nChecking {d... |
deded8d03a7387442d392ac168f44fccbaf1bf83174dc0814515bb45f1900533 | Python | 3,932 | 122 | from __future__ import annotations
import numpy as np
import pytest
from ase.build import bulk
from quacc.recipes.mlip.elastic import elastic_tensor_flow
torch = pytest.importorskip("torch")
from importlib.util import find_spec
libraries = []
if has_matcalc := find_spec("matcalc") and find_spec("matgl"):
libra... |
fd85a2312efb09f1f19a89666d5a8c0729052b8d1f945937cf85fdf7bf99437e | Python | 3,932 | 111 | import numpy as np
import pickle
from Loader import SignedPairsDataset, get_index_dicts
from Trainer import ERGOLightning
from torch.utils.data import DataLoader
from argparse import Namespace
import torch
import pandas as pd
import os
from os import listdir
from os.path import isfile, join
import sys
def read_input_f... |
e4a61a33d7ecc64458cf0d5be64d1f2fe8fff9ecc8c3e8a3f6bf7b6bd307c4b6 | Python | 3,934 | 102 | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Con... |
3128aacf8da6b2d60accbfe64782219d3e04649f350095b93a5faa4cf950435b | Python | 3,935 | 159 | # 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... |
3ffbdc09e9bb4c6a87f8152a510f207de49e8422004f2ebbc4ed8121855ad729 | Python | 3,936 | 127 | # 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... |
89828ae1e7fc13afa75097cb9f55e73d6b6957c709bf4bd02e53f9fb45b0a663 | Python | 3,936 | 81 | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... |
2ecfd8d4c19ed3254f0a378a932c636c000b37f2be15df6b4b841d3d8567b4d8 | Python | 3,937 | 107 | import matplotlib.pyplot as plt
from scipy.optimize import minimize
import autograd.numpy as np
import autograd.numpy.random as npr
import autograd.scipy.stats.multivariate_normal as mvn
from autograd import value_and_grad
from autograd.numpy.linalg import solve
def make_gp_funs(cov_func, num_cov_params):
"""Fun... |
30514688312c93ce387fda3d4f70b265f82272b51753f5095b0f6d3c02244737 | Python | 3,938 | 93 | # MEGIT cross detection batch processing script
# This script will process ALL subfolders
import sys
import os
sys.path.append(os.getcwd())
import argparse
import csv
import numpy as np
import warnings
from megit.fio import cjsh_read, cjsh_write
from megit.batch import avgint_roi, det_avgint, det_prdpos, ... |
47551154ce839e09655d35593192a50bd4ec5b66ec16272945d88acd11d75104 | Python | 3,938 | 109 | """Implementation of CLI check command."""
import os
import json
import warnings
import numpy as np
from treem.io import SWC, TreemEncoder
def check(args):
"""Checks morphology reconstruction for structural consistency."""
# pylint: disable=too-many-branches
# pylint: disable=too-many-statements
da... |
17127ffec0c72304a3899a4ef746c0faffacb38f8207759c607bff101bf7207f | Python | 3,939 | 109 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
"""
import wx
import os,sys,pydoc
import deeplabcut
media... |
0ab488237b0c97e1668b9dde0b6f5683f9fef3ce9f4b46542ff742ff5237dcaa | Python | 3,940 | 92 | import os
import mne
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib as mpl
from Functions.invert import invert
mpl.rcParams['pdf.fonttype'] = 42
if __name__ == '__main__':
hpf = 30 # Can be 30 or 1
folders = ['main', 'piloting']
peak_lat = 0.052
# Testing las... |
38dfd1e2dc9f0d72a9a7fb2b2f4d01b4d7c98eb2178d85d215908754bde87825 | Python | 3,940 | 112 | rest_api_version = 3
def update_param(name, param):
if name in ('alpha', 'lambda'):
param['ptype'] = 'numeric, [numeric]'
param['dtype'] = 'Union[float, List[float]]'
return param
return None # param untouched
def class_extensions():
@property
def Lambda(self):
... |
a16f3f455bfe0ef433a45006eba6b9f30474916ca900c1c31507a0371661da6e | Python | 3,941 | 116 | from typing import Any, cast
import torch
from elasticai.creator.arithmetic import (
FxpArithmetic,
FxpParams,
)
from elasticai.creator.base_modules.linear import Linear as LinearBase
from elasticai.creator.nn.design_creator_module import DesignCreatorModule
from elasticai.creator.nn.fixed_point.linear.design... |
9c770b0e5c80a6d1e718c3232d2ed0eb539af316b4c0d29fd1a5ac9e48de6b14 | Python | 3,943 | 112 | #!/usr/bin/env python
#$ -cwd
#$ -S /usr/bin/python
SPINEXCODIR = "/home/users/dgront/STORAGE/TOOLS/spineXpublic/"
import os, re, sys, commands
from run_jobs_commons import *
"""
INFO: dla inputu: sciezka/file.fasta wyniki:
predykcji struktury drugorzedowej w ./file.spinex.ss2
predykcji dostepu do rozpuszczalnika... |
d41c5345e96e55e480d2072efb641d351d330b970acc9f722fb9a25846485311 | Python | 3,944 | 122 | # Libraries
import os
import sys
code_path = os.path.split(os.path.split(os.getcwd())[0])[0]
sys.path.append(code_path)
import numpy as np
import random
from sklearn.metrics import accuracy_score
from joblib import load
import argparse
from setting import *
from loader import *
from XAI_interpret import *
from utils im... |
5f804040e3b6e8634e47b9c7fdf853cc07deb9cb76ac141cc7fd79332141a5cb | Python | 3,946 | 111 | # SPDX-FileCopyrightText: 2015 Eric Larson
#
# SPDX-License-Identifier: Apache-2.0
from tempfile import NamedTemporaryFile
import mmap
class CallbackFileWrapper(object):
"""
Small wrapper around a fp object which will tee everything read into a
buffer, and when that file is closed it will execute a callb... |
c536b3ba7b76e5084b428ec863b9f3b352ff31d380463f2aba11471256eeee0e | Python | 3,946 | 131 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Fig4c
usage:
python main.py --p /Users/jiangshengdian/Desktop/Daily/PhD_project/Platform/fullmorpho/data/soma\ marker/soma_0_vs_1.marker
'''
import pandas as pd
import numpy as np
import os
import math
import argparse
import vtk
import vtkmodules.vtkInteractionStyle
i... |
04cbf361bd7382c187c92132b6327c67a17305e4eb90850a5e55c4014bdf73ce | Python | 3,948 | 126 | """Utilities for manipulating geometry of morphology reconstructions."""
import math
import numpy as np
from treem.io import SWC
# pylint: disable=invalid-name
# pylint: disable=too-many-locals
def rotation_matrix(axis, angle):
"""Computes rotation matrix for 3D manipulations.
Args:
axis (float[3]... |
ab02e142165c4aba8dc62c2506d972f94e788407e27a850d4a256f89dff1b0d8 | Python | 3,949 | 100 | import torch
import math
import torch.nn as nn
import torch.nn.functional as F
class BasicConv(nn.Module):
def __init__(self, in_planes, out_planes, kernel_size, stride=1, padding=0, dilation=1, groups=1, relu=True, bn=True, bias=False):
super(BasicConv, self).__init__()
self.out_channels = out_pla... |
0734b7efb80f7f9a08ce3d36750f09137a73e1496774eb2b693f48301fdc5a86 | Python | 3,950 | 122 | from cloudvolume import CloudVolume
import numpy as np
roi5 = CloudVolume("gs://neuroglancer/pinky100_v0/father_of_alignment_v3/roi", mip=5)
roi6 = CloudVolume("gs://neuroglancer/pinky100_v0/father_of_alignment_v3/roi", mip=6)
# dst5 = CloudVolume("gs://neuroglancer/pinky100_v0/aligned_test_v28", mip=5, cdn_cache=Fal... |
6142750a3066251de23b9dd46805e905796995ba1efa8abc2e2d114ef1104d59 | Python | 3,950 | 84 | import os
from optparse import OptionParser
import gzip
### help and usage ###
usage = "usage: %prog [options] args"
description = '''Function: extract 4-fold synonymous SNPs and filtered sites'''
version = '%prog 07.26.2021'
parser = OptionParser(usage=usage,version=version, description = description)
parser.add_opt... |
662c7fe462cd0dd0c4f12ec7e26c9ad9fa3e19991dcfd640634597b8af9f6f5b | Python | 3,951 | 104 | # Copyright (c) 2019 Mwiza Kunda
# Copyright (C) 2017 Sarah Parisot <s.parisot@imperial.ac.uk>, , Sofia Ira Ktena <ira.ktena@imperial.ac.uk>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, eit... |
2f1b0d8c288887dca44cc444fa0b9356abcb440689dd2229dbe4e5fe7f578efb | Python | 3,952 | 86 | import mne.viz
import matplotlib as mpl
import prepro_functions as pp
import os
subjects = ['esgpilot01', 'esgpilot02', 'esg01', 'esg02', 'esg03', 'esg04', 'esg05']
montage_file = '/data/pt_02889/main/code/standard-10-5-cap.elp'
run_1_ReadFilter = 0
run_2_ManualRejectionPreICA = 0
run_3_quickAverageSingleSubject = 0
... |
c158acac28d940129441abd49af9992d657a9ba9e5346deb243cd41749b713ff | Python | 3,952 | 81 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Initialization of LFPy, a Python module for simulating
extracellular potentials.
Group of Computational Neuroscience,
Department of Mathematical Sciences and Technology,
Norwegian University of Life Sciences.
Copyright (C) 2012 Computational Neuroscience Group, NMBU.
... |
d36f06b8c18d2711108071505d25b120652f468d6f58236ff961a31cc8364803 | Python | 3,952 | 96 | """Tests for the computeAllMetrics full=True/False opt-in.
Verifies that:
- full=False: all 9 standard keys are present; SSIM/MIND_SSD/Hausdorff95
are nan; cheap metrics (NCC, MSE, Dice) are finite.
- full=True (default): all 9 keys are present and all are finite for
non-degenerate inputs.
"""
im... |
74b41eb34c480047ae20e9ab71608b4cccd349f18759350b5464039e701fbcdf | Python | 3,953 | 137 | """
Contrast Limited Adapted Histogram Equalization (CLAHE) for a GraphMCF property
Adaptation to GraphMCF of:
A. M. Rez, Journal of VLSI Signal Processing 30, 35-44, 2004
Input: - GraphMCF (pkl)
- Property to equalize
- CLAHE setting
Output: - Equalized property added to... |
ed0165f32219384a709bbde2d49dcb7690f486b7c7ce0dff89a08a9d7af2575b | Python | 3,953 | 137 | import os
import sys
import traceback
import numpy as np
from functools import wraps
from multiprocessing import Process, Queue
def unroll_data(x, t=1):
"""
This function is used by recurrent neural nets to do back-prop through time.
Unrolls a data_set for with time-steps, truncated for t time-steps
... |
14ab6f6efdad976a7298ec2795ab51d1a1e4bf4a974f6047e3270369853ccb1a | Python | 3,954 | 109 | # -*- coding: utf-8 -*-
from collections import defaultdict
import os
from lab import tools
from matplotlib import ticker
from downward.reports.scatter import ScatterPlotReport
from downward.reports.plot import PlotReport, Matplotlib, MatplotlibPlot
# TODO: handle outliers
# TODO: this is mostly copied from Scat... |
22e83be1f01f651ab12501783fcafa237295beb250fac5162f747b1ddc4c1506 | Python | 3,955 | 140 | #!/usr/bin/env python
"""
Create correlation-distance matrices for IS-RSA.
For each movie and Schaefer parcel, this script computes the pairwise
correlation distance between subjects' parcel-wise fMRI time series.
Correlation distance = 1 - Pearson correlation.
"""
import os
import pandas as pd
import numpy as np
f... |
37cf8f60dd811e1a04448a7c5994dd678c83d997ee4fde0509f6f6d3dacb456b | Python | 3,956 | 132 | # 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... |
8b90371b86c482bc2fadbd3b9780d7df1912264a5532670b8db9114ce4c1fe34 | Python | 3,958 | 100 | # 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... |
26db2748a15084bc760d37722f4ca14c22ae77e999e30bdb94d2103de86f03b2 | Python | 3,959 | 126 | import datetime
import os
import yaml
import argparse
import sys
def parse_gpus(gpu_ids):
gpus = gpu_ids.split(',')
gpu_ids = []
for g in gpus:
g_int = int(g)
if g_int >= 0:
gpu_ids.append(g_int)
if not gpu_ids:
return None
return gpu_ids
def load_config(confi... |
2ba96380d66949b1744549955562fbc2540c819323f07bf5b9f5cc1d8fe184c9 | Python | 3,959 | 102 | """Tests for the registration parameter-preset storage layer (issue #112).
Qt-free; the JSON path is sandboxed via the session-state ``redirect_to`` hook.
"""
import json
import pytest
from regtools.registration.gui import parameter_presets as pp
@pytest.fixture
def sandbox(tmp_path):
# redirect... |
5220e0bb18556c5bce952575b11cb70b13d7bb65031d1ac8a55544c45475b3ee | Python | 3,959 | 111 | # -*- coding: utf-8 -*-
"""
Converts DICOM files to NIfTI files including their JSON sidecars in a
temporary directory which can be inspected to make a dc2mbids config file.
"""
import argparse
import logging
import platform
import sys
import os
from pathlib import Path
from datetime import datetime
from dcm2bids.dcm2... |
53fbcf929ccad2c295419103e1013874d6a7f7361d3492c6e909d71384fe7e28 | Python | 3,960 | 124 | #!/bin/env python3
'''
This class defines the quasi-particles that show up at phase defect lines
'''
from dataclasses import dataclass
from .yamlrepr import YAML_String_Representer
from fractions import Fraction
Number = int|float|Fraction
@dataclass(frozen=True)
class Particle(YAML_String_Representer):
name: str... |
71f7dde2385c32907bdefd3a5fda860bb0f9748b440135f25129d9ca2a56021d | Python | 3,960 | 105 | """
Coefficient of variation for event-time prediction distributions.
Author: Weijie Sun
"""
from __future__ import annotations
import numpy as np
def cov(
cdf: np.ndarray,
t_grid: np.ndarray,
return_details: bool = False,
) -> float | tuple[float, np.ndarray]:
"""
Compute the coefficient of va... |
ebcf3865247d2a762a659fc4a45adff053d2d86209abe2e0e85cc8033cbe815b | Python | 3,960 | 109 | import torch
from torch.nn.modules.batchnorm import _BatchNorm
def disable_running_stats(model):
def _disable(module):
if isinstance(module, _BatchNorm):
module.backup_momentum = module.momentum
module.momentum = 0
model.apply(_disable)
def enable_running_stats(model):
d... |
0024dcf91871c8593eb58917abf44fa1829403b60b3f2dfd23dbd1a7248c46a8 | Python | 3,961 | 133 | import json
import sys
import os
import datetime
import numpy as np
from PIL import Image
from shutil import copyfile
import SimpleITK as sitk
from src.utils import file_utils as futils
from src.utils import sitk_utils as sutils
Image.MAX_IMAGE_PIXELS = 933120000
def get_paths(dir, extensions=list(... |
16a04ca769fdaeef7a7fd1506d5d3eeac7334ccce5dcc4b2b6c6fb5f7d92eb2f | Python | 3,961 | 127 | # 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... |
d4495ea6333be2126e4d1d68fd329253bab5ac874d7b5af76ad9577766e55105 | Python | 3,961 | 86 | """The entropy-GrabCut masker as production code, reachable from compute_tissue_mask.
It ships in ``regtools.tissue_masking.core.grabcut``; the benchmark notebook imports that
module rather than owning a copy, so the published numbers describe the code that runs.
"""
from __future__ import annotations
import... |
357aa001a3f7b2d3b4438659df0840a394568b6ceea83369f24e98e29cafa8a6 | Python | 3,962 | 124 | # 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... |
397034e3af21729473d90d21ec9c4d2f67e387950d2e4eddb16832b5cee95c0a | Python | 3,962 | 118 | # -*- coding: utf-8 -*-
# @Author: Sadamori Kojaku
# @Date: 2022-11-02 13:34:28
# @Last Modified by: Sadamori Kojaku
# @Last Modified time: 2023-05-23 05:31:38
import os
import pathlib
import tempfile
import numpy as np
import pandas as pd
from scipy import sparse
import networkx as nx
def detect(
A, q, iters... |
f40848d04e710df02cda291c93853f5ed8c511905245a6d404c758b7fbbe51f6 | Python | 3,962 | 127 | #
# 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,... |
67b019f330a5c79aa9580ae64117831a7af00628e8e2cac498b90ab6c3e1975b | Python | 3,963 | 91 | """`_reorient_voxel_points` must match nibabel's own `apply_orientation`.
nibabel indexes an `ornt_transform` result by the SOURCE axis: ``xfm[i, 0]`` is
the DESTINATION axis that source axis ``i`` becomes. Reading it as
``xfm[dst_ax, 0] -> source axis`` applies the INVERSE permutation, which is a
no-op only for ... |
6f57b69b8061f41e0c825a0835e28b7083ea02c360555b1eb2afb04d21fbbf9d | Python | 3,963 | 115 | """
Prosper_nn provides implementations for specialized time series forecasting
neural networks and related utility functions.
Copyright (C) 2022 Nico Beck, Julia Schemm, Henning Frechen, Jacob Fidorra,
Denni Schmidt, Sai Kiran Srivatsav Gollapalli
This file is part of Propser_nn.
Propser_nn is free software: yo... |
ce34d7dee76adc2ad54840e7ac528ddc45ebb1d2be75ebc2089075d764cd1dba | Python | 3,963 | 107 | # 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... |
d41e19f47596cb00397be67efcafbf75afb3a17db4e10a201d62906fa6a5b66b | Python | 3,963 | 116 | import os, sys
import numpy as np
import h5py
import pandas as pd
from nd2reader import ND2Reader
import statistics
from tifffile import imread
from .image import imAdjust
from PIL import Image
def mkdir(fn,opt=0):
if opt == 1 :# until the last /
fn = fn[:fn.rfind('/')]
if not os.path.exists(fn):
... |
35618ecdee550510337ff3e1dcf98fdd76b6a1f9d2809b3b7a52bef548809fa6 | Python | 3,964 | 131 | # Node group "Offset Raycast" (ShaderNodeTree), 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 regenerated... |
a50b13da8d1257ad503533b0940a342a09bad3a25a6b8ceee304d86481570d1a | Python | 3,964 | 87 | from typing import Tuple
import torch
import torch.nn as nn
class CCNN(nn.Module):
r'''
Continuous Convolutional Neural Network (CCNN). For more details, please refer to the following information.
- Paper: Yang Y, Wu Q, Fu Y, et al. Continuous convolutional neural network with 3D input for EEG-based emo... |
fd6b0f69f5ffbac047455883b768a927778b6703e745dbfb7c800e0475c1716b | Python | 3,964 | 100 | """
This script performs post processing on a rendered Quarto site by doing
- adding canonical url tags to pages
- stripping index.html from urls in the sitemap
"""
from xml.dom.minidom import parse
from urllib.parse import urlparse, unquote
import warnings
from pathlib import Path
SITE_DIR = Path('_site')
SITEMA... |
00427732e647d9806534dbadb475353e6452c365f514ac25f1890cf2e906eed3 | Python | 3,965 | 60 | import numpy as np
import scipy.io
from os.path import exists
# conductance calculations
def calcconds_nrn_withcas(filename_nrn):
Measured_species = [ [ ['GluR1_S831', 'GluR1_S845_S831', 'GluR1_S831_PKAc', 'GluR1_S845_S831_PP1', 'GluR1_S831_PP1', 'GluR1_S845_S831_PP2B', 'GluR1_memb_S831', 'GluR1_memb_S845_S831', 'Gl... |
85543316ff9e1525b9003ee6905009eb909d4cd0f44500b6a3475001a7e12b95 | Python | 3,965 | 108 | import numpy as np
import torch
from ase.calculators.calculator import (
Calculator,
all_changes,
PropertyNotImplementedError,
)
from ase.neighborlist import neighbor_list
class MiaoCalculator(Calculator):
implemented_properties = [
"energy",
"energies",
"forces",
"str... |
885a658d181d87935216454b91bfb1ba7553eb5992c39e5bf3200785eaec9341 | Python | 3,965 | 115 | """Closing a stitching / cell-counting preview dialog mid-run must drain its
worker thread, not leave it running to be destroyed later (a Qt6 abort).
Both dialogs create ``self._worker_thread = QThread()`` with NO parent and had
no closeEvent, so closing the window while a preview was computing could destroy
a ru... |
ada4d970a736799232b99b72359089a2f3d7c0b0ade5764922f6845a87056374 | Python | 3,966 | 59 | """SPIKING_WEIGHTS.py 2026-10-03. Pre-registration: 04-NOTES/PREREG-2026-10-03c-SPIKING-WEIGHTS.md
Can the inequality's one baseline run be the spiking model itself? Weights from one spiking baseline of the laboratory prior
(cut-out, 50 channels x 5 trials), threshold frozen at 0.456; tested on LAW_IN_SPIKES S1's spiki... |
b7d594558067be74ad95e421f556820c58319e86e300b939a08f18d0a2d63f4f | Python | 3,966 | 107 | """Public damage-detection shim: ``geometry_registration.damage_mask``.
The silhouette comes from the project's seeded Multi-Otsu-4 GrabCut
(``tissue_masking.core.grabcut.compute_entropy_grabcut``); only Nitin Agarwal's
tear GEOMETRY is reused from ``_vendor`` (``compute_tear`` + constrained
Delaunay). The old ve... |
bbafd4c60bfd1d0091c779ef82c48acced00ee7f32df5b5556f6a0f828c60a49 | Python | 3,967 | 136 | # pylint: disable=invalid-name, missing-function-docstring
""" Attention MLP 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 AttnMLP(model_cfg)
def default_HPs(cfg: ... |
891ea4f156b66b1973356161243903f8705ad9364934f71d167e9b395d879599 | Python | 3,969 | 85 | import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
import util
import time
import torch
import pprint
from torchdrug.utils import comm
from torchdrug import core, models, tasks, datasets, utils
from siamdiff import dataset, model, task, transform
# new added import for performing CG-sca... |
aa4f34bc8ad0aed975fd173f734ee09b8e3b5544c9e429790a7728d7235db048 | Python | 3,969 | 134 | # Node-group asset "Force Mesh Collide" (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_CHE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.