sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
158358d032e06532505b224d5c4ddaef7fe3db12b3504457f0970e1bc3765f4a | Python | 3,843 | 121 | """Miscellaneous utility functions."""
from functools import reduce
from PIL import Image
import numpy as np
from matplotlib.colors import rgb_to_hsv, hsv_to_rgb
def compose(*funcs):
"""Compose arbitrarily many functions, evaluated left to right.
Reference: https://mathieularose.com/function-composition-in-... |
3bd44df39a7d7e90d471909ec03a4c3d20312fbae3d577b01b95642d9396629a | Python | 3,844 | 73 | """Configuration for a DeepMapper run, plain dataclasses, no heavy deps.
Importing this module is cheap (stdlib only); torch/timm are only touched when a
backbone is actually built. The defaults encode two project decisions:
* **Minimal augmentation.** Pseudo-images are simpler and far less variable than
natural ph... |
8dd2edda54adc07c003392e6f7df1ed505dfec0b3d6010af134877a2ea2e575e | Python | 3,844 | 74 | #!/usr/bin/env python
import os
import tempfile
import subprocess
from joblib import Parallel, delayed
from ..constants.constants import HUMAN_SOMATIC_CHROMOSOMES, BASELINE_LD_URL
from ..utilities.utilities import untar
class LDScores:
SUFFIXES = [ ".l2.M", ".l2.M_5_50", ".l2.ldscore.gz", ".annot.gz" ]
@st... |
798213ce13435a536a39973e8af3f9a61ad76b1b6b3e2fdc41006f2c728144e2 | Python | 3,846 | 77 | #!/usr/bin/env python3
#$ -cwd
#$ -V
#$ -N m_na_chap
#$ -e /cluster/uz_lab/cmives/TRP_channels/MDS/permeation_analysis/pore_architecture/m_na_chap.err
#$ -o /cluster/uz_lab/cmives/TRP_channels/MDS/permeation_analysis/pore_architecture/m_na_chap.err
#$ -pe smp 2
#$ -q c6100.q
import os
import sys
import glob
import sub... |
9eb1476082a80dd0852f2799dc64561d339906ebaa6d09b71404e5b6a6f21014 | Python | 3,848 | 96 | """
Plot the correlation across subjects of a behavioral measure between the two tasks.
"""
import argparse
import data_analysis_utils as dana
import data_behavioral_measures as bmeas
import matplotlib.pyplot as plt
import numpy as np
import os.path as op
import pandas as pd
import pingouin as pg
import plot_utils as p... |
6b3def39311d8f19449c3ad19850b5658bc9a65e0d9de7bbaa87929fc002534f | Python | 3,851 | 130 | """
Write OPC3 parameters into a SMIRNOFF force field.
Based on ambertools-22.0-py310h206695f.
Water Lennard-Jones parameters and geometry from $AMBERHOME/dat/leap/parm/frcmod.opc3
Water hydrogen charge from $AMBERHOME/dat/leap/lib/solvents.lib
Ion Lennard-Jones parameters from $AMBERHOME/dat/leap/parm/frcmod.ionslm_12... |
8ad5323e093feb9ae1965ab13022b8fb3e54a0e816b70862741f9a0732ffe1fc | Python | 3,851 | 69 | import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import Sequential
from dipgnn.models.layers.residual_layer import ResidualLayer
class Bond2BondBlock(layers.Layer):
def __init__(
self,
hidden_size,
num_b2b_res_layers,
name='bond2bond_block',
... |
9442fbbd048de304f55c36cd65eb1bed5c8d73c7d0617f60eec251eae8cfd2d9 | Python | 3,852 | 114 | import pathlib
import sys
import numpy as np
import openmm.app
import openmm.unit
from openff.toolkit import ForceField, Molecule
from openmmforcefields.generators import SystemGenerator
DATA_PATH = pathlib.Path(".") / "canary" / "data"
coverage_mols = DATA_PATH / "coverage.smi"
propyne_mols = DATA_PATH / "propynes.s... |
429d8e99546edb546e554a3a895cccbb9239c3778cc8870b8c8a6e994728f77b | Python | 3,856 | 143 | ########################################################################
# Stochastic second-order irreversible reaction: [A]0 != [B]0
# RESTORE
# AIMS: to verify checkpointing and restoring of the well-mixed stochastic
# solver 'Wmdirect' in the context of the Second-Order Irreversible
# Reaction model (see valida... |
6a78f6c1726f745b1420688c35bf390fb5bd4b490f24c378cbfbf13a97516a6f | Python | 3,856 | 47 | """fig12 (v2): how separable are held-out inputs from source calibration inputs under P4?
(a) out-of-fold classifier probability p(test | x) for calibration (source) and test (held-out) inputs, one held-out dataset;
(b) AUC per held-out dataset and the fraction of calibration weights that hit the clip floor (1/20).
Nea... |
17992abea22063342ca033017222b7673c956467147b331eaf4b4ddf366b6ced | Python | 3,859 | 106 | import math
from itertools import combinations
import numpy as np
import pandas as pd
from scipy import stats
from tqdm import tqdm
from pgmpy.base import DAG
from pgmpy.ci_tests import get_ci_test
from pgmpy.global_vars import config
from pgmpy.metrics import BaseUnsupervisedMetric
class FisherC(BaseUnsupervisedMe... |
ece77770d4db591b7185bf382884775c346426b52a645a90d0aabcb56122d3a7 | Python | 3,861 | 106 | # Training procedure for WideNet 32-10 for CIFAR-100.
import keras
import numpy as np
from keras.datasets import cifar100
from keras.preprocessing.image import ImageDataGenerator
from keras.layers.normalization import BatchNormalization
from keras.layers import Conv2D, Dense, Input, add, Activation, GlobalAveragePoolin... |
05a29334cf9ce15a1b2bda051583be7dd77d6f41c1e3a7386d8d81a600b26a88 | Python | 3,862 | 110 | import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
from skimage import measure
import nibabel as nib
import SimpleITK as sitk
import glob
def brain_bbox(data, gt):
mask = (data != 0)
brain_voxels = np.where(mask != 0)
minZidx = int(np.min(brain_voxels[0]))
maxZidx = int(np.max(br... |
6dd3435d6914797a767f105558a01dcc952f3fae568e082c11c455c3facb4a4d | Python | 3,862 | 124 | from asyncore import write
from logging import RootLogger
import xml.etree.ElementTree as ET
import os
import subprocess
from tqdm import trange
import shutil
import random
cwd = os.getcwd()
# This Script works only when you set the correct paths to RAY-UI and rayx
# add RML Files for testing here
# These are the o... |
e64bfa3694530eb98b0e0e16370c5d82ae99ad68c5ecd71b6b2938ad279ec6d4 | Python | 3,862 | 132 | """Utilities for working with HTML."""
import logging
import re
from collections.abc import Sequence
from urllib.parse import urljoin, urlparse
logger = logging.getLogger(__name__)
PREFIXES_TO_IGNORE = ("javascript:", "mailto:", "#")
SUFFIXES_TO_IGNORE = (
".css",
".js",
".ico",
".png",
".jpg",
... |
33a7f7b4dcd0ef663bb147b372ecfa7aae2e73b44bc9ee2f6f049f47858f5358 | Python | 3,865 | 112 | """
This file is adapted from https://github.com/ozan-oktay/Attention-Gated-Networks
"""
import math
import torch
import torch.nn as nn
from networks.utils import UnetConv3, UnetUp3, UnetUp3_CT, UnetDsv3
import torch.nn.functional as F
from networks.networks_other import init_weights
class unet_3D_dv_semi(nn.Module)... |
3ddd05a83dbe3d4ce77d675e52d34cb0ef2ee4401afe357464b65ad72da8aa78 | Python | 3,866 | 239 | # Copyright (c) 2023 Shihao Ma, Haotian Cui, WangLab @ U of T
R2_to_type = {
"C01": "2A",
"C02": "2A",
"C03": "2A",
"C04": "2B",
"C05": "2A",
"C06": "2A",
"C08": "2C",
"C09": "2C",
"C10": "2C",
"C11": "2I", # 2C or 2I
"C12": "2C",
"C13": "2D",
"C14": "2C",
"C15"... |
03766e74ef77fdc6b0909d339a288f453ed50de4afd6e04e1f9c24e70fc143b2 | Python | 3,869 | 118 | # Copyright (c) MONAI Consortium
# 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, so... |
5af842d1bfee04af0f2840ec0a69fcf9ecb71078f0ebb1d781c381b21625ece8 | Python | 3,869 | 126 | ###########################################
# IMPORTS
###########################################
import numpy as np
import os
from nose.tools import nottest
from unittest import skipIf
import pytest
###
from perses.dispersed import parallel
###
running_on_github_actions = os.environ.get('GITHUB_ACTIONS', None) == 't... |
3115ee61a18a70378fcdfa9a7eb3bc9cb765b7734cd481156110d711f9c41143 | Python | 3,873 | 136 | """LangChain **Runnable** and the **LangChain Expression Language (LCEL)**.
The LangChain Expression Language (LCEL) offers a declarative method to build
production-grade programs that harness the power of LLMs.
Programs created using LCEL and LangChain `Runnable` objects inherently support
synchronous asynchronous, ... |
a51fa6d8324681545b1e10bb2f062987b8de029c1563a2cf09cb7b7762766d54 | Python | 3,875 | 114 | from abc import abstractmethod, ABCMeta
from typing import Optional
from .utils import act_class_mapping, GatedEquivariantBlock
import torch
from torch import nn
__all__ = ["Scalar", "VectorOutput"]
class OutputModel(nn.Module, metaclass=ABCMeta):
def __init__(self, allow_prior_model):
super(OutputModel... |
fc9880755f0119c26087dd308c8b232640a39f007328a242b4617013d3d33d32 | Python | 3,876 | 103 | import numpy as np
import pandas as pd
import voxcell as vc
from scipy.spatial import ConvexHull
from shapely.geometry import Point, Polygon
def positions_to_mask(positions, annotation):
mask = np.zeros(annotation.shape)
indices = annotation.positions_to_indices(positions)
for indx in indices:
ma... |
38ef7b1ccbe79db8762149001c0a9053032725a19ce7d95efa340d3b5b7a9daa | Python | 3,877 | 96 | """
Parse MSigDB datasets
Download link: https://www.gsea-msigdb.org/gsea/msigdb (C2, C3, C5)
Homo_sapiens.gene_info.gz (from NCBI's ftp)
keep protein-coding genes only
"""
import numpy as np
import pandas as pd
import pathlib
class ParseMSigDB:
"""
"""
def __init__(self, root=None, ncbi=N... |
39f383e8bebdafdfdc984294d90cee8a59edba1296b37748cdba68b46f9aa205 | Python | 3,878 | 133 | from pathlib import Path
from fidnet import config
from fidnet.ca_detect.fidnet_2d_caDetect import direct_decouple as _ca_direct_decouple
from fidnet.con_decouple.fidnet_2d_conDecoup import direct_decouple as _con_decouple
from fidnet.ctcp_decouple.fidnet_2d_ctcpDecoup import direct_decouple as _ctcp_decouple
from fid... |
5d5276e8d67cff244a90e0412522c84c101122450822f09837335c9ae4a12954 | Python | 3,879 | 123 | import sys
sys.path.append(".")
import argparse
import gzip
from tqdm import tqdm
import multiprocessing as mp
from queue import Empty
from crystallm import (
semisymmetrize_cif,
replace_data_formula_with_nonreduced_formula,
add_atomic_props_block,
round_numbers,
extract_formula_units,
)
try:
... |
db2e754093bc3162893d9342af1d67b4d4605bbe5cdf4b0482acde06f462066f | Python | 3,882 | 120 | import torch
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from torch.utils.data import Dataset, DataLoader
import pandas as pd
from sklearn.metrics import precision_score, recall_score, f1_score, mean_squared_error, roc_auc_score, \
confusion_matrix, accu... |
8b65ffbf3a20f7ec71710d50dc8a1b9b6054c285b2da6cd47c2cfeea14bde1af | Python | 3,883 | 96 | # Copyright (c) MONAI Consortium
# 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, so... |
a928ca73ad5e5848ab8273393ae257b23625549bbb571ddcff5e15f4f55ce65d | Python | 3,883 | 120 | """Serialize LangChain objects to JSON.
Provides `dumps` (to JSON string) and `dumpd` (to dict) for serializing
`Serializable` objects.
## Escaping
During serialization, plain dicts (user data) that contain an `'lc'` key are escaped
by wrapping them: `{"__lc_escaped__": {...original...}}`. This prevents injection
at... |
ed654034969f37e02165b0165086470752897aeb8e8d33bae75f872658ad281f | Python | 3,884 | 90 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
78305d0db7b774ba92fa4831f71a6bd6283ed7fa4173cee479c8b9d2cbdc8864 | Python | 3,885 | 90 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
3c2a71df650f2916737418d50b32c533ea937770aca0b8483354138c219ab21d | Python | 3,886 | 129 | """Module contains a few fake embedding models for testing purposes."""
# Please do not add additional fake embedding model implementations here.
import contextlib
import hashlib
from pydantic import BaseModel
from typing_extensions import override
from langchain_core.embeddings import Embeddings
with contextlib.su... |
fd6f88a46361640872b47b9bb69b75617117b70bb500ef23b28989ee4ad4fadf | Python | 3,886 | 118 | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 16 14:26:39 2023
@author: pku
"""
import matplotlib.pyplot as plt
#%%
import numpy as np
import tensorflow as tf
from tensorflow.keras import applications, regularizers, optimizers, activations
from tensorflow.keras.models import Model, Sequential
from tens... |
58df810d732dd18d5c8d7dc4de5a3895633f22d500637413dbb7dcfe76964ac1 | Python | 3,887 | 96 | # Sconda conda activate ghmc1; cd /mnt/BioAdHoc/Groups/RaoLab/Edahi/Projects/09.TimeCourse5hmC/ForFerhatGit/GhmCN/reviewer_questions/plot_showing_significance_of_averaged_model; python
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import ttest_rel
# Re-define the data sets ... |
49a0fdb265bda2e7c798a5dc5c51b99cd9b27848c39d07dc00adb35dfce5cb55 | Python | 3,889 | 100 | import keras
from keras.models import Sequential, Model, load_model
from keras.layers import Dense, Dropout, Activation, Flatten, Input, Lambda
from keras.layers import Conv2D, MaxPooling2D, Conv1D, MaxPooling1D, LSTM, ConvLSTM2D
from keras.layers import GRU, BatchNormalization, LocallyConnected2D, Permute
from keras.l... |
b6a6908b593b65013e7851db814ea4d335e7a46088b8093312bf2808b018ae3b | Python | 3,893 | 142 | """
GTF.py
Kamil Slowikowski
December 24, 2013
Modified by: Maciej Bak
26.03.2020
Read GFF/GTF files. Works with gzip compressed files and pandas.
http://useast.ensembl.org/info/website/upload/gff.html
LICENSE
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modif... |
0829e1f82d5956d8c14088ef4781f4845a78559864636645b20aea1c87d3cb97 | Python | 3,895 | 99 | # Copyright (c) MONAI Consortium
# 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, so... |
7d3708e890e671498b9f91b188c432f452eafac85a3d295057339f9b9362999c | Python | 3,896 | 124 | """
Find the subset of k1-mers which enables the most k2-mers.
"""
import os
import pickle
import sys
from collections import defaultdict
from itertools import product
import pulp
from utils.misc import valid_cpg_mc_kmer
from utils.misc import parse_ilp_sol
from utils.constants import KMER_LEN
def solve_kmer_ilp(... |
8a67c1d088a921abb422443b87a45d81e9f38c39a1b41cb0b8e75c8b4d2b3d08 | Python | 3,896 | 110 | "OT decorrelation"
import pyrootutils
root = pyrootutils.setup_root(search_from=__file__, pythonpath=True)
from tqdm import tqdm
import logging
log = logging.getLogger(__name__)
import numpy as np
import hydra
from omegaconf import OmegaConf,DictConfig
import torch as T
from sklearn.model_selection import train_te... |
8835a59ba78e2c3d211550128e11a73b69c1db26c67d00f056a77fd32dc92ada | Python | 3,898 | 137 | import pandas as pd
import numpy as np
from urllib.request import urlretrieve
import datetime
from multiprocessing.dummy import Pool as ThreadPool
import requests, sys
goa_human_gaf_gz = None
try:
now = datetime.datetime.now()
cur_date_str = now.strftime("%d_%m_%Y")
print("Current date:", cur_date_str)... |
a024918621570714646cd29bd7070d8c8847fac04235666b99b17d462d0bcb76 | Python | 3,898 | 74 | # Copyright (c) 2008-2026 the MRtrix3 contributors.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Covered Software is provided under this License on an "as is"
#... |
925273651770bfe65ada9a83d09f1c395c7429d6eb09f3680efcfd52ec0e5ae0 | Python | 3,900 | 54 | """Graphical abstract for GEIT: 2.5:1 strip, rendered at 2656 x 1062 px (twice the 1328 x 531 minimum, proportional as the Guide allows).
Three findings, left to right; numbers are read from the result ledgers so the figure cannot drift from the paper."""
from __future__ import annotations
import os, sys
import numpy a... |
83e51bbf7bb047d4ededaee42bd9c45976b328edb27ff4aca2e5b6248a96dd8c | Python | 3,902 | 113 | # -*- coding: utf-8 -*-
"""
Created on Mon May 3 23:11:04 2021
@author: yw_ji
"""
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = 2
import datetime
import tensorflow as tf
class DICE(object):
def __init__(
self,
model_dir,
model_name,
batch_size=100,
... |
1d0c9118ff8c4e0965e9b1d81cf317afe12ff6bc514b3f3b189796bb33575f75 | Python | 3,904 | 94 | import torch
def compute_accuracy(pred, target):
return float(torch.sum(torch.max(pred.detach(), dim=1)[1] == target).cpu().item())/len(pred)
def do_AttrMasking(batch, criterion, node_repr, molecule_atom_masking_model):
target = batch.mask_node_label[:, 0]
node_pred = molecule_atom_masking_model(node_re... |
6f9e7e40eb7021ad0e81d7dc951276cf9c1e31b64e6a3836c1a776d35660fb27 | Python | 3,906 | 110 | import torch
from genie.diffusion.diffusion import Diffusion
from genie.diffusion.schedule import get_betas
from genie.utils.loss import rmsd
from genie.utils.affine_utils import T
from genie.utils.geo_utils import compute_frenet_frames
class Genie(Diffusion):
def setup_schedule(self):
self.betas = get_betas(se... |
f8f5a85be6c027cf210b905c26871a7dd481a1d9cb402ceabcf4c18b86c9dd0f | Python | 3,907 | 98 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
3d69c3b454ee0d032256b42149374a3dca7e92c722e1bb105ed838b33c962df6 | Python | 3,908 | 72 | import pandas as pd
data6269_1 = pd.read_excel('data6269_1.xlsx', index_col=0, header=1)
data6269_2 = pd.read_excel('data6269_2.xlsx', index_col=0)
data6269_3 = pd.read_excel('data6269_3.xlsx', index_col=0)
data6377 = pd.read_excel('data6377.xlsx', index_col=0)
data9692 = pd.read_excel('data9692.xlsx', index_col... |
d2de2eeb4bdd5dbd9dfba47c7409e47d3ae87a50e245f81a595c61acdfc4d1d1 | Python | 3,908 | 98 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
5cfc955eb86b4d999d4d037c17dcd79f0981ea4a01fd3ede6d60475ae7a0993d | Python | 3,909 | 131 | #!/usr/bin/env python3
import argparse
import pathlib
from typing import Optional
import yaml
import pandas as pd
import seaborn as sns
from matplotlib.patches import Rectangle
def parse_arguments(
key: Optional[str] = None, stage: Optional[str] = None, method: Optional[str] = None
):
"""
Parses command... |
6a4731857037fbddae18664556c998329bb6b1af4cc732a8b4fd3da26a6fa8a0 | Python | 3,910 | 94 | """
Created by Jude Wells 2023-04-20
Objective is to create a secondary structure matrix for each protein
1) renumbers the pdb file (1-indexed)
2) runs stride to get secondary structure file
3) parses the secondary structure file to create a matrix of secondary structure
# should take around 3 minutes for 1000 structu... |
ee16d0494467818e9909e18c3abb85223840c6b3073195d63f8f3c98e36b0f73 | Python | 3,910 | 94 | # 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... |
7a4cd631aea222d5f2438e17ebaf0049f510dc6eb84b7ad193634d12ee31b011 | Python | 3,911 | 112 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
b9819b2c0a4499d36c83bc34ee68cb1f78d0bd6134d86f3c18b4045e60696dec | Python | 3,912 | 90 | """Property tests for pydeepmapper.hybrid_assembly: the semantic invariants (idempotent tagging,
namespace separation, sc-table assembly). Stdlib + pytest + hypothesis only (no torch,
no external bio tools, only the PURE core is exercised here)."""
from __future__ import annotations
import os
import sys
import pytest... |
7e637f29e3008df2d327d190f6d74897de9390fde94406356753a9a744ff64d0 | Python | 3,914 | 121 | # Copyright 2024 Eelke Spaak, Donders Institute.
# See https://github.com/Spaak/rift-phase-and-visibility for readme/license.
# Belongs with:
# Spaak, E., Bouwkamp, F. G., & de Lange, F. P. (2024). Perceptual foundation and extension
# to phase tagging for rapid invisible frequency tagging (RIFT). Imaging Neuroscience,... |
9f59f4793315c94f8c9043775f76df5cd7aae9740bd057227eb0c7a33c37a4af | Python | 3,914 | 102 | import numpy as np
from pgmpy.base import DAG, PDAG
from pgmpy.metrics import BaseSupervisedMetric
class SHD(BaseSupervisedMetric):
r"""
Computes the Structural Hamming Distance (SHD) between two graphs.
Given two graphs (DAGs or PDAGs) :math:`G_1` and :math:`G_2` over the same vertex set, let :math:`S(... |
6e6eda3f9d9c7c8b0f7aeb36aac143f6b5d0dcb0ee9181d67f6eaccd266ba4a4 | Python | 3,915 | 95 | #TO BE UPDATED
from NeuronModel.NeuronClass import neuronClass
import numpy as np
from NeuronModel.Hodgkin_Huxley import hodgkin_huxley_parameters
from NeuronModel.Hodgkin_Huxley import mainer_parameters
from NeuronModel.Hodgkin_Huxley import neuronal_dynamics_parameters
def hodgkin_huxley(params = 'HH'):
dict = ... |
c65de8fd25623b12715aacf4a0ad9e1367de14c690687a92972137f1cc6cf131 | Python | 3,919 | 107 | # Training procedure for WideNet 32-10 for CIFAR-10.
import keras
import numpy as np
from keras.datasets import cifar10
from keras.preprocessing.image import ImageDataGenerator
from keras.layers.normalization import BatchNormalization
from keras.layers import Conv2D, Dense, Input, add, Activation, GlobalAveragePooling... |
44f324f790886cc9974e6e9b2b218cc4e17343f4f7bb56f8e39979f635a162b1 | Python | 3,921 | 86 | import os
import glob
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from scipy.stats import iqr, linregress
from paths import TRAINING_DATA_PATH, TEST_DATA_PATH
MARKERSIZE = 15
flow_path = TEST_DATA_PATH + "/flow/"
ALL_MODELS = ['ALL', 'ACOUS', 'BASE', 'BG_0-100', 'BG_60-80... |
e665aaef4e99687b7b8793a61e23cdea3717477207675afadfd69b66c04bf6a2 | Python | 3,924 | 92 | '''
Count chronic stats of a mouse
8/30/2022
'''
import os
import json
import re
import datetime
import shutil
import numpy as np
import matplotlib.pyplot as plt
from utils.read_mda import readmda
POSTPROC_NAME = "postproc_220913"
STATFIGS_NAME = "statfigs_220913_from__" + POSTPROC_NAME.replace('/', '-') + "__"
def... |
a495b9f78ff357d567d0b95c5d29dd834ae3ac200e3e8ad526ccdb4d6fd0613a | Python | 3,925 | 65 | """Validate the FreeSurfer tools and atlas files used by surface processing."""
import os
from pathlib import Path
def configured_home(args):
backend = getattr(args, 'postprocess_backend', getattr(args, 'backend', 'auto'))
runtime = getattr(args, 'postprocess_runtime', getattr(args, 'core_runtime', None))
... |
f31434017bf5eefe1e4b4b23de2ecc28dff749e13ceb3919f6260e8288d57057 | Python | 3,925 | 109 | import unittest
import numpy as np
from rdkit import Chem
from unittest.mock import patch
class TestFingerprintFunctions(unittest.TestCase):
def test_create_RDKFingerprint(self):
from polyfingerprints.fingerprints import create_RDKFingerprint
smiles = ["CC", "CCC"]
result = create_RDKFing... |
def854fd0c683adca9214625b3708d2ff5e39f42aab116bb366cbfc5054aa2f4 | Python | 3,926 | 106 | import warnings
import numpy as np
from torch import nn
from .. import activations
from .base import Encoder
class FiringRateEncoder(Encoder):
def __init__(
self,
core,
readout,
*,
perspective=None,
shifter=None,
modulator=None,
elu_offset=0.0,
... |
0219d943fc148b31194b67075dcee5d8912ba0c0a76afd9c67edf73fdcdf456c | Python | 3,927 | 102 | """DeepMapper feature->pixel transform, the PURE, contracted core.
A feature vector is laid out into a small ``dim x dim`` pseudo-image by padding to
a perfect square and reshaping. Different *arrangements* come from a seeded
permutation of the feature order; per-pixel attributions are projected back to
feature space ... |
13b991327d63b2509a4c4c58a5adc6f988bec79a62fba12c17bb25d98f98f684 | Python | 3,927 | 144 | import tensorflow as tf
class CriticBase(tf.keras.Model):
def __init__(self,
net,
input_cats=None):
super(CriticBase, self).__init__()
self.net = net
self.input_cats = input_cats
self.can_condition = self.input_cats is not None
return
... |
6a6185f59de4cbe75f649393e20cef8612822325be0cc3f26eadf49a7834c3f7 | Python | 3,929 | 78 | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... |
7fb80a701d904baaa6c48e43646054dbdd00fa273a5952d5af41c9f0148c473d | Python | 3,929 | 90 | import numpy as np
import scipy
import scipy.signal
def pad(x,K):
before = x[:K][::-1]
after = x[-K:][::-1]
x_padded = np.concatenate([before,x,after])
return x_padded
class filter_trace():
def __init__(self,range_filter = 1,type_filter = 'mean', M=None, p=None) :
self.range_filter = range... |
a6f9cec823fa50a21d7e261fa8238a25129bcee0b06742b75566212377ae59b3 | Python | 3,929 | 125 | #!/usr/bin/env python2
"""Annotate sequences with info from uniprot
Usage:
./01_scripts/05_annotate_genes.py sequence_file annotation_folder output_file
"""
# Modules
import sys
import os
# Classes
class Fasta(object):
"""Fasta object with name and sequence
"""
def __init__(self, name, sequence):
... |
848dd735416c5b11509a89429ffeb48f0da97e0035c751e8275d17d28ae23183 | Python | 3,930 | 98 | # Extracts IQMs from MRIQC, identifies outlier subjects, and creates covariates
# Note: this is specific to SRNDNA
#
# usage example:
# python code/SRNDNA_OutlierID.py --mriqcDir="derivatives/mriqc"
#
# originally written by Jeff Dennison (Spring 2020)
import numpy as np
import json
import pandas as pd
import os
impor... |
9b0016869058876625d56b916ba759abb64811e0e80855ffe1a70434fe78a07a | Python | 3,930 | 113 | import numpy as np
from mimic3models import common_utils
import threading
import random
import os
class BatchGen(object):
def __init__(self, reader, discretizer, normalizer, batch_size,
small_part, target_repl, shuffle, return_names=False):
self.batch_size = batch_size
self.targ... |
94be36a8a89c70ef43f14a3d5f740f0fe5d38f960a9fb237edb5c7a1ee88ef7f | Python | 3,931 | 117 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
3b7da970c0d067919b7a8cfc563f9d90c7d33082f075dd557afdfdb491769ae8 | Python | 3,932 | 126 | import math
import torch
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
from torch.autograd import Variable
from functools import partial
class C3D(nn.Module):
"""
This is the c3d implementation with batch norm.
[1] Tran, Du, et al. "Learning spatiotemporal features w... |
fb0825c80347416a0f555fd1a9ac0c7dbf0f621ba5127f3326eb147a52a6e702 | Python | 3,932 | 117 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
ce3fe215f0cb2d330b7cec5fa25af4a61b060b197e199e1809b0ea5ee1c6b9e3 | Python | 3,933 | 91 | import pandas as pd
import numpy as np
import re
import argparse
def get_data(rawdata_path,save_path,cancer):
data_CNV=pd.read_csv(rawdata_path+'/'+cancer+'.CNV_masked_seg.csv',sep=',')
data_CNV['ID']='chr'+data_CNV['Chromosome'].astype(str)+'_'+data_CNV['Start'].astype(str)+'_'+data_CNV['End'].astype(str)
... |
a939f1273f5e55fbdb87f79fb7cf2593016b2ace5c0b1d20702204a7ee31d825 | Python | 3,935 | 110 | import ccg
import numpy as np
import jpype as jp
# import jpype.imports
from jpype.types import *
from os.path import realpath, dirname, join
from os import getcwd
import atexit
if not jp.isJVMStarted():
EASYCCG_JAR = join(realpath(join(getcwd(), dirname(__file__))), "astar.jar")
jp.startJVM(convertStrings=Tr... |
f6cb36cf346bb05483cf8dba946b4fac517923fde3308dfb328a600c4e3e4918 | Python | 3,935 | 116 | ###########################
# Latent ODEs for Irregularly-Sampled Time Series
# Author: Yulia Rubanova
###########################
import numpy as np
import torch
import torch.nn as nn
from torch.nn.utils.spectral_norm import spectral_norm
import lib.utils as utils
###################################################... |
91b30b8a5d7bf4f7c4d82e762cd8582fb6c8499ba3dfaf8a840df0ecc977ddaf | Python | 3,937 | 133 | # Copyright 2021 AlQuraishi Laboratory
# Copyright 2021 DeepMind Technologies Limited
#
# 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
#
# U... |
b90b81de248fefd4eeeee3555490b6e3477fcfd5882a01c1d7948fb484cfa47b | Python | 3,937 | 105 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 19 14:14:57 2022
@author: athanasiadis
"""
import numpy as np
import pickle
from joblib import Parallel, delayed
import multiprocessing
num_cores = multiprocessing.cpu_count()
import relevance_id as idf
def main(att_res):
"""
main
_... |
2b2b17cc35a03d26ba4ea3d5ae5724177b2442533228d17476cf30a27ad9bd11 | Python | 3,940 | 116 | """Map-reduce chain.
Splits up a document, sends the smaller parts to the LLM with one prompt,
then combines the results with another one.
"""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
from langchain_core._api import deprecated
from langchain_core.callbacks import... |
d57cf3504f98b2246c33c6988d1dc1f2b1bc95203619f851911a5b772194310f | Python | 3,941 | 128 | """ Script to merge partial mrds files into a single mrds file after
parallel processing"""
from pathlib import Path
from typing import List, Union
from MRdataset import load_mr_dataset
from MRdataset import save_mr_dataset
from MRdataset.base import BaseDataset
from mrQA.utils import txt2list
def _check_partial_da... |
1420395a3c3bae384aa0bdfaad92984e4a83501a37fec30b7fffac1527e2d0cb | Python | 3,942 | 133 | #!/usr/bin/env python3
import argparse
import pathlib
from typing import Optional
import yaml
import pandas as pd
import seaborn as sns
from matplotlib.patches import Rectangle
def parse_arguments(
key: Optional[str] = None, stage: Optional[str] = None, method: Optional[str] = None
):
"""
Parses command... |
7f004d00e86a438333741cb954b6c8496295cfdca674e73e9149384a91e01c9c | Python | 3,942 | 96 | from typing import TYPE_CHECKING, Any
from langchain_classic._api import create_importer
if TYPE_CHECKING:
from langchain_community.chains.graph_qa.prompts import (
AQL_FIX_TEMPLATE,
AQL_GENERATION_TEMPLATE,
AQL_QA_TEMPLATE,
CYPHER_GENERATION_PROMPT,
CYPHER_GENERATION_TEMPL... |
d1d8021df51d5d8ce5e367ed951f0b62cbf4527ee1d8c09e4cfc22a46491e7c5 | Python | 3,943 | 109 | import json
from collections.abc import Callable
from typing import Any
from langchain_core.utils.json import parse_json_markdown
from typing_extensions import override
from langchain_classic.evaluation.schema import StringEvaluator
class JsonEditDistanceEvaluator(StringEvaluator):
"""An evaluator that calculat... |
3474c6d7adf8918dfd47c706674a4a34083c9c9b867fb70e58583fe2b2907771 | Python | 3,944 | 115 | from copy import deepcopy
from multiprocessing.pool import Pool
from batchgenerators.utilities.file_and_folder_operations import *
from medpy import metric
import SimpleITK as sitk
import numpy as np
from nnsegnext.configuration import default_num_threads
from nnsegnext.postprocessing.consolidate_postprocessing import... |
5e09725590918ca324fb7a18b9e306ccfcac4cf312e2b540275dfcc05757c7d8 | Python | 3,944 | 104 | import keras
from keras.models import Sequential, Model, load_model
from keras.layers import Dense, Dropout, Activation, Flatten, Input, Lambda
from keras.layers import Conv2D, MaxPooling2D, Conv1D, MaxPooling1D, LSTM, ConvLSTM2D
from keras.layers import GRU, BatchNormalization, LocallyConnected2D, Permute
from keras.l... |
62fa4a1a6b30470dcdf5d3cce38841d6589da5dc472b0a7cb79b0838a479c853 | Python | 3,945 | 46 | from .base_options import BaseOptions
class TrainOptions(BaseOptions):
"""This class includes training options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser):
parser = BaseOptions.initialize(self, parser)
# visdom and HTML visualization para... |
5c5ef9d2a9774b07881a8cd0c8d214a61ee3c089172a67ae8e7dde115ea9d6ef | Python | 3,946 | 145 | """
Full-Batch L-BFGS Implementation with Wolfe Line Search
Demonstrates how to implement a simple full-batch L-BFGS with weak Wolfe line search
without Powell damping to train a simple convolutional neural network using the LBFGS
optimizer.
This implementation is CUDA-compatible.
Implemented by: Hao-Jun Michael S... |
a0b4be1a8a62fbcb0f16aaaa3f97fdbd6a8b2939d7b180e607cb6da2e728589b | Python | 3,946 | 118 | # Copyright 2020 DeepMind Technologies Limited. 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... |
96117d4f7790a1cad965d229fb281d3752187013a0348597155da6789016bbee | Python | 3,948 | 115 | from typing import Any
from typing_extensions import override
from langchain_core.caches import RETURN_VAL_TYPE, BaseCache
from langchain_core.globals import set_llm_cache
from langchain_core.language_models import FakeListLLM
class InMemoryCache(BaseCache):
"""In-memory cache used for testing purposes."""
... |
e94adaa9c56b9ad9099f831fc02903ba99f0c19b6000476f8d4639ca162e3a3a | Python | 3,949 | 78 | from langchain_core.prompts import PromptTemplate
template = """You are a teacher grading a quiz.
You are given a question, the student's answer, and the true answer, and are asked to score the student answer as either CORRECT or INCORRECT.
Example Format:
QUESTION: question here
STUDENT ANSWER: student's answer here... |
19a20ffda44ec920ccd32cc96fe366a2c0a5236ac588564a29012d3676e2cdb7 | Python | 3,950 | 113 | import numpy as np
import torch
from .logreg import LogReg
import torch.nn as nn
from sklearn.metrics import f1_score
from torch.nn.functional import softmax
from sklearn.metrics import roc_auc_score
##################################################
# This section of code adapted from pcy1302/DMGI #
################... |
387d1c604c32faecf1c1c0e88c7c9ae3cea46bac5ba012ff0ecf285f26d57da3 | Python | 3,950 | 96 | # This file is a part of the `allegro` package. Please see LICENSE and README at the root for information on using it.
import torch
from e3nn.o3._irreps import Irreps
from e3nn.o3._spherical_harmonics import SphericalHarmonics
from e3nn.util.jit import compile_mode
from nequip.data import AtomicDataDict
from nequip.n... |
2b9a9a946d630f799a2a3ae45f6df6b05f776fbf5accb5b875019afb0eb0ce1e | Python | 3,951 | 102 | import pandas as pd
import numpy as np
import argparse
def get_data(path,label_path,reference_path,save_path):
feature_data = pd.read_csv(reference_path+'/gene_all.txt',header=None)
feature_data = list(feature_data[0])
label=pd.read_csv(label_path,sep='\t')
sample=list(label['sample_id'])
count_typ... |
5dbda2b1888eb61f31925831ea1ea008df2810ee48f02bbb674160affc4bfe26 | Python | 3,951 | 128 | #!/usr/bin/env python3
import argparse
import pathlib
from typing import Optional
import numpy as np
import pandas as pd
import yaml
def parse_arguments(
key: Optional[str] = None, stage: Optional[str] = None, method: Optional[str] = None
):
"""
Parses command line arguments
"""
parser = argpars... |
88c057721687bff88cdac5a791e423f5397d4a31e9a49c5653d9ef626f50d9ce | Python | 3,951 | 117 | import logging
import os
import numpy as np
__all__ = ['check_can_write_file', 'normalize_3d_volume', 'volume4d_to_matrix']
def check_can_write_file(fpath: str, force: bool = False,
verbose: bool = False):
"""
Check if a file can be written.
The function checks if the file alre... |
1126e4ab6d79b9ddc24107678a2bd7aea24cdcbfa2639d35d456656e5adddc90 | Python | 3,952 | 119 | import os
import glob
import tifffile
import numpy as np
import math
def aug_sim_img_2D(save_dir,input_dir,gt_dir,patch_size,num_patch=50000):
input_list = sorted(glob.glob(os.path.join(input_dir,'*.tif')))
gt_list = sorted(glob.glob(os.path.join(gt_dir,'*.tif')))
img_num = len(input_list)
if... |
3a469ca96712e112b039965056f43ce43b95990319ca9d064f84e8f5f581e542 | Python | 3,952 | 94 | import logging
import os
import socket
import sys
from fcest.helpers.array_operations import get_all_lower_triangular_indices_tuples
import numpy as np
import pandas as pd
import pingouin
from configs.configs import get_config_dict
if __name__ == "__main__":
data_split = 'all'
experiment_dimensionality = '... |
0992a379a57fff9d702ef582f2138e731f1095e77374be76ecf35bae6dbe5151 | Python | 3,954 | 99 | import numpy as np
import itertools
from Simulator.SimulatorDMS import simulatorPatternDMS
from Articles.DMS_DLS.Code.ParserPattern import create_parser_main_DMS
from NetworkModel.StriatumNeurons import find_params_neuron
class paramsGestDMS:
def __init__(self):
self.parent_parser = create_parser_main_DMS... |
b10a5f107f7dc0f7ffcf623c04e8e33301f68e752f2e132d744d5b087a3e2fa6 | Python | 3,954 | 104 | import os
import pandas as pd
import iFeatureOmegaCLI
import torch
import numpy as np
from torch_geometric.data import Data
import warnings
warnings.filterwarnings("ignore")
import pickle
from tqdm import tqdm
import multiprocessing
import logging
from torch_geometric.utils import add_self_loops
import contextlib
impor... |
ac86714181eee2e34090631717247bcfe7bb8a72cbbaf9f1ab09003311beb544 | Python | 3,955 | 122 | import argparse
import ctypes
import logging
import os
import random
from functools import wraps
from typing import Union, List, Dict
import numpy as np
import torch
import torch.distributed as dist
from torch import Tensor
import datetime
from h3xsemble.utils.rigid_utils import Rigid
def aggregate_residual(feats1, fe... |
d31df2f83adfa5c63e94b505b648fd06801dd24bf05f8f1a72b9c9515702c626 | Python | 3,956 | 125 | """
Tools for managing datafiles in perses
"""
__author__ = 'John D. Chodera'
def get_data_filename(relative_path):
"""get the full path to one of the reference files shipped for testing
in the source distribution, these files are in ``perses/data/*/``,
but on installation, they're moved to somewhere ... |
4e53ac2dd5d0147c11f826c54fba9ceaca19324ee88703ec0f9a7de0d19ad6c3 | Python | 3,957 | 112 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 8 15:38:23 2022
@author: biener
"""
import torch
import torch.nn as nn
from torch import Tensor
import numpy as np
import copy
import mAECell_Utils as utils
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# Plots the dif... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.