sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
82ff846ac36ea3e6e30844a47a900994f0f89406ca95a31348bc91f80c6fab0a | Python | 1,443 | 51 | from __future__ import annotations
import pytest
prefect = pytest.importorskip("prefect")
from ase.build import bulk
from quacc import flow, job
from quacc.recipes.emt.core import relax_job
from quacc.recipes.emt.slabs import bulk_to_slabs_flow # skipcq: PYL-C0412
@pytest.mark.parametrize("job_decorators", [None... |
fa2aa84935bc7a6012a91a7106ee2ad89afc14a152acec722ef922503fa7b945 | Python | 1,443 | 47 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, BaselSlurmEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
DIR = os.path.dirname(os.path.abspath(__file__))
BENCHMARKS_DI... |
127adf2a628ccd601daa0fc989c2c238ff58f79531ef31e1e0e6efa8bb50723a | Python | 1,444 | 50 | """Execute exactly this copy of pip, within a different environment.
This file is named as it is, to ensure that this module can't be imported via
an import statement.
"""
# /!\ This version compatibility check section must be Python 2 compatible. /!\
import sys
# Copied from setup.py
PYTHON_REQUIRES = (3, 7)
def... |
15ddbb70822eeb8ba447064cdd59710107671c5a4d957a6124561afcf06dc708 | Python | 1,444 | 55 | import fsspec, requests
import json
import os
from bs4 import BeautifulSoup
from skimage import io
from napari_bil_data_viewer.dataset_info import get_datasets
location_of_dir = os.path.dirname(os.path.abspath(__file__))
print(location_of_dir)
dataset_info = get_datasets()
dataset_imginfo = {}
for dset in dataset_i... |
6524cb3f58b89d6d704b34fdb4eefee518ca194dca41d046ad5cd334dc092d5b | Python | 1,445 | 48 | # -*- coding: utf-8 -*-
import shutil
from pathlib import Path
import os
def assert_dirs_empty(parser, args, required):
"""
Assert that all directories exist are empty.
If dirs exist and not empty, and --force is used, delete dirs.
Parameters
----------
parser: argparse.ArgumentParser object... |
7f172fed220136c91206ee765ef6159661267cc131cdf082258e95888146b213 | Python | 1,445 | 46 | from typing import Dict, Union, Tuple
import numpy as np
from ..base_transform import EEGTransform
class Reshape(EEGTransform):
r'''
Reshape the input EEG representation to the specified shape.
.. code-block:: python
from torcheeg import transforms
t = transforms.Reshape((6, 1... |
610fd32ff194704633e130af138fef040e0c446d0a001196325184b6328dd112 | Python | 1,446 | 40 | import click
import os.path as op
import pandas as pd
from glob import glob
from tqdm import tqdm
# from https://github.com/translationalneuromodeling/tapas/blob/7371f120610a25b233f9da6e51013cb077d7879b/PhysIO/code/model/tapas_physio_create_retroicor_regressors.m
NAMES = [
# modality, cos/sin, order
'cardiac_c... |
116da6f94ec780aed366c91aab125ee8bbe0ea9ac23fa1485a28ca3817f1c485 | Python | 1,447 | 51 | import subprocess
class CameraSearch:
def __init__(self):
self.cameraList = []
def detect(self):
command='''
for dev in `find /dev -maxdepth 1 -iname 'video*' -printf "%f\n"`; do
v4l2-ctl --list-formats --device /dev/$dev | grep -qE '\[[0-9]\]' && echo $dev `cat /sys/class/vid... |
5a1b533332a4b4ec4a6292591a0d95617e415802179625de70ef2f7e589a2228 | Python | 1,447 | 25 | """PASS C: same selected segments as PASS B, but keep the POSTSYNAPTIC partner id."""
import pyarrow as pa, pyarrow.ipc, numpy as np, pandas as pd, os, time
ROOT=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CLS=['gaba','acetylcholine','glutamate','serotonin','octopamine','dopamine','neither']
PC=['nts_11... |
b99e8a634a286ec652984c36ed6598881adcf2cb0d6d9c1fac5e0276f22552fa | Python | 1,447 | 56 | import torch
import torchvision.transforms.functional as F
import numpy as np
import yaml
from pathlib import Path
IGNORE_LABEL = 255
STATS = {
"vit": {"mean": (0.5, 0.5, 0.5), "std": (0.5, 0.5, 0.5)},
"deit": {"mean": (0.485, 0.456, 0.406), "std": (0.229, 0.224, 0.225)},
}
def seg_to_rgb(seg, colors):
i... |
04d10ffa26a5299df51cce3e7c78b6f9f854ec6688ca1fb343bc2e2f6ef270bd | Python | 1,448 | 43 | # Copyright 2019 Murdoch Children's Research Institute,
# Melbourne, Australia
#
# 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 req... |
2bbe8864f3560fdc7aa29c822dfb003f16e6991884f4736742881afc1af88809 | Python | 1,449 | 40 | from setuptools import setup, find_packages
# Read the long description from README.md
with open("README.md", "r", encoding="utf-8") as fh:
long_description="Annotatability, a method to identify meaningful patterns in single-cell genomics data through annotation-trainability analysis, which estimates annotation co... |
3e0228e077a8574d3873d203031a5c0c7ba490d39788dc14f6d2c47fb950b705 | Python | 1,449 | 39 | from mahotas.features.texture import haralick_labels
import GLCMFeatures
import ExtendGaborFeatures
import FirstOrderFeatures
def TextureExtraction(Rowcoord,Colcoord,dicomImageBrain,dicomImageRaw,Distances,Gaborkernel_bank):
windowsize=8
subImageBrain = dicomImageBrain[Rowcoord - 4:Rowcoord + 4, Col... |
4eb6d8497b53a071f3ba8a0414c1a2febae62f62ae6e6b5f9e90a45020278d54 | Python | 1,449 | 35 | import os
import scipy.io as sio
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../..')
from src.Mice.utils import *
from src.Mice.src_nn.main import NOEMRFNetMT ,NOEMRFNetNOE
def main(args):
acquired_data_mt, acquired_data_noe = preprocessing(args)
params = define_model_path(args... |
a03f5e5a03e84c63b9ebdad2ee177990b473ad3e0817df30aa1bc14bc941ce95 | Python | 1,449 | 44 | from pathlib import Path
import numpy as np
import numpy.testing as npt
import astrovascpy.report_writer as test_module
from astrovascpy.report_reader import BloodflowReport
TEST_DIR = Path(__file__).resolve().parent
TEST_DATA_DIR = TEST_DIR / "data/reporting/export"
if not TEST_DATA_DIR.exists():
TEST_DATA_DIR... |
63e9b366791057886a115f27e2c3488e894b6c02240e72fd9ce5c301b5c8624f | Python | 1,450 | 51 | import sys
from pybioshell.core.data.io import Pdb
from pybioshell.simulations.movers import LigandTossingMover_core_data_basic_Vec3_t as LigandTossingMoverVec3
from pybioshell.simulations.systems import AtomRange
from pybioshell.simulations.systems import ResidueChain_core_data_basic_Vec3_t as ResidueChainVec3
from p... |
d578e8333bb59e2d7fb091f2a8fb924dff045d245a874b60705495e8bbb10220 | Python | 1,452 | 36 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2024 Clinic for Diagnositic and Interventional Radiology, University Hospital Bonn, Germany
#
# 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 ... |
ab0c66d263ccbcb12af3d46eb5e68a60f19772866faa9b51d19c1f1cf1aa1a37 | Python | 1,454 | 59 | # Node-group asset "Velocity" (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
from... |
fc3c5b3f17415f1fe10998e7f927c6af305a4924e820b23cd3bb496fae213cd6 | Python | 1,454 | 48 | # 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... |
027668a9379f4635313a63b1259676c458a247ee269a35666874466967ecb912 | Python | 1,455 | 40 | import matplotlib as mpl
import pandas as pd
import numpy as np
import seaborn as sns
from constants import CLASS_COLUMNS, ABSOLUTE_ERROR, SQUARED_ERROR, NUM_MISCLASS
__all__ = [
'compute_errors',
'init_mpl'
]
def compute_errors(predictions, ground_truths):
results_df = pd.DataFrame(columns=['figure_id'... |
9a0b77b1ac530414c1b92b4f8c1a193d3e000e88291f1eed7d924fc470490814 | Python | 1,455 | 48 | import os
from setuptools import setup, find_packages
PACKAGES = find_packages()
# Get version and release info, which is all stored in shablona/version.py
ver_file = os.path.join('scanphyslog2bids', 'version.py')
with open(ver_file) as f:
exec(f.read())
# Long description will go up on the pypi page
with open('... |
9b5588f5e3c407a57451c1943e5e2f4a27fd24e7fd7ddabc5c9e02cdc14eae53 | Python | 1,455 | 70 | # flake8: noqa
# There's no way to ignore "F401 '...' imported but unused" warnings in this
# module, but to preserve other warnings. So, don't check this module at all.
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use thi... |
b7ebc5540f680031150ed3a4a1cb1a3f080b6b485295a3652deed002425acd46 | Python | 1,455 | 45 | import torch
from torch.nn import Linear as Lin, Sequential as Seq
import torch.nn.functional as F
from torch import nn
class PAE(torch.nn.Module):
def __init__(self, input_dim, dropout=0.2):
super(PAE, self).__init__()
hidden=128
self.parser =nn.Sequential(
nn.Linear(input_... |
ee24b0f739314441bb28181d660abd43b826964950d6286c160f94fca1718ade | Python | 1,455 | 46 | """Engbert & Kliegl 5-sample velocity estimator.
EK 2003 eq. 1:
v_n = (x[n+2] + x[n+1] - x[n-1] - x[n-2]) / (6 * dt)
Applied independently to x and y. The first two and last two samples have
no defined velocity under this kernel; we set them to NaN so callers can
exclude them from threshold and event detection wi... |
61e9989dfc0277bd0ffef20b2e960ec1e6b453e0f01b89cc8bcf2a687683ae3d | Python | 1,456 | 46 | import argparse
import os
import shutil
from subprocess import Popen, PIPE, DEVNULL, STDOUT
DEBUG = 1
def execute_command(cmd):
"""Wrapper for executing CLI commands.
Args:
cmd (str): Command to execute.
"""
if (DEBUG):
print(cmd)
process = Popen(cmd, shell=True, stdout=PIPE)
... |
7defe73d90a42127a545287dd3621ee91259c627f8f70c365dceb165d38fbed2 | Python | 1,456 | 44 | """Testing for the python bindings of the C++ flagser library."""
import os
from numpy.testing import assert_almost_equal
from pyflagser import load_unweighted_flag, load_weighted_flag, \
flagser_count_unweighted, flagser_count_weighted
cell_count = {
'a.flag': [5, 7, 1],
'b.flag': [4, 6, 3],
'c.fl... |
ee7658aae11131438d3c0f187ab5574d2045852364b2187e4ef7fc549cfb0359 | Python | 1,456 | 58 | import math
from collections import defaultdict
def p_log_p(p, base = 2):
assert 0 <= p and p <= 1
if 0 < p and p < 1:
return p*math.log(p, base)
else:
return 0
def create_prob_list(list_hash):
"""
Gives a list of probabilities [p_1, ..., p_n] with p_1 + ... + p_... |
2278eacc8c80dd8c0ef4a6fdf475200d649e751426a0d06612c3629044ebf181 | Python | 1,457 | 27 | import os
import sys
import importlib
# Designed to work with Python >=3.6, using only the standard library
# Get path this this folder
SCRIPT_FILE_PATH = os.path.realpath(__file__)
SCRIPT_FOLDER_PATH = os.path.dirname(SCRIPT_FILE_PATH)
apt_track_wrapper_path = os.path.join(SCRIPT_FOLDER_PATH, 'apt-track-wrapper')
#... |
5160edaa7bcb6b5f7c0afadef2bd151bdd9a33abde9f779f7f0f6c4119ef807d | Python | 1,457 | 41 | """
Wrapper for epi_reg command
"""
import fsl.utils.assertions as asrt
from fsl.wrappers import wrapperutils as wutils
@wutils.fileOrImage('epi', 't1', 't1brain', 'fmap', 'fmapmag', 'fmapmagbrain', 'gdc', 'wmseg', 'weight', outprefix='out')
@wutils.fileOrArray('init', 'out.mat')
@wutils.fslwrapper
def epi_reg(**kwa... |
721aef0e0f9aaf447989436dc75f412caf8417810c6b5216e2f2231d131ee85b | Python | 1,457 | 43 | import shutil
import os
import pandas as pd
from os.path import join
from PyUtilities.read_write import read_tsv_from_df, write_tsv_from_df, read_json_to_dict, write_json_from_dict
fname_ds_desc = 'dataset_description.json'
fname_readme = 'README'
fname_participants_json = 'participants.json'
def copy_templates_to_... |
f38ef1adb8806c0174644676e73341816e576469600724e0594ea1bddec7a888 | Python | 1,457 | 47 | from unittest import TestCase
from pyseg.globals import *
from pyseg.vtk_ext import vtkFilterSurfBorderAlgorithm
import vtk
__author__ = 'martinez'
class TestVtkFilterSurfBorderAlgorithm(TestCase):
def test_Execute(self):
# Read reference
reader = vtk.vtkXMLPolyDataReader()
reader.SetFi... |
4a54affe8671e25b87729e13c0b4b1e237c11cb0ff978c8467bc42f6d9255738 | Python | 1,458 | 32 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2024 Clinic for Diagnositic and Interventional Radiology, University Hospital Bonn, Germany
#
# 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 ... |
6a2990ce82614fe354a17437c76a0253daf080b63de5db6eaa4d8dc3d2eea8ca | Python | 1,458 | 45 | """
Optuna example showcasing the new Optuna Terminator feature.
In this example, we utilize the Optuna Terminator for hyperparameter
optimization on a RandomForestClassifier using the wine dataset.
The Terminator automatically stops the optimization process based
on the potential for further improvement.
To run this... |
c9b55082c7b893534cb8708267d6f0fb2354dfee14416b134d1ea41dc18cf633 | Python | 1,458 | 46 | from collections.abc import Iterable
from typing import cast
import pytest
import torch
from elasticai.creator.nn.fixed_point.precomputed.identity_step_function import (
IdentityStepFunction,
)
from tests.tensor_test_case import assertTensorEqual
def generate_step_lut(min: float, max: float, steps: int) -> torc... |
067c069c02d456613d884fb4e570542b796d7e0f59b99ccd47c0e4ae071ca94e | Python | 1,459 | 61 | import math
import meep as mp
from meep import mpb
# 2d system: triangular lattice of air holes in dielectric
# This structure has a complete band gap (i.e. a gap in both TE and TM
# simultaneously) for a hole radius of 0.45a and a dielectric constant of
# 12. (See, e.g., the book "Photonic Crystals" by Joannopoulo... |
2feb93d2c20870491ecbc4a767175b61ea9b9bcf6e39cd0a97879af192cdea5c | Python | 1,459 | 38 | import sys
def reformat_header(header):
parts = header.split('; ')
transcript_id = parts[0].split()[0][1:]
length_info = parts[1].split('=')[1].split(',')[0]
orf_info = parts[1].split(',')[2]
coords = parts[3].split('=')[1]
strand = "+" # evigene does not have strand info... |
40100254558f53b1e150bb6edbc13d9a58537fbc3185f2c24761e76b86a870ae | Python | 1,459 | 43 | from dataclasses import dataclass
import torch
@dataclass(frozen=True)
class FixedPointConfigV2:
"""
This class behaves almost like a frozen instance,
but calculates and sets minimum_as_rational_tensor and maximum_as_rational_tensor just once in __post__init__.
After the __post_init__ the __setattr__... |
611f34f5a5f50ac447d9eefa5c233eb93857e74904abebf628f51be1583266a0 | Python | 1,459 | 50 | """Utilities for working with lists."""
from __future__ import annotations
def merge_list_params(
*lists: list[str], removal_prefix: str | None = "#", case_insensitive: bool = True
) -> list[str]:
"""
Merge list string parameters, taking list2 as the priority. Also removes any entries
that start with... |
85dbe802d64ac9e36e829f07b04be2b98b0f8c94dc765a0ec49de21050d0678f | Python | 1,459 | 59 | import time
import warnings
import autograd.numpy as np
from autograd import deriv, grad
from autograd.builtins import list as make_list
def timefunction(f):
t = time.time()
f()
return time.time() - t
def assert_linear_time(f):
t = timefunction(lambda: f(1))
t10 = timefunction(lambda: f(10))
... |
a2e4b98eb3b669acb5bb5a58549c1bec77fdd249a9b5faa22d97f18af5f62e8e | Python | 1,459 | 30 | import sys
ref=[sys.argv[1]]
rfh=open(sys.argv[1]+'_summary.txt','w')
rfh.write('Sample\tSequenced_Read-pair\tMapped_Read-pair\tNonclonal_Read-pair\tIntra_less\tIntra_more\tInter\tCpG_met\tCHG_met\tCHH_met\n')
for fn in ref:
fn=fn.split()[-1].split('/')[-1]
dfh1=open(fn+'_bismark_SE_report.txt','r')
... |
01bf44d577fb392350595e57928cbe34cb9fe8bf8aa4a89efd7677d00651c6fa | Python | 1,460 | 47 | import os
import re
from setuptools import setup, find_packages
# Read version from _version.py
version_file = os.path.join(os.path.dirname(__file__), 'topaz', '_version.py')
with open(version_file) as f:
version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M).group(1)
# Read requirements from ... |
80207529b17e8072bc91720132b2964ed446f452d8461211655d5b95867704a1 | Python | 1,460 | 50 | import os.path
SEED = 42
def set_track(new_track="sub01_1"):
global track
global VID_FOLDER
global FMRI_FOLDER
global OUTPUT_FOLDER
global ROIs
track = new_track
data_clip = "sub03"
OUTPUT_FOLDER = f"{PROJECT_FOLDER}output/"
FMRI_FOLDER = f"{DATA_FOLDER}fmridata/{track}/"
VI... |
0130236516a28b0c0b77f86fb9c8ea448e5baa79d95542b150f90655a2e7362b | Python | 1,461 | 48 | #!/usr/bin/env python
from __future__ import print_function
import random
import time
from progress.bar import (Bar, ChargingBar, FillingSquaresBar,
FillingCirclesBar, IncrementalBar, PixelBar,
ShadyBar)
from progress.spinner import (Spinner, PieSpinner, MoonSpinne... |
fee2e73d3e11cb1ac5d5fda1b2eb221f3dfa24dd32b329e1df8926eddd4c291d | Python | 1,461 | 51 | # 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... |
4c3fb97812fc28efdf0c1523d8f14260ad560fd133fdc6b7b3ca76fde720c00b | Python | 1,462 | 46 | # 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... |
18ed64b179e0a28e7db6792faf2e99b4c8528533e1833a4a22531209632fa17b | Python | 1,463 | 48 | # 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... |
1a7d19bd29b7174f27c85e6df1435057cf642010dc02a955862898f7ab3417ef | Python | 1,463 | 53 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Report making
=============
This script will generate basic HTML reports with:
- raw data info
- PSD
- Covariances matrices (noise and normal)
- projections if any
- ICA ?
- Alignment of trans- files
- evoked for auditory localisers
- c... |
20089121d8f9ba2ddb70f23ef4cb1859b870063732ed14e80a9b401f0dc7b9d5 | Python | 1,463 | 43 | import pytest
from elasticai.creator.file_generation.savable import Path
from elasticai.creator.nn.sequential.design import Sequential
from elasticai.creator.vhdl.auto_wire_protocols.port_definitions import create_port
from elasticai.creator.vhdl.design.design import Design
from elasticai.creator.vhdl.design.ports imp... |
b5b41334a2652ab1e281ac0b37f9b06bd77c3d9fa07fc05769863384d9cf5381 | Python | 1,463 | 46 | # basic imports
import pandas as pd
import sys
import numpy as np
import pandas as pd
import scanpy as sc
# add `Tangram` to path
import tangram as tg
sc_file_path = sys.argv[1]
spatial_file_path = sys.argv[2]
celltype_key = sys.argv[3]
output_file_path = sys.argv[4]
ad_sc = sc.read_h5ad(sc_file_path)
ad_sp = sc.rea... |
1e6ca509df522fd0f131a891801f2bc849237b7c8f635b8d3bdd618c30840518 | Python | 1,464 | 55 | # 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... |
3337b901c7f946be1dce7c84c2d2275ba2a8af7b1a48cf574b8b7740db5e1421 | Python | 1,464 | 52 | from __future__ import annotations
import pytest
prefect = pytest.importorskip("prefect")
from ase.build import bulk
from quacc import flow, job
from quacc.recipes.emt.core import relax_job
from quacc.recipes.emt.slabs import bulk_to_slabs_flow # skipcq: PYL-C0412
@pytest.mark.parametrize("job_decorators", [None... |
7db06edf6727778d22fced7d4bb80683493418054dc713a1a612fb52d40d9565 | Python | 1,464 | 28 | import os
import sys
import importlib
# Designed to work with Python >=3.6, using only the standard library
# Get path this this folder
SCRIPT_FILE_PATH = os.path.realpath(__file__)
SCRIPT_FOLDER_PATH = os.path.dirname(SCRIPT_FILE_PATH)
apt_track_wrapper_path = os.path.join(SCRIPT_FOLDER_PATH, 'apt-track-wrapper')
#... |
f9b46784dbc537af2c746741d1028bad420550feb35b56c4f3a332e50983e4ac | Python | 1,464 | 30 | import pandas as pd
from sklearn.ensemble import RandomForestRegressor
import numpy as np
# Load your dataset
data = pd.read_csv(r'H:\data\data.csv',dtype={"tg":float, "ldl": float},encoding='ISO-8859-1',low_memory=False)
# Identify features with missing values
features_with_missing_values = ['plt','wbc','rbc','h... |
016e4090b8a5d6772b4d753082363e2cd09b1a9033ac527d4f55ff99ad7dfe8b | Python | 1,465 | 49 | from dataclasses import dataclass
from typing import Iterator
@dataclass
class Port:
inputs: dict[str, str]
outputs: dict[str, str]
def signals(self) -> Iterator[str]:
for s, type in self.inputs.items():
yield f"signal {s} : in {type}"
for s, type in self.outputs.items():
... |
0d75711da6707bc587fbd1eca8c180eab582ce54d2a0b068e53a95986d7178ed | Python | 1,465 | 47 | from typing import List, Tuple
import numpy as np
import torch
import yacs.config
def ricap(
batch: Tuple[torch.Tensor, torch.Tensor], beta: float
) -> Tuple[torch.Tensor, Tuple[List[torch.Tensor], List[float]]]:
data, targets = batch
image_h, image_w = data.shape[2:]
ratio = np.random.beta(beta, bet... |
32927d466f6e2927b5e229e3232577dc67b12febf52cfd9272aad7b41769996a | Python | 1,465 | 80 | """
Global variables for the package
"""
__author__ = 'martinez'
import numpy as np
MAX_FLOAT = np.finfo(float).max
MB_SEG = 'mb_seg'
MB_LBL = 1
MB_IN_LBL = 2
MB_OUT_LBL = 3
STR_H = 1
STR_T = 2
STR_C = 3
STR_F = 4
STR_CELL = 'cell'
STR_STR = 'str'
STR_LEN = 'len'
STR_PEN = 'pen'
STR_PENT = 'pent'
STR_PEN_LEN... |
7970d9a2a7f1c9e9881e153dc666cf35d97e051509b16ae28b74f356d1b2cb86 | Python | 1,465 | 57 | import theano
from pylearn2.utils import serial
import sys
from pylearn2.gui.patch_viewer import make_viewer
from pylearn2.space import VectorSpace
from pylearn2.config import yaml_parse
import numpy as np
import ipdb
# TODO, only works for CIFAR10 for now
grid_shape = None
repeat_samples = 1
num_samples = 5
_, mo... |
9046ea277b38440210b91c58835a3ba929054c1e3f863248a64650fdf862f45f | Python | 1,465 | 43 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 12 18:40:11 2021
@author: u0139894
"""
import os
import sys
import cobra
import logging
logging.getLogger("cobra").setLevel(logging.ERROR)
from pathlib import Path
path = Path.cwd()
base_path = "/".join(os.path.abspath(__file__).split("/")[:-2])
sys.path.insert(0, base... |
545470cc9310ac8a075212ddfc6dea5e2177996a44c4340fe3058e5202a4cc84 | Python | 1,466 | 47 | def signed_to_unsigned(n, num_bits):
"""
Helper function to do 2s complement conversion on returned error codes.
Returns function as a string representation in hexadecimal form.
"""
return hex(n & ((1 << num_bits) -1))
hresult_error_lookup = {
'E_ACCESSDENIED':"0x80070005",
'E_INVAL... |
0e3801dcfce7ed5df3a18fa06c9815722b7fdd3a1fc0dc8c6fb3e399d2084b4d | Python | 1,467 | 38 | import os
import torch
# Borrowed from e3nn @ 0.4.0:
# https://github.com/e3nn/e3nn/blob/0.4.0/e3nn/o3/_wigner.py#L10
# _Jd is a list of tensors of shape (2l+1, 2l+1)
_Jd = torch.load(os.path.join(os.path.dirname(__file__), "Jd.pt"))
# Borrowed from e3nn @ 0.4.0:
# https://github.com/e3nn/e3nn/blob/0.4.0... |
6dba77eae50ed8e13a27d52cd6954ffcba2505a9a0dd096affc832fb7c99296a | Python | 1,467 | 46 | """
Optuna example using warm starting CMA-ES.
In this example, we first optimize a *biased* sphere function as a source task.
With the result of optimization, we optimize a sphere function as a target task
by using warm starting CMA-ES.
"""
import optuna
# 2-dimensional box-constrained sphere function
# The optim... |
f07b3e8fcecd2b6e303b4c5eb7fef67d88e11c2773601a13f2cafb1031b3f45a | Python | 1,467 | 42 | import argparse
from dataset import TCGA_Project_Dataset
import dataset as module_dataset
import datasets_manager as module_datasets_manager
from parse_config import ConfigParser
from utils import set_random_seed
SEED = 1126
set_random_seed(SEED)
def main(config):
# Produce train / test indices
Datasets = {}
... |
34bc52bffc30b94e766514f6d287a5de53a3fe7309fb40241caa1a45a8e4d159 | Python | 1,468 | 48 | from typing import Optional
from torch import nn, Tensor
import torch
import torch.nn.functional as F
from ._functional import label_smoothed_nll_loss
__all__ = ["SoftCrossEntropyLoss"]
class SoftCrossEntropyLoss(nn.Module):
__constants__ = ["reduction", "ignore_index", "smooth_factor"]
def __init__(
... |
6569586c61e36fe4304691f7490f6ebb19ff5fe1768a1710092e47b53fd6f659 | Python | 1,468 | 51 | import sys
def disable_importlib_metadata_finder(metadata):
"""
Ensure importlib_metadata doesn't provide older, incompatible
Distributions.
Workaround for #3102.
"""
try:
import importlib_metadata
except ImportError:
return
except AttributeError:
from .warning... |
6c379444b37245e3fb5ce67a2a8174f1f3cc4ac7d98f2477c71dedaf992bcfbf | Python | 1,468 | 45 | from typing import cast
import pytest
import torch
from elasticai.creator.nn.float.round_to_float import RoundToFloat
from tests.tensor_test_case import assertTensorEqual
def roundToFloat(
inputs: float | list[float] | torch.Tensor, mantissa_bits: int, exponent_bits: int
) -> torch.Tensor:
if not isinstance... |
63765d898310a5fffcbc35e6b3a0a50e9713928be0904732d55d19f205546d66 | Python | 1,469 | 46 | from psychopy import gui, visual, event, core
from os import system, path, chdir
from random import shuffle
my_path = path.abspath(path.dirname(__file__))
chdir(my_path)
def quit():
win0.close()
core.quit()
event.globalKeys.add(key='escape', func=quit, name='shutdown')
ID_box = gui.Dlg(title = 'Subject iden... |
cdfa7df70afc063b4a350713a6a77b40b6b95c915f3a1ae93a67648f82f3402b | Python | 1,469 | 27 | import os
import sys
import importlib
# Designed to work with Python >=3.6, using only the standard library
# Get path this this folder
SCRIPT_FILE_PATH = os.path.realpath(__file__)
SCRIPT_FOLDER_PATH = os.path.dirname(SCRIPT_FILE_PATH)
apt_track_wrapper_path = os.path.join(SCRIPT_FOLDER_PATH, 'apt-track-wrapper')
#... |
3dab710ff879aa7922c849d4c642f6b1cad9e1fac59d3ca7ec47d8cede473989 | Python | 1,470 | 49 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
from lab.environments import LocalEnvironment, MaiaEnvironment
import common_setup
from common_setup import IssueConfig, IssueExperiment
from relativescatter import RelativeScatterPlotReport
DIR = os.path.dirnam... |
558dfb2413dc2f6f2b2b10e10f1508214148ba492ffdf7765b14d77023f90e31 | Python | 1,470 | 59 | import tensorflow as tf
physical_devices = tf.config.list_physical_devices('GPU')
import janggu
import pandas as pd
import numpy as np
import sonnet as snt
from tqdm import tqdm
import time
import os
import glob
import json
import functools
import tensorflow_probability as tfp
import h5py
import sys
train = pd.read_c... |
ff10d58788cee3200aed3f7578d3378e37e235c477180b4dc1bcc925e11fa583 | Python | 1,470 | 45 | from analyse import *
import os
import subprocess
from jinja2 import Template
proteins = initProteins()
proteins.to_csv('proteins.csv')
submission = Template("""#!/bin/bash
#PBS -W group_list=ku_10001 -A ku_10001
#PBS -N {{name}}
### Only send mail when job is aborted or terminates abnormally
#PBS -m n
### Number of ... |
b10bc43014077fb345027e0a5cc980883e409fb8fcc4f96cb9dfb3e24df75db5 | Python | 1,471 | 44 | # 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... |
b994459e9e7fce2b16ae421939080481a7adc29ed2c571e8cd462abc6365a72c | Python | 1,471 | 48 | from pathlib import Path
import elasticai.experiment_framework.remote_control as eaixp_rc
import pytest
from elasticai.experiment_framework.synthesis import CachedVivadoSynthesis
from elasticai.creator.testing import HWTester
from elasticai.creator_plugins.xnor_popcount_mac.tests._common import (
CNNBuilder,
... |
da3c4096ac501bd4fa7a2ea168bf1cddc0299b817ef0cd7ecf7b9621a46e222d | Python | 1,471 | 42 | # 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... |
7cbb03780bd0d6800194dac70c052580fbdde151983b67b0f08f426e3869df1d | Python | 1,472 | 48 | """Launch a registry entry as its own subprocess (its existing GUI)."""
import subprocess
import sys
from regtools import get_project_root
def repo_root():
return get_project_root()
def python_exe():
exe = sys.executable
if exe.endswith("pythonw.exe"):
return exe[: -len("pythonw.e... |
b01e7415eb8f47d4efeaf919aa167600a59bead54731cfa44d1a075f9287b3ec | Python | 1,472 | 34 | ## This script, takes all artifact masks and fused them to get overall artifact mask. Which will be best to subtract from binary-mask and produce artifact free mask for nonartifact_tiler.py
import numpy as np
import os
from PIL import Image
import time
def mask_fuse(listofmasks):
shape = Image.open(os.pat... |
cbe8729166dfdacb51f05228daeabc7c3f88872ae77041f4c5646dcf14d61a93 | Python | 1,473 | 38 | """Implementation of CLI convert command."""
import numpy as np
from treem import Node, SWC, Morph
def convert(args):
"""Converts input data to compliant SWC format."""
vprint = print if not args.quiet else lambda *a, **k: None
nam = 'I', 'T', 'X', 'Y', 'Z', 'R', 'P'
fmt = 'i', 'i', 'f', 'f', 'f', '... |
d8d3cb9a62368d5a74cd40e7d41ca14eeda24eb7651c12bfb4af64458029549f | Python | 1,473 | 38 | """Implementation of CLI convert command."""
import numpy as np
from treem import SWC, Morph, Node
def convert(args):
"""Converts input data to compliant SWC format."""
vprint = print if not args.quiet else lambda *a, **k: None
nam = 'I', 'T', 'X', 'Y', 'Z', 'R', 'P'
fmt = 'i', 'i', 'f', 'f', 'f', '... |
54b2fb2ef9ed284f2ac5d854744261728b45cd4b0e488f0d352d38df150b29ec | Python | 1,474 | 41 | """Metadata generation logic for source distributions.
"""
import os
from pip._vendor.pyproject_hooks import BuildBackendHookCaller
from pip._internal.build_env import BuildEnvironment
from pip._internal.exceptions import (
InstallationSubprocessError,
MetadataGenerationFailed,
)
from pip._internal.utils.sub... |
7382a9bfa3d2bcc43146c7536c312ecba6d409c21d790455c643d541fa45c31a | Python | 1,474 | 62 | # import netket as nk
import jax.numpy as jnp
from functools import partial
import jax
import numpy as np
from src.utils import real_dtype
from netket.jax import tree_ravel
def smooth_svd(Aobj, b, acond=1e-4, rcond=1e-2, exponent=6, x0=None):
"""
Solve the linear system using Singular Value Decomposition.
... |
858b82397377eac2f4704074d33e8cecc02c84fcc58f38df359596dc3d0087c2 | Python | 1,474 | 37 | from utils.api import get_filters_result_from_project
from utils.logger import setup_logging
from utils.util import set_random_seed
from pathlib import Path
from preprocess.external_project import External_Project
SEED = 1126
set_random_seed(SEED)
if __name__ == '__main__':
setup_logging(Path('./Logs/Tests/'))
... |
f1fffacf4b597d5122e0120f11c75efff664a87e1bf3cc9d010d10e984c9794a | Python | 1,474 | 48 | import sys
from PyQt5 import QtWidgets
from PyQt5 import QtCore
import colorbar_ruler
import crossbar_cells
class CrossbarPanel(QtWidgets.QWidget):
def __init__(self):
super(CrossbarPanel, self).__init__()
self.initUI()
def initUI(self):
self.setWindowTitle("Crossbar"... |
ff795549c29135c0947f7e0206ca3e55397dc717fc1d008c8160b32fef0315e9 | Python | 1,474 | 45 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
'''
Compute reliability bootstrap of a given set of sims
Author(s): Daniela Egas S.
Last update: 10.2023
'''
import os
import sys
import numpy as np
sys.path.append('/gpfs/bbp.cscs.ch/home/egassant/reliability_... |
0f649bf1842f1a12588ada0231c0fe7be3c36227418b6553e7d1a175e71ee581 | Python | 1,475 | 57 | from enum import Enum, auto
class NodeFeature(Enum):
'''Enum class for the different node features to be used.'''
# basic
ATOMIC_NUMBER = auto()
ELECTRONEGATIVITY = auto()
COVALENT_RADIUS = auto()
# bound hydrogen
BOUND_HYDROGEN_COUNT = auto()
# bond order totals
WIBERG_BOND_OR... |
dc6b994395ef7ee794271916fd170eff325de3ed45005697ca4fb152cfe9e2bc | Python | 1,475 | 52 | """Utilities for working with lists."""
from __future__ import annotations
def merge_list_params(
*lists: list[str] | None,
removal_prefix: str | None = "#",
case_insensitive: bool = True,
) -> list[str]:
"""
Merge list string parameters, taking list2 as the priority. Also removes any entries
... |
2035b52a7e8fe9ceb860cee6f3185d74470323a9123b79321f1f635ca7b83eef | Python | 1,476 | 47 | # 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... |
5c602ac050d3362e037ea678b493a6b3a923b8729635da4b26c026101b5b2b69 | Python | 1,476 | 57 | import yaml
from pathlib import Path
from pydantic import BaseModel
from typing import Any
class ArrayAction(BaseModel, extra='forbid'):
name: str
method: str | None
# The name of an optional reference signal
ref_name: str | None = None
alt_ref_names: list[str] | None = None
kwargs: dic... |
7d5bd2893cebdbe44ce88b235a38f87e468eb433a00e1516bfab00f7d768e024 | Python | 1,476 | 53 | """Main entry point."""
from __future__ import annotations
from pip._vendor.platformdirs import PlatformDirs, __version__
PROPS = (
"user_data_dir",
"user_config_dir",
"user_cache_dir",
"user_state_dir",
"user_log_dir",
"user_documents_dir",
"user_downloads_dir",
"user_pictures_dir",
... |
958f49b458485a12ddb6f6646fd7d0893c11b781d2017683f31a56d844d2671c | Python | 1,476 | 27 | # Copyright (c) 2020, Ko Sugawara
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and t... |
f7d7b97af8e14da9dd642f4e143d82929fc59cec3b8fd3458cc1376cc0947528 | Python | 1,476 | 47 | # 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... |
1cfa3d9e2b754260df4c15f3e6176735752fe5d013f6bbf88e9da61afa778e69 | Python | 1,477 | 44 | import ecdsa
from ecdsa.util import sigencode_der, sigdecode_der
from hashlib import sha256
# https://zhuanlan.zhihu.com/p/100736598
class Request:
# byte order BigEndian
# x = int.from_bytes(xy[:32], byteorder='big')
# y = int.from_bytes(xy[32:], byteorder='big')
# signing_key.curve.generator.curve... |
e0b18758e4dbf9d850762ffeb8fd0b48917fc2403ebeb2848a423a2df7f3e95b | Python | 1,477 | 44 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 28 07:34:49 2022
@author: heavens
"""
from matplotlib import pyplot as plt
import numpy as np
def auc_plot(TP,FP,axs,add_head = False,print_AUC = True,**kwargs):
c = kwargs['color'] if 'color' in kwargs.keys() else None
label = kwargs['labe... |
a47e314bfc335e59f3f20cb8602ae11d6c57858e6d4ee545a5e26e1340906aad | Python | 1,478 | 44 | import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from neuro_py.plotting.figure_helpers import set_size
import seaborn as sns
def plot_data_progress(summary_table):
fig = plt.figure(figsize=set_size('thesis', fraction=1.5, subplots=(1, 1)))
fig.subplots_adjust(bottom=0.2)
... |
7d9dda6f79b1b27e67e7bd560be080105ea9b6895cc13d9dedb3e6365614be9e | Python | 1,479 | 49 | from __future__ import annotations
import gzip
from io import StringIO
from pathlib import Path
import numpy as np
import pytest
from ase.io.espresso import read_espresso_ph
from quacc.calculators.espresso.espresso import EspressoTemplate
RUN_PATH = Path(__file__).parent / "test_runs"
def _read_gzip_file(file_pat... |
e66cffeb2e478926456751cb10a510d65c4a2493f6f7fe7433c7d46e13eec5d6 | Python | 1,479 | 36 | import numpy as np
from trajectories_utils import strength_preserving_rand_sa_trajectory
from utils import pickle_dump
from joblib import Parallel, delayed
from joblib.externals.loky import set_loky_pickler
set_loky_pickler('pickle')
import os
os.environ['OPENBLAS_NUM_THREADS'] = "1"
os.environ['MKL_NUM_THREADS'] = ... |
62f9ca8e5656094026b4bc52dd394f08198d8ea8e0c2f6dfe3792719ae4e91cf | Python | 1,480 | 37 | from wonambi import Dataset
from wonambi.trans import math, select, frequency, apply_baseline
from numpy import array
from numpy.testing import assert_array_almost_equal
from .paths import micromed_file
def test_baseline():
d = Dataset(micromed_file)
ev = [ev['start'] for ev in d.read_markers()][1]
chan... |
844011591021ae53a3c4874a3e6c6ae0cd36a7467add4eebf43e3cd80c2308ee | Python | 1,480 | 44 | """Defined constants for definitions, def labels, and expanded labels."""
from enum import IntEnum
# The whitespace that may not begin or end a column name or a top-level sidecar key (specification 3.2.10):
# blank, tab, line feed and carriage return only. A non-breaking space is not padding.
NAME_WHITESPACE = " \t\n... |
bd17ad53a0b0461143ebc8ac4476769c69ec01ca370ceb97c34107fdd27d68f0 | Python | 1,480 | 54 | import cocotb as ctb
import pytest
from cocotb.clock import Clock
from cocotb.triggers import RisingEdge
from cocotb.types import LogicArray
from elasticai.creator.testing import CocotbTestFixture, eai_testbench
pytest_plugins = "elasticai.creator.testing.cocotb_pytest"
@ctb.test()
@eai_testbench
async def check_sl... |
d4c906106f5607bba3f2d8158aa1f8b0afb41c19f6283a8e26e45709e7d52ea0 | Python | 1,480 | 57 | # Librairies
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 collections import OrderedDict
from joblib import load
import argparse
from setting import *
from utils import *
from loader import *
# Arguments
argParser = a... |
fc7b0ab3c86ea6b80d595ee65497e4d90c957d8c06618b2f19e52e50fc24210a | Python | 1,480 | 54 | #!/bin/env python3
"""
Example script to test ithildin.simdata
"""
import ithildin as ith
import matplotlib.pyplot as plt
# stem = "results/pdl2D_6"
# stem = "results/PDL_12"
stem = "results/PDS_21"
# stem = "results/edu_95"
# stem = "results/phase_68"
# read simulation results
simdata = ith.SimData.from_stem(stem)
... |
a1b38a8c9e42ac1e5eec94be08a6803e026aaa385cff893550b1d7ecb29105de | Python | 1,481 | 54 | from typing import Dict, List, Union
from ..base_transform import LabelTransform
class FixCategory(LabelTransform):
r'''
Returns a pre-set label for all samples, usually used to supplement the dataset with new categories.
.. code-block:: python
from torcheeg import transforms
t = trans... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.