sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
d3bc2988cdd8c4aeb47b503f203a1335aab35e2dc4699ca16fc35fcca971a574
Python
6,148
178
#!/bin/python3 # Utility functions for displaying and storing data # Copyright 2021-2024 Jannik Luboeinski # License: Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0) # Contact: mail[at]jlubo.net import time from datetime import datetime import os import re ###################################################...
48776d72249dc38c12e8d4c9b6c09883f14f669cfccb7ffe82e6def6543b85d5
Python
6,150
195
# ----------------------------------------------------------------------------- # Copyright © 2023- The Spyder Development Team # # Released under the terms of the MIT License # (see LICENSE.txt for details) # ----------------------------------------------------------------------------- """Provides utility functions f...
027a78b1e6ab1ad275ab3b2740fd15fd772253c9b487a7ac7b131d0bb72e364a
Python
6,151
154
''' LiFH ''' import numpy as np import sys def intro(): print(""" SHORT List of potential energy surfaces for LiFH: P: potential energy, G: Gradient, D: Nonadiabatic coupling vector U: diabatic potential energy matrix UG: gradient of diabatic potential energy matrix This is listed at the end...
0914228a55d70544e8f5bfd53db6926d524425e4a1c61ed958647b0d0c978b43
Python
6,151
193
#!/usr/bin/python # ## @file # # AA Opto-electronics AOTF control. # # This class saves the set frequency for each channel # to make it easier to implement a frequency offset # function. # # Hazen 12/10 # import time import storm_control.sc_hardware.serial.RS232 as RS232 ## AOTF # # Class for cont...
41a43f40f26447374a9d89b4822a9675c55d71bbb5510731d8772f349570728b
Python
6,152
171
# 移除 s1 层 import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from model.coatnet import conv_3x3_bn, MBConv # Assuming conv_3x3_bn and MBConv are defined elsewhere in your code class hswish(nn.Module): def forward(self, x): return x * F.relu6(x + 3, inplace=Tru...
a21703bb49d77e558e869a613ad09f8146c227b74c08d2c0a22befe54ff73bd4
Python
6,152
164
import numpy as np import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec from matplotlib.colors import is_color_like class OrthoAxes: def __init__(self, fig, coords, interactive=True, closest_threshold=10): # Creating figure at the right size and ratios size = coords.ptp(axis=1...
6bb0fd317cd588da77cf1ebf79282991fc5c9229adae71606d1b195bff4ff3c9
Python
6,154
144
# -*- coding: utf-8 -*- # # partition.py # # Copyright 2020 Amazon.com, Inc. or its affiliates. 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....
8b23b42ecfb93be83bb3eba904488dcad78328b45223dc867691b9b1c5646f3f
Python
6,154
144
####################################################################################### ### Functions to calculate the mutual information from the firing rate distribution ### ### in a network at two different times ### ########################################################...
c1f7317283c66436dd07c94f042cbbdceec04bd34e1bcc52402b9a5f1113a6c7
Python
6,155
141
from collections.abc import Sequence from dataclasses import dataclass from typing import TYPE_CHECKING, Literal if TYPE_CHECKING: from eir.setup.schemas import al_max_sequence_length, al_tokenizer_choices al_sequence_operations = Literal["autoregressive", "mlm"] @dataclass class SequenceOutputTypeConfig: "...
50b12a8d25e550b4c24950434c75e0eabc84dc06ea93130882ee9d36250f07ae
Python
6,156
183
"""Extract and save the NSD-core image features, using deep neural network models. Parameters ---------- model : str Name of deep neural network model used to extract the image features. Available options are 'alexnet', 'resnet50', 'moco', and 'vit_b_32'. nsd_dir : str Directory of the NSD. project_dir : str Direc...
8c454f5d85718b06d55043ccb8526038ac31f0193c170159518a3542e58563d2
Python
6,157
143
import os import yaml import mlflow import torch from utils.env_config import path_check_and_join from utils.models import WindTurbineModel from model_optim.optimize import optimize_model, help_evaluate_dataset, help_mlflow_logging def execute_optimization(experiment_id, experiment_name, run_id, run_name, dir_yaml, p...
bdaa1345c2ecb9770891cb095b1cf805f87eff93b699d2a035d6f0e6f05fce2c
Python
6,158
199
""" Defines various activations functions to be used in neural net. """ import numpy as np import torch from typing import Union ######## MML_ activation def MML_activation(x: torch.Tensor, leak: Union[float, int]): """Returns the output of the Michaelis-Menten function Parameters ---------- x : tor...
27ecbc691f0178083dea4d01cfb3eab41806b8d332dbd3a36144ff7e42d89062
Python
6,159
291
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Fit FLIM data """ import os import mbflim.utils as ut import mbflim.parameters as par import tools.flim.flim_set_processing as fl_setpro import tools.flim.flim_visualization as fl_vis #%% Parameters # Parallelism PROCESS_NB = 16 MAX_THREAD_NB = 32 # Mask # Somata...
a0b0aa305ccb4cf44d30b24e061b7335d793bd73748b92e3abfc17facfd0a815
Python
6,159
169
import os import numpy as np import pandas as pd import scanpy as sc import seaborn as sns import matplotlib.pyplot as plt from matplotlib import cm, colors from scipy.cluster.hierarchy import linkage, dendrogram, fcluster # Compute mean expression within a cell group def grouped_obs_mean(adata, group_key, layer=None...
0113bb7d0e59ad9bcf530d3c280ee9ebe1ae9d6069a16641da2949e6b801e778
Python
6,160
147
""" Random Erasing (Cutout) Adapted from https://github.com/rwightman/pytorch-image-models/blob/master/timm/data/random_erasing.py """ import sys import random import math import torch from monai.transforms.transform import Transform def _get_pixels(per_pixel, rand_color, patch_size, mean=0, std=1.0, ...
09c161eca279a81fb956690f00bf74f3bd8c632218687fdd1c0dc6cafc99a04b
Python
6,160
183
"""Extract and save the NSD-synthetic image features, using deep neural network models. Parameters ---------- model : str Name of deep neural network model used to extract the image features. Available options are 'alexnet', 'resnet50', 'moco', and 'vit_b_32'. nsd_dir : str Directory of the NSD. project_dir : str ...
1986e27f4a4d0aa324a2be528604c553ae853f346a89226beb53da565bf9a453
Python
6,160
170
from __future__ import absolute_import from torch import nn from torch.nn import functional as F from torch.nn import init import torchvision import torch from .pooling import build_pooling_layer __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152'] class ResNet(nn.Module): ...
5e9f15d0fb043558340e4c3842a2c358057d7d52830f2249a63a359b15582705
Python
6,160
207
import torch from torch import nn from torch.nn import Parameter import torch.nn.functional as F from torch_geometric.nn import ( GATConv, GCNConv, GPSConv, GINConv, SAGEConv, LGConv, GATv2Conv, GCN2Conv, GraphConv ) class SAGEConv_Encoder(torch.nn.Module): """ Encoder based on GraphSAGE convolution. ...
fb8d0eb2809a44dc7a4ab31e5e40ff8b02226ad4733e8f18a55dfc5d78d2c0f6
Python
6,160
138
import nighres import os import nibabel import numpy import glob import scipy.ndimage inpath = '/home/pilou/Projects/Cerebellum/Cerebellar-segmentation-ABC/' in_sfx = 'nighres/tissues/' out_sfx = 'nighres/topology/' wmprior_sfx = '_anat_inv1_s2c10_lcpca-den_qt1map-t1_cr_def-img_msk_wmprior.nii.gz' gmprior_sfx = '_ana...
c346a165e6b5c479783fb07a5e35f97bc8517e98ae94630342273b7300fbdeda
Python
6,162
170
################################################################################## ### Module : dmriatlasbuilder.py ### Description : Atlasbuilder api ### ### ### ### Written by : scalphunter@gmail.com , 2022/10/08 ### Copyrights reserved by NIRAL #######################################################################...
8dea6d7fa0f979b80b767610cffea21f2f5dbc92c8f4d560e8c1a2dc9483c396
Python
6,163
208
from airflow.utils.log.logging_mixin import LoggingMixin from airflow.utils.dates import days_ago from datetime import timedelta from airflow.models import DAG from airflow.operators.python import BranchPythonOperator # Kaapana operators from kaapana.operators.MinioOperator import MinioOperator from kaapana.operators....
e795dd598324aa3caf50d3494cd9103c8d69e4119550e330ac8c3c790480a197
Python
6,164
291
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Fit FLIM data """ import os import mbflim.utils as ut import mbflim.parameters as par import tools.flim.flim_set_processing as fl_setpro import tools.flim.flim_visualization as fl_vis #%% Parameters # Parallelism PROCESS_NB = 16 MAX_THREAD_NB = 32 # Mask # Somata...
21eafbc8ec90509ab534c5920f6601f8c7224a329c9ea20e15a0c32af3782e4e
Python
6,166
115
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'add_line.ui' # # Created by: PyQt5 UI code generator 5.12.2 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_addLine(object): def setupUi(self, addLine): addLine.setO...
d8451ccfb7f7103bc03a0a8f6bb02442de6d1dcbed9bd82ef8129bc78d58b7d7
Python
6,166
134
import unittest from causallib.positivity import Trimming from causallib.positivity.metrics import cross_covariance, cross_covariance_score from causallib.positivity.datasets.positivity_data_simulator import make_multivariate_normal_data from sklearn.linear_model import LogisticRegression import pandas as pd import num...
daa6cf93e88271293fdbe60149cec336b5d3ec06fd37793e9e2619a887640180
Python
6,166
262
import numpy as np from scipy.stats import norm, chi2 """ Credits to Xihao Li and the STAAR developers for the following functions https://github.com/xihaoli/STAAR """ def saddle(score_stat, egvalues, wcov_mat): """ Saddlepoint approximation (Deprecated). Score statistics have been normalized such that...
822aaf589806b64f7f3235e4a46f43a04fa9ce18282e9a6610ed0b0af9c4ff22
Python
6,168
157
from os import listdir import numpy as np import scipy import scipy.signal import scipy.ndimage as ndimage import re import matplotlib import matplotlib.pyplot as plt from matplotlib import gridspec import moviepy.video.io.ImageSequenceClip import imageio as iio # simulate ideal C_location def access_distance_map(n, ...
9f4752d7893a86821dd5b6d5be20feff03a5696835d98c52065964d99a06921d
Python
6,168
188
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT import csv import json import os import random import sys from itertools import product NAME = "analytics" def read_rules(name): rules = [] with open(os.path.join(sys.argv[1], f"{name}.csv")) as f: reader = csv.DictReader(f) ...
02415a532294421648b4b0028d71a4aa52997b3baec2aca7310cc3ab459691d2
Python
6,170
116
import os from importlib import import_module from pathlib import Path cell_graph_config = { "cell_f_list": [ 'fourier', 10, False, ], "edge_f_list": [ "cmtocm_x", "cmtocm_y", "cmtocm_len", "cmtocm_angle", "contour_dist", ], "...
3b437e4a6dc5ca0062557412c499fc5d122ab3be31bf2a213766d4887e909e43
Python
6,170
126
import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from sklearn.utils import resample from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis from statsmodels.stats.multitest import multipletests from sklearn.decomposition import PCA def normalize_to_NN_NT_cells(adata...
80d353e8d4e4741b4da10c234c376f2c81d76f5e9a987bc839a8bf6847e7a125
Python
6,171
151
"""Downloading a peak-detection trace saves a file, like every other figure. "Download PNG" worked everywhere except CAT-NAP's peak-detection traces, where it opened the image in a tab instead. Two independent halves of the same oversight, and either alone was enough to break it: * ``/api/trace`` was the one image ro...
85ddf57f755713bcc0caf65c458ef31fc7b4d6940dc45a07b5727f7d5519fcd6
Python
6,171
167
# -*- coding: utf-8 -*- """ Created on Tue Dec 3 16:53:36 2019 @author: Yoshi """ import numpy as np from shapely.geometry import Point,Polygon def cell_and_background_array(cell_locations,image_shape): # Creates an empty list for storing arrays cell_arrays = [] background_arrays = [] # ...
ce4f33a679f62f75221dfd7445ff0d23477920e7019d2fa4afc6993cd5874541
Python
6,171
116
import os from importlib import import_module from pathlib import Path cell_graph_config = { "cell_f_list": [ 'fourier', 10, False, ], "edge_f_list": [ "cmtocm_x", "cmtocm_y", "cmtocm_len", "cmtocm_angle", "contour_dist", ], "...
4385c3fa3e268915da55a8fb4120acc99b75158e40467c07a4e73bf6d469c47f
Python
6,172
208
"""Demonstrates a failure of the LSTM-based DyNeMo model in learning long-range temporal dependencies. - Simulates hierarchical HSMM+HMM data. - The lifetime of the top-level HSMM is longer than the sequence length, which means the LSTM cannot learn the top-level transitions. """ print("Setting up") import os impor...
f4c40bf1b248064dce7e7c7369a445ca4ca622a0bc206e7a0b903711b1476024
Python
6,172
120
### script for writing meta information of datasets into master.csv ### for node property prediction datasets. import pandas as pd dataset_dict = {} dataset_list = [] ### add meta-information about protein function prediction task name = 'ogbn-proteins' dataset_dict[name] = {'num tasks': 112, 'num classes': 2, 'eval ...
06f7a621c02df032629d1cea262ed665464126d082c9f5dc28f6fcd24b0fa89c
Python
6,173
173
# 移除 s1 层 import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from model.coatnet import conv_3x3_bn, MBConv # Assuming conv_3x3_bn and MBConv are defined elsewhere in your code class hswish(nn.Module): def forward(self, x): return x * F.relu6(x + 3, inplace=Tru...
3b5e3f06c965852708c6c42ae499619de6f0f9b7fea88522f7d2289d2337ae57
Python
6,173
208
import os.path from typing import Tuple, Dict import torch import torch.nn.functional as F from skimage.morphology import skeletonize from torch import Tensor from tqdm import tqdm def save_train_test_split( mask: Tensor, skeleton: Dict[int, Tensor], z_split: int, base: str ): """ Splits a volume of bina...
57c00260429aac4a159a8c1ab46791a02678f26a890e52d9e1076899305d4ae3
Python
6,173
163
"""Functions for downloading and reading MNIST data.""" import gzip import os import urllib import numpy SOURCE_URL = 'http://yann.lecun.com/exdb/mnist/' def maybe_download(filename, work_directory): """Download the data from Yann's website, unless it's already here.""" if not os.path.exists(work_directory): ...
efff2809553bebc3a72575a25d16ecc161b68a8ead83caefa41ff13e90f2004a
Python
6,173
160
# Copyright (c) OpenMMLab. All rights reserved. import torch from mmcv.cnn import ConvModule, constant_init from torch import nn as nn from torch.nn import functional as F class SelfAttentionBlock(nn.Module): """General self-attention block/non-local block. Please refer to https://arxiv.org/abs/1706.03762 fo...
d4ad883f83ab068d1b3ad0f5839e150880c1cbc204ee71c303945d6f0e7c7255
Python
6,174
144
""" Location Decoder @ 2021 Knowblesse Using the Multi Layer Perceptron based Regressor, decode the current animal's location using the neural data. Input : TANK_location The Tank must have these two data 1) buttered_data.csv (from butter package) 2) neural spike data (get it from the Matlab) """ import n...
9e08321951809a30b439a398a3d0c8342ee8178383da3a40dbc6520921a7072e
Python
6,175
236
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## # # See COPYING file distributed along with the PyMVPA package for the # copyright and license terms. # ### ### ### ### ###...
c67824f17d3cee5a32c01dc09db2129d5347c913242ecc14bc5bacf41d0724b5
Python
6,175
170
############################################################################# # Copyright (C) 2020-2026 MEmilio # # Authors: Patrick Lenz # # Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Licen...
4868c4f3a40a639df3df449a885c8a6fd3ffd4131a7bcbb3a19dd9b8ef03b55c
Python
6,176
222
''' Reward delivery implementation ''' import typing import asyncio import pathlib import logging import datetime import platform import functools import subprocess from .config import * from .qt import * Executable = typing.Callable[[], None] LOGGER = logging.getLogger(__name__) SENTINEL = object() class MeteredU...
9820092253fb503aeca525190ab6db69a35fdd4756c990076b587c98b7e7aa2a
Python
6,178
169
# Copyright (c) DP Technology. # 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. from typing import Optional import torch import torch.nn as nn import torch.nn.functional as F from . import Tr...
b64ca3614021c44bf381fe4fc93e261adaa1e7dabceca3394fda7deb5743e27d
Python
6,178
167
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from model.coatnet import conv_3x3_bn, MBConv # Assuming conv_3x3_bn and MBConv are defined elsewhere in your code class hswish(nn.Module): def forward(self, x): return x * F.relu6(x + 3, inplace=True) / 6 clas...
371469e1def2b602cf4d50782768a5b4f4c85a53fe9df7d62927c0a74ddf45b1
Python
6,179
170
# tifffile/numcodecs.py # Copyright (c) 2021-2026, Christoph Gohlke # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, #...
3f508000d2eec7ce374ac4352038ac630ecbbab9ba7ca78b6be95dd6d868225f
Python
6,179
173
from collections.abc import Sequence from typing import Any from fastapi import FastAPI from eir.predict_modules.predict_tabular_input_setup import ( ComputedPredictTabularInputInfo, ) from eir.serve_modules.serve_api_models import ResponseModel, create_input_model from eir.serve_modules.serve_experiment_io impor...
afd34f4c599f18621feaa789df726ffe02fe72b2a3b7576671f4c7e6fcb47403
Python
6,179
291
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Fit FLIM data """ import os import mbflim.utils as ut import mbflim.parameters as par import tools.flim.flim_set_processing as fl_setpro import tools.flim.flim_visualization as fl_vis #%% Parameters # Parallelism PROCESS_NB = 16 MAX_THREAD_NB = 32 #%% Fixed param...
18fc5a4a009ea1bf05bd98b531db819acb2304155a3361de39952cc050eb9ee2
Python
6,180
179
# Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from __future__ import annotations import unittest from types import SimpleNamespace from unittest.mock import Mock from rest_framework import serializers from cvat.apps.quality_control.attribute_comparators import ( AttributeComparisonRule, ...
b9b80f6985eb5e75a706683b5c1949d2e3b75ce83a4a52446f77deb1d085f92b
Python
6,181
212
from dataclasses import dataclass, field from typing import Annotated, NamedTuple, Optional import pytest from typing_extensions import TypedDict from magicgui.schema._ui_field import UiField, build_widget, get_ui_fields from magicgui.widgets import Container EXPECTED = ( UiField(name="a", type=int, nullable=Tru...
24640e3b434378ae98bc56701c701d225ded5bfb1fee229196da607c77a585fb
Python
6,182
176
#!/usr/bin/env python3 import os import sys import glob import argparse def parse_args(args=None): Description = "Generate nf-core/rnaseq samplesheet from a directory of FastQ files." Epilog = "Example usage: python fastq_dir_to_samplesheet.py <FASTQ_DIR> <SAMPLESHEET_FILE>" parser = argparse.ArgumentPa...
71ff4b8a6f4958b32e8141366f7c845d6365623cac231d5520af9a3d725acc06
Python
6,182
192
import json import numpy as np import pytest import tifffile from napari_dmc_brainmap.preprocessing import preprocessing_tools from napari_dmc_brainmap.stitching import stitching_tools @pytest.mark.parametrize("compression", ["deflate", "lzw"]) @pytest.mark.parametrize( ("image", "photometric"), [ (...
642e1eda8ae2f5d58bfe141cded63ed6ad32b21776329b4602915f407725e6e8
Python
6,185
188
""" Generate figures for the Keypoint Fidelity How-To documentation. Uses the same geometry as tests/test_keypoint_fidelity.py: centered squares of half-size r, with corners derived from np.where(arr > 0). Blue = fixed keypoints, red = moving keypoints. Produces: 1. Side-by-side view of fixed and moving squares (ke...
6521f3a5a3fc7afa16f33c463631b513b4e8a5636c650e51f75f05a28b947b27
Python
6,186
149
import os import numpy as np import torch from time import process_time, time from datetime import timedelta import pandas as pd from monai.transforms import AsDiscrete from brainCT.inference.faster_bootstrap import get_dataset from brainCT.main import get_model import SimpleITK as sitk from brainCT.inference.ensembl...
9a6e7b6c3c31c2bf786411aabac9df0b5a211700607204dcfdb7cfc338a2743d
Python
6,187
202
#!/usr/bin/env python3 # # ImpedanceFitter documentation build configuration file, created by # sphinx-quickstart on Thu Aug 29 12:24:51 2019. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file...
9db1ce529ba691ead0f29560faad82a7bb0bce16590acf6964f5213e4c6fa6fc
Python
6,187
183
""" R-wave detection in 3-lead ECG waveforms acquired using an MR scanner - lead waveforms contaminated by magnetohydrodynamic effect (T-wave elevation) """ import numpy as np import pandas as pd from scipy.signal import spectrogram, find_peaks from scipy.interpolate import interp1d from .bidsphysio import save_bids_p...
77e9428616fe30ec349ae1bf6210044cc14f94ef1c41db4996d8026bd7367540
Python
6,189
160
import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.switch_backend('agg') from sklearn.decomposition import PCA from util import read_expr, read_list, read_symbols, get_symbol import argparse import os import matplotlib as mpl mpl.rcParams['axes.spines.left'] = True mpl.rcParams['axes.spines.righ...
12f2e33fa93d9363234909bc24c55e969e3af228916ceca5a57594a67116928b
Python
6,190
163
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license from __future__ import annotations import os import shutil import sys import tempfile from pathlib import Path from typing import TYPE_CHECKING from . import USER_CONFIG_DIR from .patches import torch_save from .torch_utils import TORCH_1_9 if TYPE...
959c1c7bcc0b4a1665e173f2d155b4074f7b27bde680218b8e5599dcbd4f304c
Python
6,191
119
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file '/media/lg/disk2/PycharmProjects/ISAT_with_segment_anything/ISAT/ui/info_dock.ui' # # Created by: PyQt5 UI code generator 5.15.10 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this fil...
ab3cca81091e4cbef72ec52b10151903c794083478169ff3947634558cde40a6
Python
6,193
178
""" analyze colocalized synapse types """ import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.patches as patches import seaborn as sns from matplotlib.colors import LinearSegmentedColormap from palettable.colorbrewer.sequential import (PuBuGn_4, ...
219dbab2cdc172036c20f826454334ea92b8626975b5fe985e30ba12a1295982
Python
6,194
162
"""Regression tests for input_structure_file path resolution in run_ase_core. Background ---------- Coordinate files are written into the session log directory via ``_resolve_path`` (see ``ase_core._resolve_path``). When a tool writes ``water.xyz`` into ``CHEMGRAPH_LOG_DIR`` but ``run_ase`` is later invoked with the B...
86af4a65378f997ce6c4b135b414cddce37df7f26cf654f8f1d848d56ad93e05
Python
6,194
172
import math import torch from torch.distributions import constraints from torch.distributions.distribution import Distribution from torch.distributions.multivariate_normal import ( MultivariateNormal, _batch_mahalanobis, ) def _standard_normal_quantile(u): # Ref: https://en.wikipedia.org/wiki/Normal_dist...
1aedd57859c7a2103a58756c10199fb91c1aa6a7db88c7aa5473aca76de0cec8
Python
6,196
128
import cv2 import numpy as np import pandas as pd from typing import List, Union from pathlib import Path from skimage.measure import label, regionprops from natsort import natsorted from napari_dmc_brainmap.utils.path_utils import get_info from concurrent.futures import ProcessPoolExecutor, as_completed class Centroi...
3e62c1c86eb6102fd6bf3e62370164f7b9937255b464c9fd06c14b68afd17eec
Python
6,196
188
import numpy as np import constants import split_dataset as sd import argparse import sys, os sys.path.append("./") import pandas as pd import split_dataset as sd BASE_PATH = "../data" SEEDS = [10, 24, 36, 42, 56] # ---------------------------- # REDUCED TRAINING SET SIZES # ---------------------------- TRAIN_SIZE...
b6334bddbb1a33a1b87d08024cb8b41fb646ccbf0269561e8ff24df07d1271eb
Python
6,198
198
# Copyright (C) 2020-2022 Intel Corporation # Copyright (C) CVAT.ai Corporation # # SPDX-License-Identifier: MIT from __future__ import annotations import json import os import re from contextlib import closing from pathlib import Path from typing import TYPE_CHECKING, Any import urllib3 from cvat_sdk.api_client.ap...
3ce5898e6b3a03c5e8102cd1139d51dd608b6fdaab624c7c4ee94ac063a98e4c
Python
6,200
173
import sys import yaml import os import numpy as np import matplotlib.pyplot as plt pathpath,run1,run2,stag1,stag2,ncluststr1,ncluststr2, cmethod = sys.argv[1:] stags = [stag1,stag2] ''' pathpath = 'PATHS/filepaths_carlen.yml' run1 = 'runC00dMP3_brain' run2 = 'runCrespZP_brain' stags = ['spont','resp'] ncluststr1 = ...
95b372ec91360b8325df4e1ff279204c935e5076d781ce899df75e5584f38cc4
Python
6,200
190
import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers,models from tensorflow.keras import callbacks from tensorflow.keras import regularizers from tensorflow.keras.optimizers import Adam from tensorflow.keras.callbacks import LearningRateScheduler from keras.utils.vis_utils imp...
ada43858ecdf64ce68b1ac0000f0cfa31c8cffc53b58ff967950d018f712bcc7
Python
6,201
189
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # ImpedanceFitter documentation build configuration file, created by # sphinx-quickstart on Thu Aug 29 12:24:51 2019. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in t...
18fe9645e5b243d482464efec4305cfa0332dfb7250ebba5f6c8fbac8ffac3f1
Python
6,202
157
import sys import os import time import numpy as np import pandas as pd import matplotlib.pyplot as plt import torch import torch.nn as nn import torch.optim as optim from torch.nn import functional as F import random from sklearn import metrics from model import * inpt_ = "mock_genomes.npy" #input genotype file in n...
ac68e0eb9ed4953df305d36e62a85791c3f816d0d47be622a9a377cdb8d8c61a
Python
6,202
201
""" Defines various activations functions to be used in neural net. """ import numpy as np import torch from typing import Union ######## MML_ activation def MML_activation(x: torch.Tensor, leak: Union[float, int]): """Returns the output of the Michaelis-Menten function Parameters ---------- x : tor...
1658fb3c626c58f26e8e8838ebbc29cfc41e0635cbe0209b27d4aacb024c793d
Python
6,203
196
import os import shutil import tarfile import zipfile from os import listdir, makedirs, remove from os.path import exists, join import nibabel as nib import numpy as np from tensorflow.keras.utils import get_file ############## # Parameters # ############## data_splits = ["train", "test"] num_labels = 3 # Main proj...
95b44bc913e1005990cd35102bdc9c72a3cb6e722372f0c517b2e8dd619b834b
Python
6,203
219
#!/usr/bin/env python3 """ Locate or download the PRS-EDM DM SQL database (variants.db) and metadata (prs_meta.json). Robust for: - Normal laptops/desktops - Unix clusters where ~/.local/share may be restricted Public API: - get_dm_sql() -> returns path to variants.db - get_dm_meta() -> returns path to...
1aad242ac06c41e642e81b69021e8fbddb79fc9742604265347ea347bacfa101
Python
6,204
195
# flake8: noqa import argparse import csv import os from collections import OrderedDict def init_config(config, default_config, name=None): """Initialise non-given config values with defaults""" if config is None: config = default_config else: for k in default_config.keys(): i...
98e6c3966c73d26997d5509a06bdb6ba6d80d30eccd888c7daa6fa6ddcbfc141
Python
6,204
231
#!/usr/bin/env python2 import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np from optparse import OptionParser ############################################################################### def windowToKey(a): k = a[0] + ':' + str(a[1]) + '-' + str(a[2]) return k ######...
d8f07d2f1281665471c43b417a14189d15ad83d74080d3216999151d934f2a64
Python
6,204
174
import logging from typing import Generator, Tuple, Any from zigzag.classes.stages.Stage import Stage from zigzag.classes.cost_model.cost_model import CostModelEvaluation logger = logging.getLogger(__name__) class MinimalEnergyStage(Stage): """ Class that keeps yields only the cost model evaluation that has...
03f6cd0f373e72b5e33fe82dadb974cde908a1d92649b19e8d9dd72ccd87d40e
Python
6,205
172
#!/usr/bin/env python """ Training Script for Thermal Sensor H-FNO Model This script trains an H-FNO model for thermal sensor (RTD) response prediction. Usage: python train_thermal.py --config configs/thermal.yaml python train_thermal.py --epochs 100 --batch_size 16 """ import argparse import logging import ...
b37a85635316de3410ed59d5c284f5d9151c944da28ac20c511aea2ccb61e888
Python
6,205
204
"""Session persistence utilities for the ChemGraph Streamlit UI. Bridges the gap between the UI's in-memory ``conversation_history`` format and the :class:`~chemgraph.memory.store.SessionStore` persistence layer. Every function is Streamlit-free so it can be unit-tested without a running Streamlit runtime. """ from ...
f1e14efa9cfaf7c538d1531f3ab474c913adf6abbd100d0a3fc3d8b31477730e
Python
6,205
162
import matplotlib.pyplot as plt import numpy as np import nibabel as nb import subprocess import os.path from skimage.measure import label import pandas as pd import seaborn as sns # Set data path ROOT = '/Users/sebastiandresbach/data/s1Anfunco/Nifti' SUBS = ['sub-12'] DIGITS = ['D1', 'D5'] # =======================...
120465d1bf551564a4ae775a0c9e49b604c2d30fbb8e08169658dba8036980c8
Python
6,207
210
import unittest import warnings from unittest.mock import patch from rscvp.spatial.main_align_map import AlignPeakMapOptions from rscvp.spatial.main_ev_pos import EVOptions from rscvp.spatial.main_place_field import PlaceFieldsOptions from rscvp.spatial.main_population_matrix import PopulationMTXOptions from rscvp.spa...
27986a40b98bd882b236e2812c831ef85c6d690f977917140a63a9838a8adc1f
Python
6,207
162
from __future__ import annotations from collections.abc import Callable from enum import Enum, EnumMeta from typing import TYPE_CHECKING, Any, cast from magicgui.types import ChoicesType, Undefined, _Undefined from ._value_widget import BaseValueWidget, T, ValueWidget if TYPE_CHECKING: from typing_extensions im...
654aebee2780e8d76ef3b6e25d766ecbeea52e83a30661e677eb33addcca86ba
Python
6,208
173
#!/usr/bin/env python3 """Train 3D ViT-UNet using preprocessed BraTS .npy volumes.""" from __future__ import annotations import argparse from pathlib import Path import numpy as np import segmentation_models_pytorch as smp import torch from sklearn.metrics import accuracy_score, jaccard_score from torch import nn fr...
71c918d0d60ed61587c13bc6d265e86509e9bedec49fc4b22b19c41d98b1ec7b
Python
6,208
201
""" dlim_train.py ----------------------- This script trains the D-LIM (Deep Latent Interaction Model) on different datasets, such as "harry", "elife", and "protein_inter". It compares the performance of the spectral and non-spectral variants of the D-LIM model. Each experiment evaluates model performance using Pears...
cdd6b46d40babbc9962eaaa06428f00e79a76a0787219d7975a42c47de867328
Python
6,209
141
#!/usr/bin/env python3 import os import argparse import re from datetime import datetime from pathlib import Path from typing import List, Optional, Tuple # Map file extensions to comment styles COMMENT_STYLES = { '.py': '#', '.cpp': '//', '.cu': '//', '.h': '//' } def get_comment_style(filepath: str...
5902a4a32651b609966d1127f83e62f8fc871e029d561396c72a5d5b3a5f7eb9
Python
6,210
200
""" Quick n Simple Image Folder, Tarfile based DataSet Hacked together by / Copyright 2019, Ross Wightman """ import io import logging from typing import Optional import torch import torch.utils.data as data from PIL import Image from .readers import create_reader _logger = logging.getLogger(__name__) _ERROR_RETR...
849181cbc9b333575212aad5d1aeb2507e165bf7e58c6a2586154587d63145f7
Python
6,210
118
# Tests of the datasheet detection of dmrifiberprofile (file names only): # python -m unittest discover -s tests import tempfile import unittest from pathlib import Path from dtiplayground.dmri.fiberprofile import datasheet as ds PROTOCOL = {'propertiesToProfile': 'FA, MD, FWFA, FWF, FWf, NDI', 'useDisplacem...
138c3cdb83c036c22bcb46638ffd688fb50582d2d833e52d72652981f8611e97
Python
6,212
210
from collections.abc import Sequence import pandas as pd import pytest import timm import torch from timm.models import get_pretrained_cfg_value from tests.conftest import should_skip_in_gha from tests.test_models.model_testing_utils import ( check_eir_model, prepare_example_test_batch, ) def get_test_inter...
fde53f08e657ba633294eae41c01222c9b759b004288b04916ad93d331adc8a7
Python
6,212
191
import numpy as np import glob import torch from torch.utils.data import Dataset from torch_geometric.nn import knn_graph import json import cv2 import matplotlib.pyplot as plt from matplotlib.pyplot import figure # This function converts Spherical coordinates to Cartesian.........................................####...
0b3195950c6f92343f397d8fe103176e3eef0849d481990cbb532607222449bf
Python
6,213
160
from typing import Final, Literal import numpy as np import polars as pl from argclz import AbstractParser, as_argument, str_tuple_type, argument from argclz.dispatch import Dispatch, dispatch from neuralib.atlas.ccf import ROIS_NORM_TYPE from neuralib.atlas.typing import Area, TreeLevel from neuralib.plot import plo...
175891fcfe51b2156a31a9e2caef07824b231d89d9eb32a21815592c9505fd4f
Python
6,213
180
# -*- coding: utf-8 -*- # python standard library inputs import os import datetime # external inputs import numpy as np import nibabel as nb import shutil as sh __all__ = ['get_vfs', 'get_weighted_vfs'] def get_vfs(input_sphere, input_white, input_patch, input_aparc, hemi, ecc_real, ecc_imag, pol_real,...
a207b9f7d2429557454e898d1afef9461f5ad72d54c0e2009723dfd39f1473bb
Python
6,213
178
import hashlib from nipype.interfaces import BIDSDataGrabber from PUMI._version import get_versions from nipype.pipeline.engine.nodes import * import subprocess import json def get_interface_version(interface): """ Try to get the version number of the underlying tool used in an interface. Return None ...
c62e77f620e8b75e874c7a61c3c191c7ee300cb243660ba3cd48950cf4131c69
Python
6,213
161
import logging import unittest import numpy as np import pandas as pd import scipy.stats as stats import diffxpy.api as de class _TestPairwiseNull: noise_model: str def _prepate_data( self, n_cells: int, n_genes: int, n_groups: int ): if self.nois...
d6e779faa29a6e789edea31ad2186ea0c4fe89adda3f77ada9813143eb4ffc63
Python
6,213
186
""" Decorator functions to wrap around entry and exit ... to easily apply to a function, functions that check/process inputs and outputs """ from functools import wraps import numpy as np from . import error from . import matrix from . import util as u ## Hacky way to handle python2 not having `ModuleNotFoundError` ...
e7ecc9fc11d8a601bd0520b78008653c6c27e3d65853c1e756685c7b51220dd7
Python
6,215
209
""" High-level read/write functions for several formats. """ # Author: Oualid Benkarim <oualid.benkarim@mcgill.ca> # License: BSD 3 clause import tempfile import gzip import os from vtk import (vtkPLYReader, vtkPLYWriter, vtkXMLPolyDataReader, vtkXMLPolyDataWriter, vtkPolyDataReader, vtkPolyDataWrit...
856eeb88dfcaead9d2f3457eead49476b5f872f4c20c9c0d2cd882423678d4a7
Python
6,216
146
# src/train/train_regression.py """ Train multi-output regression model for one CV fold. Run: $ python -m src.train.train_regression --fold 0 """ from __future__ import annotations import argparse from pathlib import Path import numpy as np import torch import torch.nn as nn from torch.optim.lr_scheduler import Re...
bd71ea6ee44288723ba5e3511745abba65a29c5bebecfa2f7e6f4edc63d71d15
Python
6,219
155
from typing import Callable, List, Union import numpy as np from rdkit import Chem, DataStructs from rdkit.Chem import AllChem Molecule = Union[str, Chem.Mol] FeaturesGenerator = Callable[[Molecule], np.ndarray] FEATURES_GENERATOR_REGISTRY = {} def register_features_generator(features_generator_name: str) -> Cal...
c57fedd958620d266078acd41fd6287617f00997341a050c38dcdedd789b6367
Python
6,219
135
# (C) Copyright 2019 IBM Corp. # # 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 applicable law or agreed to in writing,...
a3b41fa48bac65c53dbb9c261366f7b4a8a80ad4f2b244c319876ec4fd88eef3
Python
6,222
164
import os import pysam import numpy as np import sys sys.path.append('../bin') from sc_remove_low_qual_reads import remove_low_qual_reads from sc_split_reads import split_reads def test_low_qual_reads_removed(tmp_path): input_bam = "data/sc/mix_qual_reads.bam" out_bam = f"{tmp_path}/high_qual_reads.bam" ...
278e8c77ef916f1dc9ea0479101db55188be95646a1f77297b7e3d795255da72
Python
6,223
161
import tweepy import datetime import time # TwitterAPI 6253282 # TwitterDev 2244994945 user_fields = ['created_at', 'description', 'entities', 'id', 'location', 'name', 'pinned_tweet_id', 'profile_image_url', 'protected', 'public_metrics', 'url', 'username', 'verified', 'withheld'] tweet_...
9715c2f8b7a0ffdb65094b6f2ad8417f57375403ff2df5f6f91ee2328217c813
Python
6,227
175
import torch import logging import torch.nn as nn import torch.nn.functional as F from typing import Optional BINARY_MODE: str = "binary" MULTICLASS_MODE: str = "multiclass" MULTILABEL_MODE: str = "multilabel" EPS = 1e-10 logger = logging.getLogger(__name__) def expand_onehot_labels(labels, target_shape, ignor...
aed56feb9a2628371d0227b230d47815f08b513f681fb66e78c4008110799fb6
Python
6,229
195
############################################################################### #################### Boilerplate ######################## ############################################################################### import pandas as pd import matplotlib.pyplot as plt import os import matplotlib...
ff688f07f4801de0d7f529a65b12e78375bf2a398c81072f6238d24770eeeb2f
Python
6,229
213
"""Ordinary least squares fitting for a GLM.""" import logging from typing import Optional, Tuple import numpy as np from sklearn.linear_model import LinearRegression _logger = logging.getLogger("osl-dynamics") def _validate_dimensions( X: Optional[np.ndarray] = None, y: Optional[np.ndarray] = None, co...