sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
c328563e66e9a0a1128ec5f4500d01d50500537ec4d7b26b3f1fee08c280a7a9 | Python | 12,104 | 341 | """
Unit tests for Database API endpoints.
Tests database queries for runs, experiments, and cached database information.
"""
import json
import unittest
from unittest.mock import Mock, patch
from ethoscope_node.api.database_api import DatabaseAPI
class TestDatabaseAPI(unittest.TestCase):
"""Test suite for Dat... |
292c27f4fe9e70b91243277be90fc5a35014a234113e660675899f69d734157c | Python | 12,105 | 441 | """
Methods for managing colors
"""
from __future__ import annotations
import random
import matplotlib
import numpy as np
__all__: list[str] = [
"invert_color",
"random_colors",
"N_colors",
"colorname2tuple",
"colortuple2str",
"col_range",
"Color",
"combine_hex_values",
"mix2colo... |
84aabb3f56719ba77c9a59b17e60844931f2fce870d85c3e652b88765410afd7 | Python | 12,107 | 320 | # MIT License
# Copyright (c) 2018 Adrian Wolny (https://github.com/wolny/pytorch-3dunet)
# 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 t... |
06f19e9e998d54b729fa7ef454e1e391815c837adc5adb69524861577e703838 | Python | 12,112 | 401 | from datasets.celeba_uf import CelebA
import random
import pandas as pd
import time
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
from torchvision.models.resnet import resnet18 as Net
import torch.nn.functional as F
import torch.nn as nn
import torch.optim as optim
import torchvision.trans... |
4b8879beaa99c9e972e5ae437cf9f8b19b0f83d8e008195cbabce62c0514f6b9 | Python | 12,119 | 251 | from helpers.configurations import TAKE_SPLIT, OR_4D_DATA_ROOT_PATH
import numpy as np
from torch.utils.data import DataLoader
from functools import partial
from role_prediction.graphormer.data import get_dataset
from role_prediction.graphormer.collator import collator
import torch
from torch.nn import functional as F
... |
2243e58636d916c467748ca152e038327a1ed1d3e83a0082b1e5dfd38baeb860 | Python | 12,131 | 310 | #!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
"""
Sum-of-squares polynomial transformer for autoregressive normalizing flows.
"""
# ============================... |
c18f0474de1220facbaf86e49147551853e249dae7ed763dfe061caa76d25017 | Python | 12,131 | 322 | """Utility functions for managing and manipulating model objects."""
import numpy as np
from specparam.sim import gen_freqs
from specparam.data.stores import FitResults
from specparam.utils.checks import check_input_options
from specparam.models import (SpectralModel, SpectralGroupModel,
... |
9aa151fb95a262d6862f7687ef9c68254aa324f4b72db8c8b016a3176573f408 | Python | 12,134 | 395 | """PYTEST_DONT_REWRITE
Coverage for Phase 5 multi-pass Layer conditional aggregation.
"""
from __future__ import annotations
import torch
import torch.nn as nn
import torchlens as tl
from torchlens import trace as trace_fn
from torchlens.data_classes.layer import Layer
from torchlens.data_classes.trace import Trace... |
0de1b97dd82c49b0508d1f97955753f6d747f7aab3d5a2175ada89d198720f41 | Python | 12,136 | 284 | """ PyTorch Feature Extraction Helpers
A collection of classes, functions, modules to help extract features from models
and provide a common interface for describing them.
The return_layers, module re-writing idea inspired by torchvision IntermediateLayerGetter
https://github.com/pytorch/vision/blob/d88d8961ae51507d0... |
f5e249a201198954747e0336e955dc41eed45df659e88646b2ea826af2c92e79 | Python | 12,136 | 321 | #!/usr/bin/python3
#-*-coding:utf-8-*-
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use th... |
74adc2fbc958afca6f7f4fa9754e682dd5d322ad649160cca844bd2271b6bbcf | Python | 12,140 | 348 | """
Loads and handles the settings-tab. Modifies core system settings.
SimplyFire - Customizable analysis of electrophysiology data
Copyright (C) 2022 Megumi Mori
This program comes with ABSOLUTELY NO WARRANTY
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General P... |
35e672aaa26780dcaa4390bd6f58390d6e8a4cad3273781e2cdb54062834b4bb | Python | 12,142 | 324 | # This is try to code spatial suppression motion task
import sys
import numpy as np
from numpy.polynomial.polynomial import polyfit
from psychopy import visual
from scipy.interpolate import interp1d
from neurogym.utils import spaces
from .psychopy_env import PsychopyEnv
class SpatialSuppressMotion(PsychopyEnv):
... |
4a79a13e87ed59ed1cf47ae9b5bbe81b25df13ab149ea883aa4caf8b19fe1501 | Python | 12,147 | 351 | """
Top-down car dynamics simulation.
Some ideas are taken from this great tutorial http://www.iforce2d.net/b2dtut/top-down-car by Chris Campbell.
This simulation is a bit more detailed, with wheels rotation.
Created by Oleg Klimov
"""
import math
import Box2D
import numpy as np
from gym.error import DependencyNot... |
9f67c74e71ee8f336e12ec0ca49fc8e9cf080e465bc0f8c5ae47f87fba269d00 | Python | 12,149 | 319 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
import numpy as np
from .. import fmtxt
from .. import plot
from .. import test
from .._data_obj import combine
from .._stats.stats import ttest_t
from .._text import ms
from ..fmtxt import Section, linebreak
def source_results(res, surfer_kwargs={}, title="Re... |
05d632b9454bcb98730f5a185f6793ef14429005758555fe5d606522fc8bca10 | Python | 12,153 | 334 | """
Unit tests for File API endpoints.
Tests file management including browsing, downloading, and file removal.
"""
import datetime
import os
import unittest
from unittest.mock import Mock, call, mock_open, patch
import bottle
from ethoscope_node.api.file_api import FileAPI
class TestFileAPI(unittest.TestCase):
... |
223fa030b3f82365ceffe8160cbac11b6487d629d960ab1cb4674f0fcde1bc75 | Python | 12,155 | 320 | """Round-6 security regression: state-mutator + storage-unsafe callable denial.
Round-5 closed the FILE-I/O sub-class of side-effecting torch callables reachable
from an untrusted ``.tlspec`` bundle. This round closes the PROCESS-STATE-MUTATION
+ STORAGE-UNSAFE sub-class. Their real ``__module__`` is the allowlisted t... |
a28c492b199618289515fb838ebb00a4fefa9a7b68f584b598e6bc6cade9479d | Python | 12,160 | 291 | import numpy as np
import itertools
import tensorflow as tf
import sonnet as snt
from collections import namedtuple, Counter
from sklearn.model_selection import KFold, StratifiedKFold
import matplotlib.pyplot as plt
import sklearn
import sys
import argparse
from distutils.util import strtobool
parser = argparse.Argume... |
e03c45f1f2bfce58d5cd0885a9bb6886176791b54efb8296ebf90711dea5ed97 | Python | 12,160 | 206 | import numpy as np
from gym import utils
from gym.envs.mujoco import MujocoEnv
from gym.spaces import Box
class PusherEnv(MujocoEnv, utils.EzPickle):
"""
### Description
"Pusher" is a multi-jointed robot arm which is very similar to that of a human.
The goal is to move a target cylinder (called *obj... |
72a4e4971856489f64ae1017f1d494e8281a5ec756192f212c81c2489428779d | Python | 12,162 | 361 | #!/usr/bin/env python
# ensure that you have downloaded the LDC dataset LDC97S62 and tar exists in a folder e.g.
# ./data/swb/swb1_LDC97S62.tgz
# from the deepspeech directory run with: ./bin/import_swb.py ./data/swb/
import codecs
import fnmatch
import os
import random
import subprocess
import sys
import tarfile
impor... |
fa09d2c675a0ffc7da700082d022340db61163a1c6d545a6671470ea38cfb794 | Python | 12,165 | 448 | import os
from itertools import product
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats
import tensorflow as tf
from matplotlib import cm
from tqdm.auto import tqdm
import pandas as pd
import RNAutils
def ei_vec(i, len): # give a one-hot encoding
result = [0 for i in range(len)]
result... |
737c5dde9033be7b57c198afe5da0a2bda59fb11e386262cd6d692e506f6bcb3 | Python | 12,167 | 292 | """Reachable-surface walk + 4-way classification gate (build item 2).
The cheapest row that would have caught the commissioning surface: the door
whose bugs commissioned the oracles panel was OUTSIDE ``__all__``, so every
``__all__``-rooted harness would never have tested it. The enumeration root
here is the walked re... |
980434f5d4a239b4de1ce336ec9f645ba996fc4f006df854d1d5a88f22343f1c | Python | 12,168 | 248 | #==============================================================================#
# Author: Dominik Müller #
# Copyright: 2024 IT-Infrastructure for Translational Medical Research, #
# University of Augsburg ... |
22e1589e65333816c5a47f942af3e0f3c182f2ac785dacf343b49da6906d989a | Python | 12,170 | 283 | # Copyright (c) 2021 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... |
a93195a4fd12a7ec89721e9104953c06064bb85afffee7ce4cc5dd9ee908a088 | Python | 12,170 | 240 | # pytest unit tests for sct_process_segmentation
import pytest
import logging
import numpy as np
import tempfile
import nibabel
import csv
from spinalcordtoolbox.scripts import sct_process_segmentation, sct_image
from spinalcordtoolbox.utils.sys import sct_test_path
from spinalcordtoolbox.image import add_suffix
log... |
5609594733e426ba5db9596f046b003867141ac489c0f845638adeb2c209bbc0 | Python | 12,177 | 359 | """Run pytest in small batches per test file for a marker selection, bounding memory.
A single long-lived pytest process executing hundreds of heavy model-capture
tests in one interpreter accumulates memory across the whole run: the weekly
"Slow and rare tests" job's runner was killed by the GitHub Actions host
partwa... |
9bcfc786244c39c8aa961b73a805e0a609eaaebdcc716679172f0a85470ab07c | Python | 12,181 | 401 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
"""Wrapper for binaries
For permission errors: try ``os.chmod`` or ``os.chown``
subprocess documentation
------------------------
http://docs.python.org/library/subprocess.html
http://www.doughellmann.com/PyMOTW/subprocess/
http://explanatorygap.net/2010/05/1... |
2d3b9b5e19cdf69ca4473fc3456a00efdf5b198fdcb7eed88b019bb297860cf2 | Python | 12,185 | 419 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
''' Modified based on: https://github.com/erikwijmans/Pointnet2_PyTorch '''
from __future__ import (
division,
absolute_import,
w... |
4f0c3f3f55c4828df29921050e87e8d3461ce675f2cd77aa902ac81d126ee132 | Python | 12,190 | 237 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
import json
import random
import time
from pathlib import Path
from threading import Thread
from urllib.request import Request, urlopen
from ultralytics import SETTINGS, __version__
from ultralytics.cfg import MODES, TASKS
from ultralytics.utils impo... |
53db461b598ecddb433de470192e5ed2db3d2de337ec6698e91f229e86c80c3d | Python | 12,193 | 284 | #!/usr/bin/env python3
"""
Intel CPU Scraper
This script uses requests and BeautifulSoup to scrape CPU names and their associated TDP values
from the Intel ARK website using the advanced filter search URL.
uv run pip install beautifulsoup4
uv run python intel_cpu_scrapper.py
"""
import csv
import os
import re
impor... |
9fb9ee7b4bfd38d593a0c44bdc63d39cc63528f71556eb99ddf7408e09e86483 | Python | 12,193 | 362 | import sys
import seaborn as sns
import pandas as pd
import numpy as np
import json
from matplotlib import pyplot as plt
from collections import Counter
from matplotlib.backends.backend_pdf import PdfPages
def plot_entropy(entropy,tscript_name,head_name):
""" Plot nucleotide position vs Shannon entropy of attentio... |
8adb0dc33b37e29d6be2b3589675429fab91a56e8fa771aaeb9963efe9cdb48c | Python | 12,195 | 371 | from __future__ import annotations
from typing import overload
import numba as nb
import numpy as np
from numpy.typing import NDArray
@nb.guvectorize(["(u1[:], u1[:])"], "(n)->(n)", target="parallel", cache=True)
def gufunc_pad_left(
seq: NDArray[np.uint8], res: NDArray[np.uint8] | None = None
) -> NDArray[np.u... |
0308092720c78b9d051ba70d638889434432e129061d482521d8c7d7fade0773 | Python | 12,197 | 289 | # %%
import os
import os, sys
from config import *
sys.path.append(where_am_i())
import wandb
import cv2
from skimage.metrics import structural_similarity as ssim
from models.models_system import MoDLReconstructor, UNetReconstructor
from models import alternating as altmodels
from pathlib import Path
import numpy as... |
c3a7f7ac65fb926a986aeb29dd0f246b90f10b91533adad702c94a9ed4541577 | Python | 12,197 | 290 | #%%
import os
import os, sys
from config import *
sys.path.append(where_am_i())
import wandb
import cv2
from skimage.metrics import structural_similarity as ssim
from models.models_system import MoDLReconstructor, UNetReconstructor
from models import alternating as altmodels
from pathlib import Path
import numpy as ... |
763dd7b443810a7c1f548b8fb8ac12fa4790c144386dbf9db4c94017ec28e6ab | Python | 12,202 | 371 | """
Discovery of importable raw recordings.
Scans a directory for recordings a lab format can read, without importing
them, so the import app can list candidates cheaply.
"""
from __future__ import annotations
from dataclasses import dataclass
import inspect
from pathlib import Path
from larvaworld.lib import reg
f... |
4a44760089cc87eaa9385833c4ea9aa3a94714b3559a0e780e6f18437a303c3c | Python | 12,204 | 387 | """Adapted from: https://github.com/facebookresearch/swav/blob/master/src/resnet50.py."""
import torch
from torch import nn
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
"""3x3 convolution with padding."""
return nn.Conv2d(
in_planes,
out_planes,
kernel_size=3,
... |
b82f1e8279783231c0a656a20db6bc563fb16a19cc840064773a01fc53367869 | Python | 12,204 | 288 | # Asteroid Impact (c) Media Neuroscience Lab, Rene Weber
# Authored by Nick Winters
#
# Asteroid Impact is licensed under a
# Creative Commons Attribution-ShareAlike 4.0 International License.
#
# You should have received a copy of the license along with this
# work. If not, see <http://creativecommons.org/licenses/b... |
244cca5aaf31eb2ab594c8a5075ae4f450e50524b85a49bdacd6b2d127d2a1f0 | Python | 12,207 | 328 | """
Containing anything realted to drug bank.
"""
from dataclasses import dataclass, field
from typing import List, Set, Dict, Tuple, Optional
import zipfile
import pickle
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import xml.etree.ElementTree
from tqdm import tqdm
class DrugDAL():
"""
Drug reader fr... |
d40396395c6b2bfbbf2c5094953993a303c35d8f7bfb8b5ed4f7ec567c9917df | Python | 12,207 | 320 | #!/usr/bin/env python3
"""
File: plot_df_per_column.py
Created: 2021/10/26
Last Changed: 2021/10/28
Author: M.Vochteloo
Copyright (C) 2020 University Medical Center Groningen.
A copy of the BSD 3-Clause "New" or "Revised" License can be found in the
LICENSE file in the root directory of this sourc... |
55e3d8106386dd0df31e9341a2bd2b23599b73ec7ffce372d4642eaca6aad36b | Python | 12,208 | 342 | import math
import os
import re
import subprocess
from dataclasses import dataclass
from typing import Optional
import psutil
from codecarbon.core.units import Power
from codecarbon.core.util import SLURM_JOB_ID
from codecarbon.external.hardware import B_TO_GB, BaseHardware
from codecarbon.external.logger import logg... |
d8f66cbdf3fe0ab77056f649ce1a40d16d530001056f2f66b660e86807e26128 | Python | 12,208 | 291 | import glob
import math
import os
import random
import blobfile as bf
import numpy as np
from PIL import Image
from mpi4py import MPI
from torch.utils.data import DataLoader, Dataset
def load_data(cfg):
"""
For a dataset, create a generator over (images, kwargs) pairs.
Each images is an NCHW float tenso... |
569f1eb01a2ea2f41661cd839a0e8f3fce636fe11e72d307abe2a0d69bbbed43 | Python | 12,216 | 486 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import cv2
import scipy
import numpy as np
from scipy.spatial import Delaunay
from scipy.spatial.distance import pdist
__author__ = ['Nico Curti']
__email__ = ['nico.curti2@unibo.it']
__all__ = [
'imfill',
'get_perilesion_mask',
'extract_triangulation',
'_triang... |
92372915e0a74882246d6cdb8195430af44aefff878fbeaf13c5e13f1a7a8cb7 | Python | 12,220 | 319 | import re
import warnings
import numpy as np
from copy import deepcopy
"""
The Cigar class is try to parse cigar string and achieve fast indexing.
We define three kinds of positions of an aligned read:
1. reference position: The position based on the reference. Normally, start or end without any suffix is r... |
b824b0b4f0a5158f7a803072bc7e86753592bba7aa77e5ffbcbd47be3a3238af | Python | 12,220 | 297 | """b5 R50-1a: no package attaches an UNDECLARED private field to a Trace.
Backends, capture, validation, viz, and I/O all reach in and write private
attributes onto the Trace (``trace._mlx_op_captures = ...``,
``setattr(trace, "_validation_replay_status", ...)``). Most of those names
appear in NO authority: not ``Trac... |
bd10cf9ada47607afdf953c5ac8e7b418a97cfb7da551bf1bf59d70c6cbb3fcf | Python | 12,222 | 301 | # -*- coding: utf-8 -*-
"""
Created on Thu May 7 15:57:21 2020
@author: Caterina Brighi
"""
#%% Set environmental variables
import numpy as np
import SimpleITK as sitk
import os
#%% Obtain an image intensity range - useful for windowing
def get_img_intensity_range(image):
'''Prints t... |
ece6567890751430a8e4bacf3827d2fe7ccd49928ac9172347e587593e279aad | Python | 12,227 | 306 | """Pre-release field registrar: sprint-gated fields under a frozen tlspec.
VERSION DISCIPLINE (persistence-schema seam): no active schema change ships
under the CURRENT ``tlspec_version``. A new portable field therefore lands in
its record's ``FIELD_POLICY`` declared ``FieldPolicy.DROP`` (non-persisting)
and is REGIST... |
7df9bad9032ffbdfb5bcb6ccb084ac843173f43052bdc15ed09508717c08f7a7 | Python | 12,231 | 223 | ##########################################################################
## ##
## Copyright (c) 2019 Philipp Lösel. All rights reserved. ##
## ##
## This file is par... |
e2d8d491ef9cbad7421b614345ea0979f27253ff357ec5565aaa38fc235a40ff | Python | 12,240 | 377 | """TensorFlow backend derived-gradient preview tests."""
from __future__ import annotations
from typing import Any
import numpy as np
import pytest
from conftest import tensorflow_backend_modules
import torchlens as tl
from torchlens.backends import BackendUnsupportedError
from torchlens.backends.tf import GradOpti... |
14aad83f7c7e7d3b87608f905f3e5bbb6e5c19979ff26c985f5745cb6c322e40 | Python | 12,242 | 317 | #!/usr/bin/env python3
"""
figshare_5450293 (Vicchietti et al. / Pineda et al.) — CAR + 5D Reprocessing
Cohort:
59 AD + 7 MCI + 102 HC = 168 subjects.
Format heterogeneity ("preprocessing asymmetry"):
- HC subjects: single .mat file `<id>fir.mat` with var `segmenty`,
shape (22, 12288), 128 Hz, microvolt scale... |
b6abd4e0f54c3ca222d01555ecfbcdd1ecfcd22e51a6fd68d752d89c353305b1 | Python | 12,242 | 1 | import matplotlib
import matplotlib.pylab as plt
from matplotlib.ticker import AutoMinorLocator
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import numpy as np
import seaborn as sns
import glob
import pandas as pd
from matplotlib.axes import Axes
from matplotlib.figure import Figure
import os
sns.set(st... |
7d3bd5fabda2a07bc49828976a5b7861a15104c3909ea197110c7e74cefd14ad | Python | 12,243 | 328 | #!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
"""
Test objects and function in tfep.utils.geometry.
"""
# ======================================================... |
ac860f806f1dcf8f6d2d59289cdfb3717329c40dc47567e53689ff1783df9755 | Python | 12,245 | 375 | # MIT License
# Copyright (c) 2018 Adrian Wolny (https://github.com/wolny/pytorch-3dunet)
# 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 t... |
1a97c4388f64f59260737af2212084914425c4560b485e686b336b7a7e960bb9 | Python | 12,254 | 352 | """Regression tests for r18h introspection.py + hashing.py hardening.
Covers the round-18 A1 findings in the introspect/hash group:
* H5 -- ``dir()`` cached by ``type(item)`` dropped per-instance tensors on a
second same-typed object (order-dependent capture gap).
* M6 -- ``make_short_barcode_from_input`` untyped `... |
7ede044452a80cc0004265baed0ddb992669b27bffc85677aa5c1a8dda3894ed | Python | 12,256 | 336 | import fnmatch
import json
import logging
from abc import ABC, abstractmethod
from collections import defaultdict
import numpy as np
from matplotlib import pyplot
from matplotlib.backends.backend_pdf import PdfPages
from sklearn import linear_model
from .cromwell_metadata import CromwellMetadata, convert_type_np_to_p... |
7514c4c39f62b9b9e7ee9c0aa29914d45447045414e6b0ac6544557a8cb9fc56 | Python | 12,257 | 323 | """
Populates widgets around the trace_display plot
SimplyFire - Customizable analysis of electrophysiology data
Copyright (C) 2022 Megumi Mori
This program comes with ABSOLUTELY NO WARRANTY
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as pu... |
e5edee97c16aeadf53e69b1514c61ffd15712b1de3a42386b17bce97cb398f8d | Python | 12,261 | 306 | import logging
from typing import (
Any,
NamedTuple,
TYPE_CHECKING,
)
from uuid import UUID
from sqlalchemy import (
select,
sql,
true,
update,
)
from galaxy import (
exceptions,
model,
)
from galaxy.managers.context import ProvidesUserContext
from galaxy.model import (
Dynamic... |
15123a5ee5f9760b4c3dd28f7da0ee6f7b9ac9a0c164ac928e0ce9b67fab578c | Python | 12,262 | 287 | """Visualize segmentation performance"""
from os.path import join as opj
import io
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image, ImageDraw, ImageFont
from scripts.utils.metrics import dice
class SegmentationOverlayVisualizer():
"""
Visualizes the original image, ground truth and p... |
26260d4107d0573fd2b8c66d816543dc17c81c95354c4a024715a47caa8c9f04 | Python | 12,266 | 321 | import pathlib
import numpy as np
import scipy.io
import fractions
import itertools
import tqdm
import os
# Local dependencies
import model_builder
import data_generator
import basics
def load_weights(model, output_dir):
print('=== Loading model weights ------------------------------------------')
weights... |
642011f488af5391c8ae32206779c2a5a7e82814408cc529f140e4ae1b2bb0d8 | Python | 12,269 | 289 | """Span registry, region, session engine tests (torchnative W1.1-W1.3).
Includes the ONE-profiler-door dependency test the megaplan row mandates:
a second ``torch.profiler.profile`` construction site or a second grad_fn
node-hook stack anywhere in the package is RED.
"""
from __future__ import annotations
import ast... |
f2ac09a54d7dbd957dd50f52e32376fae1fdecec2134973ad9759ab3e7c5d178 | Python | 12,273 | 263 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Define a class to import, preprocess and epoch the data saved by eyelink.
@author: Florent Meyniel
"""
import re
import pandas as pd
import numpy as np
import os
import copy
from scipy import signal
import matplotlib.pyplot as plt
class pupil:
def __init__(self,... |
982e7d953790cf6c7206e94eccbd68540dbbb9f600eb5e5a110587d87f87ebfd | Python | 12,281 | 318 | import os,re,glob,copy
import pandas as pd
import numpy as np
from rdkit import Chem
from rdkit.Chem import AllChem
from torch_geometric.data import InMemoryDataset
from torch_geometric.utils import add_self_loops
from tqdm import tqdm
import sqlite3
import torch.utils.data
from torch_geometric.data import Da... |
f238f06da026ac9fddb9c32122d882192b2ab90c13f3e9d25650328262851fba | Python | 12,281 | 415 | """A directed acyclic graph of reusable components."""
from collections import deque
from threading import Event
from kombu.common import ignore_errors
from kombu.utils.encoding import bytes_to_str
from kombu.utils.imports import symbol_by_name
from .utils.graph import DependencyGraph, GraphFormatter
from .utils.imp... |
24625a8455ed70579d626e79d8dbd0bfdf2efe539e485d0e0874ce44701a97c3 | Python | 12,284 | 308 | # Copyright (c) 2021 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... |
b011ab330f0d154f561c7995c4704fbd2f50e84e60877606d03d776a1255de7e | Python | 12,289 | 385 | import numpy as np
from impose.geometry import shapes
def test_getstate_circle():
shp = shapes.Circle(x=11, y=10, r=8, point_um=.25)
assert shp.__getstate__()["x"] == 11
assert shp.__getstate__()["y"] == 10
assert shp.__getstate__()["r"] == 8
assert shp.__getstate__()["point_um"] == 0.25
def te... |
1365fb23d99eb23775b16125902fdd9e1cc3417fb3a4ff7bd550f3e090cddadd | Python | 12,292 | 323 | """
generate view imange from CAD files
"""
import os.path, shutil, os, sys
import glob, stat
#import zmq
import json
import multiprocessing
import subprocess
from collections import OrderedDict
_debug = True
from input_parameters import *
regenerating_images = testing
using_threading = not testing # False, can hel... |
946001d87d5db8b18bd7dae7eb96fa86cf313f7d84bdfb340212224cb7979b52 | Python | 12,298 | 268 | import numpy
from voxcell import VoxelData
from parcellation_project.analyses import flatmaps as fm_analyses
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from parcellation_project.split import decide_split as splt
from parcellation_project.split.reversal_detector import reversal_det... |
18355cf636ea8137d4608f9775774228d5fd2ef741002adf8d04f0f39b35be81 | Python | 12,301 | 223 | # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
from __future__ import annotations
import math
from contextlib import ExitStack
from pathlib import Path
import numpy as np
import torch
from ultralytics.utils import LOGGER
from .base import BaseBackend
class HailoBackend(BaseBackend):
"""H... |
91fb27ec803349897d1b77b8bdaf67dc45495e152c1656d0b679f051b814a03c | Python | 12,301 | 397 | """Click customizations for Celery."""
import inspect
import json
import numbers
from collections import OrderedDict
from functools import update_wrapper
from pprint import pformat
from typing import Any
import click
from click import Context, ParamType
from kombu.exceptions import OperationalError
from kombu.utils.ob... |
f9ddc6e81146f0958b22c59256619ca7378fe44e9a59ce0d3467b9de44bee5b6 | Python | 12,303 | 326 | #!/usr/bin/env python3
"""
Diagnostic P — 5-cohort expansion with LEMON as 5th HC cohort.
Goal: tighten the Dx N Quad_LDA LOCO precision by adding an independent
5th HC cohort (MPI LEMON, n=215 after EEG filtering). Rerun the canonical
AD-vs-HC tool configuration (15 ap+topo+conn_alpha features, quadratic
expansion, F... |
cb9578a9a699f463be8add7ef045da201c0ecfa050d9d04b7ba3333918c72e9a | Python | 12,306 | 295 | """
05: Aperiodic Component Fitting
===============================
Choosing and using different modes for fitting the aperiodic component.
"""
###################################################################################################
# Import the model object
from specparam import SpectralModel
# Import f... |
02b1378f70755de3f9aa3bbd7a88e372053c89d2409fe7986443f0c81c7ad6c5 | Python | 12,310 | 413 | """Backend helpers using array-api-compat for NumPy/PyTorch support."""
from array_api_compat import (
array_namespace as get_namespace,
device as xpd,
is_numpy_array,
is_numpy_namespace,
is_torch_array,
)
from array_api_extra import atleast_nd
import numpy as np
from sklearn.covariance import (
... |
be50fb1d4e7255e1175171f1daa210b36275ae0cb7cf9e1220a0b6745f425f08 | Python | 12,310 | 292 | #!/usr/bin/env python
import os
import argparse
import json
from functools import partial
import numpy as np
from scipy import ndimage,signal
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
from imfun import ofreg, multiscale, fseq, core, ui
from imfun.ofreg import imgreg, stackreg,... |
6ea055f1023fd1a7e926789a3c0c5adaa6bca0b102194584a70eb3a332c4f1d1 | Python | 12,312 | 335 | """Logit-lens 5.x slice handling + streaming prediction extractor (A03).
Two fixes pinned here:
* transformers 5.x causal LMs project only the last ``logits_to_keep``
positions through the head, so the captured ``logits`` facet is
sequence-sliced; lens validation now compares the reconstruction's exact
suffix i... |
41921b0cc24122d8086ab5d6a87a85f466b4b4b41314c25339d622f1ad42cac3 | Python | 12,315 | 335 | """Universe registry gates: printed cardinalities, drift lockstep, adequacy plants.
Compo memo row 0.2. The registry is the closure object (D1): every universe
prints its count and fails on unexplained drift; adequacy plants prove each
``planted`` derivation catches a member the weaker derivation misses (the
error-con... |
d7f054b1ad92f1fb1aace29a597922d949ea81feb5166ed9a6a97e0f71fb570c | Python | 12,315 | 332 | from __future__ import annotations
from typing import NamedTuple, Optional
import grpc
import bream4.legacy.device_interfaces.devices.minion as legacy_minion
from bream4.device_interfaces.devices.base_device import BaseDeviceInterface
Temperature = NamedTuple("Temperature", [("current_temp", float), ("desired_temp"... |
45fd39aae7a3e229ad7eb4458402b4aa5236c489aa56e08a90070e80332a9936 | Python | 12,318 | 235 | from typing import List
import torch
import torch.nn.functional as F
from models.basic import DeepLearningModel
from strategies.basic import MultiSiteLearningStrategy
class OWM(MultiSiteLearningStrategy):
name: str = 'owm'
def __init__(self, model: DeepLearningModel, config: dict, alpha=1.0, a_lambda=0.1, ... |
6e16b5d7c21e09bf1447ed101556b8714e688d64612916b8c39e71fabcfb37d2 | Python | 12,319 | 314 | """Monitor for history audit table changes.
Detects history changes via PostgreSQL LISTEN/NOTIFY (instant) or by polling
the history_audit table (SQLite fallback). Dispatches SSE events to connected
users via Kombu control tasks.
Only active when ``enable_sse_updates`` is True in the Galaxy config.
"""
import loggin... |
a298259412646e4e8f4512bea635fe3e18f2d57d5b2cf2edcff9a5e7c3ee160b | Python | 12,319 | 326 | """Lowered-counterfactual ADMISSION-GATE matrix (mikit D11, pre-signed).
Per-cell equality: the eager-DIRECT edit and the fused-LOWERED add must
agree below the eager-vs-SDPA noise floor, across gpt2-class (fused Conv1D)
and Llama-class (GQA -- the expanded-v path) R0 families, both lowering
kinds, plus the refusal ro... |
ee645dbb23ede147c90433c32707be7b2b20e7a2108def9ef569a1ad02cd7e85 | Python | 12,322 | 360 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import atexit
import copy
import queue
import threading
import time
import cv2
import slowfast.utils.logging as logging
from slowfast.visualization.utils import TaskInfo
logger = logging.get_logger(__name__)
class VideoM... |
21c70dd4115547de3d3b4345aa677ef6521bdb645028cde66812cfcce615553b | Python | 12,325 | 284 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import matplotlib.pylab as py
import pandas as pd
import numpy as np
import json
import IPython
import os
import glob
import string
WAVE_TYPES = ['spindle', 'SWA']#, 'delta', 'theta', 'alpha', 'beta']
PROFILE_TYPES = ['counts', 'percent']
ylabels = {'spin... |
79f80c6c91a9e491b7c55a6a914bad9ddd54286adc9358c4c2876dc1176f2256 | Python | 12,326 | 271 | import json
import numpy as np
import os, sys
import random
from collections import Counter
from sklearn import preprocessing
from sklearn.metrics import f1_score
from sklearn.metrics import confusion_matrix
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn_utils
import torch.nn.functional as F
from t... |
c2ede53cf01b17ba1606e51bfbc2a86a51a234cd53d4ccfff68639d7604a8396 | Python | 12,327 | 328 | """
===============================================================================
Online Artifact Detection with Riemannian Potato Field
===============================================================================
Example of Riemannian Potato Field (RPF) [1]_ applied on EEG time-series to
detect artifacts in onli... |
2dab619474ec001772d156d02fed11225cbf59934b97c7cc602d496d85911bf3 | Python | 12,331 | 319 | """Child-process and fork capture-guard behavior for the global toggle state.
Split from ``test_global_state_inventory.py`` (r7 R43-F1 file-size ratchet
paydown): the guard family that proves a non-rank child process is refused
typed (``child_process_capture_unsupported``), spoofed/inherited rank
evidence never readmi... |
b2b5b2ba676a98190dac283af951c411de1c928ca59c655f93fd8f3f71edc16f | Python | 12,331 | 263 | '''
CRF train loop.
- no marginals
- no train metrics
'''
import json
import pickle
from typing import Dict, List, Tuple
import os
from torch.utils.data import DataLoader
from .models import LSTMCNNCRF, SimpleLSTMCNNCRF, SelfAttentionCRF
from .utils import add_dict_to_writer, PrecomputedCSVForOverlapCRFDataset
#from .... |
47bbfce998ab4af96bd67fdd5ee0074048d808863c7861c863d5d8daa5439573 | Python | 12,334 | 347 | #!/usr/bin/env python3
import multiprocessing
import regex as re
import logging
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from MarkovModels import common
from MarkovModels.BeattieModel import BeattieModel
from MarkovModels.ClosedOpenModel import ClosedOpenModel
from M... |
e47bb3b4159ddea2cc08750645fc5fc00ef951dbddaba4d22ce4abf7e15c4977 | Python | 12,334 | 277 | """
Bifurcation analysis of the Jansen-Rit Model
============================================
Jansen-Rit model, a neural mass model of the dynamic interactions between 3 populations:
- pyramidal cells (PCs)
- excitatory interneurons (EINs)
- inhibitory interneurons (IINs)
Originally, the model has been d... |
ac1d2939cfda41b144df3c12f0669e2e636f4f14fb0aa85c2c1a2152119baaac | Python | 12,337 | 321 | import collections
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, List, Tuple
import xarray as xr
from tqdm import tqdm
from hobj.benchmarks.common import (
compare_msen,
simulate_sessions,
summarize_bootstrap_score,
)
from hobj.benchmarks.generalization.estimator impo... |
204ea6a4d1c8476275d7499ad837f6321306a520189725a471afee5546d4cfad | Python | 12,339 | 447 | """Tests for ergonomic TorchLens input coercion."""
from __future__ import annotations
from typing import Any
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens._input_coerce import _coerce_input
class TokenOutput:
"""Simple tokenizer return object with HuggingFace-style inp... |
b34330ceaebf7d3422ab1e2f1335dcd32e00ce304133018ffb8a6ef6df2e2c85 | Python | 12,339 | 328 | from __future__ import annotations
import math
from typing import Any
from PySide6.QtCore import QPointF, QRectF, Qt
from PySide6.QtGui import QBrush, QColor, QPainter, QPen, QTransform
from PySide6.QtWidgets import (
QGraphicsItem,
QGraphicsEllipseItem,
QGraphicsLineItem,
QGraphicsRectItem,
QGrap... |
1ddd84868f788e51af05f40977d1a2c9565618932cb3096c0e69aba540d338a5 | Python | 12,342 | 356 | import numpy as np
from neurogym.core import TrialEnv
from neurogym.utils import spaces
from neurogym.utils.ngym_random import TruncExp
class PerceptualDecisionMaking(TrialEnv):
"""Perceptual decision-making task.
Two-alternative forced choice task where the agent integrates noisy stimuli
to decide whic... |
8fcaef03bb6eb17f50a6acacbaae13de4fb91da07be733dce8b6a0ee228cb2ea | Python | 12,343 | 322 | # ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Written by Bin Xiao (leoxiaobin@gmail.com)
# Modified by Bowen Cheng (bcheng9@illinois.edu)
# ------------------------------------------------------------------------------
fro... |
b159c3fd6803a7a02683cc628e4d43790dda0e7e44f42df1505cc9313e4ab472 | Python | 12,343 | 383 | from __future__ import annotations
import pytest
from pybind11_tests import ConstructorStats, UserType
from pybind11_tests import stl as m
def test_vector(doc):
"""std::vector <-> list"""
lst = m.cast_vector()
assert lst == [1]
lst.append(2)
assert m.load_vector(lst)
assert m.load_vector(tup... |
8cc6ce8ab691d998118b452727dbd0fb183655a0429c7f76355cf6e96029339f | Python | 12,345 | 354 | from prodict import Prodict
import json
import matplotlib.pyplot as plt
import numpy as np
import sys
import torch
import utils
from typing import Dict, List, Optional
from matplotlib import colors
import matplotlib.lines as mlines
from matplotlib.cm import ScalarMappable
sys.path.extend(["src", "../TDNODE"])
import... |
f460935816a2f169500338f5810bb95186e8d010e38c2755c7f4dc0b385b860e | Python | 12,346 | 344 | """Compare standard FA4 and SwapAB decode with num_splits=0 under CUDA graphs.
A shape fails if FLASH_ATTENTION_SM100_BACKEND=swapab falls back to the standard kernel.
Each graph traverses whole cycles of the same seeded input pool (>=512 MiB KV,
>=2 copies). Latency is the minimum of interleaved round medians, in us... |
9b29915db3d902c45c9d2ddb71e27e3893cd69146467737073a08cb4801c53d5 | Python | 12,349 | 322 | """Fast pose network for alpha pose"""
# pylint: disable=arguments-differ
import math
import os
import mxnet as mx
from mxnet import initializer
from mxnet.gluon import nn
from mxnet.gluon.block import HybridBlock
from .utils import ZeroUniform, _try_load_parameters
__all__ = ['get_alphapose', 'alpha_pose_resnet101_... |
a76185fa3bc05cbd1c1dbc5c882c056f4b0ffc698db0e3cac3299c3ea7497f83 | Python | 12,350 | 314 | #!/usr/bin/env python3
"""
5D Eval — Diagnostic F scale-up: compute IAF/DFA/KOP/LZc extras
for BrainLat, ds006036, ds003775 (cortical-dementia + normative cohorts).
Reuses each cohort's existing pipeline for loading + preprocessing, then
swaps the 5D compute step for the extras library.
Output:
outputs/brainlat_ext... |
824010d6899ab9ed50a0ac803c05719aac7d6ccac8b74a0787502c1827cdc37d | Python | 12,352 | 372 | import numpy as np
from absl.testing import parameterized
from numpy.lib.stride_tricks import as_strided
from keras.src import layers
from keras.src import testing
def _same_padding(input_size, pool_size, stride):
if input_size % stride == 0:
return max(pool_size - stride, 0)
else:
return max... |
e5c6aed35c7b12bf123534b05579832290712d4e8f4bfd8d9ee9341890335565 | Python | 12,354 | 327 | """Curated catalog of beginner-facing behavioral scenarios.
The registry ships 57 experiment configurations whose IDs (``PItest_off_OSN``,
``RvsS_on_q15``, ``noMB_patch_grid``) mean nothing to a newcomer, and whose
durations range from 30 seconds to 24 hours. This module hand-picks a small set,
gives each a human titl... |
74694535aa59c6555d5e51b68b5624a0b689fd7d594c7ba51989dd5458169e4f | Python | 12,355 | 308 | from typing import Any, List, Optional, Tuple, Union
import matplotlib.pyplot as plt
import numpy as np
from anndata import AnnData
from kneed import KneeLocator
from scipy.sparse import csr_matrix, isspmatrix, spmatrix
from sklearn.decomposition import PCA
from sklearn.metrics import silhouette_score
from ...configu... |
cde971a281b9d758cf0eb6da54d5f4266b3bee5fac5368ec57058a4bd7d4ab9b | Python | 12,357 | 294 | # predicting metal binding sites
import pandas as pd
import pathlib
import torch
import os
import urllib
#from base.find_proteins_sitesV3 import load_potential_sites
from itertools import permutations
import numpy as np
import time
from base.extract_potential_sites import new_load_potential_sites
from base.postprocess... |
7c91cbbdc4e63612e834bb41dd406037ba4c0ff80b4da8c30cf29e3dcdaabf9f | Python | 12,358 | 281 | import torch
import torch.nn as nn
import torch.nn.functional as F
from time import ctime
from torch_geometric.nn import GCNConv,GATConv,GINConv
import numpy as np
from torch_geometric.utils import add_self_loops
from torch_geometric.nn import PairNorm,LayerNorm
class EMGNN(torch.nn.Module):
def __init_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.