sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
480efe59feb082eaaa665ce8a89c0fe0aab51d862a7ec59ec6494b9f717eff13
Python
6,312
148
"""Unit tests for the PubMed download verification in src/createcompendia/publications.py. verify_pubmed_downloads() is the backstop that makes it safe to carry PubMed files forward from a previous run (see docs/RunningBabel.md, "Preloading PubMed downloads"): it MD5s every downloaded `.gz` against the `.md5` file Pub...
98bd572facc4016e3ab9b1de3fb20082eb9ea5d0af1e825aafdcb8b4d3e25afe
Python
6,313
118
# Generate events files for task-narratives # This script reads raw behavior data files from d_beh for task-narratives, extracts time stamps and design information, and stores them in new *events.tsv files accompanying BOLD files. # For more information, please see README.md and the associated paper (Jung et al., 202...
2ef3e3b9d2119a6d3b735ff6343b8c46eb8c79c5fbc030877bcf2c3067bcb901
Python
6,315
167
# ############################# # # Copyright (C) 2018 # Jennifer Dreiling (dreiling@gfz-potsdam.de) # # # ############################# import os # set os.environment variables to ensure that numerical computations # do not do multiprocessing !! Essential !! Do not change ! os.environ["MKL_NUM_THREADS"] = "1" os.en...
8591b8b6f5631cbf91a5c7956f784fd93d3da94d63da0ddb917043a5bb2fa598
Python
6,316
128
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, 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 of the License at # # http://w...
8e0a42e1ad2ba9007658da8fc0bd09dd53b53bc21d00b448ca705778c09c43d0
Python
6,316
103
import numpy as np from batchgenerators.utilities.file_and_folder_operations import * from nnunet_mednext.dataset_conversion.utils import generate_dataset_json from nnunet_mednext.paths import nnUNet_raw_data, preprocessing_output_dir from nnunet_mednext.utilities.file_conversions import convert_2d_image_to_nifti if _...
91f768fc735ebb77ce83102e811c59bf6aaccf9ec621e675d83950b96e913ab7
Python
6,316
199
# -*- coding: utf-8 -*- """ Created on Mon Oct 30 14:27:23 2023 @author: ingvieb """ from glob import glob import shutil import datetime import SimpleITK as sitk import numpy as np import nibabel as nib import json import os def createParameterMap(file, regType): with open(file, "r") as f: param_dict ...
a7bf480bee123e98310b50edd8768c94cafa5dbeda4c3d8d39666ffeb277af6a
Python
6,319
206
""" 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. """ import math import numpy as np import torch from scipy.special import binom from torch_geometric.nn.models.schnet import Gaussia...
fa8c94906240152bb0827b8a0053c5f4fa59f9d768f02d48bf61431b234f44a3
Python
6,319
205
# pylint: disable=too-many-locals """Tests for learning to rank.""" from types import ModuleType from typing import Any import numpy as np import pytest import xgboost as xgb from xgboost import testing as tm from .utils import Device def run_ranking_qid_df(impl: ModuleType, tree_method: str, device: Device) -> No...
7f2d0960e4b90adbc2e2423cded3cc28b81e7cc05ac4e590dd7635165aa3f7e9
Python
6,321
183
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- import o...
388a1511ce6fc6ecec02114c014630a87a450d29d92d8cd256afbf15093182b2
Python
6,322
222
"""Test l5pc example""" import json import os import sys from contextlib import contextmanager import bluepyopt from bluepyopt import ephys if sys.version_info[0] < 3: from StringIO import StringIO else: from io import StringIO import pytest L5PC_PATH = os.path.abspath( os.path.join(os.path.dirname(__...
142597235dc525da0ccd40ad025252914fa25a0f758b97002388f03dca2b079b
Python
6,328
201
#!/usr/bin/env python """ MetaWIBELE: extract_uniprot_pfam module Extract the Pfam and UniProt mapping info Copyright (c) 2019 Harvard School of Public Health 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...
653cf711104060960789f9bad99945331a34bcc1647bdd9cf41868d152e7fdc9
Python
6,334
164
import torch from Bio.PDB import Selection from Bio.PDB.Residue import Residue from Bio.PDB.PDBParser import PDBParser from Bio.PDB.MMCIFParser import MMCIFParser from easydict import EasyDict from .constants import (AA, max_num_heavyatoms, restype_to_heavyatom_names, B...
eeb17ca8f0be26c74611bf1eb0f0504e72f9b6e878801eb2c12f777081843d0d
Python
6,334
205
"""Database models and session management.""" import logging import uuid from collections.abc import AsyncIterator from datetime import datetime from typing import TYPE_CHECKING, Annotated import sqlalchemy as sa from fastapi import Depends, Request from fastapi_users.db import SQLAlchemyBaseUserTableUUID, SQLAlchemy...
a4911461f9c11287efa7d73f8b367b97e1fe3fa70b7286e7864883f608bd67c1
Python
6,335
180
# Modified from https://github.com/open-mmlab/mmcv/blob/master/mmcv/video/optflow.py # noqa: E501 import cv2 import numpy as np import os def flowread(flow_path, quantize=False, concat_axis=0, *args, **kwargs): """Read an optical flow map. Args: flow_path (ndarray or str): Flow path. quantiz...
cefa64fa35ca6d7cf1d10211bd68778abd8f764d17ee5b1bfae0b7d26bc8bc95
Python
6,335
148
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/07b_collections.callbacks.ema.ipynb (unless otherwise specified). __all__ = ['EMACallback'] # Cell import logging from typing import Any, Dict from copy import deepcopy import pytorch_lightning as pl import torch import torch.nn as nn from pytorch_lightning.callbacks i...
17dec5105c4f975dcff1378bf6c17a6f098c74f899936225cbf00a8a8fffa4b4
Python
6,339
190
import pytest from CybORG import CybORG from CybORG.Simulator.Scenarios import EnterpriseScenarioGenerator from CybORG.Agents.SimpleAgents.ConstantAgent import SleepAgent """ Testing the implementation of the mission_phases functionality. Initially, step starts at -1 but allowed_subnets are filled as if mission_phas...
03f011f710d4f11b2f2751a753d3ddc40c8c716544b7924846a244d38f688bd0
Python
6,340
115
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, 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 of the License at # # http://w...
15f304c20b8dfe3f62e87bd606a3f0c86659022ee94d889bcec7d7e3b670387e
Python
6,343
187
import bdpy import numpy as np import pandas as pd import hdf5storage import os from itertools import combinations, product def load_parameters(param_file): """ Load converter parameters from a CSV file. """ return pd.read_csv(param_file) def load_brain_data(brain_dir, subjects_list): """ Loa...
72401534893629798214ed8a4cd226388501e7e173f1880a473d2859aea404c4
Python
6,346
215
""" Getting started with learning to rank ===================================== .. versionadded:: 2.0.0 This is a demonstration of using XGBoost for learning to rank tasks using the MSLR_10k_letor dataset. For more infomation about the dataset, please visit its `description page <https://www.microsoft.com/en-us/res...
e6842a22dbe78b3b61d2b3625fc6633e946ba899ee18dc329a57fbc043555dfc
Python
6,353
212
""" Experimental support for external memory ======================================== This is similar to the one in `quantile_data_iterator.py`, but for external memory instead of Quantile DMatrix. The feature is not ready for production use yet. .. versionadded:: 1.5.0 See :doc:`the tutorial </tutorials/exter...
5db2b772fc9933ca4283df8f32e5b350769ec35c66afb71b95e010629f5b29e6
Python
6,355
179
from typing import List, Tuple import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import build_conv_layer from torch import Tensor from mmseg.registry import MODELS class PatchTransformerEncoder(nn.Module): """the Patch Transformer Encoder. Args: in_channels (int): the...
447b5347fd08b2d165a6922e96ca35b30876ab41bcdc0c717eaf9fe45ecebaad
Python
6,356
203
from types import SimpleNamespace import numpy as np import pandas as pd from masscube.params import Params from masscube.raw_data_utils import ( MSData, McrawStore, Scan, load_mcraw, mcraw_matches_source, read_mcraw_manifest, save_mcraw, ) def _make_mcraw_data(): data = MSData() ...
e4d2619460d0eae243c7c57c7cb17d0e91dec330695d9c1ab7a39453685ba08a
Python
6,358
205
#!/usr/bin/env python """ MetaWIBELE: mspminer_msp_uniref_annotation module Assign UniRef annotation to MSPs Copyright (c) 2019 Harvard School of Public Health Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal i...
42ea6039e7740231244c36a1c004349a3dbb87fe144f4d9228324c7ef2ab702b
Python
6,364
186
# Modified from https://github.com/open-mmlab/mmcv/blob/master/mmcv/fileio/file_client.py # noqa: E501 from abc import ABCMeta, abstractmethod class BaseStorageBackend(metaclass=ABCMeta): """Abstract class of storage backends. All backends need to implement two apis: ``get()`` and ``get_text()``. ``get(...
385ecd8359dfaef6be3b5bac2e3632ff06f154feabbaef06aae9fa004d7abb5f
Python
6,365
164
import argparse import os import json import torch from fengshen_inner.models.llama.configuration_llama import LlamaConfig as FengshenConfig from fengshen_inner.models.llama.modeling_llama import LlamaForCausalLM as FengshenLlama from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer from fengshen_inner...
d408c134fc599b05c4df2e6147585b9e158dc6a3645cc9bf2bf33a37b6b35e2a
Python
6,369
141
import torch import os import random import math import argparse from fengshen.data.fs_datasets.fs_datamodule import FSDataModule from fengshen.example.deepVAE.vae_pl_module import DeepVAEModule from pytorch_lightning import ( Trainer, loggers, ) from pytorch_lightning.callbacks import ModelCheckpoint, Learni...
1bfdd70db2695f233f43f7c862ac2db3a9ae34e76deeaaeb8bd93b0f15497e28
Python
6,371
143
import argparse import pickle import numpy as np import tensorflow as tf from tensorflow import keras import tsgm N_EPOCHS_DEFAULT = 10 BATCH_SIZE_DEFAULT = 256 LATENT_DIM_DEFAULT = 16 DEFAULT_GAN_ARCHITECTURE = "cgan_base_c4_l1" DEFAULT_VAE_ARCHITECTURE = "vae_conv5" def _gen_dataset(X, y, batch_size=BATCH_SIZE_D...
61ac96b11fec1df2dac0e68ac3db61f6071c9283cd5ef9c45eeabb5c04db5212
Python
6,372
153
""" Benchmark the 3 modes: 1. Static feature: AtomType 2. Marching Observers 3. Probability Density Flow """ import os, argparse, time, json import h5py as h5 import numpy as np import pytraj as pt from collections import OrderedDict import nearl import nearl.features, nearl.featurizer, nearl.io # from nearl.io ...
45bc3e0cb4050bf793d0f8c50116ad2e871b982633b9a664031ecb2d7fe597cd
Python
6,374
204
#!/usr/bin/env python """ MetaWIBELE: sum_to_protein_family_abundance module Sum over protein families based on reads mapped to gene catalog of nucleotide representatives Copyright (c) 2019 Harvard School of Public Health Permission is hereby granted, free of charge, to any person obtaining a copy of this software a...
5ca453d7bf9d1d3a436b292aa4b8a5b13d1d38899c7c3e370ce2ba29b5c2e7f6
Python
6,376
184
import base64 import logging import os from time import time import yaml from medperf.asset_management.gcp_utils import CCWorkloadID from medperf.entities.cube import Cube from medperf.entities.model import Model from medperf.entities.dataset import Dataset from medperf.entities.execution import Execution from medper...
3a7eebba22dc3139971b986f804da1f169948991a4d5374466b3322897152bb7
Python
6,379
179
from __future__ import annotations import os from medperf.entities.interface import Entity from medperf.entities.schemas import CertificateSchema from medperf.account_management import get_medperf_user_data from medperf import config from medperf.exceptions import MedperfException from medperf.utils import generate_tmp...
a25764f7f1b32b0b6d123956e64c0e5a10a9f244f26197c72e7197b30952f609
Python
6,379
170
import numpy as np import scipy.sparse import scipy.sparse.linalg try: import pyamg except ModuleNotFoundError: pyamg = None try: import cupy import cupyx.scipy.sparse import cupyx.scipy.sparse.linalg except ModuleNotFoundError: cupy = None cupyx = None try: import sparseqr except Mod...
d0ab0dd2741b1dfaf6ec60548022784feb4cef943e2788cee80394b9697fa142
Python
6,381
188
# -*- coding: utf-8 -*- from django import template from django.db.models import Count from ..models import Project from .common import is_string_type, natural_sort register = template.Library() @register.filter def get_stack(stacks, pos): """ Returns an image stack out of stacks. Which one is determined by ...
36d0a00fbfd7b948592a6cd2d5fe9cbfdd227deb1f30fd4cca1aeae89b339548
Python
6,384
162
"""Whole-session time-binned metrics. Some experiments score a continuous behavioral variable at a coarse cadence -- akinesia severity rated once every two minutes, say -- and ask how the photometry signal tracks it. That question needs the session reduced to one value per fixed time bin rather than to event-triggered...
d390ce152ac04d8ee66c6c6c2975be00cdc29cfff5eeb5aa165b5b196d982195
Python
6,385
180
import importlib import inspect import re import sys from itertools import compress from keras import backend as K import pytest if K.backend() != 'tensorflow': pytestmark = pytest.mark.skip modules = ['keras.layers', 'keras.models', 'keras', 'keras.backend', 'keras.engine', 'keras.wrappers...
50d2afa85796dec89cc90486fd373fd64b242a84f073cfcbc009655e6494f03b
Python
6,386
183
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. 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.o...
118a465321803b4dcbb8d702c39bbfd29f35f70a7c6af37a9c52afbc1e2869b8
Python
6,387
193
from typing import Dict, List, Optional, Tuple import torch from torch import nn, Tensor from torch_scatter import scatter_mean from oa_reactdiff.model import EGNN from oa_reactdiff.model.core import GatedMLP from oa_reactdiff.utils import ( get_subgraph_mask, get_n_frag_switch, get_mask_for_frag, get...
81abd48cb6cfae52116b7e2687b654a1c33439b66ab8110c02bd7a47721ae535
Python
6,393
249
#!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt from data.sequencing import data_import from data.sequencing import data_analysis # Plot settings plt.rcParams.update({'font.size': 20, 'svg.fonttype' : 'none', 'figure.figsize...
ae76c0a50d198b0d19565bd8bfc5d6663050de67fbf808152b0a9212818bd410
Python
6,395
184
import plotly.graph_objects as go import plotly.express as px import plotly.io as pio import pandas as pd import numpy as np import seaborn as sns from matplotlib.colors import to_hex from params import palette, nanfiller def figure_adjustments_rep(fig): for data in fig.data: data['mode'] = 'text' ...
db65e6ed09dce82cd09ad927bc149a5c18982592698ac9939f8b7144b5aa50ed
Python
6,396
159
""" simulator.py - main entry point to start the motion simulation - run this script (from iml-dl/.) with: python -u ./projects/motion-simulation/simulator.py --config_path path_to_config_file.yaml Note: A config file needs to be generated first. An example of a config file can be found under motion-simul...
17493ef390f3be4b6b0eb320cb88169faee06f03a3764e912de7507adfbd6b1c
Python
6,399
168
import os import sys import itertools import numpy as np import pandas as pd import torch from torch.autograd import Variable import bdpy # Adding the parent directory to sys.path for module imports sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) from NCC_content_loss.models impor...
95e3d1ed1c139cd2659525b8e67cf7be860d5faed5e4551b304b5e516853419c
Python
6,401
185
#!/usr/bin/env python # # Utility function to denoise images # # Copyright (c) 2015 Polytechnique Montreal <www.neuro.polymtl.ca> # License: see the file LICENSE import sys from time import time from typing import Sequence import numpy as np from spinalcordtoolbox.image import Image from spinalcordtoolbox.utils.fs i...
f264b848ea618cb42f045ec34cd06dc66ff6c81313d3ea2dc9a5c984053ce60f
Python
6,403
139
import logging import re from dataclasses import dataclass, field from pathlib import Path from typing import Optional import yaml logger = logging.getLogger(__name__) _instance: Optional["SynonymFilter"] = None def get_synonym_filter() -> "SynonymFilter": global _instance, logger if _instance is None: ...
856d64d71e44407401297b551884fb4cd1aba8082de0ff5fc60fac3dd42f094d
Python
6,405
174
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import logging import os import torch from hydra import compose from hydra.utils import instantiate from omegaconf import...
f0995adb86fc444621ead57fbb591eea9df7891b0d90bc75e9647627d02b12ca
Python
6,405
159
"""Integration-suite-local shared constants and helpers. Split out of ``conftest.py`` so the handful of integration test modules that need these symbols at import time (``test_integration_step2.py``, ``test_integration_dandi.py``) can import them directly via a package-relative import, instead of relying on the ambigu...
c24d23af327f196e633e20ac2a5410454b38596981ed33c81658808cf2dbeaff
Python
6,408
194
from medperf.exceptions import ExecutionError, CommunicationError from medperf import config import os import requests import semver from .docker_utils import volumes_to_cli_args as docker_volumes_to_cli_args import shlex from medperf.utils import run_command import logging def get_docker_image_hash_from_dockerhub(d...
40b9261dfe0e8fdb67acc0587b40d9927c0e9f529693cf943fd869ed754e1bb9
Python
6,413
221
"""Ortholog retrieval and donor tracking for v7+ databases. Provides methods for: - Finding orthologs from speciation events - Tracking closest donors for functional annotation - Filtering orthologs by taxonomic scope """ from typing import Dict, List, Optional, Set, Tuple from .db import EggnogDB from .tax_scope im...
195ce1a5efe9e784f44cf6a591b38963cb3c67eb793d805b10531bde43e8d072
Python
6,419
160
# tests/test_ordering.py """Tests that all paginated list endpoints return items newest-first (DESC).""" import time import pytest from conftest import make_room_address from zndraw_joblib.schemas import ( JobSummary, PaginatedResponse, TaskResponse, WorkerSummary, ) # ── Jobs ──────────────────────...
52dbaed86a67fa39eaa5ccabd1ec9faaa29e13c106664cf34553e3f48c601d28
Python
6,419
212
""" 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. """ import math from typing import Dict, Union import numpy as np import torch from scipy.special import binom from torch_geometric.nn.models.sc...
f729dafb76bdeb05381496233a97679f74802e6acc19b26c55645246885ca041
Python
6,420
157
# -*- coding: utf-8 -*- """ Created on Thu May 9 20:36:51 2024 @author: mbmad """ import numpy as np import pandas as pd import pyabf from patchanalysis.measures.measuretools import InvalidRecordingError, NoResultError from typing import Union class WorkerAttemptedDestructiveOverwrite(Exception): """ Raise ...
cfbdef93235b2b512b8776bba936bf8e334af7499d1517bdc5a071cdc9436006
Python
6,425
189
#-*- coding: utf-8 -*- # Some basic tools for data processing from numpy import nonzero, sign from scipy import stats from scipy.interpolate import interp1d from pylab import * from scipy import signal from scipy.fft import fft, ifft, fftshift from matplotlib.backends.backend_pdf import PdfPages import matplotlib.color...
254533aa260ce4bf160fbd1cebf3788cdafa1b3951462d719d6eed3ff1e5bc34
Python
6,427
138
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, 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 of the License at # # http://w...
c6ce64d9c9eda83ce489f10d5e5de7c4b482a68d5756028a0affe978cfb81c35
Python
6,427
142
import os import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN def plot_dbscan_clusters(cluster_arr, dbscan_labels, hierarchical_label, save_path=None): outlier_indices = np.where(dbscan_labels == -1)[0] non_outlier_indices = np.where(dbscan_labels...
5bb8cb706d1f54ea13d46422b89cc42cc3c962c6763fd568e1388c4cde574e71
Python
6,432
177
#! python3 # -*- encoding: utf-8 -*- # =================================== # File : test_model_with_fine_tune.py # Time : 2024/06/05 12:19:59 # Author : Zehong Zhang # Contact : zhang@fmp-berlin.de # =================================== import os import torch import torch.nn as nn import torch.optim as o...
dae9d5a90d4b0d217b97aac6f512dc18d214d2b15d3ec9b24f8953139b814ecf
Python
6,441
153
"""Unit tests for src/datahandlers/doid.py. Two fixtures, both copied verbatim from `babel_downloads/DOID/doid.json`: - `doid_icd_xref_sample.json` holds [`DOID:2476`](http://purl.obolibrary.org/obo/DOID_2476) "hereditary spastic paraplegia", the grouping term whose `ICD10:G11.4` xref -- shared with all 60 of its...
c7a2cf717da539aca55b35149be8377fdd54d71fbd28e78994e3bc9caf72dbc8
Python
6,443
205
""" 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. """ import torch from torch_scatter import scatter from ocpmodels.modules.scaling import ScaleFactor from ..initializers import he_orthogonal_i...
12f5a1e3d4126340e41e2b20304de6bf5ff7456cfae6103a9f006afaf96ccd0c
Python
6,444
201
# -*- coding: utf-8 -*- """ Created on Mon Oct 30 14:27:23 2023 @author: ingvieb """ from glob import glob import shutil import datetime import SimpleITK as sitk import numpy as np import nibabel as nib import json import os def createParameterMap(file, regType): with open(file, "r") as f: param_dict ...
81fdd6ec12cc1c6e328fe3c2b77f8431d2aed52b02215fcc68fa84debf690060
Python
6,447
134
import argparse import pandas as pd from sklearn.metrics import confusion_matrix from tqdm import tqdm # pytorch import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import DataLoader from torchsummary import summary # data set formatting from nanopore_dataset import create_sample_map ...
3fe5d450b628330ebdca7868e33031d806d99d79341bca6a3dd5035eed3f0a9f
Python
6,450
200
""" Demo for defining a custom regression objective and metric ========================================================== Demo for defining customized metric and objective. Notice that for simplicity reason weight is not used in following example. In this script, we implement the Squared Log Error (SLE) objective and...
ea68b4946da3f1c7e4c8954eff97de480ffb2260d322b7ed269a7c292d80b150
Python
6,451
181
import torch import torch.nn.functional as F import numpy as np import matplotlib.pyplot as plt import os import logging from torchvision import datasets, transforms from torch.utils.data import DataLoader from torchvision import models # Ensures reproducibility by setting the random seed across all libraries def seed...
a412415b2cad158dcf9f433cd29143cfa8b6b67692f6bc799a850b8319fd72b6
Python
6,465
152
############ # https://github.com/lessw2020/Ranger-Deep-Learning-Optimizer # This code was taken from the repo above and was not created by me (Fabian)! Full credit goes to the original authors ############ import math import torch from torch.optim.optimizer import Optimizer class Ranger(Optimizer): def __init_...
22fdf8c21c86059c81377581b402d1b30a1e336a3c4e7dcb9b88be96bae86800
Python
6,467
202
# -*- coding: utf-8 -*- """ Created on Mon Oct 30 14:27:23 2023 @author: ingvieb """ from glob import glob import shutil import os import datetime import SimpleITK as sitk import numpy as np import nibabel as nib import json def createParameterMap(file, regType): with open(file, "r") as f: param_dict ...
bdfb46dcb755c0f7c6ffd8fdaf001b26c2c02211db7f515460a5d8747ff9560d
Python
6,473
211
""" 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. """ import math from typing import Dict, Union import numpy as np import torch from scipy.special import binom from torch_geometric.nn.models.sc...
01c18ebb306c52f2fb423f2931375ff9ab6494c20fe621cff44d597311f8baa1
Python
6,477
157
import torch import torch.nn as nn class RealValCNNLineDet(nn.Module): """ Convolutional network to classify kspace lines Input to the network is multi-echo kspace data, where real and imaginary parts are on two separate channels. Output is a mask classifying each line as artefact-free or corrupted. ...
8bfe16a6c8d9295b060be8375d42ed5787fc0b077d26abbe52feb4741bc607d9
Python
6,486
198
#!/usr/bin/env python # coding: utf-8 import os.path as op import random import time import matplotlib.pyplot as plt import numpy import sklearn import torch import torch.nn.functional as nn_func from sklearn import preprocessing from sklearn.metrics import adjusted_rand_score from torch.nn import Linear from torch_g...
c1be2a9ef4aad1d5a5bd1c4e6daef62a395af6af765f0dd8dc8cc8539967e4d5
Python
6,487
180
"""Benchmark numpy-return commands vs the *_dlpack GPU-output commands. Three destinations per feature family: 1. numpy: the command's own wall time, result on the host 2. numpy+to_gpu: plus torch.from_numpy(...).cuda(), i.e. what a model actually needs 3. dlpack: written straight into CUDA memory, alloca...
b7a26309632d83ca88e030bb6326786ff799f875b9a7e4cebb7fd6a261c5e54c
Python
6,489
193
"""Integration test for template room isolation. Verifies that when a room is set as the default template: 1. New rooms copy frames from the template 2. Modifications to new rooms don't affect the template 3. The template remains unchanged after operations on derived rooms """ import pathlib from collections.abc impo...
a08fa10217b6ee8cf3deec31e55c6c660e80081c27d0dc88d8d63c708fbd32e1
Python
6,497
194
from luna.paths import LunaPaths from luna import candidate_info, dataset from luna.ct import Ct from luna.prepcache import LunaPrepCacheApp from torch.utils.data import DataLoader from Utils.models import * from Utils.TrainModelLUNA import * from Utils.config import * from tqdm import tqdm import matplotlib.pyplot as ...
3938ee423f3d03bfc66aa2068f6350b3d270ffadf3e02035e3b8896c8574eed9
Python
6,498
192
#!/usr/bin/env python # # Merge images. See details in function "merge_images". # # Copyright (c) 2014 Polytechnique Montreal <www.neuro.polymtl.ca> # License: see the file LICENSE # TODO: parameter "almost_zero" might case problem if merging data with very low values (e.g. MD from diffusion) import sys import os fro...
759411e1afe5492d22360e637cc4ecab7379f2ced9e5018c52b80d61d57d21c5
Python
6,507
158
import copy import numpy as np import torch from oa_reactdiff.dataset.base_dataset import BaseDataset, ATOM_MAPPING, SAM_CHARGED_ATOM_MAPPING FRAG_MAPPING = { "reactant": "product", "transition_state": "transition_state", "product": "reactant", } def reflect_z(x): x = np.array(x) x[:, -1] = - x...
6c431af9832c92d5af48bf2f0bebafdb6a55b17ca249fc4c3d94f056aca4ff33
Python
6,510
138
import numpy as np import matplotlib.pyplot as plt import os from grid_cell.manifold_fitter import label_mesh from sklearn.model_selection import train_test_split from sklearn.decomposition import PCA from grid_cell.sphere_manifold import Circle_Manifold, get_circle_mesh from grid_cell.ori_tuning_manifold import Ori_Tu...
b53983a3a4a5325249963436fac14a391e2de5c40220c3a47d095bf97a29bd0b
Python
6,515
99
# Copyright (c) OpenMMLab. All rights reserved. from mmseg.registry import DATASETS from .basesegdataset import BaseSegDataset @DATASETS.register_module() class COCOStuffDataset(BaseSegDataset): """COCO-Stuff dataset. In segmentation map annotation for COCO-Stuff, Train-IDs of the 10k version are from 1 ...
cfdd42adacaff16b8556499c7f1966161c9cb2ce42815364c382021e44e9fb08
Python
6,524
200
# -*- coding: utf-8 -*- """ Created on Sat May 23 10:38:20 2020 @author: george.dickinson@gmail.com This program is a Python script developed to analyze the motion of intracellular Piezo1 proteins labeled with a fluorescent tag. It allows the user to load raw data from a series of image files and track the movement o...
28fa3657644b360e20a5e46e3808df4fdc8fd93d30c4d028c9689c3bd0309405
Python
6,529
195
import pandas as pd import numpy as np import matplotlib.pyplot as plt from src.circuit import _positive_angle from src.bold import calc_sum_activity def plot_bold(bold,outdir): """ Plots bold signal and saves it to file. Arguments: bold (dataframe): bold signal for each condition (columns = conditions, rows = ...
f365ac1205abd71403e32b9c524e440382b7f5874969a19aa9ef8812554be5d2
Python
6,530
174
import copy import numpy as np class PID: def __eq__(self, other): if issubclass(type(other), PID): return True if type(other) is int: return True return False def compare_fundamental_observations(obs1: dict, obs2: dict, translation: dict): assert type(obs1) ...
4ef182bd36093b06d05c2b708bb48a9661feeb16b088113cf9bc2b61594fd8c2
Python
6,531
207
"""Isosurface REST endpoint — marching cubes extraction for volumetric data.""" from __future__ import annotations from typing import Annotated from uuid import ( UUID, # noqa: TC003 # runtime: FastAPI builds TypeAdapter for owner_id path param ) import msgpack import msgpack_numpy import numpy as np from fast...
bd38eb1725f81e9291c072fb74f070f659f64cb68a276ad7746b7e841fd48a64
Python
6,533
147
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, 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 of the License at # # http://w...
7c5ce79f4d10338a6e4b3493c6ef8020bc94568941ed32d24c50411526ba470e
Python
6,535
287
"""Pydantic models for Socket.IO events. Event names are derived from class names in snake_case: - RoomJoin -> "room_join" - SessionJoined -> "session_joined" """ from __future__ import annotations from datetime import datetime from typing import TYPE_CHECKING, Any, Literal, Self from uuid import UUID from pydantic...
199e711f690a043e231e7406a99789e487f2382f732cd9733de26382aac97d91
Python
6,536
189
import os from medperf import config import yaml from medperf.utils import get_file_hash from medperf.exceptions import CommunicationRetrievalError from medperf.tests.mocks.benchmark import TestBenchmark from medperf.tests.mocks.dataset import TestDataset from medperf.tests.mocks.execution import TestExecution from me...
8f8331978c8c1ff91a1df00996ec08abcc164834c5c6112d2dea24387e84ea5e
Python
6,536
187
from django.http import Http404 from rest_framework.generics import GenericAPIView from rest_framework.response import Response from rest_framework import status from rest_framework.request import Request from django.contrib.auth import get_user_model from .models import Certificate from .serializers import ( Certi...
b43e79f2bb72b765eb66a5b858daa004eb5f42e591856a256cc870aa85ce3560
Python
6,537
207
#!/usr/bin/env python # # Copyright 2006, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
d973ffa7ed2c468f8e9db6e4860f9fb5d9d9ea1348aa7dbfab92e123e497a35e
Python
6,539
203
import functools import pandas as pd from torch.utils.data import DataLoader import numpy as np import pandas as pd from sklearn.metrics import roc_auc_score from sklearn.linear_model import LinearRegression from tqdm.auto import tqdm from rde.utils.misc import inf_iterator, BlackHole from rde.utils.data import Paddi...
44034a2982112bbb04f4ee11e8a72f915cdfb3f2dbe08649cc0baaf6cb29158e
Python
6,541
147
import os import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN def plot_dbscan_clusters(cluster_arr, dbscan_labels, hierarchical_label, save_path=None): outlier_indices = np.where(dbscan_labels == -1)[0] non_outlier_indices = np.where(dbscan_labels...
574126655d8bcd8af235ed37c119fcae7b5afc12a81659a0f21bf7b528adcae9
Python
6,541
186
import argparse import glob import logging import os from typing import Dict, Optional import ocpmodels """ This script provides users with an automated way to download, preprocess (where applicable), and organize data to readily be used by the existing config files. """ DOWNLOAD_LINKS_s2ef: Dict[str, Dict[str, str]...
bce37f51949816ed39fff340e92b7139e0cae3cdca8998a27365db8d5048259a
Python
6,541
132
from ipaddress import IPv4Address import random from typing import List, Tuple import pytest from CybORG.Agents.Wrappers.BlueEnterpriseWrapper import BlueEnterpriseWrapper from CybORG.Shared.AgentInterface import AgentInterface from CybORG.Shared.Session import Session from CybORG.Simulator.Actions.ConcreteActions.Cont...
37c25ea4b246cf1cb479fb6e4112d64fdc41c5438eaabd77f035f2ed296d1d60
Python
6,542
174
from __future__ import absolute_import from __future__ import print_function import pytest import numpy as np from keras import backend as K from keras.utils.test_utils import get_test_data from keras.models import Sequential, Model from keras.layers import Dense, Activation, GRU, TimeDistributed, Input from keras.uti...
949c34d147bab0f96d48d42e8b38f44c55d819b5f566f08bc1d916981d3cb888
Python
6,542
206
"""Tests for default camera GET/PUT endpoints, delete cleanup, and Python client.""" import json import pytest from helpers import auth_header, create_test_room, create_test_user_in_db from httpx import AsyncClient from sqlalchemy.ext.asyncio import AsyncSession from zndraw.client import ZnDraw from zndraw.geometrie...
182e43370f1c115e209c861c61d9f19ba6411f79cbc9958ac7a8dffd3c22fcd1
Python
6,544
173
import os import subprocess import time import dask import numpy as np from dask.distributed import Client, LocalCluster, performance_report import nearl from nearl import _tempfolder, features # Only needs the fingerprint of the def parallelize_traj(traj_list, focused_res): traj_list = [i for i in traj_list] ...
3e9127bd071114c01ebf740abaab69b8d777c084482ffc9affa58c351916f011
Python
6,544
140
import os, sys sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) # For replicating the experiments SEED = 42 import argparse import time import random import numpy as np import scipy.sparse as sp import torch np.random.seed(SEED) torch.manual_seed(SEED) from torch import optim import...
3d8bda99d290c6f0a9b3388e50f290751f16ba1649d33a9449d7c8276a6094c1
Python
6,546
216
import torch.nn as nn import torch.nn.functional as f from torch import Tensor import torch import numpy as np class CE_AV(nn.Module): """ 0 Anger 1 Anticipation 2 Disgust 3 Fear 4 Joy 5 Sadness 6 Surprise 7 Trust Positive: Anticipation, Joy, Surprise, Trust Negative: Anger,...
23f01acc8ad028217e771ef7c3e5c8b0082ba2ffbe8a1461b8059d89f96bc673
Python
6,550
202
import torch import torch.nn as nn import torch.nn.functional as F class ScaledSiLU(nn.Module): def __init__(self, inplace: bool = False) -> None: super(ScaledSiLU, self).__init__() self.inplace = inplace self.scale_factor = 1.6791767923989418 def forward(self, inputs): return...
58d45c0f7c4643565eaaf57679a780b61d0591fcab380ea901a95d5f75df8566
Python
6,553
142
# run fit_gkr_models.py first import hickle as hkl from umap import UMAP from grid_cell.ploter import gp_torus_surface from grid_cell.util import pca_accumulated_variance_explained_ratio from sklearn.decomposition import PCA import matplotlib.pyplot as plt from grid_cell.gkr import GKR_Fitter from grid_cell.manifold_fi...
081b821deb10c50e49241fb9a3d06a0824144138a63411f5ef1fb84e1c30724e
Python
6,557
142
# -*- coding: utf-8 -*- """ @author: Eslam Mohamed @email: es.ahmed@nu.edu.eg Functions to read, load and process EEG Data """ import os import pandas as pd import numpy as np from scipy import signal from typing import List, Tuple def process_eeg(TIME_STEPS:int = 1200, included_states: List[str] =["Up", "Down", "L...
f9622a1ae3cc029eab5076d3ef2ba6e7e8cf5ae791dc677293226817867788f4
Python
6,561
161
import numpy as np from collections import Counter # Custom functions from src.utils import * class SIRIRAJ(): def __init__(self, args) -> None: self.data_dir = os.path.relpath(args.data_dir) self.results_dir = os.path.relpath(args.results_dir) self.models_dir = os.path.relpath(args.models...
91a336d365c620e4ac6e3ca92055a55e46d50143addf37c71d95b5c4f03b00b4
Python
6,563
182
import os from pathlib import Path import shutil from medperf.entities.dataset import Dataset import medperf.config as config from medperf.entities.cube import Cube from medperf.entities.benchmark import Benchmark from medperf.utils import ( approval_prompt, dict_pretty_print, get_folders_hash, sanitize...
2f30645f9135a82690ec6f677b0f93740eeaadaccaf7f7169f32266666b6db75
Python
6,565
212
import os from kgx.source import OwlSource from kgx.transformer import Transformer from tests import RESOURCE_DIR from pprint import pprint def test_read_owl1(): """ Read an OWL ontology using OwlSource. """ t = Transformer() s = OwlSource(t) g = s.parse( os.path.join(RESOURCE_DIR, "g...
a1e0cc51d69c53c436dc75ceae365531f771a03f8c9de966a891ceea120413c1
Python
6,568
163
# SPDX-License-Identifier: BSD-3-Clause import os import torch import onnxruntime import numpy as np from retinanet.model import Model from PIL import Image from torchvision import transforms from onnx import numpy_helper import urllib data_dir = 'test_data_set_0' url, filename = ("https://github.com/onnx/models/ra...
7b11a272ed64aa331b6d1cdea66b043ec3214f0cd8e614ba88150d0f538bd476
Python
6,572
214
#*******************************************************# # Classes used as configuration files #*******************************************************# class DatasetConfig: ''' Class for defining dataset parameters: shape, split ratio, augumentation etc. ''' ''' Imgs_png_home_path = Root direct...
12279a19fc9f8327a5e7503509f48c8f9c5c45accc3773b0fe4134e41baa4275
Python
6,573
164
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, 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 of the License at # # http://w...
405d2bd4ef169cb07034ad6eea5884ba395d1aa78b849461cec74df8a539aca3
Python
6,578
190
import pickle import numpy as np import torch from torch.utils.data import Dataset import torch.nn.functional as F from oa_reactdiff.dataset.datasets_config import ATOM_MAPPING, SAM_CHARGED_ATOM_MAPPING class BaseDataset(Dataset): def __init__( self, npz_path, center=True, zero_c...