sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
748134c5120b400557c1c88229e8738ef8d63af20208cc575ac61771c805ea1a | Python | 8,921 | 273 | from __future__ import annotations
from typing import Any
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
# integer dtypes
arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
scalars: list[Any] = [2] * len(arrays)
# floating dtypes
arrays += [pd.arra... |
c7c458e7241c936402b57648e4238334ad84269f879ad66e9d7146f3f653ee56 | Python | 8,926 | 153 | import argparse, textwrap
from pgen.esm_msa_sampler import ESM_MSA_sampler
from pgen import models
from pgen.utils import write_sequential_fasta, parse_fasta, SequenceSubsetter, RawAndDefaultsFormatter, run_phmmer, generate_alignment
from pathlib import Path
import sys
from tqdm import tqdm
import math
import ... |
e3b361344fe14b18028c2cbdd677347c4abbe29ceb4753ea150f60937f4e93c9 | Python | 8,926 | 169 | """
Created on Sept 2019
@author: Alice Geminiani - alice.geminiani@unipv.it
olivocerebellar spiking neural network with E-GLIF neurons and PLASTICITY, for classical eyeblink conditioning simulations
Publication: Geminiani et al., biorXiv, 2022 - doi: https://doi.org/10.1101/2023.06.20.545667
NEST CEBC simulat... |
302e41cd8adbbf770d267c888281856d77d62fcab4228ed65b254ce3ed28aee9 | Python | 8,929 | 260 | import numpy as np
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
from pandas.io.formats.format import EngFormatter
@pytest.fixture(autouse=True)
def reset_float_format():
yield
pd.reset_option("display.float_format")
class TestEngFormatter:
de... |
c4a1bf80cb8f6540910e2270d2dda0fca989f111b7e58277c75a3d476d00e85b | Python | 8,934 | 205 | """
TODO: module docstring
"""
import os
from cptools2 import colours, commands, filelist, loaddata, splitter, utils
from cptools2.colours import pretty_print
class Job(object):
"""
class to generate staging, analysis and
de-stating commands for an SGE array job.
"""
def __init__(self, is_new_i... |
8d2773df8905858d933290ce7020a4c88eff6e83219f0faee9e7a0edee08c2e5 | Python | 8,935 | 297 | import numpy as np
import pytest
from pandas._libs import lib
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize(
"input_index, input_columns, input_values, "
"expected_values, expected_columns, expected_index",
[
(
["lev4"],
"lev3",
"va... |
5ad9771d49481a258e6cad097a428d681bac01dd2fcbd9b2501c9e61fdf88738 | Python | 8,939 | 269 | from __future__ import absolute_import
from keras import backend as K
from keras import optimizers
from keras import initializers
from keras.layers import Dropout
from keras.callbacks import Callback, ModelCheckpoint
from keras.utils import get_custom_objects
from keras.metrics import binary_crossentropy, mean_squar... |
8c5a01d5c7349dba15f49f672ee532c301bdec0adef76fa0d5e4a76338228935 | Python | 8,939 | 288 | # IMPORTS
import os
import glob
import torch
from pathlib import Path
from typing import MutableSequence, Optional, Union, Literal, TypedDict, overload, List, Dict
import requests
import yaml
from VINNA.utils import logging, Plane
Scheduler = "torch.optim.lr_scheduler"
LOGGER = logging.getLogger(__name__)
# Default... |
e69e1e862249b081e756ef1cde8c7dae02ee5ea0a3efb3653868288049a364f9 | Python | 8,939 | 324 | from __future__ import annotations
import pytest
from pandas.compat import HAS_PYARROW
from pandas.compat._optional import VERSIONS
import pandas as pd
import pandas._testing as tm
class BaseParser:
engine: str | None = None
low_memory = True
float_precision_choices: list[str | None] = []
def upda... |
3f8bd8e64e7be49d81081bd37159b1ce99fe8403e16fdceea045ab35c69460c6 | Python | 8,942 | 209 | """Cross-rank RunningMeanStd synchronization: merge math, resume seeding,
and a real 2-process gloo all-reduce roundtrip."""
import os
import numpy as np
import pytest
import torch
from rl_games.common.a2c_common import merge_rank_stats, seed_stats_sync_snapshot
from rl_games.algos_torch.running_mean_std import Runn... |
76ddc94faf973ca1928c6badd71b0bf950ee71365b8c8de0df10527af430c33c | Python | 8,942 | 179 | import logging
from tqdm import tqdm
import lmdb
import multiprocessing as mp
import numpy as np
import scipy.sparse as ssp
from utils.data_utils import process_files_ddi, process_files_decagon
from utils.graph_utils import incidence_matrix, remove_nodes, serialize, _bfs_relational
def generate_subgraph_datasets(param... |
e938164731a8463c8c6b4a38947b4fd05d6984b075d38eae696301b9d26485db | Python | 8,944 | 301 | import collections
from functools import partial
import operator
import string
import subprocess
import sys
import numpy as np
import pytest
from pandas.compat import WASM
import pandas as pd
import pandas._testing as tm
from pandas.core import ops
import pandas.core.common as com
from pandas.util.version import Ver... |
6f84390c01a679c3c4b115ccfdc3533cfc9e475197f3c3701c0a964454337174 | Python | 8,952 | 307 | import re
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def test_error():
df = pd.DataFrame(
{"A": pd.Series([[0, 1, 2], np.nan, [], (3, 4)], index=list("abcd")), "B": 1}
)
with pytest.raises(
ValueError, match="column must be a scalar, tuple, or list ... |
a10bd4abe33cf3092461f94f312eeb8572d55bdbc0823fbb8c52828112588729 | Python | 8,955 | 200 | """Isolated drivers for public native compatibility/failure regressions."""
import faulthandler
import gzip
import hashlib
import json
import os
from pathlib import Path
import sys
import zlib
import numpy as np
faulthandler.enable()
class FragmentReceiver:
"""Duck-typed public append receiver selecting the sc... |
81a05ddc28dabb0aa24c0c7c6da15c3cae4c559472a2fd78fce67b83832767f1 | Python | 8,956 | 151 | from botocore.client import Config
import ibm_boto3
from io import StringIO
import types
import os
import pandas as pd
import sys
import json
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
import pdb
from... |
c09fb83aa832b1184c94504082c67bdb72c970bfee541afdcdb867c406cb325f | Python | 8,956 | 207 | #
# Equivariant batch normalization module for taking
# batch norm of a given L
#
from tensorflow.keras import backend as K
from tensorflow.keras.layers import InputSpec
from tensorflow.keras.layers import BatchNormalization
import tensorflow as tf
class LBatchNorm(BatchNormalization):
def __init__(self,axis=-... |
09308d123d2f506a929d992eee108cadee120521aff6411ee19e4c75bb36d493 | Python | 8,958 | 285 | import re
import numpy as np
import pytest
from pandas._libs import index as libindex
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
import pandas as pd
import pandas._testing as tm
def test_labels_dtypes():
# GH 8456
i = pd.MultiIndex.from_tuples([("A", 1), ("A", 2)])
ass... |
c15b7e2c96dc06a2945c2437e591780145aa8312d2f4b03cc0257811e85544d8 | Python | 8,958 | 290 | # 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... |
adbd167da7e6c6299477e87b37e1712eaa260d8ac948fe5d0520ab796e7d494d | Python | 8,964 | 307 | """Integration tests for the PyCaret server API.
Uses FastAPI's TestClient + an in-memory SQLite to exercise every route.
Fresh DB per test — no state leakage.
"""
from __future__ import annotations
from collections.abc import Generator
import pytest
from fastapi.testclient import TestClient
from sqlalchemy import ... |
cd8650872c9fcc84c78e34feeacf1641e2043e49ea376caf4ea55e3d6c0a47f0 | Python | 8,964 | 326 | from __future__ import annotations
import os
import pytest
from pandas.compat import HAS_PYARROW
from pandas.compat._optional import VERSIONS
import pandas as pd
import pandas._testing as tm
class BaseParser:
engine: str | None = None
low_memory = True
float_precision_choices: list[str | None] = []
... |
f041a8d32bcfc1145550283699aa5df6a578c675d79b69a26ba5c5419a092964 | Python | 8,964 | 240 | """Functions to build augmentation pipelines from imgaug transform names or preset strings.
:func:`imgaug_transform` builds an ``iaa.Sequential`` pipeline from a params dict (transform
name -> {p, args, kwargs}); see its docstring for the dict format.
:func:`expand_imgaug_str_to_dict` expands a shorthand preset strin... |
0095a262215ed6d51b2acce0605609094e6ebc47024183eeb746df4adf6782fc | Python | 8,965 | 222 | # 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... |
8e0e5406d163ed311da14e088c90678c6332ce1ed538b73485f7713c42b787b0 | Python | 8,965 | 291 | """Test amplitude view."""
# ------------------------------------------------------------------------------
# Imports
# ------------------------------------------------------------------------------
import numpy as np
from phylib.io.mock import artificial_spike_samples
from phylib.utils import Bunch, connect
from ph... |
e2af3158968f9c340a051f2373f9d82adfcffc811e43975638e87440c1a7d6f2 | Python | 8,966 | 309 | # %%
import functools
import itertools
import os
from typing import cast
import pandas as pd
from deepglyco.chem.common.elements import ElementCollection
from deepglyco.chem.gpep.fragments import GlycanFragmentTypeCollection
from deepglyco.chem.gpep.glycans import MonosaccharideCollection
from deepglyco.chem.gpep.gp... |
f1b2deeaba48d9bcdbae3eea07a4148eb451acb9863b48ba969285aa73f7d9f0 | Python | 8,967 | 267 | """Automated drift detection on top of ``prediction_logs``.
Algorithm (kept deliberately simple for v1):
1. Pull the most recent ``BASELINE_ROWS`` successful predictions for the
deployment — these are the "current window".
2. Pull the next-oldest ``BASELINE_ROWS`` successful predictions — these
are the "baselin... |
729dd61d2f6d90616c69e22a2fd9c0374babdfafb6c015e2bea19dc03fab9afb | Python | 8,970 | 310 | # Test GroupBy._positional_selector positional grouped indexing GH#42864
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize(
"arg, expected_rows",
[
[0, [0, 1, 4]],
[2, [5]],
[5, []],
[-1, [3, 4, 7]],
[-2, [1, 6]... |
78eb1b6a757ac2451ddbd3f894a3e87289284c09ca6fdbfa0283b4918ccf6901 | Python | 8,970 | 270 | __all__ = [
"MonosaccharideInfo",
"MonosaccharideCollection",
"MonosaccharideComposition",
"GlycanNode",
"glycan_node_graph",
]
import functools
import os
from dataclasses import dataclass
from typing import Dict, List, Mapping, NamedTuple, Optional, Sequence, Tuple, Union
from ...util.io.yaml imp... |
974382282d297481ec07a6aca9e038a0fccf2460358ed27423f24ad62a69fcdf | Python | 8,972 | 249 | from datetime import datetime
import numpy as np
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = pd.date_range(
start="1/1/2001", end="6/1/2001", freq="D", unit="ns... |
8a4bad29263476204915e4b63983a7b8263e99533f7a09780f0d031325f49bf0 | Python | 8,982 | 289 | # Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
99601c4569e72e885ba796965573495dc7c5e6bea28a3d7f37c46521e04e82f7 | Python | 8,982 | 284 | from socket import SO_VM_SOCKETS_BUFFER_MAX_SIZE
import torch
import torch.nn as nn
import torch.nn.functional as F
from roost.core_pretrain import BaseModelClass
from roost.segments import ResidualNetwork, SimpleNetwork, WeightedAttentionPooling
class Roost(BaseModelClass):
"""
The Roost model is comprised ... |
223737488e5eb862d957f7adfd1f644342cc371af7ed579b55178599e83f7e1e | Python | 8,984 | 299 | import os
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.api.types import CategoricalDtype
from pandas.tseries.offsets import Day
def test_qcut():
arr = np.random.default_rng(2).standard_normal(1000)
# We store the bins as Index that have been
# rounded t... |
5b910edd302c13e045d1864b3fbcd5b27ff674947cc3d3c2efd2ea3edbb18ff1 | Python | 8,987 | 271 | """
This file contains code to
(a) Load the pre-trained classifier and
associated files.
(b) Transform new input data into the
correct format for the classifier.
(c) Run the classifier on the transformed
data and return results.
"""
import pickle
import numpy as np
import pandas as pd
from s... |
405c5ac45e79bdf71f415b44648dccbe8b2f963017c4e213b9a12e82f92b866f | Python | 8,990 | 294 | """Utility functions for the extract module."""
from __future__ import division
import logging
import os
import os.path as op
import numpy as np
import pandas as pd
import requests
from fuzzywuzzy import fuzz
from ..utils import _uk_to_us
LGR = logging.getLogger(__name__)
def get_data_dirs(data_dir=None):
"""... |
9607d621269920a52454cf86aff5f271f8392dd1bf5a7670252132c9b910277c | Python | 8,995 | 294 | """Utility functions for the extract module."""
from __future__ import division
import logging
import os
import os.path as op
import numpy as np
import pandas as pd
import requests
from fuzzywuzzy import fuzz
from nimare.utils import _uk_to_us
LGR = logging.getLogger(__name__)
def get_data_dirs(data_dir=None):
... |
1f4d7e18a5d5fa03ae5a7176c3e7823dd792718d164da45816371c82bed5ef37 | Python | 8,999 | 243 | """
.. module:: gfx_utils
:platform: Linux, Windows
:synopsis: Utils for interaction and creation of OpenGL resources
.. moduleauthor:: Fredrik Nysjo
"""
import numpy as np
import OpenGL.GL as gl
import glm
import struct
class Trackball:
"""Class for trackball interaction"""
def __init__(self):
... |
1e0c39efb1380f0f5b5c5adbd9eac66f85116256166874400495fe9bd6a162ab | Python | 9,000 | 247 | # Copyright 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 agre... |
79bb28fdf2f8c95a262e1192eb87e29bee7c82acea5675117f9682d6ca8d0a19 | Python | 9,000 | 256 | """
Tests that features that are currently unsupported in
either the Python or C parser are actually enforced
and are clearly communicated to the user.
Ultimately, the goal is to remove test cases from this
test suite as new feature support is added to the parsers.
"""
from io import StringIO
import os
from pathlib i... |
6da458d53d1a57c71d3eb236f49b9e2df0ce195b14df54596456932c360f64a0 | Python | 9,002 | 244 | """C-reactive protein is supplied raw, in mg/dL, and logged inside the clock.
Levine 2018 fits phenoage's CRP coefficient against ln(CRP in mg/dL), while the
BioAge-derived clocks use log1p of the same measurement. Users therefore supply
the raw value and each clock applies its own transform, so that one feature name
... |
493a26f792827e4a0425b113f0b4b4a8ba54cb70215c0d39fef63c44aecfc43f | Python | 9,007 | 253 | # 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... |
7acf0055980170b972188f8b1e9d9c60e37d94ea3c563767cd83d618d33bf798 | Python | 9,011 | 285 | import os
from datetime import datetime
import numpy as np
import pandas as pd
import torch
from scipy.special import softmax
from sklearn.metrics import (
accuracy_score,
precision_recall_fscore_support,
r2_score,
roc_auc_score,
)
from torch.nn import CrossEntropyLoss, L1Loss, MSELoss, NLLLoss
from to... |
cc97068960b70522436c6632170fa29158720443c63f70a5544386bc734431b2 | Python | 9,011 | 236 | from torchtext.data.datasets_utils import _wrap_split_argument
from torchtext.data.datasets_utils import _RawTextIterableDataset
from torchtext.vocab import build_vocab_from_iterator
import io
import os.path
from torchtext.data.utils import get_tokenizer
from torch.utils.data import DataLoader
from torch.nn.utils.rnn i... |
992f0bacbd259ac6e166e11f38c6c0a3eccdd92e36bdc583ab00f60cf09ebed3 | Python | 9,012 | 220 | import numpy as np, sys, matplotlib.pyplot as plt
import pumpprobe as pp
ds_list = "/projects/LEIFER/francesco/funatlas_list.txt"
matchless_nan_th = None
matchless_nan_th_from_file = "--matchless-nan-th-from-file" in sys.argv
matchless_nan_th_added_only = "--matchless-nan-th-added-only" in sys.argv
to_paper = "--to-pa... |
31398a1f861c159436e2efadc67e65a9dc232b250a6bbadb8098965d56329833 | Python | 9,014 | 145 | from botocore.client import Config
import ibm_boto3
import re
import os
import sys
import json
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from config.globals import ENVIRONMENT
from app import create_... |
29d8c1c3c95321c101633b1294fa3bfae82c55812d1c1a609fc339ea1f728a0a | Python | 9,015 | 189 | import numpy as np
import os
import time
from utils import mkdir_experiment_setup, add_noise
class IzhikevichKorndoerfer:
def __init__(self,
random_seed, connectivity_matrix, voltage_noise_amount,
input_strength, input_firing_rate,
input_noise_level, input_noise... |
aa77f9f5e8a2a20ce9d8657cd39ca1f9b2acafd1949488450608c915920a52f1 | Python | 9,024 | 222 | __author__ = 'etseng@pacb.com'
"""
For parsing the .snps_files results from running Mummer dnadiff into VCF
https://github.com/mummer4/mummer/blob/master/MANUAL.md#dnadiff
.snps_files file format:
(0) 1-based ref position
(1) base in ref
(2) base in query
(3) 1-based query position
(4) dist to nearest SNP
(5) ???
(6)... |
33d531858767e49bbffce8030ac2879a30a00a64caeef0f87502285fa15301cd | Python | 9,027 | 187 | # SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of sourc... |
4ddbdbae8f12543c00706771560f0c651c0e0d14b0e32119eca9c8a65299e061 | Python | 9,028 | 216 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import FAConv,GCNConv,global_mean_pool,global_max_pool, GATConv, max_pool, GraphNorm, GraphMultisetTransformer
class cell_cnn(nn.Module):
def __init__(self, model_config, out_dim) -> None:
super().__init__()
... |
648e48d1227cfcccb486a2561d3e2bd4200637bf01a317aa67075aec662d784d | Python | 9,030 | 206 | import matplotlib.pyplot as plt
import numpy as np
import os
import pickle
from sklearn.model_selection import KFold
import Load as Load
import Models
import Processing
Display_figures_Trace = False
Save_figures_Trace = True
save_alphas = True
Stims = ['Envelope_Pitch_Spectrogram_Phonemes']
Bands = ['Th... |
7f84b90ae67a840a15a15acf98fa1dc56adf1f7a5e9ad99a1df2f40529aae1ec | Python | 9,037 | 249 | #!/usr/bin/env python
# coding: utf-8
import pandas as pd
import numpy as np
import time
from pyspark.sql import SparkSession
from pyspark.sql import dataframe
from pyspark.sql.types import StructType, StructField, DoubleType
from pyspark.sql.functions import col
from pyspark import SparkConf, SparkContext
import skl... |
da82c57d91a0fe6ce3a676509bf1f2db690f2808e838bc2ea4f7bf9283d2bd83 | Python | 9,038 | 260 | import numpy as np, matplotlib.pyplot as plt, sys, re
import pumpprobe as pp, wormdatamodel as wormdm
plt.rc("xtick",labelsize=18)
plt.rc("ytick",labelsize=18)
plt.rc("axes",labelsize=18)
#plt.rcParams["svg.image_inline"]=False#("svg",image_noscale = False)
inclall = "--inclall-occ" in sys.argv
sort_t = "--sort-t" i... |
87a7e066d19f48d18edff3075b3c323ffba35e13ce4df748fba383f5520b666c | Python | 9,039 | 239 | import numpy as np
def interpdata(data, oldtime, newtime):
"""Interpolates the columns of [data] to find the values at [newtime], given that the current
values are at [oldtime]. [oldtime] must have the same number of elements as [data] has rows.
"""
# Check input sizes
if len(oldtime) != data.sha... |
a0631d60024705d460e59156c8022efbdb42810618395f4afaffeeb5e8293d28 | Python | 9,039 | 227 | import torch
from torch import tensor as t
# Typing
from torch import Tensor
from typing import Optional, Tuple, List
@torch.jit.script
def _knn_graph(x: Tensor, k: int, loop: bool = False) -> Tensor:
dist = torch.cdist(x, x)
dist += torch.eye(x.size(0), device=x.device) * (1. - float(loop)) * 1e6
j = to... |
7b57321757b7309df6e153070a96ee0a12d8a10a706ca81974c2fb264aa36ba4 | Python | 9,040 | 285 | from socket import SO_VM_SOCKETS_BUFFER_MAX_SIZE
import torch
import torch.nn as nn
import torch.nn.functional as F
from roost.core_pretrain_fl_mml import BaseModelClass
from roost.segments import ResidualNetwork, SimpleNetwork, WeightedAttentionPooling
class Roost(BaseModelClass):
"""
The Roost model is com... |
c083ab0b644eb1d490c3622ffd5adbf08f67443b3d147d3e9a6581cc887f2286 | Python | 9,040 | 248 | # Copyright 2018-2022 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... |
5d01f79bc89d9aee273e5485fd1024e24221fa0808d08ad5956fe6f208df1052 | Python | 9,044 | 209 |
from ..utils import chrom_order, chrom_aliases, PheWebError
from ..file_utils import get_tmp_path, make_basedir, genes_version, get_filepath, read_gzip
from .. import conf
import os
import re
import csv
from collections import Counter
import wget
import boltons.iterutils
from typing import List,Dict,Any,Iterator,Tupl... |
d250b5ccc983a83093e76f49a2545a5b38686ce368cc9c46760e362246d05e2e | Python | 9,045 | 239 | # Copyright 2018-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... |
e96e3bc91de767a885843760566cd98cc4b614e5363e023f93c59a87dd2270fc | Python | 9,047 | 278 | # 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... |
63464aa0473237aeea85b8badb1894a0f1ac9d9d12fffa463d9918cef4bdf02e | Python | 9,050 | 254 | import numpy as np
import pytest
from pandas._libs import index as libindex
import pandas as pd
import pandas._testing as tm
class TestIntervalIndex:
@pytest.fixture
def series_with_interval_index(self):
return pd.Series(np.arange(5), pd.IntervalIndex.from_breaks(np.arange(6)))
def test_getitem... |
87b187fc06a5b4c4387af73614562e0ce32e6b68461bb4b298892e5b9d88119f | Python | 9,051 | 178 | import os
import numpy as np
import pandas as pd
from immupute_dis import immupute_dis
import pseudo_bulk
import subprocess
from tqdm import tqdm
def list2mat(df,i_n,j_n,x_n):
TFs = df[j_n].unique()
REs = df[i_n].unique()
#Initialize matrix as numpy array
#Map row and col indices for lookup
row_map = {r:i ... |
73645221714f2c9e450abf784c0139398f8e37f59279aafa212b73c2bc60e2da | Python | 9,052 | 266 | import numpy as np
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
def test_apply_describe_bug(multiindex_dataframe_random_data):
grouped = multiindex_dataframe_random_data.groupby(level="first")
grouped.describe() # it works!
def test_series_descri... |
8dd1d162b4e12bf04ced9ab021e3cb70290b32155fd64750464b60e1be8d1181 | Python | 9,053 | 205 | import math
import torch
from torch.optim.optimizer import Optimizer
class Adam(Optimizer):
r"""Implements Adam algorithm.
It has been proposed in `Adam: A Method for Stochastic Optimization`_.
The implementation of the L2 penalty follows changes proposed in
`Decoupled Weight Decay Regulariza... |
b51abefc6c3697b468d7ff5e6e4a1d977b15aa96ca682a28776f933c6411c4fd | Python | 9,056 | 222 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
def monotonic_index(start, end, dtype="int64", closed="right"):
return pd.IntervalIndex.from_breaks(
np.arange(start, end, dtype=dtype), closed=closed
)
def empty_index(dtype="int64", closed="right"):
return pd.In... |
3c425c95aba88197e07d5f12ef0734b3d8f1f1328153e9f21ba6e90ce0ddbad2 | Python | 9,059 | 246 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# ----------------------------------------------------------------------------------------------... |
4072f3360ac7107be86f59766a35df59f4a6e7815349a01b29f90726f0098379 | Python | 9,064 | 237 | import numpy as np
import pytest
from pandas.errors import Pandas4Warning
import pandas as pd
import pandas._testing as tm
class TestPeriodRangeKeywords:
def test_required_arguments(self):
msg = (
"Of the three parameters: start, end, and periods, exactly two "
"must be specified... |
9d133034fc0bed9e9422950fbc58c3f31701f5a81344d539194920bbfaec91c7 | Python | 9,069 | 226 | """Tests for `multimodal_ad.data.volumes`."""
from pathlib import Path
import nibabel as nib
import numpy as np
import pytest
from multimodal_ad.data.manifest import Modality
from multimodal_ad.data.volumes import (
MRI_BRAIN_BOX_PARAMS,
BoundingBox,
BrainBoxParams,
ProcessingConfig,
average_4d_f... |
01413db9ca2d7d745cfbb8bdb4a86fbc69a36a361591cba69006b11447d0f03e | Python | 9,075 | 256 | import logging
import os
from typing import Optional
import torch
from pytorch_lightning.trainer.states import RunningStage
from torch_geometric import seed_everything
from torch_geometric.graphgym.checkpoint import get_ckpt_dir
from torch_geometric.graphgym.config import (
cfg,
set_cfg,
dump_cfg,
load... |
3bdab2c4ee3f1c31320f2813316fa25e9fffe7f94cac9cc885a1d334aca54cda | Python | 9,075 | 243 | # 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... |
19a3eea974275912a3ab8041b45d7760aaac406e9bd9ae24386d7dfe0be25e75 | Python | 9,078 | 277 | # 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... |
0bf4c6cd59ebb63d2c76b5070bb899e6e0be4c40be6da264635648024d72d065 | Python | 9,084 | 220 | """Models that produce (x, y) coordinates of keypoints from images."""
from typing import Any
import torch
from jaxtyping import Float
from omegaconf import DictConfig, ListConfig
from lightning_pose.data.datatypes import BaseLabeledBatchDict, UnlabeledBatchDict
from lightning_pose.data.utils import undo_affine_tran... |
cb0007e25221de1c6fe603811db7378fd5d6889e4fed0594c35d2ad487b9cd67 | Python | 9,089 | 231 | #MIT License
#
#Copyright (c) 2019 Iñigo Prada Luengo
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge,... |
1ebe83c17c7ad1d0c79fceed2d74dc151fee6a6841b60ab978d3510204de4136 | Python | 9,095 | 132 | # 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... |
852cd10b4322c6b32ebd701bbc2a61e256e741f33a02d654730266d5ac2dc439 | Python | 9,095 | 238 | from Environment import *
from Splice_post.utils import segmentation_quick_view
from Parameter import *
def concat_image(path, save_path, z_num, save_name):
os.makedirs(save_path, exist_ok=True)
concat_image = []
for i in range(z_num):
if not os.path.exists(os.path.join(path, '{:04d}_25.tif'.forma... |
b54be613df6e998263df9d7139f6b3a83410fc8a4c43eaf33d9729ca04e0c575 | Python | 9,098 | 208 | '''
From
https://medium.com/binaryandmore/beginners-guide-to-deriving-and-implementing-backpropagation-e3c1a5a1e536
Used in regression.py
NB: not used for the training of the article.
'''
#Importing the required libraries
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(x):
return 1/(1 + np.exp(-... |
b4fa44beaa6890de3203522efa3dabf8e21abc7719d34620fe3e1f57fb74033c | Python | 9,103 | 234 | """Tests for Wavelet Operator."""
from collections.abc import Sequence
import numpy as np
import pytest
import torch
from mrpro.operators import WaveletOp
from mrpro.operators.WaveletOp import WaveletType
from mrpro.utils import RandomGenerator
from mrpro.utils.reshape import normalize_indices
from ptwt.conv_transfor... |
99b9ae9a638e363ea1511515698be67c7196b7df8e07fd5d3b928a71ca3aa7be | Python | 9,106 | 258 | # Copyright 2018-2022 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... |
bb0bbd4a95228d21a3bb0ed0ffe7eb38094ee5ad8f1285491cac80116b6119c4 | Python | 9,108 | 374 | import os
import pickle as pkl
import numpy as np
import torch
import math
from utils.geo import *
from utils.model import *
record_data=True
DEFAULT_DEVICE = "cuda:0"
DEFAULT_DTYPE = torch.double
def pi_2_pi(angle):
return (angle + math.pi) % (2 * math.pi) - math.pi
def pipi_2_cw(angle): #change -pi<=theta<pi to... |
86f704f6c1732c37d49fbc5feed19150441074e9001a018c01b2a33082319fbb | Python | 9,116 | 287 | import os
from datetime import datetime
import numpy as np
import pandas as pd
import torch
from scipy.special import softmax
from sklearn.metrics import (
accuracy_score,
precision_recall_fscore_support,
r2_score,
roc_auc_score,
)
from torch.nn import CrossEntropyLoss, L1Loss, MSELoss, NLLLoss
from to... |
4027c4438850fb323ddb5c0d7d6e33426f1a605dc835e2820a4d70ba04f42465 | Python | 9,117 | 248 | """mixed_precision: TF32 by default, fp16 with loss scaling, bf16 on request.
bf16 rounding of the policy mean adds a KL of 0.01-0.03 per update and noise
in the PPO ratio at small sigma, independent of the learning rate, so the
default is no autocast. The default tests pretend a bf16-capable GPU is
present, because o... |
2526a2caef8d3c7a226baf380ef2fc600344a2c309656e254850ffcbf0d35adf | Python | 9,118 | 127 | """Download native-grid provincial subsets, with bounded tiles and full provenance.
Uses authenticated read-only Earth Engine access. No Drive/cloud exports, health
data uploads, interpolation, personal credentials or signed URLs are recorded.
"""
from pathlib import Path
from datetime import datetime,timezone
from co... |
19e78fe58b98492c51e1bf5300ae7f68cc3d6be9c23529d8913ca85ec56ce9e5 | Python | 9,119 | 264 | #!/usr/bin/env python3
# versions
import platform
import yaml
import os
os.environ["MPLCONFIGDIR"] = "./tmp/mpl"
os.environ["NUMBA_CACHE_DIR"] = "./tmp/numba"
import pandas as pd
import scanpy as sc
import numpy as np
from pathlib import Path
from typing import Tuple, List
class Arguments:
"""Parses the argu... |
06ef0a4f45b94abe07b977b868b96a43683fe6d12f7ab992d6ea315b633d958a | Python | 9,122 | 259 | """Session 54 — wire ``plot_model`` and ``evaluate_model``.
The plot library landed in sessions 47-52 as standalone module functions
(``pycaret.plots.classification.roc_curve(estimator, X, y)`` etc.). This
session re-implements the OOP entry points on top of it:
- ``Experiment.plot_model(estimator, plot=, save=, **kw... |
cb88d3ce39ad8eb7500268fa16952fd8e83cde3ba96ae5269eda0fbf2e51fa3e | Python | 9,122 | 266 | # -*- coding: utf-8 -*-
"""
Created on Sun May 1 17:33:44 2022
@author: jeanbaptiste
"""
import json
import pycromanager_tessie as pmt
from pycromanager_tessie.acquisitions import experiment
# Start platform:
platform = pmt.microscope.platform.Platform(load_synchronizer=True)
# Set LED ring
platform.neopixel.color... |
c6fdb3d26835c5a5267b6fe5a1307811d928900483e49ab0eb4782582e63051b | Python | 9,125 | 239 | # 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... |
fb6905fa504416c18852575b2f43e6252d0d4177dd41542a3ea62291453cd666 | Python | 9,130 | 238 | """Categorize the 388 open pycaret/pycaret issues against the 4.0 kill list
and the current architecture.
Buckets:
- fixed_in_4_0: issues about features we removed OR bugs the revamp resolves.
Reply with the 4.0 release-notes link and close.
- out_of_scope: issues requesting features we deliberately dropped per
KI... |
14e73bbec53c518d41f05b1ce31c3ac45d8cb7606475bb9508147f6c9a7163c7 | Python | 9,131 | 279 | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import json
import torch
from torch_scatter import segment_csr
def read_json(path):
""""""
if not path.endswith(".json"):
... |
ede15d118c2d8edaddad8939a1d0eec0345381bb6cd8de9c1e4ff098e080ea76 | Python | 9,134 | 196 | # Copyright (c) 2018-2023, NVIDIA Corporation
# 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, this
# list of condit... |
f3486a57bfb02d6f4b460353c536827c3eeddcbef599fa176b238f44b00026bc | Python | 9,134 | 268 | import os
import numpy as np
import reverb
import tensorflow as tf
import wandb
from rl_toolkit.networks.models import Actor
from rl_toolkit.utils import VariableContainer
from ...core.process import Process
class Agent(Process):
"""
Agent
=================
Attributes:
env_name (str): the ... |
a52f707a7aa6f74b63297fbd72e7a72da410e8b33dfad9ffb324b55b469101f1 | Python | 9,136 | 224 | import os
import random
import pandas as pd
import numpy as np
import argparse
import scipy.sparse as sp
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.regularizers impo... |
13c30bd72c06f129005ae120bbd060d9f9c4dacefe97de83165e0818d48db09e | Python | 9,138 | 256 | # Copyright 2018-2022 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... |
bbaa728fb7d6b6b29993454df7cd02725a3d225082262185921f1e6133e53478 | Python | 9,139 | 201 | import torch
import torch.utils.data as data_utils
from torchvision import datasets, transforms
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torchvision.models.squeezenet import SqueezeNet, Fire
from torchvision.models.resnet import ResNet, Bottleneck
from PIL import Im... |
0854525384509c952dadc2601e35c2e7075ee4ee47e43a2d726b8a81aa5e1766 | Python | 9,142 | 230 | """Tests for the conjugate gradient method."""
import pytest
import scipy.linalg
import scipy.sparse
import torch
from mrpro.algorithms.optimizers import cg
from mrpro.algorithms.optimizers.cg import CGStatus
from mrpro.operators import EinsumOp, LinearOperatorMatrix
from mrpro.utils import RandomGenerator
@pytest.f... |
04832548be6882d962b7af723e02eb993dafbb0244da3ed8a4321f21909a379f | Python | 9,143 | 221 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import wormdatamodel as wormdm
import wormbrain as wormb
import pumpprobe as pp
import mistofrutta as mf
import sys
import os
import subprocess
folder=sys.argv[1]
if folder[-1]!="/":folder+="/"
if not os.path.isdir(folder+"mov... |
494fa70a892800a7480190510cf4840878b74b69af138cf40173fadef78f63a7 | Python | 9,143 | 250 | import gzip
import re
from typing import Literal
import h5py
import numpy as np
import pytest
import requests
import torch
from mrpro.phantoms.brainweb import (
ALL_CLASSES,
OVERVIEW_URL,
VERSION,
BrainwebSlices,
BrainwebTissue,
BrainwebVolumes,
augment,
download_brainweb,
resize,
... |
ecf2266a872390ab70d83a1fba4ff398d54e0e9141e7a0455f09ceb21506c274 | Python | 9,147 | 252 | import numpy as np, matplotlib.pyplot as plt, sys, re
import pumpprobe as pp, wormdatamodel as wormdm
#Typical command: heat_raster_plot.py --j:ASH --i:AVA --inclall-occ --sort-avg --relative
headless = "--headless" in sys.argv
inclall = "--inclall-occ" in sys.argv
sort_max = "--sort-max" in sys.argv
sort_avg = "--so... |
c1723a12337ab186fd404c89a65df5a1bab03e424f38f16af6ee795de81275e1 | Python | 9,149 | 373 | # ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.14.5
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# %%
from pathlib import Path
import sys... |
a435d6b96cb47eea02b407d8575cf95b44ac7dd925c2f5bc42b5fc378cf5ab76 | Python | 9,153 | 270 | # 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... |
b589f1d49845156427b1161d6bb623243afa0221a6e6b1f6f8647c134e39c66e | Python | 9,158 | 246 | # 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... |
471be968ba8ba57f9730a8e0d70feaab6e5d3a5bc7335a14668d34ff8cabea29 | Python | 9,161 | 226 | """Parity tests for LinAge2 (Fong et al. 2025).
The expected values are the two biological ages the paper prints for its example
NHANES subjects, so these pin the port to the published output rather than to our
reading of the reference R script.
"""
import json
import math
from pathlib import Path
import numpy as np... |
b089613adac387053c15f2c1528b304e10e1c3e3b82ea4d40c04f036be4f5eb3 | Python | 9,163 | 270 | # 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... |
86035df4f9a4e8ba883f9e6acb9c039c3260e2b3781f2d72ae0c99e8af0f2310 | Python | 9,164 | 283 | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# 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 applicab... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.