sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e95c8e5a4cfb207ef98f7f2f6baf16216d2461c01444e29e97bbbb9d4706a6e2 | Python | 5,437 | 150 | # Copyright 2025 Xanadu Quantum Technologies Inc.
# 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 agre... |
29dd42c6e962732a8113e3a041d0ce0232564b9840c27c77c51634ca8ea0acc9 | Python | 5,438 | 185 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_basic():
s = pd.Series([[0, 1, 2], np.nan, [], (3, 4)], index=list("abcd"), name="foo")
result = s.explode()
expected = pd.Series(
[0, 1, 2, np.nan, np.nan, 3, 4], index=list("aaabcdd"), dtype=object, name=... |
9d0d977806c84b0dffe2617c7340d85adbd757dfd5662a2198793a11359a217b | Python | 5,438 | 111 | import os
import sys
import sys
import shutil
import pandas as pd
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
try:
from IPython.display import display, Image as IPImage
_HAS_IPYTHON = True
except Exception:
_HAS_IPYTHON = False
import seaborn as sns
from tqdm import tqdm
def ... |
ee90a239526dadd645bafe829fd0d8a9ca2c947cf6161a488be2be3ed4cc900f | Python | 5,445 | 163 | import reverb
import tensorflow as tf
from tensorflow.keras.callbacks import LearningRateScheduler
from wandb.integration.keras import WandbMetricsLogger
import wandb
from rl_toolkit.networks.callbacks import DQNAgentCallback, PrintLR, cosine_schedule
from rl_toolkit.networks.models import DuelingDQN
from rl_toolkit.u... |
dc272038769c3bd232387a1132ded77690d282bd0bd0ee7dce02b51c0cdd6ed3 | Python | 5,447 | 152 | import argparse
import glob
import hashlib
import json
import os
import re
import shutil
import subprocess
import sys
import zipfile
import pandas as pd
from moseq2_extras.model import get_syllable_id_mapping
from moseq2_extras.util import ensure_dir
from moseq2_viz.model.util import parse_model_results, results_to_d... |
5eb10f49e23d5e10018429b1461df93d39d1aca2825fc1b1840b7caf614ad991 | Python | 5,450 | 138 | import sys, argparse, pandas as pd, numpy as np
from mvpa2.misc.data_generators import double_gamma_hrf as hrf
def compute_history_intervals(X, y, series_ids):
"""
Compute row indices in **X** of initial and final impulses for each element of **y**.
:param X: ``pandas`` ``DataFrame``; impulse (predictor)... |
56591b112a505053c4906a23b075eab381eef1e8be48553fe5b1d5ae247f83c3 | Python | 5,451 | 148 | """
Tests for ndarray-like method on the base Index class
"""
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.arrays import SparseArray
class TestReshape:
def test_repeat(self):
repeats = 2
index = pd.Index([1, 2, 3])
expected = pd.Index([1, ... |
b3b3cecd3cd0a637dcd758f89d98f0c217e46b430fa7666814b9828844a96b51 | Python | 5,451 | 152 | import torch
import torch.nn as nn
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
return nn.Conv3d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dilation=dilation)
def conv1x1(in_planes, out_planes, stride=1):
retu... |
eeb483984db3d1c31120337a5bf3e23da4ad509ea841e02e028328583cb795cd | Python | 5,452 | 155 | # Calculate structure searching performance
import numpy as np
from collections import defaultdict
results_dir = "eat_results"
dataset_dir = "../../dataset"
domid_to_fam = {}
fams_search = []
with open(dataset_dir + "/search_all.txt") as f:
for line in f.readlines():
cols = line.rstrip().split()
... |
7e6a33ac9c7bbaa4d0a8e9467b40e5611d8d70184ae28c5c2b414e9d63a84628 | Python | 5,453 | 186 | """
Visualization of pair model parameters
Authors:
Thomas A. Hopf
"""
import json
import numpy as np
from evcouplings.couplings.pairs import add_mixture_probability
def evzoom_data(model, ec_threshold=0.9, freq_threshold=0.01,
Jij_threshold=10, score="cn",
reorder=None):
"""
... |
cdb4c40c398486cec9b5a929785fc2651faaefe7d037dc0a7a794e77ae88a649 | Python | 5,453 | 170 | """Tensorflow datasets for paccmann."""
import os
import logging
import tensorflow as tf
logger = logging.getLogger('datasets')
# TFRecords metadata.
DATASETS_METADATA = {
'smiles_character_tokens': tf.FixedLenFeature((158), tf.int64),
'smiles_atom_tokens': tf.FixedLenFeature((155), tf.int64),
'fingerprin... |
a76d892dcfc30474ef9403d80a5bad88246c859810c7b32c2fdf6e778702e139 | Python | 5,454 | 216 | """
This script converts .dat to .h5 files
The data contains no navigator
Author: Zhengguo Tan <zhengguo.tan@gmail.com>
"""
import argparse
import h5py
import os
import pathlib
import torch
import twixtools
import numpy as np
import sigpy as sp
from sigpy.mri import app, epi, sms, cc
DIR = os.path.dirname(os.path... |
0d299a1de619d5f9a7aebea9255088c12e59190d4998c07f07afb323cced04a9 | Python | 5,456 | 112 | # -*- coding: utf-8 -*-
"""
preprocess DSC
"""
import os
import numpy as np
import nrrd
from app.utils import get_exitcode_stdout_stderr, end_execution, wrap_string
import logging
logger = logging.getLogger(__name__)
def sk_strip_perf(imp,noStrip):
from skimage import morphology, filters
th_forep = filters.... |
b8c3f41ade329f7926a49b007b8ff9828df22f05e0bb30921c4a38f5b06ff62d | Python | 5,456 | 196 | """
Functions for detecting ECs that should not be
included in 3D structure prediction
Most functions in this module are rewritten from
older pipeline code in choose_CNS_constraint_set.m
Authors:
Thomas A. Hopf
"""
from operator import xor
from copy import deepcopy
def detect_secstruct_clash(i, j, secstruct):
... |
d1b52f4ef9df8f137305067b98febd90e48e34b689a0d745a1b2bda202dc229a | Python | 5,457 | 147 | """
Script to produce the plots in Figure 6 in the paper.
"""
from pathlib import Path
import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt
from src.np_implementation.model import TPC
plt.style.use('ggplot')
results_path = Path('./results/', 'pendulum')
results_path.mkdir(paren... |
8234b5ec65a77f1d58535665441fbe2082048d6f29248baa3eadc7a092b30a59 | Python | 5,458 | 156 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# 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... |
cc10fd59060c2d9900ce55f6d396e9ed775f7401ae1fd63255082ff06ddffa36 | Python | 5,458 | 138 | """Build the blood chemistry example dataset from NHANES IV.
The source is the public ``NHANES4`` table shipped with the R package BioAge
(Kwon & Belsky), which pools the 1999-2018 continuous NHANES cycles. Rows are
kept only where every variable a pyaging clinical clock needs is measured, and
only where every value f... |
82eb5515e3f687eb0bad145550cdaf6a75e44bb54d9134d24cbc3ad4caaefe5e | Python | 5,459 | 167 | from typing import List
import math
import torch.nn as nn
import torch.nn.functional as F
import torch
import numpy as np
class DoubleEmbedding(nn.Module):
"""Embedding layer that allows some frozen and some trainable embeddings.
An embedding layer where the first n_trainable embeddings are trainable and t... |
cbf2feea97691598521d7f32012d17e1e04b9ed361355e6045ba9489e9b50112 | Python | 5,461 | 178 | """
Tests for the pseudo-public API implemented in internals/api.py and exposed
in core.internals
"""
import datetime
import numpy as np
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
from pandas.api.internals import create_dataframe_from_blocks
from pandas.c... |
2ec0d1a66b7e9898e02f5e58d5ff1f1c65185acefc2d7edad86cfb41295a6191 | Python | 5,462 | 109 | # Copyright 2019 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... |
53de6a5c8f6526e869ea9b98a1d46bfd171c343a1266f401b89a1002e906a5ba | Python | 5,462 | 152 | import pandas as pd
import numpy as np
from pytorch_classes_and_functions import AmesDataset
def create_df_activations(df_train,train_file_type,mol_column,activity_column,model,model_hidd_neurons):
"""
function to create df_activations: n rows (training compounds), m columns (hidden neurons)
assumes... |
74027e5ea615e60c71981cc1540671137cf8d2b296b74b8341621d102a3f8d59 | Python | 5,470 | 150 | #!/usr/bin/env python3
# Copyright 2015 Google, Inc. 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 require... |
d5e3afc9d690f54a0340bf09fc955ac5705db95d07cd5d1c5564238abeaba4df | Python | 5,472 | 139 | import jax
import jax.numpy as jnp
from jax.example_libraries import optimizers
import os
import time
import data, parameters
import utils
from hyperparameters import SimArgs
from utils_training import run_epoch
jnp.set_printoptions(formatter={'float': lambda x: f'{x:.2f}'})
def train(args: SimArgs):
key = jax.r... |
2597f440f3cbc69b70c948da2142c00123786b6a519e5c0dc431981fa456f1b6 | Python | 5,475 | 127 |
import math, importlib.util
import json
import os
import csv
import boltons.mathutils
import urllib.parse
import types
import typing as ty
from typing import Dict
class PheWebError(Exception):
'''implies that an exception is being handled by PheWeb, so its message should just be printed.'''
def load_module_from... |
7639bbf8d8aadc662e1fe69530dcc05ef5e265dd148e1cef9be455458897d853 | Python | 5,476 | 169 | import re
import pytest
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize(
"to_replace,value,expected",
[
# one-to-one
(4, 1, [1, 2, 3]),
(3, 1, [1, 2, 1]),
# many-to-one
((5, 6), 2, [1, 2, 3]),
((3, 2), 1, [1, 1, 1]),
],
)
def test... |
86263c5717a5a6ffc35d1cf5e0466b3f6cb7ceb49c3d8510adc344b20427264e | Python | 5,476 | 177 | #! /usr/bin/env python
##############################################################################
## DendroPy Phylogenetic Computing Library.
##
## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder.
## All rights reserved.
##
## See "LICENSE.rst" for terms and conditions of usage.
##
## If you use this wo... |
2a848e6bed02ca8808d5636bca7f226f21a119e3297e4b25e60abee50e9d3af3 | Python | 5,477 | 124 | from sys import path as sys_path
sys_path.append('..')
sys_path.append('../base')
import os
import matplotlib
if 'DISPLAY' in os.environ:
matplotlib.use('qt5Agg')
else:
matplotlib.use("Agg")
print(os.environ)
import matplotlib.pyplot as plt
import numpy as np
import pygalmesh
from base.curveExamples import ... |
b01274403e515f043745d29c16b27d0188cad87e448dad233a7102295f960bf7 | Python | 5,479 | 134 | import numpy as np
import matplotlib.pyplot as plt
import sys
import wormdatamodel as wormdm
import wormbrain as wormb
import pumpprobe as pp
import mistofrutta as mf
import os
folder = sys.argv[1]
if folder[-1]!="/": folder += "/"
save = True
stims = None
shiftvol = 0
for s in sys.argv:
s = s.split(":")
if s... |
418125f039d45bc6cf784316a0f5595bfe250dc966552e47fefe9474e63c17b3 | Python | 5,482 | 140 | import dclab
from PyQt6 import QtCore, QtGui, QtWidgets
#: These are features only visible in developer mode
HIDDEN_FEATURES = []
for ii in range(10):
HIDDEN_FEATURES.append(f"basinmap{ii}")
class FeatureComboBox(QtWidgets.QComboBox):
def __init__(self, *args, **kwargs):
"""A DC data aware combobox f... |
aa4cb07ebb4c30b6f6665b26c7921ea0e4a9b9a4d33cc2bf95052af5928fdc61 | Python | 5,483 | 139 | """Topic modeling with latent Dirichlet allocation."""
import pandas as pd
from sklearn.decomposition import LatentDirichletAllocation
from nimare import references
from nimare.annotate.text import generate_counts
from nimare.base import NiMAREBase
from nimare.due import due
@due.dcite(references.LDA, description="I... |
b02f2280d24dee123c21d1a8bd298a3232ce946f755554eaded076c507d48eda | Python | 5,486 | 147 | import numpy as np
import h5py
from . import surfaces
from . import curves as crvs
from . import surfaceSection
def readTagData(filename, contoursOnly=False, select_sections_tag = None):
f = h5py.File(filename, 'r')
fkeys = list(f.keys())
if not contoursOnly:
if 'Template' in fkeys:
ver... |
47cdbc0f3e31e19f1160e52b14af5d083a2900eeaf1c6307862a23bd108d6da8 | Python | 5,488 | 113 | # MOFTransformer version 2.1.1
from itertools import chain
from moftransformer.run import run
str_kwargs_names = {
'load_path': 'This parameter specifies the path of the model that will be used for training/testing. '
'The available options are "pmtransformer", "moftransformer", other .ckpt paths, and No... |
8238131626a95bd6cbfbad643e51a4f23d313938ba5d382968931b91c44e7004 | Python | 5,488 | 156 | """
The most famous integral in quantum mechanics is the Feynman path integral.
In principle, the quantum mechanics of any system (with a classical limit)
can be reduced to a problem in multidimensional integration. Normally there
are too many variables, and the integrand is too peaky to attempt using
something like ... |
97ab5378c88bff5569bd6aa9c8f2d3b82e36db5386d9aa9efce241f73d05a4b4 | Python | 5,489 | 170 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# 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... |
80a02c9d5ac1e2fb21de4c33bc7198850040b2c25d42b1857d8c075706538c0e | Python | 5,490 | 196 | import numpy as np
import pandas as pd
ops = ["mean", "sum", "median", "std", "skew", "kurt", "prod", "sem", "var"]
class FrameOps:
params = [ops, ["float", "int", "Int64"], [0, 1, None]]
param_names = ["op", "dtype", "axis"]
def setup(self, op, dtype, axis):
values = np.random.randn(100000, 4)... |
1df9c766baf703c4c122adc209620394a3128096b0af0eae0070b89c607ae30a | Python | 5,493 | 154 | '''
Class to handle URSO datasets
'''
import os
import numpy as np
import os.path
import skimage
import pandas as pd
import se3lib
import utils
from dataset import Dataset
class Camera:
fov_x = 90.0 * np.pi / 180
fov_y = 73.7 * np.pi / 180
width = 1280 # number of horizontal[pixels]
height = 960 # nu... |
5f7bb1f0af9e807d6b159f249e7c697813744571b5ec63cd05ec7cad8adafb34 | Python | 5,493 | 134 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 18 22:39:18 2022
@author: vman
"""
import nilearn as nl
import nilearn.image as nlimg
import xml.etree.ElementTree as ET
from nilearn.plotting import plot_glass_brain, plot_markers
from scipy.stats import zscore
import numpy as np
import pandas as... |
c22e5a7c2e0a864a0d65efd024f65951ff2710c66a85f4ce6a2fbae4ca685011 | Python | 5,493 | 159 | #!/usr/bin/python3
# filter_unpaired_mappings.py: Filter alignments so that every pair of lines represents a valid read pair
"""
Filter out unpaired mappings so that the results can be used as input for interleaved, paired
alignment. Ensure that for each even value of i, then lines i and i+1 contain mappings for
the ... |
094f3c3e291fcfcfcfe847c241445db10ff812f3d8dec32ceb00dfc7397e052a | Python | 5,495 | 156 | import scipy as sp
from scipy import special
import h5py
from functools import partial
import numpy as np
import os
os.sys.path.append('/gscratch/spe/mpun/protein_holography/fourier')
def zernike_coeff_lm_new(r, t, p, n, r_max, l, m, weights):
# # check input dimensions of arrays
# if (np.array(r).shape ... |
e366beac3e5ff85e12345c41d22887f062917d2a65a3b5a6f9e2e05c6ee9ce70 | Python | 5,495 | 176 | import numpy as np
import pytest
from pandas.core.dtypes.dtypes import DatetimeTZDtype
import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import DatetimeArray
class TestReductions:
@pytest.fixture
def arr1d(self, tz_naive_fixture):
"""Fixture returning DatetimeArray with parame... |
e66d6de24f416de9ea3a99e062db09d0e2a9dec9f65f12493339160146431f67 | Python | 5,495 | 183 | """
Tests that can be parametrized over _any_ Index object.
"""
import re
import numpy as np
import pytest
from pandas.errors import InvalidIndexError
import pandas as pd
import pandas._testing as tm
def test_boolean_context_compat(index):
# GH#7897
with pytest.raises(ValueError, match="The truth value of... |
a6e9a7d3b0e9aff99e0dceba8931faae71a3660870791bf9c54b2ca5185dafcc | Python | 5,502 | 147 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 24 16:01:52 2022
@author: fm02
"""
# plot results of concat_indivisual_SemCat_confusion-matrix_slurm
import numpy as np
import pandas as pd
import pickle
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import sem
from scipy ... |
28ae34d881d0863a478540cdc5d9a531f78738c8af37003dddff26b99be7106a | Python | 5,503 | 127 | """End-to-end smoke test: the full data path on synthetic data, no OASIS needed.
Exercises manifest loading -> volume processing -> subject-wise splitting ->
augmentation (post-split only), and checks the specific properties called
out in the migration scope: shape/range, deterministic seeds, malformed
contracts, temp... |
a59c4134579ebf1f284ea9b00db1f8cc3087631da70c3c547e1769d2f772a3ea | Python | 5,504 | 134 | import torch
from torch import nn
from torch_geometric.utils import scatter
import copy
from ..mlp import MLP
from ..convs import EquivariantTransformerLayer
from ..basis import GaussianRandomFourierFeatures
# Typing
from torch import Tensor
from typing import List, Optional, Tuple
class Encoder(nn.Module):
def... |
aa048b9ffefba5e2a1e6feb34cc6680160a985c5d1f60674741e75f1f57f3d9c | Python | 5,504 | 165 | # Copyright 2025 Xanadu Quantum Technologies Inc.
# 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 agre... |
c3f839a06ec0dc5c3cab7350b807551134f64388a61e230e8f0d075739789965 | Python | 5,504 | 137 | import torch
import torch.nn as nn
from e3nn import o3
from e3nn.nn import Gate
from ..convs.e3nn_nequip import Interaction
# Typing
from torch import Tensor
from typing import List, Optional, Tuple
def tp_path_exists(irreps_in1, irreps_in2, ir_out):
irreps_in1 = o3.Irreps(irreps_in1).simplify()
i... |
e9876d4a70baecad15ee427f4f056e7f087ab914bdb58bd675d2d956027756bc | Python | 5,510 | 141 | """Tests for PCA Compression Operator."""
from collections.abc import Sequence
import pytest
import torch
from mrpro.operators import PCACompressionOp
from mrpro.utils import RandomGenerator
from tests import (
dotproduct_adjointness_test,
forward_mode_autodiff_of_linear_operator_test,
gradient_of_linear... |
d823a016684e4f16f2ba1430cd72d645238489f2e9ef9ba82cc046149917d0f5 | Python | 5,511 | 193 | # -*- coding: utf-8 -*-
#added comment JN 2014-12-07
"""
script generates overview figures *from ncs files* to give you a first
impression of the data quality, movement artifacts and so on
"""
from __future__ import print_function, division, absolute_import
import logging
logger = logging.getLogger(__name__)
import o... |
422b10885e6fc8c88690cd6a75588db670c5bd5824c78cac36dfdf0cb2c3a281 | Python | 5,512 | 171 | """
@author: mkowalska
"""
from builtins import range
import numpy as np
from kcsd import csd_profile as CSD
from kcsd import ValidateKCSD2D
from figure_properties import *
try:
from joblib import Parallel, delayed
import multiprocessing
NUM_CORES = multiprocessing.cpu_count() - 1
PARALLEL_AVAILABLE =... |
7c4ff06299dadacc43abcdbbb76df997589da585fc772a6285d0ee63510d6526 | Python | 5,515 | 126 | #!/usr/bin/env python
__author__ = 'etseng@pacb.com'
import pdb
def overlaps(s1, s2):
return max(0, min(s1.end, s2.end) - max(s1.start, s2.start))
def compare_junctions(r1, r2, internal_fuzzy_max_dist=0, max_5_diff=999999, max_3_diff=999999):
"""
r1, r2 should both be BioReaders.GMAPSAMRecord
super
... |
a3b2af48451e299c61c931658a78155fcf83dcd7ff39b2dcd47a22234eb3988b | Python | 5,515 | 145 | # Copyright 2026 Xanadu Quantum Technologies Inc.
# 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 agre... |
fe3dc6dbe3f09e2153d0f4967b9e467f5e3dcbe688bc16e1fea7e6eecd7afc62 | Python | 5,516 | 120 | #%%
import glob
import matplotlib.pyplot as plt
import os
from utils.dataset import gen_materials, get_sources, gen_settings, output_process
import openmc
digits = 10
def gen_materials_geometry_tallies(a_num, panel_density):
panel, insulator, outer = gen_materials(panel_density)
min_x = openmc.XPlane(x0=-1000... |
33e2965d3deca6f6b50d012cdbcd6a0ab9444eb26b3166c512855b28ccdf75e9 | Python | 5,517 | 132 | import argparse
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
def get_args():
"""
Get arguments from command line with argparse.
"""
parser = argparse.ArgumentParser(
prog='Plot-Figures.py',
description="""Make informative figures from pre- and post-filtered... |
300b582bcafbf16a6f924255589384dec300f1d486e6cb2d014ae1b0f237dd0d | Python | 5,518 | 188 | """Utility to add soft-light effect to NotoColorEmoji-COLRv1 region flags."""
import sys
import subprocess
from fontTools import ttLib
from fontTools.ttLib.tables import otTables as ot
from fontTools.ttLib.tables.C_P_A_L_ import Color
from fontTools.colorLib.builder import LayerListBuilder
from add_aliases import read_... |
665874a7376b8fe73a04335102174661b1180959df927058b0d7c02ace5c934f | Python | 5,522 | 164 | import json
import os
import warnings
from datetime import datetime
import numpy as np
import requests
from keras.callbacks import Callback
def compute_trainable_params(model):
""" Extract number of parameters from the given Keras model
Parameters
-----------
model : Keras model
... |
81beaad8e2d03a8285a49b685122190351c0a56540aec66ace95061fb980af6f | Python | 5,523 | 140 | ''' find_changed_releases.py
Find samples that havde different releases in a publishing database (or SAGE) versus
NeuronBridge. The publishing database or SAGE will have the most recent release.
'''
__version__ = '1.0.0'
import argparse
import collections
from operator import attrgetter
import sys
import jrc_c... |
da0aaaf284108a8db0df774721386ad760d85f4a7d81b9f8e969db2ff0d49821 | Python | 5,523 | 132 | # Copyright 2018-2023 Xanadu Quantum Technologies Inc.
# 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... |
a69028e928699120ec32b6990140f51a92a89ed569df612f78f9539b8942f25f | Python | 5,526 | 149 | # %%
# Tests for 2-dimensional ks statistic (2dks)
# %%
import numpy as np
from numpy import random
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
from scipy.spatial.distance import pdist, cdist
from scipy.stats import kstwobign, pearsonr
from scipy.stats import genextreme
# %%
# ... |
1346e16388a3c204bef1780b0a1fe45511a40e10679da28a44991babd3da8845 | Python | 5,527 | 177 | import numpy as np
import pandas as pd
import seaborn as sns
import glob
import sys
import matplotlib.pyplot as plt
path = sys.argv[1]
title = sys.argv[2]
# get different_files from folder
files = sorted(glob.glob(path + "/*/differences-df.pkl"))
# Custom sorting function to move names containing "Gd" to the end
... |
7a5710f21426308ab653f31c353b5cc6b23b49a9fa90fd86ba1aea6e5f0f3628 | Python | 5,530 | 185 | import numpy
import pandas
import seaborn as sns
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt
def independentActivation(A, B, x):
#states = 2
k = numpy.array([0.2, 0.1, 0.2])
def r1(A, B, k, x):
return k[0] * A * x[1]
def r2(A, B, k, x):
return k[1] * x[0]
d... |
9f748433b58ba73349aace050e5dab2fe15ef5b3f713bd2d9f7c16e120c48a45 | Python | 5,533 | 143 | #!/usr/bin/env python3.9
import pandas as pd
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
import sys
import argparse
import os
import gc
from utils import create_pytorch_geometric_graph_data_list_from_smiles_and_labels, init_weights, KFoldGen, JSONLogger
import pickle
from ... |
a6792e46ed679521652947e6fdb168fa50b40f1dc5913f4670d19e0651e102cc | Python | 5,533 | 167 | """
.. _metas_correctors:
===================
The Corrector class
===================
Here we take a look at multiple comparisons correction in meta-analyses.
"""
import matplotlib.pyplot as plt
import seaborn as sns
from nilearn.plotting import plot_stat_map
#######################################################... |
e6ba4624dba089552815ac12aea30e95c8e3072f248bd0734e9997b8807c2e77 | Python | 5,533 | 130 | import torch
import torch.nn as nn
import numpy as np
import pretraining.tools as tools
import pretraining.modules as m
class DCG(nn.Module):
def __init__(self, parameters):
super(DCG, self).__init__()
# save parameters
self.experiment_parameters = {
"device_type": 'gpu',
... |
9175f975db8b397d2d1c9901caa3e031b0ba2c19064d3541d8e5fc41aa112f38 | Python | 5,534 | 161 | from __future__ import annotations
import pytest
from pandas.compat import (
pa_version_under20p0,
)
import pandas as pd
import pandas._testing as tm
pa = pytest.importorskip("pyarrow")
@pytest.mark.parametrize("typ", ["int64", "uint64", "float64"])
def test_median_not_approximate(typ):
# GH 52679
res... |
334e6a3a66773e350acb47e064f368dbc0db8f3b75c46a166e83ea99e5f5719a | Python | 5,535 | 150 | from datetime import (
UTC,
time,
)
import zoneinfo
import numpy as np
import pytest
from pandas._libs.tslibs import timezones
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
class TestAtTime:
@pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Easter... |
42a23d19c03560bb29eea67eff8ea1b9fe683d842b81001e8f280e2c6c3156ab | Python | 5,536 | 162 | from __future__ import annotations
from datetime import time
import math
from typing import (
TYPE_CHECKING,
Any,
)
import warnings
import numpy as np
from pandas.compat._optional import (
VERSIONS,
import_optional_dependency,
)
from pandas.errors import Pandas4Warning
from pandas.util._exceptions im... |
bc7fe7b223669ea94dd272307f781a39ba2e42f78744645979093d838d548ecf | Python | 5,539 | 105 | import pandas as pd
#define paths
data_location = "./results/literature-review-results.xlsx"
master_location = "./results/Literature Review.xlsx"
save_location = "./results/results_organized.xlsx"
data = pd.read_excel(data_location) #Read the data
# Define those items that were markers for humans, but useless to com... |
d2274c0b8155c9683ee6be1b88ad6513c46678e0eb6c7c11fd957d8aa79b8405 | Python | 5,539 | 134 | import sys
import numpy as np
import matplotlib.pyplot as plt
from game_functions import Game, Game_Bayes
import color_palette as cp
from game_functions import percentile_discrete
whichsubject=str(sys.argv[1])
whichdistrib=str(sys.argv[2])
whichspecies=str(sys.argv[3])
whichloss=str(sys.argv[4])
whichdelay=str(sys.arg... |
1d1f4e12a5a639bde74dcf0bc2ac65485f0eac670fcef95e39f6748e83e7e30c | Python | 5,540 | 188 | #!/usr/bin/python3
"""
Generate timeseries slurm script.
Run this after preprocessing the fMRI data with fmriprep-slurm.
"""
from pathlib import Path
import sys
import argparse
import re
import json
import time
SLURM_ACCOUNT_DEFAULT = "rrg-pbellec"
SLURM_JOB_DIR = ".slurm"
SLURM_LOGS_DIR = ".logs"
FMRIPREP_SPECIF... |
56a0a9a444df4872f216e156a53affc0182c7de724fb58fb8e8c4413d2328911 | Python | 5,540 | 194 | from pcntoolkit import (
BLR,
HBR,
BsplineBasisFunction,
LinearBasisFunction,
SHASHbLikelihood,
)
from pcntoolkit.math_functions.likelihood import get_default_normal_likelihood
from pcntoolkit.math_functions.prior import LinearPrior, Prior, RandomPrior
def linear_BLR():
# Linear BLR with a fix... |
daaf5b92e7f533aeb0dcb51bf115260dfe833ccd43b343a9f42ffeb0153395f2 | Python | 5,540 | 193 | """Custom exceptions for the SAM algorithm.
This module defines exception classes used throughout the samalg package
to provide clear, specific error messages for different failure modes.
"""
from __future__ import annotations
class SAMError(Exception):
"""Base exception for all SAM-related errors.
All cus... |
f136800b4d465fbc0d399effc3dd2a5000bdeb8fc379a5261561d5548b1dbe14 | Python | 5,540 | 149 | #
# This file computes the atomic spherical coordinates in a given set of
# neighborhoods and outputs a file with these coordinates.
#
# It takes as arguments:
# - The name of the ouput file
# - Name of central residue dataset
# - Number of threads
# - The neighborhood radius
# - "easy" flag to include central res... |
1e2dd576124c1062482631708ddfc6410a3252aa6fa880a4400abd1654259652 | Python | 5,541 | 140 | 'Author: Brad Kenstler'
from tensorflow.keras.callbacks import *
from tensorflow.keras import backend as K
import numpy as np
class CyclicLR(Callback):
"""This callback implements a cyclical learning rate policy (CLR).
The method cycles the learning rate between two boundaries with
some constant frequenc... |
343d9b39a5ab998fb52ee80abc493e8be0364c2c93b95e99fa3b45bd665fe6fa | Python | 5,544 | 178 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 25 14:19:27 2023
@author: jeanbaptiste
"""
import tensorflow as tf
number_of_cores = 8
tf.config.threading.set_inter_op_parallelism_threads(number_of_cores)
tf.config.threading.set_intra_op_parallelism_threads(number_of_cores)
import os
import copy
import time
import uui... |
66013e220b6b3e025f2cb9f84211c2ce718fde20444ef40ab868902f9de5a574 | Python | 5,544 | 126 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# 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... |
656d0759aa5a798fd305bfa5ae1136949e528f9e711b956f375fb27fd5e09d40 | Python | 5,548 | 153 | from rdkit import Chem
from rdkit.Chem import AllChem
from itertools import combinations
import numpy as np
import torch
def get_neighbor_atoms(m,substr_atoms,radius=1):
"""
get set of atoms not in substr, but in range of radius (dependent on radius)
m: mol object of considered compound
... |
94a8b0dbd37a1d538727bf347b132968fe065111ca0ef060d5cc0baaa7b4de07 | Python | 5,549 | 176 | import numpy as np
import pytest
from pandas.core.dtypes.cast import can_hold_element
import pandas as pd
def test_can_hold_element_range(any_int_numpy_dtype):
# GH#44261
dtype = np.dtype(any_int_numpy_dtype)
arr = np.array([], dtype=dtype)
rng = range(2, 127)
assert can_hold_element(arr, rng)
... |
8618b8692fc4a90dc416c4ae2f5b88b4c5015b3ca088f99f51b687b878e688c3 | Python | 5,550 | 147 | import numpy as np
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
class TestDataFrameRenameAxis:
@pytest.mark.filterwarnings("ignore:The inplace keyword in DataFrame.rename_axis")
def test_rename_axis_inplace(self, float_frame):
# GH#15704
... |
232c09fe7a00e3c46398ff47c504662f1794e7a25ea083e72e76d0ec4fa0ace9 | Python | 5,552 | 181 | ''' bucket_status.py
Show status for every NeuronBridge library on AWS S3
'''
import json
import re
import boto3
import aws_s3_common.aws_s3_common as AW
def read_object(bucket, key):
''' Read a "counts_denormalized" object and return the number of objects
Keyword arguments:
bucket: bucket n... |
5628c16d0564a0c5ec8986a19254c8737264d2cdfc0c7fcd261f289799f6e332 | Python | 5,552 | 185 | # MOFTransformer version 2.0.0
import os
import wget
import tarfile
from pathlib import Path
from moftransformer.database import (
DEFAULT_PRETRAIN_MODEL_PATH,
DEFAULT_COREMOF_PATH,
DEFAULT_QMOF_PATH,
DEFAULT_FINETUNED_MODEL_PATH,
DEFAULT_HMOF_PATH,
)
class DownloadError(Exception):
... |
f5ce9fd8959ecf89f7b3a0069ca01eacdb3bbddb13fd2bcdcc4d80a88239b58f | Python | 5,554 | 166 | """Postgres datasource driver.
Connects to a Postgres database described in ``config`` (host, port,
database, optional schema) with the password in ``secret_value``. Reads
either a named table (``config['table']``) or a custom query
(``config['query']``).
``psycopg`` / ``sqlalchemy`` are already deps for the server i... |
ae9c42d44682432ad03c43a64c8617a53c6df2802f852fbd9e8e0aa68a8b9c4d | Python | 5,556 | 205 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_data_frame_value_counts_unsorted():
df = pd.DataFrame(
{"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
index=["falcon", "dog", "cat", "ant"],
)
result = df.value_counts(sort=False)
expec... |
d886ed32fdfd153ef4d373c024afa2dd424d8cbc4162edebdceddfd6c2940c95 | Python | 5,558 | 177 | """
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 argparse import ArgumentParser
import torch
from models import Unet
from torch.nn import functional as F
from .mri_module import MriMo... |
e2b1dff80e6a63154dcc65605312b6352289ed63648a025b5dd3353fc97bf30d | Python | 5,558 | 173 | # Copyright 2026 Xanadu Quantum Technologies Inc.
# 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 agre... |
3799842c341ac0fd1e3f081a4fd6926dc35deefca190b0bd8002f8e13bd02f93 | Python | 5,561 | 167 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.models.resnet import resnet18, resnet50
from torchvision.models.densenet import densenet121
from timm.models import create_model
import numpy as np
#diffmc
class ConditionalLinear(nn.Module):
def __init__(self, num_in, num_out, n_... |
8d5655ff605fa895c0c7affceead835cfa32cc70e4a4c17929e41231fb97a05a | Python | 5,561 | 158 | # Calculate structure searching performance
import numpy as np
from collections import defaultdict
dataset_dir = "../../dataset"
known_problems = ["d6a1ia1"]
domid_to_fam = {}
fams_search = []
with open(dataset_dir + "/search_all.txt") as f:
for line in f.readlines():
cols = line.rstrip().split()
... |
2de7c325bf7b6c41065a18f36ff3a04b56c68da3f2669c9d4cbfeeeb40117eec | Python | 5,562 | 127 | """Opt-in policy telemetry must expose outliers without counting masked rows."""
import pytest
import torch
from rl_games.common.diagnostics import DefaultDiagnostics, PpoDiagnostics
def _batch(sigma, mu=None, advantages=None, logratio=None, masks=None):
sigma = torch.tensor(sigma, dtype=torch.float32, requires... |
c6d8cc3eca2549283040ab634cfe268b8f091b6582a1b9a00eae8cdcb9797da6 | Python | 5,562 | 244 | # The values here are updated from the male human model.
N=200
# physical constants
RT = 2.57 # J/mmol; R = 8.135 J K-1 mol-1, T = temperature in K (273 + temp in Celcius)
RTosm = 1.93e4
F = 96.5 # C/mmol
visc = 6.4e-6
# number of variables for H-K-ATPase
Natp = 14
# Vwbar = Molar volume of water (cm3/mm... |
ce2f0d651866543c43884a524cff880e11c3c14ace1bfd7d4ebd5327355a58d3 | Python | 5,562 | 83 | import sys
import sets
import collections
print( '\\documentclass[tikz]{standalone}' )
print( '\\tikzset{>=latex,->}' )
print( '\\tikzstyle{reft}=[circle,minimum width=2.5ex,inner sep=0pt,draw]' )
print( '\\tikzstyle{pred}=[node distance=20mm,anchor=mid]' )
print( '\\begin{document}' )
## For each discourse graph...
... |
7b3332dad2b05d49223cfe665d1ec6646a1a2bf56edcfebdd109d91d8e519533 | Python | 5,564 | 252 | """
Define signature overrides for Cython classes used in the documentation.
Cython classes do not expose the signature for documentation
building. We must overwrite the signature manually for it to
appear in the docs. See
https://github.com/cython/cython/issues/3873
"""
from datetime import timedelta
import inspect
... |
6f9f3566135515a263816ae1876badedc1ed1853129f59bfc0304bb3d9f3626a | Python | 5,565 | 153 | """Tests for sensitivity operator."""
from collections.abc import Sequence
import pytest
import torch
from mrpro.data import CsmData
from mrpro.operators import SensitivityOp
from mrpro.utils import RandomGenerator
from tests import (
dotproduct_adjointness_test,
forward_mode_autodiff_of_linear_operator_test... |
0e439138d2bc95617cdfd3420f7b78ebed9ee02df0f27822a5d197c313fab297 | Python | 5,566 | 170 | # -*- coding: utf-8 -*-
"""
Basic i/o definitions for Neuralynx files
"""
from __future__ import print_function, division, absolute_import
from os import stat
from datetime import datetime
import re
import numpy as np
# pylint: disable=E1101
NCS_SAMPLES_PER_REC = 512
NLX_OFFSET = 16 * 1024
NCS_RECSIZE = 1044
# Time ... |
108998fc5db308e9d7904cbcd6810ca81d1b3744a6ea5a9183ffd994506f1544 | Python | 5,568 | 154 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# 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... |
4775fe425824fa365d5acbf6a461b73c22eaf84520ab3c13e660e52d02f192c9 | Python | 5,569 | 156 | #!/usr/bin/env python
import os, sys, subprocess, datetime
import argparse
from argparse import RawTextHelpFormatter
###################################################
### 0. script description and parsing arguments ###
###################################################
synopsis1 = "\
create a tabulated summary o... |
0901d6a1704af137d0f0dffc849fbb4d10709130584dd4e98d2f8523d449cc4d | Python | 5,570 | 158 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestDataFrameTruncate:
def test_truncate(self, datetime_frame, frame_or_series):
ts = datetime_frame[::3]
ts = tm.get_obj(ts, frame_or_series)
start, end = datetime_frame.index[3], datetime_frame.inde... |
aaaac820870e7ab6954abbc383666bd1774090d447d54a5b8044c97786820301 | Python | 5,570 | 167 | # Copyright 2024 Xanadu Quantum Technologies Inc.
# 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 agre... |
cd58508235db95dc8f75ccd0b2b1dcce7e79a4013c6a056c55573afd64e8da73 | Python | 5,571 | 164 | import run_LFP
import numpy as np
import matplotlib.pyplot as plt
import sys
import os
from kcsd import sKCSD, sKCSDcell
from kcsd import sKCSD_utils as utils
import kcsd.validation.plotting_functions as pl
import sKCSD_utils
import numpy.random
n_src = 512
l = 1e-1
R = 16e-6/2**.5
dt = 2**(-1)
noise_levels = [0, 16, ... |
e04cb76717daa8176eef76032ad755c89c658a348c319be2962118c3a3921603 | Python | 5,576 | 179 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Code to measure the audiovisual similarity of the audio and visual stream of
each video in a dataset using multimodal versatile network (MMV;
Alayrac JB, et al. Self-Supervised Multimodal Versatile Networks.
In: Advances in Neural Information Processing Systems (Neur... |
ea666fe9004770d26996976e2d25dc0e9cc885c0970ff615977b512df7349a0a | Python | 5,578 | 164 | import torch
import numpy
import matplotlib.pyplot as plt
import bionetwork
import plotting
import pandas
from scipy.stats import pearsonr
#Setup optimizer
inputAmplitude = 3
projectionAmplitude = 1.2
batchSize = 5
MoAFactor = 0.1
spectralFactor = 1e-3
maxIter = 5000
noiseLevel = 0.02
L2 = 1e-6
#Load network
netwo... |
fbb218f0728f094fb0501eea797e75bc6d578f0f2e309f8df572aa28a0c57a41 | Python | 5,578 | 150 | """Tests for TotalVariationRegularizedReconstruction."""
import pytest
import torch
from mrpro.algorithms.reconstruction import TotalVariationRegularizedReconstruction
from mrpro.data import CsmData, DcfData, KData
from mrpro.operators import DensityCompensationOp, FourierOp
def test_total_variation_automatic(cartes... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.