sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
3fb81d867d5ca519b034ac6e21f37a60eadd57268690807b7b13b39a70c1dc6a | Python | 4,023 | 115 | """
Outlier detection module.
"""
__all__ = ['outlier_advisory']
from genericpath import exists as pexists
from os import makedirs
from os.path import join as pjoin
import numpy as np
from scipy import stats
from sklearn.ensemble import IsolationForest
import visualqc.config as cfg
from visualqc.readers import gat... |
067e00f4290b95956bd89fa1897673d5dc92eb8f618cff27068fb5c6c64d4f86 | Python | 4,024 | 80 | import numpy as np
import pandas as pd
from sklearn.metrics import r2_score, mean_absolute_error
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
df = pd.read_csv('../CSV/Predictions/random/regression/mp_logp_tpsa/DMPNN_seed1.csv')
# Create two subplots side by side
fig, axes = plt.subplots(1, 3, f... |
0ba18b46e7cf6a2201986f568cf93496fd70d5deacd6f89298b57535f870f752 | Python | 4,024 | 167 | # -*- coding: utf-8 -*-
from bulbs.neo4jserver import Graph
from bulbs.model import Node, Relationship
from bulbs.property import Property, String, Integer, Float, DateTime
from bulbs.utils import current_datetime
# TODO: check latest gist's
# Requirements (installable with pip)
# pytz ujson six
# You need: sudo apt... |
a25be281da479df7e4f98b36a2c73c45363fa1a286d7edd058925e0ebe2ea42d | Python | 4,027 | 113 | import string
import pytest
from cutadapt._match_tables import matches_lookup
from cutadapt.adapters import KmerFinder
from cutadapt._kmer_finder import MAXIMUM_WORD_SIZE
KMER_FINDER_TESTS = [
# kmer, start, stop, ref_wildcards, query_wildcards, sequence, expected
("ACGT", 0, None, False, False, "ACGTACG", T... |
af75fedc8313b6713ff3c2df3fac0bcfeaf2d3024a686c8c43675c1cb4715f0c | Python | 4,027 | 103 | ## Restormer: Efficient Transformer for High-Resolution Image Restoration
## Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Ming-Hsuan Yang
## https://arxiv.org/abs/2111.09881
import numpy as np
import os
import argparse
from tqdm import tqdm
import torch.nn as nn
import torch
imp... |
6ea3b0ae469a36655733bef2c98807cd8772bf0bd4190307f5ae9bc9afd0225d | Python | 4,028 | 90 | from scipy.stats import bootstrap
import numpy as np
def mean_diff(sample1, sample2, axis=-1):
mean1 = np.mean(sample1, axis=axis)
mean2 = np.mean(sample2, axis=axis)
return mean1 - mean2
def calculate_bootstrap_diff_CI(sample1, sample2, confidence_level=.95, method='basic'):
data = (sample1, sample2... |
653570d8c03a9415bb2f882b9d3e42b8d4395b81919cc2550ca979bff24501a9 | Python | 4,030 | 103 | ## Restormer: Efficient Transformer for High-Resolution Image Restoration
## Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Ming-Hsuan Yang
## https://arxiv.org/abs/2111.09881
import numpy as np
import os
import argparse
from tqdm import tqdm
import torch.nn as nn
import torch
imp... |
a2cfcf45a93324ceed65ac06a9556902e9bc73e7cf265c7b66cf9b121483a979 | Python | 4,030 | 113 | import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import math
import scienceplots
import matplotlib.gridspec as gridspec
from functools import reduce
import torch
import math
from scipy import stats
import matplotlib as mpl
def cohen_d(x,y):
return (np.mean(x) -np. mean(... |
a5dcd188724a947778366449dee70b3d545b922b02aedc02212efa1f2cb69b1f | Python | 4,030 | 108 | """
This code identifies sub/ses/task/run files that have shorter than expected TRs
"""
import json
import os, glob
# Standard values based on the task and run combination
standard_values = {
"task-narratives_acq-mb8_run-01": 967,
"task-narratives_acq-mb8_run-02": 1098,
"task-narratives_acq-mb8_run-03": 1... |
7638ea96c5c2d8f2e267610ff71006c14185d1062f472e0024f559afc917bcb8 | Python | 4,034 | 126 | """Tests for ClientSettings source chain: init > env > pyproject.toml > state file."""
from __future__ import annotations
import pytest
@pytest.fixture(autouse=True)
def _clean_env(monkeypatch):
"""Remove ZNDRAW_* client env vars to isolate tests."""
for key in (
"ZNDRAW_URL",
"ZNDRAW_ROOM",... |
9fe495a82a92969012f62f8405fb19058be21873d5aec80361e048d868c5e459 | Python | 4,034 | 132 | # Copyright (c) 2021, EleutherAI
# This file is based on code by the authors denoted below and has been modified from its original version.
#
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complian... |
e4ad67ea3b106e87867d3e7815f0095cdf22e26151b086669d66f38cba6c4ab5 | Python | 4,035 | 131 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# tests/debug_tests.py
################################################################################
# EncoderMap: A python library for dimensionality reduction.
#
# Copyright 2019-2024 University of Konstanz and the Authors
#
# Authors:
# Kevin Sawade
#
# Encodermap is ... |
171c36a5fab0a97f0c096e0cd611f4871ebcd2e8f18bfaf0fc1c375f73768c07 | Python | 4,036 | 117 | #!/usr/bin/env python
#
# Copyright 2008, 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... |
4ea07d38a358e35b18548a1bd48ddd1b5cb020d72b9bc78166a3bb7714b84c2b | Python | 4,036 | 135 | import psycopg2
import pandas as pd
import sys
import spacy
import re
import stanfordnlp
import time
import scispacy
from tqdm import tqdm
from heuristic_tokenize import sent_tokenize_rules
# update these constants to run this script
OUTPUT_DIR = '/PATH/TO/OUTPUT/DIR' #this path will contain tokenized notes. This di... |
80b7f010bcfc17f166cf92fde70010ec181e6ba10caf49a14836f65f990b2afe | Python | 4,039 | 64 | # 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... |
b90274aabeff0662c1c670ba266f49ab7309de9c4c59348cb9980f2e187d0a36 | Python | 4,040 | 121 | import torch
import torch.nn as nn
from collections import OrderedDict
# -------------------------
# Depthwise Separable Convolution Block for MobileNetV1
# -------------------------
class DepthwiseSeparableConv(nn.Module):
def __init__(self, in_channels, out_channels, stride=1):
super(DepthwiseSeparableCo... |
be067e7f124c077bb3332bff67c503561aed9f7c5edb5676fed97e398373cc03 | Python | 4,040 | 97 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn.functional as F
from mmengine.structures import PixelData
from torch import Tensor
from mmseg.registry import MODELS
from mmseg.structures import SegDataSample
from mmseg.utils import SampleList
from .fcn_head import FCNHead
@MODELS.registe... |
24d9e5e2354504835d43fc6487720660e334425d9f77b9ef5de54a90be77de75 | Python | 4,043 | 121 | """Parse, validate, and write user-supplied custom event timestamps.
This module backs the optional "Import Custom Events" GUI step. A custom event
is written as a GuPPy-compatible event CSV — a single column with the header
``timestamps`` and one timestamp (in seconds) per row — into a session folder.
``detect_acquis... |
a20fbe0677de77643859335eb8cc9696d3504cc9a50b8c7beb55a38630458dc6 | Python | 4,043 | 104 | """
PyTorch policy class used for PPO.
"""
import gym
import logging
from typing import Dict, List, Type, Union
import ray
from ray.rllib.agents.ppo.ppo_tf_policy import setup_config
from ray.rllib.agents.ppo.ppo_torch_policy import *
from ray.rllib.evaluation.postprocessing import *
from ray.rllib.models.modelv2 im... |
7fd0e95da8cc71ba3264bd10a7baff221c1b57d5178812924cb90dd28aaedc6d | Python | 4,044 | 139 | from torch.nn import Module
import torch
from torch.nn.parameter import Parameter
def get_tau_trainer_class(name: str):
if name == "interpolation":
return InterpolationTrainer
elif name == 'interpolationExpSigmoid':
return InterpolationExpSigmoidTrainer
elif name == "fixed":
return... |
aa13d8e188f61c5bee2395b1cabb38fe916ef4794116b31326407f80dcbbca0e | Python | 4,045 | 116 | from typing import Set
from CybORG.Shared.Enums import DecoyType
from CybORG.Shared.Observation import Observation
from CybORG.Shared.Session import Session
from CybORG.Simulator.Actions import Action
from CybORG.Simulator.Actions.AbstractActions.Misinform import Decoy, DecoyFactory
from CybORG.Simulator.Host import Ho... |
803e53da3d7b7f462255e1e2ce85b35fe338baf80fc38b08d992b98e68f5b283 | Python | 4,049 | 127 | from glob import glob
from itertools import product
import os, itertools
from bdpy.evals.metrics import pattern_correlation, pairwise_identification
import numpy as np
import pandas as pd
from PIL import Image
# Main #######################################################################
def recon_image_eval(
... |
8271a95ddb8f200979e685ac1df3644dc1200fb4546321418a6c8157849c0131 | Python | 4,049 | 132 | from Utils.dataloader_BrainTumorMRI import *
from Utils.config import *
from Utils.models import *
from Utils.TrainModel import *
from multiprocessing import Process
from codecarbon import EmissionsTracker
import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
def task(lr, data_partition:flo... |
0db7984eb47b7b922ac7d6bbfe56e2319ffbc85402743612ee9516b036b9c080 | Python | 4,051 | 122 | # medperf/web_ui/api/routes.py
import os
from pathlib import Path
from typing import Optional
from fastapi import APIRouter, HTTPException, Form, Depends, Query
from fastapi.responses import JSONResponse
import medperf.config as config
from medperf.exceptions import InvalidArgumentError
from medperf.web_ui.... |
a8c8068aa42489f5e3d105a20939c9af7628c04da78dea8b943fcc393a2d27a8 | Python | 4,054 | 108 | import torch
import torch.nn as nn
from nnunet_mednext.network_architecture.custom_modules.custom_networks.SwinUNETR.swinunetr import SwinUNETR as SwinUNETR_Orig
from nnunet_mednext.training.network_training.nnUNet_variants.architectural_variants.nnUNetTrainerV2_noDeepSupervision import \
nnUNetTrainerV2_noDeepSupe... |
e5e5cbd405fae0e3a81fc0557a6228595453777a4c6ebc473993fa3bd4548d4d | Python | 4,056 | 111 | import pytest
from CybORG.Simulator.Actions.Action import InvalidAction
from CybORG.Simulator.Process import Process
from CybORG.Simulator.Scenarios.EnterpriseScenarioGenerator import EnterpriseScenarioGenerator, SUBNET
from CybORG.Agents import SleepAgent, EnterpriseGreenAgent
from CybORG.Simulator.Actions.AbstractAc... |
d8a35bfc9a830ed83008668e0ba722ed2e83085864618732193c2f918af7839a | Python | 4,057 | 91 | ######################################
# wrapper for rule: alignment_single_genomic
######################################
import os
import sys
import math
import subprocess
import glob
from snakemake.shell import shell
STAR = "STAR"
SAMTOOLS = "samtools"
BEDGRAPH2BIGWIG = "bedGraphToBigWig"
shell.executable("/bin/ba... |
e7f97574b614c05f432b56ac47f4a5621c014d133bbd74d565066b0e1da4fe39 | Python | 4,057 | 116 | from collections import namedtuple
import os
import os.path as op
import pytest
from mock import patch
try:
from tinydb import TinyDB, Query
except ImportError:
pytest.importorskip("tinydb")
from subprocess import CalledProcessError
try:
from heudiconv.cli.monitor import (monitor, process, run_heudiconv,
... |
b5f355b50f0848ec998bdd51feb72472da963ab068297a1a89550ae03d409e8c | Python | 4,058 | 122 | # -*- coding: utf-8 -*-
# A file to contain exclusively dependencies of the NeuroML package.
# See:
# https://github.com/NeuralEnsemble/libNeuroML
# http://neuroml.org
import logging
from collections import defaultdict
from typing import Any, DefaultDict, Dict, List
try:
from neuroml import Cell, Segment,... |
fe9f7f11a0afaddb77a8c1a927780b49de1ac936a83549ba0defe4df12ef2607 | Python | 4,058 | 143 | import contextlib
import logging
import shutil
import sys
import tempfile
import unittest
from io import StringIO
import pytest
from xgboost import testing as tm
pytestmark = [pytest.mark.skipif(**tm.no_spark())]
from pyspark.sql import SparkSession
from xgboost.spark.utils import _get_default_params_from_func
c... |
73091c5f81b01ae2d70f721196b80f9ecb5b7960943a12570445ad8495926a4c | Python | 4,060 | 122 | import numpy as np
import pytest
import h5py
from .common import TestCase
class TestDatasetSwmrRead(TestCase):
""" Testing SWMR functions when reading a dataset.
Skip this test if the HDF5 library does not have the SWMR features.
"""
def setUp(self):
TestCase.setUp(self)
self.data =... |
6e1a8e3504aebc43d83c033209a589703c7d80df620bf065e8658c1aee129eeb | Python | 4,062 | 129 | # Copyright (c) OpenMMLab. All rights reserved.
import functools
import numpy as np
import torch
import torch.nn.functional as F
from mmengine.fileio import load
def get_class_weight(class_weight):
"""Get class weight for loss function.
Args:
class_weight (list[float] | str | None): If class_weight ... |
096bfd60efbf063524ed41b384e5cf369c8e4a54f71643c18292dc531f75cf32 | Python | 4,066 | 145 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Andrei Istudor andrei.istudor@gmail.com
"""
from os import path
from PyQt5 import QtCore
from TaskState import TaskState
class PhenoTask(QtCore.QObject):
'''
Class encapsulating one video file and it's current status.
Every time a vide... |
efd25826389d9d6b88fb0be75d2728cb04f542d1913aa435fc3d4efc3309dae8 | Python | 4,066 | 133 | import urllib.request
from pathlib import Path
from zipfile import ZipFile
import pytest
from n2v.internals.N2V_DataGenerator import N2V_DataGenerator
from n2v.models import N2VConfig, N2V
@pytest.fixture(scope="session")
def temp_dir(tmp_path_factory):
# create temp dir
tmp = tmp_path_factory.mktemp("data"... |
3c9823448124df7efbc8bc37c57468315f43fe224ddfb23c19314fb3871ac298 | Python | 4,068 | 96 | from sklearn import metrics
from munkres import Munkres
import numpy as np
from sklearn.manifold import TSNE
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# Tmp
# Ref: https://github.com/MysteryVaibhav/RWR-GAE
class clustering_metrics:
def __init__(self, true_label, predict_label):
... |
dcc57bd877c94c8f8a8b3361aa265579e38d85f56178dc96ed81b876d8d32a73 | Python | 4,068 | 125 | from __future__ import annotations
import numpy as np
import pytest
from chgnet.graph.graph import DirectedEdge, Graph, Node, UndirectedEdge
@pytest.fixture
def graph() -> Graph:
"""Create a graph with 3 nodes and 3 directed edges."""
nodes = [Node(index=idx) for idx in range(3)]
graph = Graph(nodes)
... |
fb995dc7a4b3dea90fbe94afdb057f73a4d11d88932a3ca06d2e07ca66c03694 | Python | 4,069 | 120 | # pytest unit tests for spinalcordtoolbox.reports
import logging
import pytest
import numpy as np
from spinalcordtoolbox.image import Image
from spinalcordtoolbox.reports.slice import Sagittal
from spinalcordtoolbox.reports.qc import generate_qc
from spinalcordtoolbox.utils.sys import sct_test_path
logger = loggin... |
5ef131ce78d5504e7617912042dc07d644c3b54888d387eebbc9168814b61280 | Python | 4,070 | 151 | import numpy as np
from nearl import all_actions
# from nearl import features
agg_map = {
1: "mean",
2: "std",
3: "median",
4: "variance",
5: "max",
6: "min",
7: "sum",
8: "slope",
}
def get_mean(points):
return np.mean(points)
def get_std(points):
return np.std(points)
... |
8bd57b129412b94bcebb647db58aa62b0a7fabf916b04240f2b2d1205e054824 | Python | 4,070 | 83 | # %%
import os, re, glob
import argparse
import matplotlib.pyplot as plt
import nibabel as nib
import numpy as np
import pandas as pd
from pathlib import Path
from nilearn.datasets import fetch_language_localizer_demo_dataset
from nilearn.glm.first_level import first_level_from_bids
from nilearn.glm.first_level import ... |
12142b333e8be2403bf96f4a142eb3c07943e6262567e8e1a6a7edfd304acccd | Python | 4,073 | 123 | import torch # type: ignore
import torch.utils # type: ignore
from torchvision import models, transforms # type: ignore
import pandas as pd # type: ignore
import numpy as np # type: ignore
from code_files.utils import ( # type: ignore
set_seed,
worker_init_fn
)
from code_files.preprocessing import ( # type: ... |
cb19ed471277abdb1d61121a9107d09f4f461cf6d62536fbe74f0292669ca6b0 | Python | 4,073 | 112 | """Tests for room REST API endpoints."""
import pytest
from httpx import AsyncClient
from zndraw.schemas import RoomCreateResponse
async def _get_user_token(
http_client: AsyncClient,
email: str,
password: str = "testpassword",
) -> str:
"""Register a user and get their auth token."""
reg_respon... |
e3741f3abf542199f68f8ea0b09b5547b0f2dd60c0d1750b76a0ef1c5efaac57 | Python | 4,073 | 128 | #!/usr/bin/env python
"""
MetaWIBELE: split_family_abundance module
Split the abundance of families
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 the Soft... |
5cf762ba8f797824b2f2353a122c7b20939e3f0ca80d50b83f22f1153dbbaba4 | Python | 4,075 | 146 | """Copyright 2024, XGBoost contributors"""
import json
import os
import tempfile
from typing import Type, Union
import numpy as np
import pytest
import xgboost as xgb
pl = pytest.importorskip("polars")
@pytest.mark.parametrize("DMatrixT", [xgb.DMatrix, xgb.QuantileDMatrix])
def test_polars_basic(
DMatrixT: Un... |
57cf7d321e7ef95641e7e78aa587d28bbc0714bba351a200085aed90fbf4e8a3 | Python | 4,076 | 105 | '''
get example grid cell tuning by averaging spike count
'''
import numpy as np
import matplotlib.pyplot as plt
from grid_cell.util import select_arr_by_t, remove_ax_frame
import grid_cell.tuning as gct
from scipy.ndimage import gaussian_filter # for smoothing grid cell tuning
from grid_cell.util import get_data_filen... |
b0b7467861c06ad45b35427f4d2c97ed61957ec579e24e1e37df659ea1e29c69 | Python | 4,076 | 105 | import numpy as np
import os
import pandas as pd
import re
from scipy.spatial import Delaunay
import matplotlib.pyplot as plt
from matplotlib.tri import Triangulation
import ast
file = 'labels.csv'
df = pd.read_csv(file)
patient_label = {i:j for i,j in zip(df['Patient'],df['Group'])}
file = 'CRC_clusters_neighborhoods... |
2006759a07e8f56cb2055333185fecf2339730067acd4c6d09984beecc4e26e7 | Python | 4,077 | 112 | from ast import parse
import os
import psutil
import time
import random
import numpy as np
import scanpy as sc
import torch
from torch.utils.data import DataLoader
import argparse
from dataset import Dataset
from model import SpaCLR, TrainerSpaCLR
from utils import get_predicted_results
import pandas as pd
import warn... |
2b9e93d0709a60c73e058410d77ed398f84d70ece50cbb597d9b11d945449a1b | Python | 4,077 | 120 | import glob
import os
import shutil
import numpy as np
from PIL import Image
def check_maskid(train_imgs):
for i in train_masks:
img = Image.open(i)
print(np.unique(np.array(img)))
def reformulate_file(image_list, mask_list):
file_list = []
for idx, (imgp,
maskp) in enumer... |
1902c57c533d423b655705bc28a6d6d964b7f4d11c24600b085729ad29c1d519 | Python | 4,078 | 135 | from medperf.enums import Status
from medperf.exceptions import InvalidArgumentError
import pytest
from medperf.commands.association import utils
@pytest.mark.parametrize("dset_uid", [None, 1])
@pytest.mark.parametrize("mlcube_uid", [None, 1])
@pytest.mark.parametrize("bmk_uid", [None, 1])
@pytest.mark.parametrize("t... |
8805be472cec06d7279370ac1fdab91b12adcca0ac4846cc3a12e621bd5d9092 | Python | 4,078 | 94 | #!/usr/bin/env python3
"""
The purpose of this script is to convert redcap data (ethnicity, gender, race)
into a table for Inclusion Enrollment Report
Parameters
------------
csv_fname: str
the REDcap downloaded file, which contains ethnicity, gender, race information
Return
------------
df_tally: pand... |
6a305e72bb54c0c64f64d9c1835d65678f355b3e8d623bde3af1615c0e68b177 | Python | 4,079 | 115 | # SPDX-License-Identifier: MIT
import numpy as np
def area_of(left_top, right_bottom):
"""
Compute the areas of rectangles given two corners.
Args:
left_top (N, 2): left top corner.
right_bottom (N, 2): right bottom corner.
Returns:
area (N): return the area.
"""
hw = n... |
8a07bbdc4d4cde37174515340eae4c427b6fdce86922907b408d1ec984fd65f7 | Python | 4,080 | 115 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import glob
import imageio
import numpy as np
import SimpleITK as sitk
import transformations as T
import tensorflow as tf
import sys
sys.path.append('/vol/medic01/users/bh1511/_build/geomstats-farre... |
29dfe21725584c67b143dbd9c6994191a05886b8524e5dad64b596f156ca5e33 | Python | 4,082 | 124 | """Testing conversion with conversion saved on datalad"""
from glob import glob
import os
import os.path as op
import pytest
from heudiconv.cli.run import main as runner
from heudiconv.external.pydicom import dcm
from heudiconv.utils import load_json
# testing utilities
from .utils import fetch_data, gen_heudiconv_ar... |
ab44bef96b58e7668782420450d58ae3529615e7b4bf16f465678f8851babf7d | Python | 4,083 | 106 | import os
import tarfile
from rano_monitor.constants import REVIEWED_FILENAME
from rano_monitor.utils import is_editor_installed
from rano_monitor.widgets.tarball_subject_view import TarballSubjectView
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Center,... |
d2c534f791806915cfb5a8a8884dc4fdf8805061bff035a7393a349aaa18a125 | Python | 4,084 | 86 | import numpy as np
def concatenate_and_realign_data(
segments: list[tuple[np.ndarray, np.ndarray]], *, timeForLightsTurnOn: float, sampling_rate: float
) -> tuple[np.ndarray, np.ndarray]:
"""Concatenate ordered data segments and realign their timestamps into one continuous series.
The first segment's tim... |
543d34d5dd673dd47ab3805f265f794149638cc8552af3cfa4865619a1a90699 | Python | 4,089 | 109 | from django.db import migrations, models
import django.contrib.gis.db.models.fields
forward = """
BEGIN;
ALTER TABLE treenode_connector_edge RENAME TO treenode_connector_edge_old;
-- Create new version of the treenode_connector_edge table, which uses the
-- bigint data type for its ID. All other con... |
8aeec3d0eb35a5e94ec91c2a774bb2917c415570a51dc8941d021c33b6cb145f | Python | 4,089 | 84 | from langchain.prompts import PromptTemplate
from langchain.chains import RetrievalQA
from langchain.vectorstores import Chroma
import sys
sys.path.append("../")
from qa_chain.model_to_llm import model_to_llm
from qa_chain.get_vectordb import get_vectordb
import sys
import re
class QA_chain_self():
""""
不带历史记录... |
1a4c8f166ca6d8bca9627f87f62e2b55fb5ce1be677677cce9d97b1585955936 | Python | 4,094 | 132 | # coding=utf-8
import unittest
from hw3.src.lib.ScoringFunction import entropy, sum_of_pairs
from hw3.src.lib.ScoringMatrix import blosum_62
__author__ = 'burkhart'
S_FUNC_EPSILON = 0.01
class TestScoringFunction(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def t... |
c2e12caab83c1ba59961552010f7521f6e9f50559d6209cf65359a0d8b59529f | Python | 4,096 | 116 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.models.decode_heads.decode_head import BaseDecodeHead
from mmseg.registry import MODELS
class UpBlock(nn.Module):
"""Upsample Block with two consecutive convolution layers."""
def __... |
aee1c288a5a60a0c5df64b9e35f4c755f9c524c8caa4a010893e38dcf3c5b31d | Python | 4,097 | 88 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
0e4b185a85a4f0a61da68b3ad6dbdc7954d76e9f87b23a011b8fe0d6399d5dbd | Python | 4,099 | 118 | # 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 --------------------------------------------------------------
# If ex... |
2100d079ffe43680b5177d17a9e8f31701e186d21c6a60ffcd49578eab641de3 | Python | 4,101 | 118 | # 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 --------------------------------------------------------------
# If ex... |
a2f5ced42a34e77f7d0c7c85e197e858928341966151883ca1404489f7ca279b | Python | 4,103 | 118 | #!/usr/bin/env python
"""
psortb_annotator.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Run PSORTb to predict secreted peptides based on representatives of clusters
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 docum... |
a0a5cd4f99ff1bece685f34e06c887ea3fb66800f0e7ac088ff50b463bc4ad27 | Python | 4,104 | 125 | import ase
import numpy as np
from ase.data import covalent_radii
from frozendict import frozendict
from hydromace.interface import HydroMaceCalculator
from simgen.hydrogenation_deterministic import build_xae_molecule
NATURAL_VALENCES = frozendict(
{1: 1, 6: 4, 7: 3, 8: 2, 9: 1, 15: 3, 16: 2, 17: 1, 35: 1, 53: 1}... |
8b48c2a11169203365ab2b54be4390579eb6b116e421a0cd49978d76a981663b | Python | 4,105 | 113 | import sqlite3
from ..Helper_funs.utils import get_canonical_and_alias
class MoleculeDatabase:
def __init__(self, db_filename: str = "molecules.db"):
self.db_filename = db_filename
self.conn = None # Connection will be created when needed
def _connect(self):
"""Internal method to es... |
342369edef2fcae36a0af92b4bacf4bd8969668c983ee26106a3bcb417ac42dc | Python | 4,106 | 123 | import torch
import time
import torch
import torch.distributed as dist
import torch.nn.functional as F
import utils
def val_epoch(
epoch,
data_loader,
model,
criterion,
device,
logger,
tb_writer=None,
distributed=False
):
print('validation ... |
2c6abd68fd590ac6d9bd5f6f8462cd2f5aed174408b649b95d0f8a1de1d195ee | Python | 4,107 | 127 | # Copyright (c) OpenMMLab. All rights reserved.
"""Use the pytorch-grad-cam tool to visualize Class Activation Maps (CAM).
requirement: pip install grad-cam
"""
from argparse import ArgumentParser
import numpy as np
import torch
import torch.nn.functional as F
from mmengine import Config
from mmengine.model import r... |
0f167b89215e5be8ebb5bf12cf08d64e029cacdbe98d1f51e2dc6b7bb21c3bbb | Python | 4,110 | 98 | #!/usr/bin/env python2.7
import os
import argparse
import subprocess as sp
import multiprocessing as mp
import shlex
import datetime
import re
import chisel
src = os.path.dirname(chisel.__file__)
from ..Utils import *
def parse_args():
description = "CHISEL command to run the pipeline starting from inferred co... |
6ebfd40b310b41b287e095bcdbc808de5b11aa9d7309c25436ec6f75e6f340b3 | Python | 4,110 | 114 | """Phase 8 / v3.2 — backend selection tests for the delta-varint codec.
The public `eggnogmapper.annotator.codec` is a shim that prefers the Cython-
compiled `_codec` extension and falls back to pure-Python `codec_py`
when the extension wasn't built (no Python.h in the install env). These
tests assert that:
1. Whiche... |
cf0ec90e1a176fb95bc30bedfd66ee5a72249542ca015e5d842e392f53788fe3 | Python | 4,112 | 115 | """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:
... |
fa140d6ed65624c3f66e5eee14e7eb4edccd41a91d318c8f52fa7d6b970a6528 | Python | 4,114 | 71 | import os
def create_key(template, outtype=('nii.gz','dicom'), annotation_classes=None):
if template is None or not template:
raise ValueError('Template must be a valid format string')
return (template, outtype, annotation_classes)
def infotodict(seqinfo):
"""Heuristic evaluator for determining w... |
1086220bddea554fe937fcf877f0b81ea97baf8e1f6c5bd9d3da00179befd071 | Python | 4,115 | 85 | """
Spinal cord flattening in different planes
Copyright (c) 2020 Polytechnique Montreal <www.neuro.polymtl.ca>
License: see the file LICENSE
"""
import logging
import numpy as np
from skimage import transform, img_as_float
from spinalcordtoolbox.image import change_type
from spinalcordtoolbox.centerline.core impor... |
280e5c48b8ade964ef8887b19590b5c1e3f47c6d9912295e467462af00d3376f | Python | 4,115 | 120 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 2 14:53:24 2023
@author: george
"""
import flika
from flika import global_vars as g
import os
from qtpy.QtCore import *
from qtpy.QtGui import *
from qtpy.QtWidgets import *
# function to prompt user to select a file for opening
def open_file_gui... |
e9b68d46e50f5b1a359b66739192de0c4c470ce9a882ba350956703816d261c8 | Python | 4,115 | 121 | import itertools
import typing as T
import tqdm
import numpy as np
import tsgm
from tsgm.backend import get_distributions
# Lazy loading of distributions
distributions = None
def _get_distributions():
global distributions
if distributions is None:
distributions = get_distributions()
return dist... |
2e80637cbd02797d4b007991761ff21de154135af434ff624d8ebab2eeae2ed9 | Python | 4,116 | 99 | #!/usr/bin/env python
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the Heudiconv package for the
# copyright and license terms.
#
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Bits of packaging metada... |
4330b65010b04c4d06c1100d042134967e160aa3f1d1c8a9136a9b0fbbb2decf | Python | 4,116 | 106 | ## The following code contains work of the United States Government and is not subject to domestic copyright protection under 17 USC § 105.
## Additionally, we waive copyright and related rights in the utilized code worldwide through the CC0 1.0 Universal public domain dedication.
"""
pertaining to actions that escala... |
d70f9881b29fa1a683a904211b6887c5b4a4ac531b26b9607fb5ab8d4c1b10ae | Python | 4,118 | 91 | import os
import torch
from torch import nn
from transformers import LlamaConfig, LlamaForCausalLM
from transformers import BitsAndBytesConfig
def get_model(args):
if args.model_name == 'llama2':
dev_map = 'auto' if args.use_cuda else 'cpu'
model = HuggingFaceModelWrapper(args.model_name, args.n_la... |
e06e28e81b3ffc97245da116ff37c5b3624e747c0f5deede231e4b4fd4394e81 | Python | 4,118 | 115 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import psycopg2
import os
import yaml
first_migration = '2011-07-10T19:23:39'
try:
conf = yaml.load(open(os.path.join(os.environ['HOME'], '.catmaid-db')))
except:
print >> sys.stderr, '''Your ~/.catmaid-db file should look like:
host: localhost
databa... |
6a04e3131e8b505ac9259b856d34ff099fa14ea4c15660833b828cd0512577b6 | Python | 4,120 | 122 | #!/usr/bin/env python3
import os, sys, time, traceback
import argparse, multiprocessing
# get the path of this script and add it to the "pythonpath"
SCRIPT_PATH = os.path.split(os.path.realpath(os.path.abspath(__file__)))[0]
sys.path.insert(0, SCRIPT_PATH)
from eggnogmapper.emapperException import EmapperException
f... |
bc2f51b8db37695368458989bc0fb78e841ec8d982273466c2886f2270e00278 | Python | 4,122 | 103 | """
Unit tests for src/createcompendia/drugchemical.py.
These exercise _validate_and_apply_manual_concords, which validates manual
concord pairs against the chemical compendia and normalises their CURIEs.
"""
import logging
import pytest
from src.createcompendia.drugchemical import _validate_and_apply_manual_concor... |
699180ce1f8a077c2fd46c208daa85b407b0dff564239467c0573fc249a3d75a | Python | 4,123 | 93 | import os
import sys
import uvicorn
import torch
from fastapi import Body, FastAPI
from transformers import T5Tokenizer, MT5ForConditionalGeneration
import pytorch_lightning as pl
sys.path.append(os.path.abspath(os.path.join(
os.path.dirname(__file__), os.path.pardir)))
os.environ["CUDA_VISIBLE_DEVICES"] = '5'
os.e... |
9e9ded6ccfab21c9be79bdc06441f55984155d620c823b3d79348064919b95f6 | Python | 4,123 | 144 | """bluepyopt.parameters tests"""
"""
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
b... |
484d7531287b72f0b8563a147d1c89f8c47c4b20bbe359cbcbb1e030158b87fd | Python | 4,124 | 116 | ##
## CPCantalapiedra 2020
import os
import multiprocessing
import subprocess
from tempfile import NamedTemporaryFile
from ...emapperException import EmapperException
from ...common import get_pfam_db, get_data_path, set_data_path, HMMPRESS
from .pfam_common import filter_fasta_hmm_files, wrap_group_queries_pfams
fr... |
3abbb4bb49032d8e6a8b76662600ab0f6295d21397429e7ef9711c7bdbafa9bf | Python | 4,128 | 116 | import logging
import os
from pyalfe.data_structure import PipelineDataDir, Tissue, Modality
from pyalfe.image_processing import ImageProcessor
from pyalfe.tasks import Task
class T1Postprocessing(Task):
"""This task postprocesses the t1-derived tissue segmentation
to generate ventricles segmentation.
A... |
cfcaac2df61d044dbefd5e571ff44cfe35ecaf9912cc1bb36f3e95ae361f63b3 | Python | 4,128 | 144 | """
Original
File: create_posenet_lmdb_dataset.py
Link: https://git.io/fpPuw
Author: Alex Kendall <https://alexgkendall.com>
Modified
File: make_dataset_kingscollege.py
Author: Benjamin Hou <bh1511@imperial.ac.ukm>
Download KingsCollege Dataset:
http://mi.eng.cam.ac.uk/projects/relocalisation/#dataset
"""
import arg... |
4db239241eaca940d12e27eafb822bb235860654fcfe31f8cb983a772282472e | Python | 4,130 | 92 | import pytest
from playwright.sync_api import expect
def _ensure_parameter_selection_card_expanded(page):
"""Open the Parameter Selection card if not already open.
The Panel server is session-scoped (see tests/UI/conftest.py::live_server),
so the Card's collapsed state persists across tests. Naively clic... |
fd3b4f9276396e15a44789405f481e962402a9a2c1719f332dd97bd47dc6d04e | Python | 4,131 | 112 | # -*- coding: utf-8 -*-
# This implementation is based on
# https://github.com/m-haziq/django-rest-swagger-docs#integrating-django-rest-swagger
from rest_framework.schemas.coreapi import AutoSchema
from urllib.parse import urljoin
import yaml
import coreapi
import logging
logger = logging.getLogger(__name__)
class... |
13e70b43bc2a8d67a051b6a0753057ace2889c403b114fe467cb459aefa26bb8 | Python | 4,133 | 123 | """
Script to generate gifs from traj
Note:
This is just a quick way to generate gifs and visalizations from traj, there are many parameters and settings in the code that people can vary to make visualizations better. We have chosen these settings as this seem to work fine for most of our systems.
Requirements:
povr... |
14e20407e929ad7e7b4d6b877b1b454ca11ba3c70e49a560fe00f5390a0515d7 | Python | 4,136 | 106 | try:
import cPickle as pickle
except:
import pickle
import gzip
import numpy
import os
import matplotlib
import matplotlib.pyplot as plt
from scipy import integrate
import pandas as pd
"""DATA IMPORT"""
base_dir1 = '/mnt/csoport31-2/Modellezo_csapat/CA1_pyramidal/Spine_project_validation_results60/Basic_set_n... |
31bc2eec993774a1684c8a4202279eb4cce10dffbecef3f9bd967cf6db3c9eb3 | Python | 4,136 | 131 | import shutil
from pathlib import Path
import numpy as np
import pytest
from guppy.testing import compare_output_folders
from guppy.testing.api import (
locate_run_folder,
remove_artifacts,
select_artifact_windows,
step1,
step2,
step3,
step4,
)
from guppy_test_data import TESTING_DATA, eve... |
3ef3be82f8ea4beb4e19c6ecbfcd76d73a5672021491cc0609524323863cf8ba | Python | 4,137 | 104 | # 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... |
6de95b4b0b785a5687ae451bc00932d1c884d2b292be081d044fc0358ad1919f | Python | 4,137 | 113 | import typer
import medperf.config as config
from medperf.decorators import clean_except
from medperf.commands.association.list import ListAssociations
from medperf.commands.association.approval import Approval
from medperf.commands.association.priority import AssociationPriority
from medperf.enums import Status
app ... |
e6edddd326841dcb3a50c107b0ed37ceee16f35d34714f7ef4fba696789b5648 | Python | 4,138 | 133 | #!/usr/bin/env python
"""
MetaWIBELE: extract_complete_ORF_seq module
Extract sequences of complete ORFs
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 the... |
c7237c2772ae07a99c2da6c347c619ddfd7673f61f87ae9493ff344629ea54da | Python | 4,145 | 90 | import shutil
from pathlib import Path
import pandas as pd
import pytest
from guppy.testing.api import locate_run_folder, step1, step2, step3, step4
from guppy_test_data import STUBBED_TESTING_DATA
SESSION_SUBDIR = "csv/sample_data_csv_1"
# Recording-site name deliberately contains an underscore — the core of issue ... |
45ceef6c381dfd328e39d43bbf222c327ecc785a4573f866c69bfd49c03160b1 | Python | 4,146 | 129 | """Transfer semantics: collision -> 409; happy path -> room_renamed."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from httpx import AsyncClient
ADMIN_EMAIL = "admin@local.test"
ADMIN_PASSWORD = "adminpassword"
async def _register_and_login(
client... |
52e31c834cb3d797ed119d2785585a81db8651219c6be1f7593f81886a9ff7a5 | Python | 4,146 | 113 | import os
from medperf.exceptions import (
DecryptionError,
EncryptionError,
ExecutionError,
MedperfException,
)
from medperf.utils import run_command
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives impor... |
920e59abe3833e55d97ccfdec180816bc111590cd97ecc65bc58350818a24e79 | Python | 4,146 | 106 | import itertools
from skimage.filters import gabor_kernel
from skimage.transform import resize
from scipy.ndimage import convolve
import torch
from torch.utils.data import Dataset
import numpy as np
class GaborDatasetOrientation(Dataset):
def __init__(self, gabor_mode, n_samples, topdown, image_size=28, noise=0):... |
fbd5d87d189f3d93f02ad26543a3af72a95ec23a9d6de8dfd83cf9d11dda6472 | Python | 4,147 | 85 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import scienceplots
import matplotlib.gridspec as gridspec
import seaborn as sns
from matplotlib.lines import Line2D
gs = gridspec.GridSpec(1, 2, width_ratios=[0.5, 0.5])
agents = [
'Centaur',
'Llama',
'Human',
]
plt.style.use(['natur... |
4cb390196196ee930387dd7b7a71600eece62b2f33fe938b66fca84cac5b6b57 | Python | 4,148 | 110 | """
This scripts trains a graphTRIP model to predict BDI scores.
The model config are the same as the graphTRIP config, except
for the prediction target.
Dependencies:
- experiments/configs/graphtrip.json
Outputs:
- outputs/graphtrip_bdi/weights/
- outputs/graphtrip_bdi/permutation_importance/
Author: Hanna M. Tolle... |
fc1af525076ea904adf07c8ebc1272b81def66040edbf617036a0b96b2e0f188 | Python | 4,148 | 123 | """Tests for FrameStorage with AsyncBlobIO subscript API."""
import uuid
import pytest
from helpers import make_raw_frame
from zndraw.storage import FrameStorage
@pytest.fixture
def room():
"""Unique room ID per test to avoid memory:// backend pollution."""
return uuid.uuid4().hex
@pytest.mark.asyncio
as... |
519c37f817fc845a415fa284e031cc366630f2e66c6bd7b809f2af11718849fd | Python | 4,150 | 125 | """Thin sqlite3 connection holder for eggnog-mapper output and version display.
In v3 the only supported schema is v7 (integer-encoded). This module
provides:
- The shared singleton `AnnotDB` (open once, kept on a module global so
output.py and the annotator share one connection).
- A 226 MB `_taxids` array preload... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.