sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
dc9ad7c084ee91cee6d2f2cc1c080c879ff1d5ac9a65946daa8e7501a471303e | Python | 5,032 | 115 | """
This script shows the training pipeline for k-fold training, without logging it via wandb.
"""
import tensorflow as tf
import tensorflow.keras as keras
import tensorflow_addons as tfa
from sklearn.model_selection import StratifiedKFold
from tf_spiking.helper import TrainingHistory
from tf_spiking import DenseLIF, ... |
96cc6903a8af7788e20d8baa9e5b8d3b4040f2af81314dbdf4726910836a5f02 | Python | 5,033 | 152 | import nibabel as nib
from pathlib import Path
from torch import from_numpy, permute, eye, tensor, diag, flip
from .transforms import apply_affine
def read_data(
path_data,
transform_data=False,
shape_data=None,
spacing_data=[1, 1, 1],
):
# Retrieve required variables
path_data = Path(path_dat... |
76d870262945cff5f4aacfa39facda6c8a803be565c3bc42623c0343ca4cd190 | Python | 5,034 | 125 | """Root SURFACE lockstep: walk == rows, budget frozen, L6+ ban (items 7 + 9).
The frozen table (test_arch_spine_surface_table.tsv) is regenerated only by
``tools/generate_surface.py`` with the diff reviewed; this suite re-derives
the live rows and demands byte equality in both directions, pins the root
budget, bans NE... |
00720ff9e12b34a9b512dbae95b368f1cb76531f977b661dbd650d3decf5afe3 | Python | 5,035 | 142 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Apr 19 2019
@author: Nathan de Lara <nathan.delara@polytechnique.org>
"""
from typing import Union, Tuple
import numpy as np
from scipy import sparse
from scipy.sparse.linalg import LinearOperator
class SparseLR(LinearOperator):
"""Class for matrices ... |
386eb4193886bd90172f29e156bf7584c220e511840d492a3584ee7e20623a93 | Python | 5,035 | 129 | # Copyright 2022 Deepfold 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 law or agreed to in writin... |
1f9fa573b6f12f36f21f538f50305e1e669d91f1318e2b4bada12075ead318d5 | Python | 5,036 | 206 | # -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot as plt
import random
import sklearn
import seaborn as sns
import scipy as sp
from matplotlib import rc
import matplotlib.ticker as mtick
import matplotlib as mpl
from scipy import signal
from sklearn.linear_model import LinearRegressi... |
96e87b310fca6e99bf3452054310f63fb6abf196f7aebca0855a8075539420b1 | Python | 5,036 | 115 | import numpy as np
import pandas as pd
from Bio import SeqIO
import os
chrom_list=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','X','Y']
genomic = {}
for chromInfo in SeqIO.parse("D:\PycharmWorkspace\Cooperation\Hucongcong\Human All genomic\hg38\\hg38.fa... |
f9e8adce36e09dca068fdf7773ec2f89352fc20d73d071dcc6b434d9bdd9f2df | Python | 5,036 | 128 | """grind-r5 b7 R55: trace-entry validation, overrides membership, context unwind.
* ``tl.trace(model, q, k, v)`` put tensor ``k`` in ``input_kwargs`` and ``v``
in the deprecated ``layers_to_save`` slot, then crashed DEEP with an
ambient-import-dependent error that never named the mistake (this
misdirected two ro... |
1c5cbfd025ade8f2f914713c3dd6944d78741c9103400458553c876425794e90 | Python | 5,037 | 135 | import argparse
from irnlm.models.glove.glove import extract_features as glove_int_extractor
from irnlm.models.glove.glove import load_model_and_tokenizer as load_glove_int
from irnlm.models.glove_semantic.glove import extract_features as glove_sem_extractor
from irnlm.models.glove_semantic.glove import load_model_and... |
8a70533258f328239ec904b66f835f9f25ae987c401d97122bb332d97170cccd | Python | 5,038 | 100 | """Nightly jobs that run a broad selection must pin the R0 candidate leg.
``tests/real_model/r0/test_realism_randinit_sweep.py`` and
``test_realism_randinit_axes.py`` assert the resolved-config fingerprint
(``tests/real_model/registry.py::resolved_config_fingerprint``) and the
op-count/behavior goldens it gates agains... |
955758a06601ec20e343d4dfc67e20e5566e9c3ce2424c40d4f0d495e0858e16 | Python | 5,038 | 140 | """Smoke coverage for glossary v5 locked field additions."""
from io import StringIO
from typing import Any
import torch
import torch.nn as nn
import torchlens as tl
from torchlens.data_classes import ParamAccessor
from torchlens.data_classes.layer import OpAccessor
from torchlens.data_classes.module import Module, ... |
ad221408c8dc15df0478e7098cf343b36a36c119cfde8ed38bef65c1f5147a43 | Python | 5,039 | 169 | #!/usr/bin/env python
import sys
full_gene_model = False
if "--full" in sys.argv:
full_gene_model = True
genome_id = None
stdin_data = []
KEY_ORDER = (
"parent",
"source",
"type",
"start",
"end",
"score",
"strand",
"8",
"quals",
)
# Table of amino acids
aa_table = {
"Ala":... |
fff1321134fbf5f59b74d2aee4389032d80be1f1b5a51a5fe3cc4f3f1b32485e | Python | 5,039 | 130 | from conftest import get_metrics
import numpy as np
from pyriemann.tangentspace import TangentSpace, FGDA
import pytest
from pytest import approx
@pytest.mark.parametrize("tspace", [TangentSpace, FGDA])
class TangentSpaceTestCase:
def test_tangentspace(self, tspace, get_covmats, get_labels):
n_classes, n_... |
0ff6ed21d96d502c6e8e1a50e21cb9b772aed40b93b9a88bb7dde7f424ab0ee5 | Python | 5,040 | 170 | #!/usr/bin/env python3
"""
Simple test routine for mAGO firmware.
Connects to the board, queries capabilities, and runs basic tests
on all available commands. Exits with 0 on success, 1 on failure.
Usage:
python test_mago.py [port]
port: Serial port (default: /dev/ttyACM0)
"""
import json
import sys
import ... |
7d012ad93cb45e96f3984a31e9fde62f5c1bb828de9ad731f8012e7de9972adf | Python | 5,040 | 164 | """
Lazy loading utility for spateo modules.
This module provides a lazy loading mechanism to speed up initial package imports
by deferring the loading of heavy submodules until they are actually accessed.
"""
import importlib
import sys
from types import ModuleType
from typing import List
class LazyLoader:
"""... |
d4e75c4632ca7c146adeacf4f2f68400b5b18043127ec909feedfecd7c487138 | Python | 5,040 | 108 | import numpy as np
import pandas as pd
from Bio import SeqIO
import os
chrom_list=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','X','Y']
genomic = {}
for chromInfo in SeqIO.parse("D:\PycharmWorkspace\Cooperation\Hucongcong\Human All genomic\hg38\\hg38.fa... |
37abcc3cd6ecbc2982ded8308e44bff6d62ac05d479a6b5000c93468b3a31ece | Python | 5,041 | 170 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Domain(_BaseLayoutHierarchyType):
_parent_path_str = "layout.smith"
_pa... |
3d0de6445fb1863c86f0f6da82544d65beb3f2a19c0f77ce16d84a1a2e27a509 | Python | 5,041 | 112 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
"""
.. _exa-compare-topographies:
Compare topographies
====================
.. currentmodule:: eelbrain
This example shows how to compare EEG topographies, based on the method described by McCarthy & Wood [1]_.
"""
# sphinx_gallery_thumbnail_number = 4
from ee... |
68d513b4992b5cc0c3545d9321dba3a70932745ec9babaabf8d584b83af94350 | Python | 5,041 | 170 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Domain(_BaseLayoutHierarchyType):
_parent_path_str = "layout.polar"
_pa... |
90fe995833eb15521ccdc350703caa94c1621ba33ab4f442e91992978b9c9d64 | Python | 5,041 | 157 | from dolfin import *
from rm_basis_L2 import rigid_motions
def elastic_stress(u, E, nu):
"Define the standard linear elastic constitutive equation."
d = u.geometric_dimension()
I = Identity(d)
mu = E/(2.0*((1.0 + nu)))
lmbda = nu*E/((1.0-2.0*nu)*(1.0+nu))
s = 2*mu*sym(grad(u)) + lmbda*div(u)*I
... |
957349ac30332a130a3d99ee810b5627dca358a21dcbf145e104d07a4e9bbcc9 | Python | 5,041 | 170 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Domain(_BaseLayoutHierarchyType):
_parent_path_str = "layout.scene"
_pa... |
b41d0217658a1029d591c60ee8e7de10c5e8662322676724224e6e7ba677f4ba | Python | 5,041 | 146 | import warnings
from typing import List, Tuple
import numpy as np
import xarray as xr
from hobj.benchmarks.generalization.simulator import GeneralizationSessionResult
from hobj.stats import binomial as binomial_funcs
def build_generalization_statistics(
results: List[GeneralizationSessionResult],
perform_la... |
930afdc82ece937a8bae87510936476966c87f335d4ea570ea672bb68bd8717b | Python | 5,042 | 131 | import torch
from torch import nn
from torch.nn import functional as F
import pdb
class _NonLocalBlockND(nn.Module):
def __init__(self, in_channels, inter_channels=None, dimension=3, sub_sample=True, bn_layer=True):
super(_NonLocalBlockND, self).__init__()
assert dimension in [1, 2, 3]
se... |
39779b65ea876e51316efa3b8350037a6f2c157b29dca9d4208ff847a3bc9521 | Python | 5,043 | 194 | """
Plot previous stimulus weights for the three environments
"""
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from stats import permutation_test_two_tailed
from stats.stars import stars
matplotlib.rcParams["pdf.fonttype"] = 42
sns.set(
style="tick... |
d4b84de0fd3432ed7c3a673d4c6603f8c2ce2a636ee9938964154f9b977025f1 | Python | 5,044 | 181 | from tempfile import NamedTemporaryFile
import polars as pl
import pytest
import seqpro as sp
from polars.testing import assert_frame_equal
from pytest_cases import parametrize_with_cases
def bed_valid():
return pl.DataFrame(
{
"chrom": ["chr1"],
"chromStart": [0],
"ch... |
f3637e7c4470a850702b5af4e8c0faffb225a7da8e3d601db22bb681fc63401a | Python | 5,045 | 153 | """
====================================================================
Motor imagery classification
====================================================================
Classify motor imagery data with Riemannian geometry [1]_.
"""
# generic import
import numpy as np
import pandas as pd
import seaborn as sns
from ma... |
55bf31bac0e74bc16c0ed36d8355d32c49a5e676cc1c8aa350fde6e0b0b104f6 | Python | 5,046 | 170 | """
BASIL GUI for Oxford ASL - Base classes and functions
Copyright (C) 2020 University of Oxford
"""
import os
import functools
import nibabel as nib
class OptionError(RuntimeError):
"""
Exception thrown because of an invalid option value (i.e.
an error that the user must resolve)
"""
class OptionC... |
be491163386427865d281c86f60c81d2b9f7ffe0d410c9cfff97af7837311c29 | Python | 5,046 | 159 | # Adaptet from pymc-lean: https://github.com/pymc-learn/pymc-learn/blob/master/pmlearn/base.py
import logging
import os
from sklearn.base import BaseEstimator
import pymc as pm
import arviz as az
import yaml
logger = logging.getLogger(__name__)
class BayesianModel(BaseEstimator):
"""
Bayesian model base clas... |
58f5ca8ccc820df3bcc2bd0261a7bb31e22e028fef7a4ae4db74982c257ab0a9 | Python | 5,047 | 170 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Domain(_BaseTraceHierarchyType):
_parent_path_str = "parcoords"
_path_str... |
aeee76e178a7f4f9cdd7b9acace8ea1d19818ad91cd792533f4f32060db26b50 | Python | 5,047 | 170 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Domain(_BaseTraceHierarchyType):
_parent_path_str = "indicator"
_path_str... |
55852831766c4ee96b35354f2f3ff5ec617d39edcff6d89d7cf1778867d63b37 | Python | 5,048 | 117 | import sys
import graphutils
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import utils
def ResetGraphs():
plt.clf()
plt.rcParams.update({'font.size': 12, 'axes.titlesize': 18,
'axes.labelsize': 18, 'xtick.labelsize': 18, 'ytick.labelsize': 18, 'lines.markersi... |
0d27831a743e8d23df2a374e2eea4989d7ccd884a97e427f353aac748cc9807e | Python | 5,049 | 108 | import glob
import h5py
import numpy as np
import os
import pandas as pd
from sklearn.linear_model import RidgeCV
from sklearn.model_selection import GroupKFold
from sklearn.linear_model import LinearRegression
from sklearn import preprocessing
import sys
from scipy.stats import pearsonr
"""
This script will run ridge... |
a22c3cf2c8feb00f120789d43ba676411473967c5baf2bdc3578f355488d4939 | Python | 5,049 | 171 | """
Created on Wed Jun 1 12:01:11 2022
@author: Pieter Barkema
This script sends normative modelling results to the user.
It connects to the SURFdrive to upload the results.
Then, it retrieves a download link for the results, and
emails the link to the user with the provided email address
and by connecting to the Gm... |
c662698561567db57abbe2316521a14daa3ff26009f01bcb91bcf5cd2a893d5c | Python | 5,049 | 125 | #!/usr/bin/python
#-*-coding:utf-8-*-
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apa... |
0028010da9eeec6ec1a088fd81a614ed53bc9e45c42cb1d8d16665b2ceccacdf | Python | 5,050 | 130 | """Ownership census for the perf-gate operation classifier.
Post-fixwave-4 the ``is_torchlens_operation`` prefix classifier decides
every blocking axis of the perf gate (missing-row, status-failure,
uncomparable, and wall-clock-fallback blocking), and it lived as two
independent hand-copies in ``perf_gate.py`` and ``p... |
f6b89e1a6671f666dc1a898421269b336ddefd78ed4d534630c066f444cdebbe | Python | 5,050 | 217 | """
Interface functions for preprocessing
This file is a part of BdPy
"""
from .preprocessor import Average,Detrender,Normalize,Regressout,ReduceOutlier,ShiftSample
from .util import print_start_msg, print_finish_msg
def average_sample(x, group=[], verbose=True):
"""
Average samples within groups
Para... |
31202d73607e5a0d8984dd81ad0a00bedfdd4968eaced5880591415c351fbebc | Python | 5,051 | 169 | from collections import defaultdict
import warnings
import attr
import numpy as np
import pandas as pd
from .well_understood_proteins import remap_motif, should_use_motif
@attr.s
class SingleVNRnaMap:
by_cell_line = attr.ib()
@property
def mean(self):
with warnings.catch_warnings():
... |
90e155865843a9697c0bcbf6c435e88868602c6108388013180a1c36d8e9d3b6 | Python | 5,051 | 130 | import json
from datetime import timedelta
from pydantic import BaseModel
from sqlalchemy import (
and_,
select,
)
from sqlalchemy.exc import NoResultFound
from sqlalchemy.orm.scoping import scoped_session
from galaxy.exceptions import ObjectNotFound
from galaxy.model import StoreExportAssociation
from galaxy... |
b8b70f34ac81f0bae3db3965133492d91eadb807e5a2a8e969409b862059e2e7 | Python | 5,051 | 132 | """A wrapper that adds human-renering functionality to an environment."""
import numpy as np
import gym
from gym.error import DependencyNotInstalled
class HumanRendering(gym.Wrapper):
"""Performs human rendering for an environment that only supports "rgb_array"rendering.
This wrapper is particularly useful ... |
6eabd3647228544ddcac7879373fad969c370148e2b7d716ed6f17dd7a206167 | Python | 5,052 | 127 | """Rebuild weakref-backed model accessors after finalization or rehydrate.
Portable loads intentionally avoid rebuilding every weakref-backed accessor in
``__setstate__``. This module centralizes the post-load repair step that
reconnects module and buffer accessors to the owning ``Trace`` once the
rehydrated object gr... |
4c44fc05f323f8b405bddb5f013ef988aeb3579462088fb71d074765e46c5dad | Python | 5,053 | 148 | """W051 regression: a re-executed episode product must round-trip save/load.
Audit finding AUD-CODE 1.1: ``run()`` on an episode capture dropped the
ledger to a travel note (capture_kind read ``plain``) but left every
``Op.episode_step`` stamp in place, so ``tl.save`` succeeded and ``tl.load``
refused ``artifact_episo... |
a5de342e73c09fed6e8b23f0d4a64e98689746b0d2d9fc55639ea5278607739d | Python | 5,053 | 147 | """A06 capture-options truth: a FAILED capture leaves the model clean.
M(oracles) item 8, the FORK-A cell all three labs agreed on: every FAILED
call is PURE of TorchLens instrumentation under either state-contract branch.
Historically a failed capture kept the per-module instance ``forward``
wrappers installed (the u... |
f23370a9cc758e3d750c6bcb760b49039d261f1ed1253fc244b23175ad9d0e00 | Python | 5,053 | 186 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import cv2
import numpy as np
from .imgproc import _get_zcoord
from .imgproc import _triangle_area
from .imgproc import extract_triangulation
from .imgproc import rectify_boundary_mask
__author__ = ['Nico Curti']
__email__ = ['nico.curti2@unibo.it']
__all__ = [
'shape... |
9b8ec84df23049b3c767db5ef6fa51e6427e44b1c267e1553564a5cd6389d58a | Python | 5,054 | 168 | """Module contains test fixtures meant to aide in the testing of jobs and
tool evaluation. Such extensive "fixtures" are something of an anti-pattern
so use of this should be limited to tests of very 'extensive' classes.
"""
import os.path
import shutil
import string
import tempfile
from collections import defaultdict... |
23d5a17a7bb913080129b22621e9b83c9a7eab9e740f57ab04abc80622a7046b | Python | 5,055 | 111 | #!/usr/bin/env python3
"""Запуск экспериментов.
python run.py solo --ticks 200000
python run.py paired --ticks 200000 # с интероцепцией vs без, один seed
python run.py social --ticks 200000 # этап 1.5: дилемма заключённого
"""
import argparse
import dataclasses
import json
import time
from sim imp... |
8136f479dd11083a8ca0525ca5fd3ec9017bc207ddddeb630164c9f1c64d0158 | Python | 5,056 | 135 | """Discharge preflight + W1-RPT + identity-v0 envelope (memo items 10/12).
The comparable-twins preflight REFUSES typed and never refutes: the registry
stays untouched and the structure trace keeps its HYPOTHESIS status. The
report names structural deltas before any bare "digests differ" fallback.
"""
from __future__... |
dea9538bf4370558f870c7e3e9a44de57f00311e3f6f312b21c348ef6cdd2688 | Python | 5,056 | 140 | """Tests for the despike workflow.
This file contains pytest for the despike workflow.
These tests can be run locally and on circleci.
Arguments have to be passed to these functions because the data may be
mounted in a container somewhere unintuitively.
"""
import os
import nibabel as nb
import numpy as np
from nip... |
578af7eaff42f286b62095a261d415d6a897ba0e226cb56584bbf74c8785fed0 | Python | 5,059 | 146 | """Mathematical equations display for Module Inspector."""
from __future__ import annotations
__all__ = ["get_module_equations_html"]
def _format_equation(label: str, equation: str, description: str = "") -> str:
"""Format a single equation with label, formula, and description."""
desc_html = (
f"<d... |
be678ec4b3d15ed6008d5a2740fce088818bf3e90b9edeb1b563ada7e383edc4 | Python | 5,059 | 158 | import numpy as np
import panel as pn
import pytest
from larvaworld.lib.param import NestedConf, OrientedPoint, TrackerOps
from larvaworld.lib.param.xy_distro import Spatial_Distro
def test_oriented_point():
P = OrientedPoint(pos=(2, 2), orientation=np.pi / 2)
# Single point
p00, p01 = (-1, 1), (1, 1)
... |
e5de9374d84ed2783c4c946acf0738de7b9a6d8277ce9402f6027ef928bdde43 | Python | 5,059 | 139 | """MS COCO Key Points Evaluate Metrics."""
from __future__ import absolute_import
import os
from os import path as osp
from collections import OrderedDict
import warnings
try:
from mxnet.metric import EvalMetric
except ImportError:
from mxnet.gluon.metric import EvalMetric
class COCOKeyPointsMetric(EvalMetric... |
7e8ddcd017aea9f9fbab322f4d637b0d28710400aa1a38e7ac2d783ff315634c | Python | 5,061 | 132 | import random
import numpy as np
import torch
import time
import math
from copy import deepcopy, copy
class Lang():
pass
def seed_all(seed=0):
print("* Setting all random seeds to ",seed,'*')
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.... |
2d055bc38544d0420af374c146e2189f8d94a21401f46b39edd725bae1d32d39 | Python | 5,062 | 138 | import urllib.parse
try:
from fs.ftpfs import FTPFS
except ImportError:
FTPFS = None # type: ignore[misc,assignment]
from galaxy.files.models import (
BaseFileSourceConfiguration,
BaseFileSourceTemplateConfiguration,
FilesSourceRuntimeContext,
)
from galaxy.files.templates.models import FtpConfi... |
276f93d230dc0194a491434ebe359d6f4fe5e9b1a3679e503efad3e71501965b | Python | 5,063 | 138 | #!/usr/bin/env python3
"""
Diagnostic Z — cohort ablation analysis.
Drop each AD-containing cohort one at a time from the Dx X canonical
pool. Recompute AUC, LOO, LOCO, and operating-point characteristics.
Test whether the tool's performance is dominated by any single cohort.
Especially probes:
- What happens when ... |
4d4ac5e16d8927c3141043f6b5fa7e177171edbcede10240bd020e637e216fd8 | Python | 5,063 | 143 | """JAX ``custom_jvp_call`` capture: inline pure primals, refuse impure typed.
``jax.custom_jvp`` customizes DERIVATIVES only; the equation's ``call_jaxpr``
is the exact forward primal, so inlining a recursively pure, const-free primal
is forward-faithful by construction. Two library shapes exist in the wild:
* ``jax... |
c9e71aa4293b826b41d6c636984e2b96585afcb916648046ee622691631add9c | Python | 5,063 | 162 | import sys
import numpy as np
import argparse
import os
def not_find(arr, str):
"""
checks if a string is NOT in an array
:param arr the array to be checked
:param str the string to be found
:return true if the string is NOT in array, false if it is in array
"""
for i in range(len(arr)):
... |
355d23780c4f17f15b4e15f8e19cd056bfa382a1f55a209d6ff848dcfb948fa8 | Python | 5,064 | 170 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Domain(_BaseTraceHierarchyType):
_parent_path_str = "funnelarea"
_path_st... |
7ebe31743db84301e1b8049dcd279ef41a85787c219f63ff26a931352f3d10fe | Python | 5,064 | 132 | """Prepare the ImageNet dataset"""
import os
import argparse
import tarfile
import pickle
import gzip
import subprocess
from tqdm import tqdm
from mxnet.gluon.utils import check_sha1
from gluoncv.utils import download, makedirs
_TARGET_DIR = os.path.expanduser('~/.mxnet/datasets/imagenet')
_TRAIN_TAR = 'ILSVRC2012_img... |
5d6e5b59c362b2a91c09a51e89d41304bee00040cb95737b1696eb059a3546b9 | Python | 5,065 | 142 | import torch
from tqdm import tqdm
import csv
import pickle as pkl
import os
from transformers.file_utils import FAISS_IMPORT_ERROR
from LRP.convert_ProtBert_to_LRP_model import convertProtBertToLRPModel
from LRP.ExplanationGenerator import Generator
import numpy as np
from interpretability.utils import (
load_se... |
f272428a4ed9d4a26c195012d8f97b231d2cbea9f2161a2fe265df7541c60d3c | Python | 5,065 | 115 | """Portable-I/O error vocabulary (logical L0; physically homed with _io).
The persistence four-way ruling (architecture memo 3.2) sends IO error
CLASSES to L0: they are frozen vocabulary consumed by every stratum that
touches an artifact. They stay physically inside ``torchlens._io`` under
Rule V's single-lower-consum... |
4a56791d4df1cb67fa4381a169eed8ec9bdc22fac73f4e83678de06f4310e721 | Python | 5,066 | 128 | import glob
import os
import shutil
import matplotlib.pyplot as plt
import numpy as np
import torchvision.transforms as transforms
from PIL import Image
from natsort import natsorted
from torchio import RandomElasticDeformation
def postprocess_tensor(in_tensor):
transform = transforms.ToPILImage()
img_out = ... |
c3347ca9f0b897af5cc4a608e0b4300f1be598b6d5f3833d128cbb65b11f1e09 | Python | 5,067 | 139 | # coding=utf-8
# Copyright 2022 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... |
d67f6f007110a508a1587967cef39c90d139a36f417fa03976f402dcfbc20f02 | Python | 5,067 | 152 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 27 10:33:17 2021
@author: Audrey Mazancieux
This script performes group-level GLM analyses on several ROIs time serie.
Single-subject estimates have to be done using the glm_roi_singleSubj scipt.
"""
# Import useful libraries
import os
import gl... |
e1a9773ccc32d0425985374c697aa342f0a53723d3d55fa65636d6beaa247d21 | Python | 5,067 | 164 | """Shared fixtures/helpers for the weightsfree (F33 / D8) test suite.
No test functions live here. Every parity fixture constructs BOTH twins
(real + meta) back-to-back BEFORE either is captured, per the W1-ORD
discharge recipe: honest twins constructed on opposite sides of a wrap
flip refute each other on saved-refer... |
92bff9e5cda702a933d77b19289383f5874b758c2c8014f54f0c408b7dca79c0 | Python | 5,068 | 128 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... |
05deb805d293b7b90491ad2b11d5f54012ba7e48dd3344f4b1f503a4cdd5d35b | Python | 5,069 | 200 | ## Coherence-enhancing diffusion filtering
import numpy as np
from numpy.random import randn
from numba import jit
from scipy import ndimage as ndi
import sys
from . import filt2d
Fx = np.array([(-3., 0, 3), (-10,0,10), (-3,0,3)])/32.
Fy = Fx.T
@jit
def calculate_gradient(img):
return filt2d(img, Fx), filt2d(... |
b439473ee026ef10aca592772399fce4a2dc3bcd1fcb84d1b04574a40e72faa0 | Python | 5,070 | 144 | #!/usr/bin/env python3
import sys
import os
import argparse
def write_pymol_arrows(base, structs, scale, color, radius, hradius, hlength, threshold):
pymol_file = base + '_arrows.pymol'
lines = []
arrow_objs = set()
t2 = threshold**2
s2 = scale**2
for i, struct in enumerate(structs):
... |
1e3a9d8020203c548379d7f9229ed738f24c211fbfd62ece8bee32161ab610e9 | Python | 5,071 | 155 | """
Author: Timothy Tickle
Description: Project constants.
"""
#####################################################################################
#Copyright (C) <2012>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of
#this software and associated documentation files (the "Software"... |
c655951923fdec0581661a50f9a256ee4c9077d34dba256c64e3a895983ed80b | Python | 5,071 | 115 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: spopoff
"""
from torch.nn.functional import relu, max_pool2d, avg_pool2d, dropout, dropout2d, interpolate
import torch
def complex_matmul(A, B):
'''
Performs the matrix product between two complex matricess
'''
outp_real = torch.matmul(... |
d9e8ffee8d6ddc8dc57e1d2cae836f2fe4f557ea865e3c5a9ea41db8ecb90d47 | Python | 5,072 | 195 | """Metrics object."""
from copy import deepcopy
import numpy as np
from specparam.metrics.metric import Metric
from specparam.metrics.definitions import check_metric_definition
from specparam.reports.strings import gen_metrics_str
#####################################################################################... |
1ea66f4fd88053b342226e264bcd5be78c432bfbfa7fcba4d43d6734d1fb6291 | Python | 5,074 | 172 | from pathlib import Path
import argparse
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm, Normalize
import seaborn as sns
from figure_utils import get_sanitized_basis_set_name
from plot_params import get_plot_params
get_plot_params()
def get_cli_args():
"""Parse co... |
27cba2014e47794be1efac383aaee44633c3a4e2a3be54f3e23ccca751cf602f | Python | 5,074 | 139 | """
StarGAN v2
Copyright (c) 2020-present NAVER Corp.
This work is licensed under the Creative Commons Attribution-NonCommercial
4.0 International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
Creative Commons, PO Box 1866, Mountain View, CA 94042, US... |
70b29b3d700fb156dd8737c8ae0cc432b8ee7ba3d6ec457cabc44f9404500e68 | Python | 5,075 | 170 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Domain(_BaseLayoutHierarchyType):
_parent_path_str = "layout.ternary"
_... |
9bae000d849345e0ce47c34207ea2e5a50273a3a3a2c55d67bcd619e49814564 | Python | 5,075 | 128 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... |
763d15d6a222bbc501d6fcb122e8fea58077cc0e81fda6587cb243d0681b00e4 | Python | 5,076 | 102 | import torch
from torch import nn
from torch import Tensor
from collections import OrderedDict
import numpy as np
class GetDensity(torch.nn.Module):
def __init__(self,rs,inta,cutoff,nipsin,norbit,ocmod_list):
super(GetDensity,self).__init__()
'''
rs: tensor[ntype,nwave] float
inta:... |
b4bcf65642dac207344e2891031e4aff3f9e175e0469b6d137dca61acc424d33 | Python | 5,078 | 154 | from pathlib import Path
import numpy as np
from anndata import AnnData
from PIL import Image
from tqdm import tqdm
def tiling(
adata: AnnData,
out_path: Path | str = "./tiling",
library_id: str | None = None,
crop_size: int = 40,
target_size: int = 299,
img_fmt: str = "JPEG",
quality: in... |
e8b3106ca92449453fb8bef5012f5cee2ca5bcf1fcdba55ce4c61abec4001010 | Python | 5,078 | 136 | """ This file contains different utility functions that are not connected
in anyway to the networks presented in the tutorials, but rather help in
processing the outputs into a more understandable way.
For example ``tile_raster_images`` helps in generating a easy to grasp
image from a set of samples or weights.
"""
... |
9ec043c120f8f9152a4a285f14e3e39b85b119f2487f2c1a089f1f81899fc0de | Python | 5,079 | 112 | import numpy as np
import cvnn.layers as layers
from time import sleep
from cvnn.layers import ComplexDense
from cvnn.real_equiv_tools import get_real_equivalent_multiplier
from tensorflow.keras.models import Sequential
from tensorflow.keras.losses import categorical_crossentropy
def shape_tst(input_size, output_size... |
f9f75b8129c76a4f0a8f29bd065fc1de4ef3c267bd887dbf3beb4baa3046c3ce | Python | 5,080 | 146 | import numpy as np
import pandas as pd
from scipy.signal import butter, filtfilt, find_peaks, hilbert
from library.utils import mat2direction
class Crosser:
def __init__(self, bin_size=0.002, window_width=0.3, bandpass=(5, 12)):
self.bin_size = bin_size
self.window_width = window_width
sel... |
1148b51239be69cebe0e00a019f15c25f941ca3df924265fe4dfb1cc0f11e1a6 | Python | 5,081 | 159 | import argparse
from pathlib import Path
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import LearningRateMonitor, ModelCheckpoint
from DeepDenoise.src.dataloader import CESTDataModule
from DeepDenoise.src.res_unet import CESTResUNet
from DeepDenoise.src.unet import CESTUnet
def save_... |
44664b30bfcf20e500bc3cbb20f245fa8c34c4c2f71531c72073c4c48b599dcb | Python | 5,081 | 143 | """Plots for the group model object.
Notes
-----
This file contains plotting functions that take as input a group model object.
"""
from specparam.modutils.errors import NoModelError
from specparam.modutils.dependencies import safe_import, check_dependency
from specparam.utils.select import find_first_ind
from specpa... |
d9e634fd5de5fa36ecb564291a3845183869fb3f12175e75c7eb9fb30a93f718 | Python | 5,081 | 140 | """
Visualisation code. Takes the name
of a model and plots the training and
validation performance metrics,
then saves them in the `./results/images` directory.
"""
import numpy as np
import matplotlib.pyplot as plt
import argparse
from sklearn.metrics import confusion_matrix, balanced_accuracy_score, precision_r... |
f863c86d78316b968c1f5876796afd04872b092b18da4bc6b3640d96d59ff843 | Python | 5,081 | 153 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Tiling(_BaseTraceHierarchyType):
_parent_path_str = "icicle"
_path_str = ... |
da2b30c6f9896c4e9c13e4b4d6d5c459b66667bf24dc3a41a4d340007b3a5f83 | Python | 5,082 | 141 | from functools import reduce
from mne import SourceSpaces
import numpy as np
from .._data_obj import VolumeSourceSpace, _point_graph
from .._types import PathArg
def merge_volume_source_space(sss, name='Volume'):
"""Merge multiple volume source spaces into one
Notes
-----
Only intended to work prop... |
0569755ca2a816aa8e1c703358c345635bbc6cff58153336660a835d31f37164 | Python | 5,083 | 134 | """Unit tests for celery.app.trace module."""
import sys
from celery.app.trace import traceback_clear
class test_traceback_clear:
"""Unit tests for traceback_clear function."""
def test_uses_exc_argument(self):
"""Test that traceback_clear(exc) correctly uses the exc argument.
This test pr... |
5f9d914c00a002f5f9321a2d124e0d7d1b228080959afac3cdfd36333e413c13 | Python | 5,084 | 143 | # Run test with:
# torchrun --no_python --nproc_per_node=8 pytest -q -s tests/modules/test_mlp_parallel.py
import pytest
import torch
import torch.nn.functional as F
from apex.transformer import parallel_state, tensor_parallel
from einops import rearrange
from flash_attn.modules.mlp import GatedMlp, ParallelGatedMlp
... |
8181988b81243d236fdc3bf34241cadc1db0969316cab262700aaebb0845f2df | Python | 5,084 | 132 | """
Author: Derek van Tilborg -- TU/e -- 23-05-2022
Basic graph attention network [1] using a transformer as global pooling [2].
1. Veličković et al. (2018). Graph Attention Networks
2. Baek et al. (2021). Accurate Learning of Graph Representations with Graph Multiset Pooling
"""
import torch
import torch.nn.functi... |
15b2066e1603c56b3213d3c5401c20f3e4324d42a9044a801ae428087ffcb45b | Python | 5,085 | 137 | import skeletor as sk
import trimesh as tm
import pandas as pd
import numpy as np
import ast
import re
import os
import pyvista
import fast_simplification
import pdb
def checksize_n_simplify(inputfile, logdir="./logs", verbose=False):
if verbose:
print("Checking file size and simplifying if necessary..")
... |
2ca353b80efcdf704a2144106a83c5a96a5977bb36339293886dc1637a4cd8e1 | Python | 5,085 | 146 | """
Utility classes allowing Job interface to reason about datasets.
"""
import os.path
from abc import (
ABCMeta,
abstractmethod,
)
from galaxy.model import (
DatasetCollectionElement,
DatasetInstance,
HistoryDatasetCollectionAssociation,
)
DeferrableObjectsT = (
DatasetInstance
| Histor... |
32b386652dad7e1431a756f0d9eb8d801ef31dbdf9a4ebd4ec3ff032dab7be15 | Python | 5,086 | 122 | import argparse
import os
import sys
import time
import pandas as pd
import polars as pl
import polars
import numpy as np
import torch
from torch_geometric.loader import DataLoader
import global_data
from create_data_test import TestbedDataset
from models.ginconv import GINConvNet
BASE_DIR = os.path.dirname(os.path.a... |
8babaabdc93160d48bfc7c6377a96fd34a800360771d4f36f6225d4a8fd1c2e9 | Python | 5,086 | 160 | """
====================================================================
Segmentation of hyperspectral image with Riemannian geometry
====================================================================
This example compares clustering pipelines based on covariance matrices for
hyperspectral image segmentation [1]_.
"... |
c9594080675ef6d810f259d689a31fe957462c1dde2480f8869accc02837552c | Python | 5,086 | 150 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 27 2022
@author: pramod
"""
import sys
import argparse
import os
import time
import random
import torch
from torch import nn
import numpy as np
import pandas as pd
from collections import Counter
import sklearn.metrics as skm
from sklearn.model_sele... |
439b8c98a7b8a35625889dd8e0d068377dc9dcc62d61c7dfaea1f747c022135b | Python | 5,087 | 149 | from __future__ import print_function, division
import subprocess
import os
import os.path
import sys
import time
import random
import numpy as np
from matplotlib import pyplot as plt
import ctypes
import array
import copy
import cppyy
import cppyy.ll
cwd = os.path.dirname(os.path.abspath(__file__))
good = cppyy.cpp... |
16b99ec52c0a770b89f4427d76988f7b095f8c4b2721207586c8fb35c4b54fbb | Python | 5,088 | 169 | """
## Mulstiscale decomposition and reconstruction routines
"""
import numpy as np
from scipy import ndimage
from . import atrous
from . import mmt
from . import emd
from . import mvm
from . import utils
#from .utils import pyramid_from_atrous
#from .utils import pyramid_from_zoom
from .constants import *
_dtype_ ... |
4ce6154586d8fbf9aa589423bd18dfdfc219cf1a8d6e2dc4cc25cf8e2397eb07 | Python | 5,088 | 136 | import numpy as np
import itertools as itools
from ridge_utils.DataSequence import DataSequence
DEFAULT_BAD_WORDS = frozenset(["sentence_start", "sentence_end", "br", "lg", "ls", "ns", "sp"])
def make_word_ds(grids, trfiles, bad_words=DEFAULT_BAD_WORDS):
"""Creates DataSequence objects containing the words from e... |
7beb51637c63b1133bc2217cfc8d8f0fb1837a5dcea543ac8b49d19bfbb8085a | Python | 5,088 | 128 | import torch
import os
import numpy as np
import argparse
import logging
from transformers import *
from src.eval.eval_model import dev_eval
from src.adapet import adapet
from torch.optim.lr_scheduler import LambdaLR
from src.data.Batcher import Batcher
from src.utils.Config import Config
from src.utils.util import g... |
75c78d506543bb46e9fc1a0680104f82149b8f46372802adbee52e04d64ee517 | Python | 5,089 | 154 | import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
from torch.autograd import Variable
from torch.nn import Linear, ReLU, CrossEntropyLoss, Sequential, Conv... |
1cc15d23351f40d3c1c501b319be4f339d386211d22eb28c074a6155e39c6e74 | Python | 5,090 | 177 | import pytest
import numpy as np
from ripser import Rips
from sklearn import datasets
from sklearn.metrics.pairwise import pairwise_distances
from scipy import sparse
def makeSparseDM(X, thresh):
"""
Helper function to make a sparse distance matrix
"""
N = X.shape[0]
D = pairwise_distances(X, met... |
27a256dbcd45761c16c484708a01f1e9767a856cfbce65332f04026daf9c10b8 | Python | 5,090 | 124 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Unifiedhovertitle(_BaseLayoutHierarchyType):
_parent_path_str = "layout.yax... |
ac05b1f301ec82abd46c8903e60f2621f91073e6ade90b77af1f555a414553a9 | Python | 5,090 | 124 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
import copy as _copy
class Unifiedhovertitle(_BaseLayoutHierarchyType):
_parent_path_str = "layout.xax... |
d27a947542893d031e6bd0f38b9669756c63d77e18348aed64be24f71a3fcc83 | Python | 5,090 | 140 | from __future__ import annotations
import pytest
from pybind11_tests import copy_move_policies as m
def test_lacking_copy_ctor():
with pytest.raises(RuntimeError) as excinfo:
m.lacking_copy_ctor.get_one()
assert "is non-copyable!" in str(excinfo.value)
def test_lacking_move_ctor():
with pytest... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.