sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
c00259e7358aa0f13404672cd765f6eca315c54a59e1d60100db55e7980aba2b | Python | 5,749 | 201 | """Edit lock REST API endpoints for room-level exclusive editing."""
import json
import time
import uuid
from typing import Annotated
from fastapi import APIRouter, Header
from zndraw.broadcast import broadcast_to_room
from zndraw.config import SettingsDep
from zndraw.dependencies import (
AccessEditDep,
Acc... |
f20c24f51600a2c7fa39c74c89c3ec0eaca228f095c173c8d01e12261dbf5d31 | Python | 5,749 | 162 | #!/usr/bin/env python
"""
MetaWIBELE: abundance_normalization module
Normalize abundance table within sample to get relative abundance
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 (t... |
0112b9a7b42791ac9f26edd9f389726a480cbd7722f589e41d7430dedeb2bd9d | Python | 5,750 | 178 | import concurrent.futures as cf
import datetime
import logging
import os
import socket
import subprocess
import sys
import time
from typer import Argument, Typer
from DiastereomericResolutions.Helper_funs.db_utils import _get_needed_pairs_from_file
from DiastereomericResolutions.Helper_funs.job_db import (
comple... |
7b274630e75243ca32361fc93bd12240621dcf0a9aae02583caa9606f561c995 | Python | 5,750 | 156 | import os
from kgx.graph.nx_graph import NxGraph
from kgx.sink import TsvSink
from kgx.transformer import Transformer
from tests import TARGET_DIR
def test_write_tsv1():
"""
Write a graph to a TSV file using TsvSink.
"""
graph = NxGraph()
graph.add_node("A", id="A", **{"name": "Node A", "category... |
8526f9d1e202a3b378f150838844f4f28035354d18c75e8f55e68a4249de360b | Python | 5,751 | 212 | """Custom pydantic-settings source backed by StateFile.
Resolves URL via health-check-based server discovery and token
via local_token (localhost) or stored access_token (remote).
"""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING, Any
from urllib.parse import urlparse
... |
ad8729e0cb6650ade7753fafd79bed2721585d91c1381eebce5ee7f045d038ae | Python | 5,752 | 137 | from n2v.internals.N2V_DataWrapper import N2V_DataWrapper
import numpy as np
def test_subpatch_sampling():
def create_data(in_shape, out_shape):
X, Y = np.random.rand(*in_shape), np.random.rand(*in_shape)
X_Batches, Y_Batches = np.zeros(out_shape), np.zeros(out_shape)
indices = np.arange(... |
1a70c7eb1e05d5c10cab8a770c675124fdb5c30fa51ca69eb9f409f4796fcc62 | Python | 5,754 | 212 | #!/usr/bin/env python
import sys
import struct
chr_name = "20"
chr_seq = ""
for line in open("%s.fa" % chr_name):
if line.startswith('>'):
continue
line = line.strip()
line = line.replace('N', '')
chr_seq += line
chr_seq += '$'
chr_sa = []
f = open("%s.sa" % chr_name, "rb")
while True:
f... |
75d4852d373ee623e0c13ca20d1cffe1d7aafee2a451259604c4194df8fc4e0b | Python | 5,755 | 165 | #!/usr/bin/env python
import argparse
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm
from MCMG_utils.data_structs import MolData, Vocabulary
from models.model_MCMG import transformer_RL
from torch.optim import Adam
from MCMG_utils.Optim import ScheduledOptim
from MCMG_utils.early_stop.pyto... |
a82a81190831353d479cfd20f7350753e4bb75428d5ff3d8ae6f03a66db23a33 | Python | 5,757 | 166 | #!/usr/bin/env python
# ----------------------------------------
# scikit-ribo
# ----------------------------------------
# pre-processing module
# ----------------------------------------
# author: Han Fang
# contact: hanfang.cshl@gmail.com
# website: hanfang.github.io
# date: 3/28/2017
# ----------------------------... |
3523f73113556a9793370414c40aa9b169e7e12158fa788a7e032d2259c709a2 | Python | 5,759 | 143 | from ionmf.factorization.model import iONMF
from sklearn.metrics import roc_auc_score
import matplotlib.pyplot as plt
import numpy as np
import pickle
import gzip
import os
import sys
np.set_printoptions(precision=5)
def load_data(path, kmer=True, rg=True, clip=True, rna=True, go=True):
"""
Load data matr... |
635882dcf0ff6229ec755657da916c34d2e50c308bb38bccb4336b71365cd550 | Python | 5,759 | 145 | 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 params import palette
from figure_2_representation import (
normalize_columns, select_axis_sign,
figure_adjustments, figure_adjustments_rep,
figure_adjustm... |
9090f8d6cbe120fd850c739f9a25c7d448051c963227deea2579fa1d005d8f4d | Python | 5,759 | 177 | import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import inspect
import time
import os
import torch as T
import numpy as np
from rich import print
from CybORG import CybORG
from CybORG.Agents import SleepAgent, EnterpriseGreenAgent, FiniteStateRedAgent
from CybORG.Simulator.Scenarios i... |
512b0deb3bb549158cbcea45d9731b4bc519789ded84d09060adaea26ff3b628 | Python | 5,761 | 156 | #!/usr/bin/env python
#
# Function to segment the multiple sclerosis lesions using convolutional neural networks
#
# Copyright (c) 2017 Polytechnique Montreal <www.neuro.polymtl.ca>
# License: see the file LICENSE
import os
import sys
from typing import Sequence
import textwrap
from spinalcordtoolbox.utils.shell impo... |
27ec0ddef6110c3120db6c7b0135c909c322e4663f2463afde7a5820b16e46e7 | Python | 5,763 | 92 | # Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .basesegdataset import BaseSegDataset
@DATASETS.register_module()
class ADE20KDataset(BaseSegDataset):
"""ADE20K dataset.
In segmentation map annotation for ADE20K, 0 stands for background, which
is not included in 1... |
d14816b0a1dcdb02038991393d06b4e84cb3ab3db3d5ee17bc7a30cf0f452e38 | Python | 5,765 | 143 | from importlib.metadata import version
import pytest
from guppy import app
from guppy import main as main_module
from guppy.main import main
from guppy.utils import dandi_filter
@pytest.fixture
def served(monkeypatch):
"""Capture the route map instead of starting a real Bokeh server.
Stubbing ``pn.serve`` ... |
d58d8aae9bd869572df230acaa4506196057b712feb2d359fc00e7f5fe589ccc | Python | 5,767 | 171 | #!/usr/bin/env python
#
# Copyright 2009, 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... |
11ab0f302ac20d27fc720d54257b70b45d174c667b53a6cbc81f3ebf9eb55c3f | Python | 5,768 | 166 | # %%
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import seaborn.objects as so
from params import palette
from figure_functions import adjust_axis
plt.style.use('../training/mpl_stylesheet')
# %%
inits = {
'l1_english': ['none','en19','en49'],
'l1_french': ['none','fr19','fr49']... |
aef036f413ada29d11788676cf2c77bbbd36e1ba731d0d72047edd03c1d4174b | Python | 5,768 | 180 | from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
import urllib
import pathlib
import os
import sys
import requests
import numpy as np
import warnings
warnings.filterwarnings("ignore")
from torchxrayvision.models import model_urls
class ResNet(... |
f8edd3fc95a13af783b5e9dd222fd8a348f1aad30c981d03349a0d2083586449 | Python | 5,768 | 142 | #############################################
# See GASTON code: https://github.com/raphael-group/GASTON/blob/main/src/gaston/binning_and_plotting.py
#############################################
from scipy.stats import mode
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import os
def bin_da... |
c0d3318a8756f68a9d5b2749d2a1c3d4a39f7d856ac024b2332e4ef53f2ac715 | Python | 5,771 | 178 | from pathlib import Path
import subprocess
import pandas as pd
from typing import Dict, Any
from ..logger import logger
from .workflow import SnakemakeWorkflow, WorkflowError
class NormalizationError(Exception):
pass
def validate_normalization_inputs(config: Dict[str, Any]) -> None:
"""
Validate inputs re... |
b129653586c8573c853fd416a57cd1e2d90114486cc2aa6f8a153d8554e1c92c | Python | 5,773 | 186 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmseg.models.backbones.mae import MAE
from .utils import check_norm_state
def test_mae_backbone():
with pytest.raises(TypeError):
# pretrained must be a string path
model = MAE()
model.init_weights(pretrained=... |
99131b962973a71b65197013a5a63cd972ef9fd255466306a48691475e1602b7 | Python | 5,774 | 163 | # %%
import pandas as pd
import numpy as np
import seaborn as sns
from matplotlib.colors import to_hex
import matplotlib.pyplot as plt
import seaborn.objects as so
from seaborn import axes_style
import os
from params import palette
from figure_functions import adjust_axis
plt.style.use('../training/mpl_stylesheet')
... |
b79311b56a5a5ec02bc9e28089143f0293d169611c44d7945ccf9a1233b15491 | Python | 5,774 | 178 | import os
import pickle
import lmdb
import numpy as np
import pandas as pd
import torch
from rdkit import Chem
from torch.utils.data import Dataset, Subset
from tqdm import tqdm
from .data import Drug3DData, torchify_dict
from .parser import parse_conf_list
def get_dataset(config, *args, **kwargs):
name = confi... |
a941f938912804ae5cf800b2edbe6d51bee76216da4df45b75a7b52dbd122137 | Python | 5,776 | 213 | import copy
from typing import List
from kgx.config import get_logger
from kgx.graph.base_graph import BaseGraph
from kgx.utils.kgx_utils import prepare_data_dict
log = get_logger()
def merge_all_graphs(graphs: List[BaseGraph], preserve: bool = True) -> BaseGraph:
"""
Merge one or more graphs.
.. note... |
aa1731de8f290d19363b4c89a3d2c98534ee122e58e40c10e2a2d61844294abf | Python | 5,778 | 151 | import pandas as pd
import deepchem as dc
import numpy as np
def data_loader_separate(csv_list, loader):
train = loader.create_dataset(csv_list[0])
valid = loader.create_dataset(csv_list[1])
test = loader.create_dataset(csv_list[2])
print(f'Got {len(train.y)} samples for train, {len(valid.y)} for vali... |
d21562f5d2681b51de704d61095e24a2b372d1fb234c15b546d7f27b25e1fda2 | Python | 5,782 | 159 | import os
import hydra
import omegaconf
import torch
import pandas as pd
from omegaconf import ValueNode
from torch.utils.data import Dataset
from torch_geometric.data import Data
from ccdvaeplus.common.utils import PROJECT_ROOT
from ccdvaeplus.common.data_utils import (
preprocess, preprocess_tenso... |
56c0366c79a33d2ac93ec8fba304e12bd7c886cce770a78e15e2fbf8b9d00f2a | Python | 5,783 | 226 | """Tests for ephys.mechanisms"""
import string
import random
import json
import difflib
import pytest
from . import utils
from bluepyopt import ephys
import bluepyopt.ephys.examples.simplecell
simplecell = bluepyopt.ephys.examples.simplecell.SimpleCell()
from bluepyopt.ephys.serializer import instantiator
simple_... |
5346d25e97a0c31d445e6fa34e6fb8c2e1f3eed6f3548bd9bc0c0ae9e8ef1f94 | Python | 5,784 | 115 | # coding=utf-8
# Copyright 2022 The OFA-Sys Team Authors and The HuggingFace 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.org/licenses/... |
aa59a55024f7303a3f323bc182ffb7d96c80cf58b823a33fce96eb8fb68b36a1 | Python | 5,784 | 188 | #!/usr/bin/env python
"""
MetaWIBELE: gene_catalog_abundance module
Summary abundance table of gene catalog
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 ... |
f51b04f4e2a4acb0cbd8696a126d03217e1e35a18807ffd34f3ee4d251203256 | Python | 5,784 | 172 | # -*- coding: utf-8 -*-
# Script initially by Tom Kazimiers 2013-01-12
# Adapted by Albert Cardona 2013-01-25
#
# The purpose of this script is to connect to a django session
# in a remote computer, and to retrieve information from the database
# such as the skeleton of a neuronal arbor and its synapses
# in the form o... |
dd5018229b222f40452cd765865b5a1ed04a62b636f03527212f096826596b2f | Python | 5,786 | 172 | """Tests for CircleCurve geometry model."""
import math
import numpy as np
import pytest
from pydantic import ValidationError
from zndraw.geometries.circle_curve import CircleCurve
def test_circle_curve_defaults():
"""CircleCurve has sensible defaults."""
c = CircleCurve()
assert c.position == [(0.0, 0... |
7a48d2981bd8fe711420715f056d87edb946b9d49d532ed9ba120afa33d0c209 | Python | 5,788 | 132 | import argparse
import numpy as np
import pandas as pd
import scanpy as sc
import h5py
import os
parser = argparse.ArgumentParser(description='preprocessing')
# input & ouput
parser.add_argument('--input_h5ad_path', type=str, default=None,
help='path to input h5ad file')
parser.add_argument('--inp... |
6ffd5e9920827239257bc59c4373895d9b71e7abee2290cc6dffa073370bd794 | Python | 5,790 | 146 | import os,csv,re,sys
import pandas as pd
import numpy as np
import scanpy as sc
import math
import SpaGCN as spg
import random, torch
from sklearn import metrics
import cv2
import matplotlib.pyplot as plt
from pathlib import Path
BASE_PATH = Path('/home/xuchang/Project/STMAP/DLPFC')
output_path = Path('... |
4ba55905598e4ffa331f4670b84fe72eb1813c2c6ceb63d8c312b88d4080b886 | Python | 5,795 | 193 | import argparse
import csv
from pathlib import Path
import yaml
import numpy as np
from sklearn.metrics import (
f1_score,
accuracy_score,
jaccard_score,
recall_score,
precision_score,
)
class MetricsClass:
"""Class wrapper for calculating the supported metrics
Args:
num_class... |
7dc0a1516d6ac0a9248a29cf1ce2256aae5ea9b7c9cea040706da6eee8ade56b | Python | 5,797 | 157 | import sys
import time
from joblib import Parallel, delayed
import cv2
import numpy as np
import pandas as pd
from scipy.spatial import distance as ssd
from pathlib import Path
def background_normalization(img, background):
sub = background - img
norm = (sub + 1) / (background + 1)
img = np.clip(norm * 25... |
0c34adbec0116aca04363692a5eb073a41887682097a8c4f042578d2e5e81aa5 | Python | 5,798 | 180 | """Layer 2: runtime broadcast contract sweep across emit families.
For each representative action against a real room, the captured event must:
* be a RoomScopedEvent subclass
* carry ``room_id == UUID(room.id)`` and ``room_address == room.public_address``
* be emitted on channel ``f"room:{room.id}"``
Sigil cha... |
1bfc5a6589a0a88fade1995b3481fdbcaecac02b6b2696eac59f83451c86bf9f | Python | 5,799 | 116 | # import cProfile, pstats
# pr = cProfile.Profile()
# pr.enable()
# test the performance of methods depending on the number of datapoints
import numpy as np
import matplotlib.pyplot as plt
import hickle as hkl
import os
from grid_cell.sphere_manifold import Circle_Manifold, get_circle_mesh
from grid_cell.ori_tuning_ma... |
f26047d0a694d3eb19a7f3c2023440a30ed88599f54624f3c7086b8ffe77ceb1 | Python | 5,800 | 113 | import numpy as np
import matplotlib.pyplot as plt
import itertools
import torch
from dataAnalysis.Constants import FEATURES, SEX_CATEGORY_COLUMN_NAME, STEPS, FEATURE_DICT, VARIATION_DF, VARIATION_SMALL_DF
import pandas as pd
from torch_geometric.data import Data
from os.path import exists
def normalize(tensor):
i... |
07af91db35cec9aa7bf5fa42ce6595cc1a4e28ea15dac2020119bfb6f6c5b8b8 | Python | 5,803 | 169 | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmseg.registry import MODELS
from .decode_head import BaseDecodeHead
def reduce_mean(tensor):
"""Reduce mean when d... |
744352cfe6782b05b51123d791ea802fb047321eb3b3c6fbb1673a5e337316fb | Python | 5,811 | 151 | import torch
from nnunet_mednext import create_mednext_v1
import data_loader
import yaml
import argparse
import os
import pdb
import numpy as np
'''
--------------------------------- Attention !!! -----------------------------------------
This script is only provide the example how the inference can be run.
Parti... |
1df59f08fc31c636c7302e4b9baf8ec307f84dd5cb7bb8619a33b8170f590331 | Python | 5,814 | 196 | ##
## CPCantalapiedra 2020
import os, sys
import time
from os.path import exists as pexists
from os.path import join as pjoin
from ...common import get_db_info, get_hmmer_databases, get_hmmer_dbpath
from ...utils import colorify
from ...emapperException import EmapperException
# from .hmmer_server import server_fun... |
154321ebef6a018e7963adc5247168db22298d073bbfbc28bbabdbf9d1bf2b70 | Python | 5,816 | 188 | import json
from tqdm import tqdm
import os
import argparse
label2desc={
'银行': '银行',
'社区服务': '社区',
'电商': '电商',
'支付': '支付',
'经营养成': '养成',
'卡牌': '卡牌',
'借贷': '借贷',
'驾校': '驾校',
'理财': '理财',
'职考': '职考',
'新闻': '新闻',
'旅游资讯': '旅游',
... |
5c70516bb17dd55740f4b8761adc2e4c22001e6b11b93513ad5f7ed7c4ff8074 | Python | 5,816 | 100 | # 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... |
f26a5eea7bd6cfca9cc9c125ea4d182aecb7d93413d47e91a240e278b7536dc8 | Python | 5,817 | 185 | import pytest
import pandas as pd
from neuprint import Client, default_client, set_default_client, clear_default_client, list_all_clients
from neuprint.client import inject_client, _register_client, _user_clients, _thread_copies
from neuprint.tests import NEUPRINT_SERVER, DATASET
EXAMPLE_BODY = 5813037876 # Delta6G, D... |
06e41d536624e0954b8270dc236f145d2f4d1fb30f0b6a15a4a5b8ca21295fb1 | Python | 5,820 | 119 | # coding=utf-8
# Copyright 2022 IDEA-CCNL and The HuggingFace Inc. 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.org/licenses/LICENSE-2.... |
f956c20c31dc34c36c7224cc8dcff3da83d8874a4c72a19e08c29bd0d1adcfd0 | Python | 5,822 | 143 | # ================================================================================
# Copyright (c) 2018 Benjamin Hou (bh1511@imperial.ac.uk)
#
# 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 ... |
95e931cc28bcb6864f0f5504525b9d578aa6e0f8118d70f5cfcc1d4a21a6334b | Python | 5,823 | 175 | #
# calculation of synthetic accessibility score as described in:
#
# Estimation of Synthetic Accessibility Score of Drug-like Molecules based on Molecular Complexity and Fragment Contributions
# Peter Ertl and Ansgar Schuffenhauer
# Journal of Cheminformatics 1:8 (2009)
# http://www.jcheminf.com/content/1/1/8
#
# seve... |
5ce1d2712a8c48610150208ab514a6571447876d83eee4ed2107878216063199 | Python | 5,824 | 166 |
# I may be missing import statements, so add if you find something I missed
import os
import pandas as pd
import numpy as np
# from tqdm import tqdm
from sklearn.decomposition import PCA
from itertools import compress
# CURR_PATH = '/Users/karinsaltoun/dblabs/asymm_pat_age_progression'
# os.chdir(CURR_PATH)
print(... |
58745c8c0f06e290dcce84472ee681ac4b42c7f7f59c19984eefb03b6e76ac96 | Python | 5,825 | 184 | from __future__ import annotations
import os
import platform
from pathlib import Path
from typing import Any, Optional, Union
from soccertrack.logging import inspect, logger
_pathlike = Union[str, Path]
_module_path = Path(__file__).parent
class KaggleDownloader:
def __init__(self) -> None:
"""An downl... |
aed216c8da6f2e82f561d3579cea0925a1eac233639342ccb6a63fdcbf79face | Python | 5,826 | 182 | __all__ = [
"EndSkip",
"Aligner",
"PrefixComparer",
"SuffixComparer",
"hamming_sphere",
"hamming_environment",
"edit_environment",
"edit_distance",
]
from enum import IntFlag
from collections.abc import Iterator
from cutadapt._align import (
Aligner,
PrefixComparer,
SuffixC... |
35347fd22ab90246e18c50162d6b9720c7607f9259ca1064ad3c32b026d99f40 | Python | 5,828 | 127 | import pytest
import random
from CybORG import CybORG
from CybORG.Shared.Enums import ProcessName
from CybORG.Shared.Session import Session
from CybORG.Simulator.Scenarios.EnterpriseScenarioGenerator import EnterpriseScenarioGenerator
from CybORG.Agents.SimpleAgents.ConstantAgent import SleepAgent
from CybORG.Simulato... |
86fc4eb8e750fd216279b9e7c7d2be84a6cff15a39149e5fe9815941bc57548a | Python | 5,829 | 122 | import os, sys
# Main entrance from https://github.com/MysteryVaibhav/RWR-GAE
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.s... |
17b9fb5b0363661e7739353edf1e4182f06903f383f34cf3fab2561af3a65ee3 | Python | 5,831 | 191 | """Main function for performing interpolation between acquired 2D sections."""
import os
import numpy as np
import pandas as pd
from brainbuilder.interp.surfinterp import (
combine_volumes,
create_final_reconstructed_volume,
volumes_to_surface_profiles,
)
from brainbuilder.interp.volinterp import volumetr... |
04997df0a57c7f158b36f3027fdf701a85c7ba0689ea2548fd36e0aedc747918 | Python | 5,833 | 152 | #!/usr/bin/env python
#
# Concatenate transformations. This function is a wrapper for isct_ComposeMultiTransform
#
# Copyright (c) 2014 Polytechnique Montreal <www.neuro.polymtl.ca>
# License: see the file LICENSE
# TODO: also enable to concatenate reversed transfo
import sys
import os
import functools
from typing im... |
699efe7534e071e7de773bb542e33e853a726a5970b1fe351b523d44e3718cf8 | Python | 5,834 | 209 | """Tests for CLI extension commands."""
from __future__ import annotations
import json
from typing import TYPE_CHECKING
from zndraw.cli_agent import app
from zndraw_joblib.schemas import (
JobResponse,
JobSummary,
PaginatedResponse,
TaskResponse,
)
from .conftest import invoke_cli
if TYPE_CHECKING:... |
370249180b0aaefbddffc8c6ea00bf100734a76d59d35132089e8370ee3f3f1e | Python | 5,835 | 161 | """Context-Aware Implicit Neural Representations to Compress Earth Systems Model Data
DEVELOPED AT:
Department of Chemical Engineering
University of Utah, Salt Lake City,
Utah 84112, USA
DIRECTOR: Prof. Salah A Faroughi
DEVELOPED BY:
... |
a0e8fb0e5b5a16dfb77635850314747c8453fe60f1d0a02645b0bbd216ffaa4d | Python | 5,835 | 190 | """
Various utilities for neural networks.
"""
import math
import torch as th
import torch.nn as nn
# PyTorch 1.7 has SiLU, but we support PyTorch 1.5.
class SiLU(nn.Module):
def forward(self, x):
return x * th.sigmoid(x)
class GroupNorm32(nn.GroupNorm):
def forward(self, x):
return super(... |
13078a2919be7af522bed630c4efb794ad377da4c2b01008d796aea952baae70 | Python | 5,836 | 161 | """Context-Aware Implicit Neural Representations to Compress Earth Systems Model Data
DEVELOPED AT:
Department of Chemical Engineering
University of Utah, Salt Lake City,
Utah 84112, USA
DIRECTOR: Prof. Salah A Faroughi
DEVELOPED BY:
... |
56c263670d083f6c078bd4622a771db91137263ebb1136acdd04812dd5ecb017 | Python | 5,839 | 150 | # # measure the localling decoding performance on different data. Run generate_processed_exp_data.py first. Requires run torus_size.py first
import numpy as np
import matplotlib.pyplot as plt
import hickle as hkl
import os
from sklearn.linear_model import LogisticRegression
from grid_cell.grid_cell_processor import Spe... |
892ddc66ca443252caa572989e7a593f0610754fb80a3f8c93fa45cc9125e5a9 | Python | 5,839 | 214 | """Customizable logger based on loguru."""
import os
import sys
from typing import Any, Iterable, Mapping
import __main__ as main
from loguru import logger
class LoggerMixin:
def __init__(self) -> None:
"""Logger mixin because loguru can't get class names."""
self.logger = logger.bind(classname... |
c6901d67f1449d78a0bffaa761df4739edfc96fa7bcb50ca2342d843313689f2 | Python | 5,840 | 152 | import pyedflib
from scipy.signal import butter, filtfilt
from scipy.signal import resample
# example file path
file_path = r'\\10.16.32.74\dataset0\xuxin\EmoEEG\sub-60\eeg\sub-60_task-emotion_eeg.edf'
edf_file = pyedflib.EdfReader(file_path)
# get basic information of the EDF file
num_signals = edf_file.s... |
16b26d2ac6cc28587f6b6bcc8c5f6e44d2acef8f98c21ac84e434ece8e1dde06 | Python | 5,841 | 157 | from utils.utils import generate_results_csv
from utils.utils import create_directory
from utils.utils import read_dataset
from utils.utils import transform_mts_to_ucr_format
from utils.utils import visualize_filter
from utils.utils import viz_for_survey_paper
from utils.utils import viz_cam
import os
import numpy as n... |
bc4b428baa2fc71afc9ba7464b835ed95c9dc28c2a07ea93ec0a6bbf44d51562 | Python | 5,845 | 184 | # COPIED FROM RDKIT'S GITHUB REPOSITORY
#
# calculation of synthetic accessibility score as described in:
#
# Estimation of Synthetic Accessibility Score of Drug-like Molecules based on Molecular Complexity and Fragment Contributions
# Peter Ertl and Ansgar Schuffenhauer
# Journal of Cheminformatics 1:8 (2009)
# http:... |
230b2c50f30b4c1abb9294d9b94e178fb934413024619fe0a6e0bba375383b98 | Python | 5,846 | 186 | import numpy as np
import pytest
import h5py
from .common import make_name
NUMPY_GE2 = int(np.__version__.split(".")[0]) >= 2
pytestmark = pytest.mark.skipif(not NUMPY_GE2, reason="requires numpy >=2.0")
def test_create_with_dtype_T(writable_file):
name = make_name()
ds = writable_file.create_dataset(name,... |
524abfcd63114ff914775d528a78ef21d49f9b6d0c2e709cc9feb8014f19c438 | Python | 5,846 | 134 | """
Preprocesses neuroimaging data and computes all metrics defined in .metrics.
License: BSD-3-Clause
Author: Hanna M. Tolle
Date: 2024-10-31
"""
import sys
sys.path.append('../')
import os
import numpy as np
from typing import Dict
from .metrics import *
from datasets import BrainGraphDataset
def run(study: str... |
e6498bc7f7cc7db44420d6f0e2a91336e2bcfdb138312634962c62ac43b995e9 | Python | 5,846 | 196 | import datetime
import logging
from sqlite3 import OperationalError
from typing import Literal, Optional
from sqlmodel import (
Field,
Relationship,
Session,
SQLModel,
String,
create_engine,
select,
text,
)
from tqdm import tqdm
from ..Molecular_dynamics.md_config import MDConfig, MDRu... |
e19460d20ae7927217faaae8398feaf8155af3d7006dad09ec20994efaf94319 | Python | 5,852 | 184 | # Copyright (c) OpenMMLab. All rights reserved.
from typing import List, Tuple
import torch
import torch.nn.functional as F
from mmcv.cnn import ConvModule, Scale
from torch import Tensor, nn
from mmseg.registry import MODELS
from mmseg.utils import SampleList, add_prefix
from ..utils import SelfAttentionBlock as _Se... |
f744cf07688e3fc12503bbeea3e6624d8492594f84ed9c9abd23233364f06968 | Python | 5,858 | 166 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmengine.model import BaseModule
from mmseg.registry import MODELS
from ..decode_heads.psp_head import PPM
from ..utils import resize
@MODELS.register_module()
class ICNet(BaseModule):
"""ICNet... |
deed471f423cacce7400e0f406bbc2d86e2a4b0bb58826bc61b8b4b74093933b | Python | 5,864 | 161 | import os
import time
import numpy as np
from pathlib import Path
import tensorflow as tf
from tensorflow.keras.models import load_model
from tensorflow.keras import layers, models
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import Callback
from dfa_lib_python.dataflow import Datafl... |
ceb359335319899f2ab01fdfb8f40d68d09f1ac7e37774334123d63b1248bbc4 | Python | 5,865 | 174 | # Import packages
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from outcome_utilities.probs_with_time import find_mrs_constants
def plot_probs_filled(A,b,times_mins, colour_list=[],
ax=None, title=''):
if ax==None:
ax = plt.subplot()
# P(mRS<=5)=1.0 at all times, so... |
72f462fcb4e1bbe6625c0b264fe678a23c312b408523e42d5c75926b0aabda34 | Python | 5,868 | 160 | #!/usr/bin/env python3
"""Generic two-rate exact panel model for S1 -> S2 -> T.
No empirical data are bundled with this script. It can be applied to a local
trajectory table with the required state structure, or run without arguments
to execute a deterministic synthetic demonstration.
Expected local input format for ... |
e66391195ccbc3e10e6a104bcf2f251ce0fb41ec8e84bcc6a9db88bc7ebf2487 | Python | 5,872 | 130 | # coding=utf-8
# Copyright 2022 IDEA-CCNL and The HuggingFace Inc. 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.org/licenses/LICENSE-2.... |
231c18624eebf227198cdf9b1a97b7bde1a8dcc74e1d13006003cdb98604a92b | Python | 5,874 | 163 | from django.db import connection
from django.http import HttpRequest, JsonResponse
from catmaid.models import (UserRole, ClassInstance, ConnectorClassInstance,
Treenode, Connector, TreenodeClassInstance)
from catmaid.control.authentication import requires_user_role
from catmaid.control.common import get_relati... |
9744005489aa01bbda81742d992cd12a5e948888a1548e20d7e560c11572723a | Python | 5,875 | 168 | #!/usr/bin/env python
import csv
import re
import sys
from collections import defaultdict
class GeneInfo:
def __init__(self, seq_id, start, end, strand):
self.seq_id = seq_id
self.start = start
self.end = end
self.strand = strand
def parse_attr(attr_field):
attr_dict = dict... |
8e0c4a157537ce9cfe9d0b780501d3bfeeac848712624dc68f5b4446d522b532 | Python | 5,879 | 158 | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import glob
import math
import os
import os.path as osp
import tempfile
import zipfile
import mmcv
import numpy as np
from mmengine.utils import ProgressBar, mkdir_or_exist
def parse_args():
parser = argparse.ArgumentParser(
description='Con... |
d60dd6d68b5866df110c69af5b53ec811678c447bcc091056e813a6df45e81e2 | Python | 5,879 | 176 | """Context-Aware Implicit Neural Representations to Compress Earth Systems Model Data
DEVELOPED AT:
Department of Chemical Engineering
University of Utah, Salt Lake City,
Utah 84112, USA
DIRECTOR: Prof. Salah A Faroughi
DEVELOPED BY:
... |
5c3bc4d8f35608d1ec9463a30ba8862fd494ab76c1baab356e34e8c3c2cb6be8 | Python | 5,880 | 153 | """Integration tests for the DANDI streaming path through step1 and step2.
These exercise the ``inputParameters["mode"] == "dandi"`` branches in
``guppy.orchestration.store_labeling`` and ``guppy.orchestration.read_raw_data``
without hitting the network: ``_stream_nwb`` is monkeypatched to open a local
mock NWB file f... |
c8568e8c7dc72288558710eead2ce15db23b9be198eb17c4249c391896c2cc08 | Python | 5,881 | 174 | import bdpy
import numpy as np
import pandas as pd
import hdf5storage
import os
def load_parameters(param_file):
"""
Load the converter parameters from a CSV file.
"""
return pd.read_csv(param_file)
def load_brain_data(brain_dir, subjects_list):
"""
Load brain data for each subject.
"""
... |
acb6ea48d8481c1f74bbabb6bf5c60c8967e41c8090bd674c0870b1c0b6300d5 | Python | 5,883 | 149 | from transformers import LxmertForQuestionAnswering, LxmertTokenizer, LxmertConfig
import torch.nn as nn
import pdb
class LXMERT(nn.Module):
def __init__(self, args, num_labels=None):
super(LXMERT, self).__init__()
self.args = args
cache_dir = '/data/chenzhuo/data/.cache/transformers'
... |
ab98d7dd9fff51d38fc65c734c1929e8b0edc9062e15e7d1d7b34131ce598d41 | Python | 5,884 | 174 | import logging
from collections import namedtuple
log = logging.getLogger(__name__).addHandler(logging.NullHandler())
METADATA_PARENT_ID = "parent_id"
METADATA_KEY_PROV_TYPE = "prov_type"
METADATA_KEY_IDENTIFIER = "identifier"
METADATA_KEY_IDENTIFIER_ORIGINAL = "identifier_original"
METADATA_KEY_NAMESPACES = "namespa... |
fba5100eea8b4b77828fae31ee666fd8a9516542d949c070cf799fdef150f674 | Python | 5,884 | 134 | import pytest
from CybORG import CybORG
from CybORG.Simulator.Scenarios import EnterpriseScenarioGenerator
from CybORG.Agents import SleepAgent, FiniteStateRedAgent, EnterpriseGreenAgent
from CybORG.Simulator.Actions import DiscoverRemoteSystems, AggressiveServiceDiscovery, Sleep, PrivilegeEscalate, DegradeServices, I... |
0cfaeaf59ef3ad298203a5064309a55758d7fea3825299cf872cafe777e90315 | Python | 5,885 | 155 | import logging
import traceback
from collections import defaultdict
from datetime import datetime
import yaml
from src.util import ensure_parent_dir
def write_download_metadata(filename, *, name, url="", description="", sources=None, counts=None):
"""Record where a download came from, when, and what arrived.
... |
971be3b769a20e7837c9ae532a6a1be7fa65781ada71a6cae6055df71b31524b | Python | 5,888 | 175 | from utils.QuickNII_functions import read_QUINT_JSON, find_plane_equation
from utils.generate_target_slice import generate_target_slice
import numpy as np
import cv2
import matplotlib.pyplot as plt
import nrrd
import sympy as sp
from sympy import symbols, solve
def generate_rectangular_image(img, pts):
# Define... |
67244d952b969bb79512fe8fb209b37af41ad08ae2033029a52d42e19b183c99 | Python | 5,889 | 126 | # SPDX-License-Identifier: Apache-2.0
import cv2
import onnxruntime as ort
import argparse
import numpy as np
import sys
sys.path.append('..')
from ultraface.dependencies.box_utils import predict
# ------------------------------------------------------------------------------------------------------------------------... |
0d88946a41d8f95abf561e70173f7e057a8f4c397f833e39009531fa94baba8b | Python | 5,890 | 170 | '''
Functions and classes to be deprecated soon. Some of these routines
will raise exceptions, while others will just dispay warnings.
'''
import warnings
import functools
import numpy as np
import freesurfer as fs
def deprecated(message):
'''
This is a decorator factory used to mark functions as deprecated... |
317f274e24d32657bfcb77f790455b13fe2a57a98412e8d2c0d4f9b766a5c095 | Python | 5,890 | 162 | import os
from typing import Optional
import medperf.config as config
from medperf.entities.cube import Cube
from medperf.exceptions import InvalidArgumentError
from medperf.utils import remove_path, sanitize_path, store_decryption_key
from medperf.commands.model.submit_util import ContinueCubeSubmission
import logging... |
0b22bab4501f0f0cf767227dcf98720af24b6fb6dff31a43ce0ca267be74e22f | Python | 5,893 | 163 | """Socket.IO manager for the ZnDraw client."""
from __future__ import annotations
import logging
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any
from uuid import UUID
import socketio
from zndraw_socketio import SyncClientWrapper, wrap
from zndraw.client.exceptions import NotConnectedE... |
ab29d038733bb7cac3cab562f839fd83ddf0157f72a51d1647d9717acc84e945 | Python | 5,893 | 163 | import logging
from collections.abc import Sequence
import numpy as np
from ase import Atoms
from mace.tools import AtomicNumberTable
from scipy.special import softmax # type: ignore
from simgen.generation_utils import duplicate_atoms
class SwappingAtomicNumberTable(AtomicNumberTable):
def __init__(
se... |
93bfcb88597c9ce97449ad9a80cdad413bcdb67958bbbbcadea967da95626cd4 | Python | 5,894 | 175 | import yaml
import os
import shutil
def generic_setup(output_logs):
tmpfolder = os.path.join(output_logs, ".tmp")
os.makedirs(tmpfolder, exist_ok=True)
# NOTE: this should be set before any code imports tempfile
os.environ["TMPDIR"] = tmpfolder
workspace_folder = os.path.join(output_logs, "workspa... |
9730f69569d6ca060b8ff627ada66dfd72607590d97e9d95e5b38ab96866952f | Python | 5,894 | 165 | """Preprocessing functions to extract gfp peaks."""
from typing import Optional, Union
import numpy as np
from mne import BaseEpochs, pick_info
from mne.io import BaseRaw
from mne.io.pick import _picks_to_idx
from numpy.typing import NDArray
from scipy.signal import find_peaks
from .._typing import CHData, Picks
from... |
9938fb686e677e61d0cd1027a0e8e067a3493f166b8cff334bcfdd44335824d9 | Python | 5,895 | 168 | import json
import os
from typing import List, Optional, Tuple, cast
import numpy as np
import pytest
import xgboost as xgb
from xgboost import testing as tm
dpath = tm.data_dir(__file__)
@pytest.fixture(scope="module")
def toy_data() -> Tuple[xgb.DMatrix, np.ndarray, np.ndarray]:
X = np.array([1, 2, 3, 4, 5])... |
07ed6a671b6ef2386cadfe02e18ab19c16f1c0f135d180d99c3034213fbb44be | Python | 5,898 | 152 | """Unit tests for the compact annotation_confidence encoder and legend.
Covers the robustness invariants:
RI-1 Field order = ANNOTATIONS_HEADER (single source of truth).
RI-2 Tier chars derived via tier_name[0].lower() from TIER_CONFIDENCE.
RI-4 None/empty conf_dict → fixed-width all-hyphen output.
RI-5 Un... |
017e56ed0c6b87b8f398c19893c39384a713e168b2efe37ae72f7bee13bd3ec9 | Python | 5,901 | 116 | # Copyright (c) OpenMMLab. All rights reserved.
import mmengine.fileio as fileio
from mmseg.registry import DATASETS
from .basesegdataset import BaseSegDataset
@DATASETS.register_module()
class PascalContextDataset(BaseSegDataset):
"""PascalContext dataset.
In segmentation map annotation for PascalContext, ... |
45ed5978e5fd188fdc4392e3ba5b869ef0a406ba3ba0b4376e6950ed25ba02ad | Python | 5,901 | 157 | ##
## CPCantalapiedra 2020
import shutil, os, unittest
from argparse import Namespace
from eggnogmapper.common import DIAMOND, ITYPE_CDS, ITYPE_PROTS
from eggnogmapper.search.diamond.diamond import DiamondSearcher, SENSMODE_MORE_SENSITIVE, \
ALLOW_OVERLAPS_NONE
class Test(unittest.TestCase):
def setUp(s... |
5188f43e50972de6d30f53ec282b286316c51e6d5a156e5460f907c34b8b340b | Python | 5,901 | 178 | #!/usr/bin/env python
from __future__ import annotations
import argparse
from collections import OrderedDict
import json
import logging
import os
import os.path as op
from pathlib import Path
import re
import shlex
import subprocess
import time
from typing import Any, Optional
import inotify.adapters
from inotify.con... |
fa56a867dd277254175fc21812692848a2c75423cc0cfa92ecafe680410aadaf | Python | 5,902 | 178 | """
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 logging
import os
import subprocess
from typing import List
import torch
import torch.distributed as dist
from ocpmodels.common.typi... |
4017a3c1fce297c294932a667b33ec7b9e2acdd217c07cb3f64f99a7e77868a8 | Python | 5,907 | 171 | # SPDX-License-Identifier: Apache-2.0
import atexit
import logging
import multiprocessing as mp
import random
import mxnet as mx
import numpy as np
try:
import Queue
except ImportError:
import queue
import utils
class CityLoader(mx.io.DataIter):
"""
Data Loader class for Cityscapes Dataset.
Pe... |
46d1dca890935c8188110155cd684263eeb5456a7af86a14d156cc1a8210d251 | Python | 5,912 | 129 | # SPDX-License-Identifier: Apache-2.0
import cv2
import onnxruntime as ort
import argparse
import numpy as np
import sys
sys.path.append('..')
from ultraface.dependencies.box_utils import predict
# ------------------------------------------------------------------------------------------------------------------------... |
89b1d6f7f0a4ee5c3cbc8524cc25d6bcffde873db2ba0fab4041e13c3dc068b6 | Python | 5,918 | 180 | import numpy as np
from scipy import ndimage
from scipy.ndimage import gaussian_filter
def LoG_kernel_3D(sigma):
'''Function to create a LoG kernel in 3D
input: - sigma: kernel size
output: - LoG kernel of size 6 * sigma'''
# kernel size
n = np.ceil(6 * sigma)
z, y , x = np.ogrid[-n//2... |
4a7f028c081f51095b94bb25c7fef35ba87a537366078a9c3e21895de33cb6b5 | Python | 5,921 | 150 | from transformers.models.llama import LlamaForCausalLM, LlamaTokenizer, LlamaConfig
from fengshen.models.megatron import mpu
from fengshen.models.llama.modeling_llama import LlamaForCausalLM as FengshenLlama
from fengshen.models.llama.configuration_llama import LlamaConfig as FengshenConfig
import argparse
import torch... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.