sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
f6555ea62db8d066f1161027cc9cb3d552604b687f405affe9dc1333222b8c69
Python
262
7
from transformers import BertTokenizer from datasets.scar_transformer import SCARTransformer class SCARBERT(SCARTransformer): def __init__(self, config, eval_only, undersample=False): super().__init__(config, BertTokenizer, eval_only, undersample)
23aca7f11da185c8b494a402f0169790709420c42bb5385f9f0800c1b8f3474b
Python
263
8
# pyproject.toml defines addopts: --strict-data-files # strict-data-files is defined & used in pandas/conftest.py def pytest_addoption(parser) -> None: parser.addoption( "--strict-data-files", action="store_true", help="Unused", )
7a9631e1fbb4454fc0820911f91727f34341f7e08ef6e55ad0215901df1b9c43
Python
263
12
from dataknead.baseloader import BaseLoader class TextLoader(BaseLoader): EXTENSIONS = ["txt"] @staticmethod def read(f): return f.read().splitlines() @staticmethod def write(f, data): [f.write(line + "\n") for line in data]
99d85b85078bff5cc51bf4cab8dedf7abc3c4177740d561ce29cb65cc3c5da00
Python
263
10
from setuptools import find_packages, setup setup( name='src', packages=find_packages(), version='0.1.0', description='ML code for detecting microplastics in sea water from their Raman spectra', author='Andrii Trelin', license='BSD-3', )
52f736519be4b5fe160b4bb2c1b40b25d62defd0189aa4bf8ba0733231f165a6
Python
264
9
from typing import Any import pandas as pd def allow_na_ops(obj: Any) -> bool: """Whether to skip test cases including NaN""" is_bool_index = isinstance(obj, pd.Index) and obj.inferred_type == "boolean" return not is_bool_index and obj._can_hold_na
4a246c1d837ef629e32d442eaa8e90e83e111edb9061a865a4c8586ade2235a0
Python
265
3
from tnn.utils.utils import seed_everything, number_network_weights, extract_data, insert_data, module_getattr, module_setattr from tnn.utils.get_logger import get_logger, makedirs from tnn.utils.utils_examples import setup_parser, matrix_match_tensor_single_layer
b61b42de3a4d7e263dd9505cb8a80052713ad31a216b8d7ad35035ef0200ac6f
Python
265
14
__all__ = ['save_yaml', 'load_yaml'] import yaml def save_yaml(data, file, **kwargs): with open(file, "w") as f: yaml.dump(data, f, **kwargs) def load_yaml(file, **kwargs): with open(file, "r") as f: return yaml.safe_load(f, **kwargs)
077e28999ee8e9e23c7a423c6bad3c39ce2cbaedabcfe8581869b315dea0caf2
Python
266
10
import sys import pandas as pd df1 = pd.read_csv(sys.argv[1], sep=',') df2 = pd.read_csv(sys.argv[2], sep=',') keys = list(set(df1.columns).intersection(set(df2.columns))) df = pd.merge(df2, df1, on=keys, how='inner') df.to_csv(sys.stdout, sep=',', index=False)
36cb818c2f3c18c0f98aa995fd76128dc0258c041a660dfd611005cc4d4f36d3
Python
266
14
"""Building blocks for numerical phantoms.""" from dataclasses import dataclass @dataclass(slots=True) class EllipseParameters: """Parameters of ellipse.""" center_x: float center_y: float radius_x: float radius_y: float intensity: float
eafe0a432e65ee5ba17b3dba0a21685693ca3558c43b3651c154e3401a67d4d0
Python
266
14
import sys import re finpunc = re.compile('[\.!\?][^a-zA-Z0-9]*$') output = '' for line in sys.stdin: word = line.strip() tmp = finpunc.search(word) #.!? if tmp != None: print(output + ' ' + word) output = '' else: output = output + ' ' + word
ef8abe72de831d63cf00e6ada82222ddb79c9a408406ec5873e4c1f6233674fd
Python
266
9
__all__ = [ 'plotting_analysis', 'plotting_mayavi', 'plotting_measurement_campaigns', 'plotting_plottools' ] from .plotting_analysis import * from .plotting_mayavi import * from .plotting_measurement_campaigns import * from .plotting_plottools import *
9182fdf938a633411f1fdcfd88c53facca1fec1d7a4c497482df59d644d22557
Python
268
5
from . import coninf from . import benchmark, spycon_inference, spycon_result, spycon_tests from .spycon_tests import ConnectivityTest, load_test from .spycon_result import SpikeConnectivityResult, load_connectivity_result from .benchmark import ConnectivityBenchmark
30d2d6f8108354391c737370616b8ef1657f5739f640af99f30f75c92a16f991
Python
269
7
import importlib # find the dataset definition by name, for example dtu_yao (dtu_yao.py) def find_dataset_def(dataset_name): module_name = 'datasets.{}'.format(dataset_name) module = importlib.import_module(module_name) return getattr(module, "MVSDataset")
455756b801158a83873f20b81abf585c703751603828928a958a27f29649213a
Python
270
15
from pandas.io.json._json import ( read_json, to_json, ujson_dumps, ujson_loads, ) from pandas.io.json._table_schema import build_table_schema __all__ = [ "build_table_schema", "read_json", "to_json", "ujson_dumps", "ujson_loads", ]
8498c3478f81c8b0807f7ba0e43161f6bcb1289ed651cec6bcc1513c01d3f9f3
Python
270
9
""" 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 .unet import Unet from .varnet import NormUnet, SensitivityModel, VarNet, VarNetBlock
6d99f509ff38d85765e6383a66ad37ab7de906c5567e1376444082e2863d928f
Python
271
8
import pandas as pd import sys skip=[152] data = pd.read_csv(sys.stdin,sep=' ',skipinitialspace=True) gold = pd.read_csv(sys.argv[1],sep=' ',skipinitialspace=True) goldids = gold['sentid'].unique() data[data['sentid'].isin(goldids)].to_csv(sys.stdout, ' ', index=False)
2684c9f59f0eb10c6cac8c7445b3cf2fa5c7d2ef61d3d4c4e10c7ce61619c43d
Python
273
12
""" Main init for the AP-Net package """ __version__ = "0.0.1" __author__ = "Zachary L. Glick" __credits__ = "Georgia Institute of Technology" from .util import load_dimer_dataset, load_monomer_dataset from .atom_model import AtomModel from .pair_model import PairModel
28f63d2d225fa8941d08c6b29e077f235484fbed6f0483025657e3ffabd03981
Python
273
9
"""Calling cards data analysis in Python""" from pycallingcards import datasets from pycallingcards import plotting as pl from pycallingcards import preprocessing as pp from pycallingcards import reading as rd from pycallingcards import tools as tl __version__ = "1.0.1"
5583c0f941bc13dc70aa6a9592bca81214714506ada6593f8c8003982dfe9951
Python
273
7
import pandas as pd import sys data = pd.read_csv(sys.stdin,sep=' ',skipinitialspace=True) data['startofsentence'] = (data.sentpos == 1).astype('int') data['endofsentence'] = data.startofsentence.shift(-1).fillna(1).astype('int') data.to_csv(sys.stdout, ' ', index=False)
8a9988debc2c125fbc602c76f9677c2a6abbea3c0ae44c40f380392ee94c8c35
Python
274
10
import sys import pandas as pd df = pd.read_csv(sys.stdin, sep=' ', keep_default_na=False) gb = df.groupby("docid") for _, df_doc in gb: print("!ARTICLE") gb_sent = df_doc.groupby("sentid") for _, df_sent in gb_sent: print(' '.join(list(df_sent.word)))
6ceaaef2a40d27428b8d653b064ad9ec2264bf02cb47448e4b44958fb2a83717
Python
279
14
__all__ = ['save_pickle', 'load_pickle'] import pickle def save_pickle(data, file, **kwargs): with open(file, "wb") as f: pickle.dump(data, f, **kwargs) def load_pickle(file, **kwargs): with open(file, "rb") as f: return pickle.load(f, **kwargs)
79e9349829f5622beabb1c3bac289d8b5115c629346a15c174a1a724baff5db9
Python
279
7
from transformers import LongformerTokenizer from datasets.scar_transformer import SCARTransformer class SCARLongformer(SCARTransformer): def __init__(self, config, eval_only, undersample=False): super().__init__(config, LongformerTokenizer, eval_only, undersample)
aefcc20a7c40faed598d2b0721e2668fc8acc04826685ca93f6a0091572d1407
Python
281
13
import pytest from cardiomyocyte_emulator import APEmulator, load_default_emulator_model import torch import numpy as np @pytest.fixture(scope="module") def emulator_init(): return APEmulator() def test_init(emulator_init): pass #TODO: Test normalizations... if needed?!
6c2e050c29ea8a597f9a4197ebdcdb3922b9085031ce76e18f8cb82486217c28
Python
282
12
import gymnasium as gym gym.register( id='TestRnnEnv-v0', entry_point='rl_games.envs.test.rnn_env:TestRNNEnv', max_episode_steps=100500, ) gym.register( id='TestAsymmetricEnv-v0', entry_point='rl_games.envs.test.test_asymmetric_env:TestAsymmetricCritic' )
94ed1fc341dc7677204bc1683c13cad86d3b328f04ac0ba90efe81f20cc0fcfb
Python
282
11
from .correlation_matrix import CorrelationMatrix from .longitudinal_score import LongitudinalScore from .velocity_model import VelocityModel from .zdiff_score import ZDiffScore __all__ = [ "CorrelationMatrix", "LongitudinalScore", "ZDiffScore", "VelocityModel", ]
f8131cfa8138836c054af6f02d738bba18b418f1ed6e25140eb9c09a89bfc408
Python
282
10
import sys import pandas as pd docs = ['Boar', 'Aqua', 'MatchstickSeller', 'KingOfBirds', 'Elvis', 'MrSticky', 'HighSchool', 'Roswell', 'Tulips', 'Tourettes'] d = pd.read_csv(sys.stdin, sep=' ') d = d[d.docid.isin(docs)] d.to_csv(sys.stdout, sep=' ', index=False, na_rep='nan')
fda22c10a925da489b66feb85426012eb7b88e7076dc69f2d9a6785681d62cf0
Python
282
21
"""public toolkit API""" from pandas.api import ( executors, extensions, indexers, interchange, internals, types, typing, ) __all__ = [ "executors", "extensions", "indexers", "interchange", "internals", "types", "typing", ]
3b91210d1ef4f20654c1e897bacb0801cf29d288681a6423e4ef7682f7b71bad
Python
284
12
import pytest import pandas.util._test_decorators as td import pandas as pd @td.skip_if_installed("tables") def test_pytables_raises(temp_h5_path): df = pd.DataFrame({"A": [1, 2]}) with pytest.raises(ImportError, match="tables"): df.to_hdf(temp_h5_path, key="df")
51b165e9efac810ab5ca16c747ec47ff3261b54e1b248c9bf75c440250259e05
Python
286
12
import sys import pandas as pd df = pd.read_csv(sys.stdin, sep=' ') times = pd.read_csv(sys.argv[1], sep=' ') time_map = {x: y.offsettime.max() for x, y in times.groupby('docid')} df['maxstimtime'] = df.docid.map(time_map) df.to_csv(sys.stdout, sep=' ', index=False, na_rep='NaN')
9c0016929da38b00fdbbe0c5f02ac36b84019238a32b9e1c46b0262e29359a2d
Python
286
10
__all__ = [ 'askervein_measurements', 'data_utils', 'measurements_line', 'perdigao_tower_positions', 'predict' ] from .askervein_measurements import * from .data_utils import * from .measurements_line import * from .perdigao_tower_positions import * from .predict import *
ef5c408e0f985a98a0226b5a9361887272305d382d2729938426561b4ef4c1d7
Python
286
6
from .gated_gcn import GatedGCN, GatedGCN_v2 from .mgn import MeshGraphNetsConv from .mgn_transformer import MGNTransformerConv from .egnn import EGNNConv from .graphormer import GraphormerConv, GraphormerVectorPrediction from .equivariant_transformer import EquivariantTransformerLayer
35bf22e4315891c04fd563808e4273cd1915b1ad39220ea0e1b8177f65b414e4
Python
287
11
import sys import os import re import collections sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts')) import tree import gcgtree for line in sys.stdin: print( gcgtree.GCGTree(line.strip()) ) #strip to prevent adding additional blank lines
ad68049a8aa6e7c1c35b91b15b600f2acf05a65e23c8adbd170f4c3a798ec600
Python
287
11
import pandas as pd import os import numpy as np pwd = os.path.dirname(os.path.dirname(__file__)) def get_result(): df = pd.read_csv(pwd+"/contrast_predictors/BitterX_result.csv", header=None, sep="\t") df.columns = ["JobName", "Label"] return np.array(list(df["Label"]))
c7d6ab6ebfb3702834d6f32ebc2eedfb79a365c9cacb577fb88f428db15d5a95
Python
287
7
# License: see [LICENSE, LICENSES/legged_gym/LICENSE] from .helpers import class_to_dict, get_load_path, get_args, export_policy_as_jit, set_seed, update_class_from_dict from .task_registry import task_registry from .logger import Logger from .math import * from .terrain import Terrain
7c1001bb834f950b5f960cb74f107f9ebf9875b5cbda28a8d1c546adba7185c2
Python
288
9
"""One file per consultation type. Each file owns: - its SYSTEM + user-prompt builder - the JSON output schema sent to the provider - a parser that validates the raw dict into `LLMAdvice` Adding a new consultation type means dropping a new file here + hooking it into `api/llm.py`. """
d51e10b50092798d8d8d2c7eae03cd5677a60dc43e34b09c7221cc3bfc646342
Python
288
3
from GCNFrame.Biodata import BipartiteData, GraphDataset, Biodata from GCNFrame.GCNmodel import model, train, evaluation, test from GCNFrame.GCNmodel import f, contribution_score, motif_transfer_list, pattern_contribution_score, pattern_group_contribution_score, motif_contribution_score
f94e05d500f70b2694eaca548e38e959083049611db1dc4813592133b5ee243e
Python
288
13
"""MRpro: PyTorch-based MR image reconstruction and processing package.""" from mrpro._version import __version__ from mrpro import algorithms, operators, data, phantoms, utils __all__ = [ '__version__', 'algorithms', 'data', 'operators', 'phantoms', 'utils', ]
b2c414c9258fb36de7aba868a0b826caced83d09c7e820ff1958658f0b075eaa
Python
289
14
from dataknead.baseloader import BaseLoader import toml class TomlLoader(BaseLoader): EXTENSIONS = ["toml"] @staticmethod def read(f): return toml.loads(f.read()) @staticmethod def write(f, data): tomldata = toml.dumps(data) f.write(tomldata)
10fc7e1463c1ab8570e9a0bec23548d2ee6e716be33e189de7c030c9533712de
Python
292
12
# ruff: noqa: TC004 from typing import TYPE_CHECKING if TYPE_CHECKING: # import modules that have public classes/functions: from pandas.tseries import ( frequencies, offsets, ) # and mark only those modules as public __all__ = ["frequencies", "offsets"]
435802a173029db507671168ef16d49906c1e20d724a4ad79029b6e897f8c703
Python
292
13
# ruff: noqa: TC004 from typing import TYPE_CHECKING if TYPE_CHECKING: # import modules that have public classes/functions from pandas.io import ( formats, json, stata, ) # mark only those modules as public __all__ = ["formats", "json", "stata"]
961ed34ea1c3eff54ec724fc52c4a94cafd9cb847c72d543a124b6988321e214
Python
292
10
import os for input_filename in os.listdir("."): if not input_filename.count(".nii"): continue prefix = input_filename.split(".")[0] output_filename = prefix + ".vtk" cmd = "c3d %s -type short %s" % (input_filename, output_filename) print(cmd) os.system(cmd)
5e04a60a719fae6513550030d46de006bff75d1a2a74c93bd80a01beaf979350
Python
294
12
# -*- coding: utf-8 -*- # Add functions from directory # from sdna.net.functional.train import * from sdna.net.functional.initialize import * from sdna.net.functional.utils import * __all__ = ['train', 'validate', 'initialize', 'encode', 'decode']
dd2c3f566f2b91ed56055f3330aabc8076587afbb235424cacd19555312b19b9
Python
294
15
# Generate FAISS index from embeddings import torch import faiss d = torch.load("afted.pt") embs = d["embeddings"].numpy() index = faiss.IndexFlatIP(128) index.add(embs) print(index.ntotal) D, I = index.search(embs[:32], 100) # Example of searching faiss.write_index(index, "afted.index")
f6d9afbe35283dcf87141b6de772ca4b6c5fb6a54426c0c8e9eba36897635beb
Python
294
16
import sys, json, yaml filebases = [ 'ParamVal', 'KernelBlockDefs', 'CompositeBlockDefs', 'TargetBlockDefs' ] for base in filebases: with open(base + '.yml', 'rb') as f: data = yaml.load(f) with open(base + '.js', 'wb') as f: f.write(base + ' = ') json.dump(data, f)
460c73ad06261d7e5bd42676b4dda6352a69149cf378e717ab977b40f74a66c3
Python
295
11
from pandas.core.arrays import IntervalArray def test_repr(): # GH#25022 arr = IntervalArray.from_tuples([(0, 1), (1, 2)]) result = repr(arr) expected = ( "<IntervalArray>\n[(0, 1], (1, 2]]\nLength: 2, dtype: interval[int64, right]" ) assert result == expected
7ba0d5ccdc01746b058f4f42309ae0118733b8daa62268f653d0b813ed609fe5
Python
295
13
import sys, json outfile = sys.argv[1:][-1] # the last one after argv[0] infilelist = sys.argv[1:-1] print(infilelist, outfile) ob = {} for in_filename in infilelist: with open(in_filename, "r") as f: ib = json.load(f) ob.update(ib) with open(outfile, "w") as f: json.dump(ob,f)
311a8063c51f0eb36fb3c716ee33dfd0e47c63ea73d31b078967e3dc3eb604ac
Python
299
7
from models.longformer.args import get_args from models.longformer.model import Longformer from datasets.scar_longformer import SCARLongformer from models.transformer_main import transformer_main if __name__ == '__main__': transformer_main("Longformer", Longformer, SCARLongformer, get_args())
02863164a9fdc1c524ca04a6122dc45b17e8b1add24686dec873ebbc87c782b4
Python
300
18
import sys import tree import pickle ip = sys.argv[1] lineNum = 0 cat = [] for line in file(ip): lineNum += 1 t = tree.Tree() t.read(line) for c in t.cats(): if c not in cat: cat.append(c) print len(cat) print lineNum pickle.dump(cat, open("chtbCats.pkl","wb"))
9f266c8f2545f9b171e761d86cae1240c7c336eb2f619d40346255c4478091f4
Python
301
15
from pandas.core.groupby.generic import ( DataFrameGroupBy, NamedAgg, SeriesGroupBy, ) from pandas.core.groupby.groupby import GroupBy from pandas.core.groupby.grouper import Grouper __all__ = [ "DataFrameGroupBy", "GroupBy", "Grouper", "NamedAgg", "SeriesGroupBy", ]
5e084bcfaf8cb72ff8b83b2d77347788b1b4cfa6d0130eae00836a89a9ba7c6a
Python
302
11
from .brain_segmentation import brain_segmentation from .intersection import volume_intersect, stack_intersect from .thresholding import otsu_thresholding, thresholding __all__ = [ "brain_segmentation", "volume_intersect", "stack_intersect", "otsu_thresholding", "thresholding", ]
9fff60bd91ca77853322ec618ab86adfb53059cc7aefad4346175b3abdebc9df
Python
302
12
import pytest import pandas.util._test_decorators as td import pandas as pd @td.skip_if_installed("numba") def test_numba_not_installed_option_context(): with pytest.raises(ImportError, match="`Import numba` failed"): with pd.option_context("compute.use_numba", True): pass
7c750c51b1550380622962240e15a1e11fd2bd9ec9b71a353cb38457ad29a006
Python
304
10
import sys sys.path.append('../') from esFCM import Segment import nibabel as nib if __name__ == '__main__': file_im = '../data/input.nii.gz' img = nib.load(file_im) fina_seg = Segment(img,mask=img.get_fdata()>0, num_tissues=3, max_iter=50, max_fail=4) fina_seg.to_filename(sys.argv[2])
4dcf90a62a411a1960b925b3351e215bf6dfefd8044a0fdca0abe14ba730670a
Python
307
17
import time def print_time(func): nano = 10 ** 9 def new_func(*args, **kwargs): start = time.time_ns() out = func(*args, **kwargs) end = time.time_ns() elapsed = (end - start) / nano print(elapsed, "seconds", func) return out return new_func
503bc6e806b6dc8d14df97a410422962a0cf43f23bab4c91b1e243e947a2f66a
Python
308
18
import unittest import twixtools infile = 'example_data/gre.dat' class test_maptwix(unittest.TestCase): def test(self): twix = twixtools.map_twix(infile) _ = twix[-1]['image'][:] self.assertEqual(1, 1, 'should never happen') if __name__ == '__main__': unittest.main()
011005ff85fbf86e28251c8d152f4d9a195f83322ec98656e3debee07706c2e3
Python
309
7
# SPDX-FileCopyrightText: 2023-present Quentin Uhl <quentin.uhl@gmail.com> # # SPDX-License-Identifier: Apache 2.0 from .estimate_nexi_noiseless import estimate_nexi_noiseless from .estimate_nexi import estimate_nexi from .powderaverage.powderaverage import powder_average, save_data_as_npz, normalize_sigma
9d31cd9b3c8c94dcf7cc95a066082e66b874f5bd7fca25bee299dd44803de4d2
Python
309
12
# cat stimuli.txt | assign_sentids.py | paste -d' ' - ngramprobtoks #assigns sentence ids to words output by the ngram models #stimuli.txt is a list of sentences import sys data = sys.stdin.readlines() print 'sentid' for sentid,line in enumerate(data): for word in line.strip().split(): print sentid
b3ebdedac2df8ea53ed58882373441edc4116627925f3278be55d682517d4093
Python
309
12
#! /usr/bin/env python __author__ = 'iped' import os os.environ['ETS_TOOLKIT'] = 'qt4' from view.pyloc import PylocControl import yaml if __name__ == '__main__': config = yaml.load(open(os.path.join(os.path.dirname(__file__), 'config.yml'))) controller = PylocControl(config) controller.exec_()
5efb4f9c9c16a3c6d1284e8b928b209725ae8ebc4f09890f113e098f09b71792
Python
310
7
from biophysics_fitting.setup_stim import setup_soma_step def soma_current_injection(cell, amplitude = None, delay = None, duration = None): setup_soma_step(cell, amplitude = amplitude, delay = delay, duration = duration) return cell
4dfc3e0c8e3eb202641716979d27f7125b5b95a646a3a2021966fa29347a30f5
Python
311
13
import pandas as pd def test_no_overflow_of_freq_and_time_in_dataframe(): # GH 35665 df = pd.DataFrame( { "some_string": ["2222Y3"], "time": [pd.Timedelta("0 days 00:00:00.990000")], } ) for _, row in df.iterrows(): assert row.dtype == "object"
4411d18bfd318806244fbbf2e2ae03633f9902aa8138740d553ca741779a8a3e
Python
312
8
# This file is used to get the version of the package from the VERSION file from importlib.metadata import PackageNotFoundError, version from pathlib import Path try: __version__ = version('mrpro') except PackageNotFoundError: __version__ = Path(__file__).parent.joinpath('VERSION').read_text().strip()
46a72a4178b4167bf75befe4a6c5785589d03d0c61928e0157a46271010a0035
Python
312
11
import pandas as pd import pandas._testing as tm class TestPickle: def test_pickle_after_set_freq(self, temp_file): tdi = pd.timedelta_range("1 day", periods=4, freq="s") tdi = tdi._with_freq(None) res = tm.round_trip_pickle(tdi, temp_file) tm.assert_index_equal(res, tdi)
a89221b90c1a132ebbd64100c27c30e4cb8bcc7e8ce92f769a9f4fb6fff5c5a6
Python
312
17
""" Public testing utility functions. """ from pandas._testing import ( assert_extension_array_equal, assert_frame_equal, assert_index_equal, assert_series_equal, ) __all__ = [ "assert_extension_array_equal", "assert_frame_equal", "assert_index_equal", "assert_series_equal", ]
4d38b6755ab6f336b6f6521faf846be55547074a3458e7fbcdcc26049548e5b7
Python
313
11
print( """ ################################################################################## ATOM-CENTERED SYMMETRY FUNCTIONS COMPUTATION ################################################################################## """ ) import MM2SF.acsf from MM2SF.acsf import mm2sf_sfc as mm2sf_sfc
bbf13ce5c7bdd573e69e8357d359975fb54e5f444a93860c672e34aa8ed197e8
Python
314
5
from mrpro.operators.functionals.L1NormViewAsReal import L1NormViewAsReal from mrpro.operators.functionals.L1Norm import L1Norm from mrpro.operators.functionals.L2NormSquared import L2NormSquared from mrpro.operators.functionals.MSE import MSE from mrpro.operators.functionals.ZeroFunctional import ZeroFunctional
22b1bee866c5194e30a5792461ef4b5060c154dd071e1fd0f28dbd1bdce0528f
Python
315
19
# 'all_of' quantifier def all_of(L,f): for l in L: if not f(l): return False return True # 'none_of' quantifier def none_of(L,f): for l in L: if f(l): return False return True # 'some_of' quantifier def some_of(L,f): for l in L: if f(l): return True return False
38506395910136e17f66b77fa81f54d88af0fce5cad6479fb9056ef9f18e6478
Python
316
15
import yaml from os.path import join from msmfcode.core.logging import log def load_yaml(path_yaml, file_name_yaml): with open(join(path_yaml, file_name_yaml)) as file: try: data = yaml.safe_load(file) except yaml.YAMLError as exc: log.exception(exc) return data
3b35225d9a63096998cd4efa52a80b13eee0d5f9b5e44867e757410fea2c4cd5
Python
317
13
"""Signal Model Operators.""" import torch from typing_extensions import TypeVarTuple, Unpack from mrpro.operators.Operator import Operator Tin = TypeVarTuple('Tin') # SignalModel has multiple inputs and one output class SignalModel(Operator[Unpack[Tin], tuple[torch.Tensor,]]): """Signal Model Operator."""
92c7720c9dde8034735a624921307b5bf272e173dbd26497c105142b2f21a6c9
Python
318
12
import sys ''' Prepend article delim !ARTICLE to linetoks to create delim.linetoks. Do nothing if !ARTICLE begins linetoks ''' firstline = sys.stdin.readline() if firstline != "!ARTICLE\n": sys.stdout.write("!ARTICLE\n") sys.stdout.write(firstline) for line in sys.stdin.readlines(): sys.stdout.write(line)
94a4eafdf96c41ecfd27077180725d187fb98c0e0dc99169bd2623b9a8cd3068
Python
319
13
import torch.nn as nn class Mixup(object): def __init__(self, alpha_sampler): self.sampler = alpha_sampler def __call__(self, x1, x2, y1, y2): alpha = self.sampler.rsample().to(x1.device) x = alpha * x1 + (1 - alpha) * x2 y = alpha * y1 + (1 - alpha) * y2 return x, y
74f833a6a08684e76f5bebba03f269b7668218e292e80864aeca3231f6a48f49
Python
320
11
from MM2SF.radial import mm2sf_radial as mm2sf_radial print( """ ################################################################################## ANALYSIS OF THE RADIAL LOCAL ENVIRONMENTS ################################################################################## """ ) import MM2SF.radial
4c28e538860fbf83dc5cd2a82513928509c6874c096d7f1c0fbcff4a08fc1c66
Python
322
7
"""Calling cards data analysis in Python""" from ._annotation import annotation, combine_annotation from ._callpeaks import call_peaks, combine_peaks, down_sample, separate_peaks from ._clean import clean_qbed, filter_adata_sc from ._filterpeaks import filter_peaks from ._makeadata import adata_insertions, make_Anndat...
ee56b45dcc019caf9916eeea17d730c145f294aca30c32c6ece8b1fc3f8f369e
Python
322
14
from dataknead.baseloader import BaseLoader import xmltodict class XmlLoader(BaseLoader): EXTENSIONS = ["xml"] @staticmethod def read(f): return xmltodict.parse(f.read()) @staticmethod def write(f, data, **kwargs): xmldata = xmltodict.unparse(data, **kwargs) f.write(xmldat...
307fef861ca551bc4302874d6759ca467b34ca3da87c28b3c714786ed37a21fe
Python
323
12
import random from typing import List # Versioning -- you can change this number and keep a changelog below to keep track of your experiments as you go. version = "v1" def seeds(num_seeds) -> List[int]: return [random.randrange(1000000, 9999999) for _ in range(num_seeds)] default_num_frames: int = 10_000_000_0...
4413b0ba808f14fd2e113e39e76a5e268fa89a72d653d3de5545a52ceeb7f2ff
Python
323
3
print("Please cite the following paper when using nnUNet:\n\nIsensee, Fabian, et al. \"nnU-Net: Breaking the Spell on " "Successful Medical Image Segmentation.\" arXiv preprint arXiv:1904.08128 (2019).") print("\nIf you have questions or suggestions, feel free to open an issue at https://github.com/MIC-DKFZ/nnUNe...
c9f4251e192d942199cf4922407dc6f723fed86895a190030b04451cda9237a4
Python
324
15
# -*- coding: utf-8 -*- from emcee import moves from .test_proposal import _test_normal, _test_uniform __all__ = ["test_normal_walk", "test_uniform_walk"] def test_normal_walk(**kwargs): _test_normal(moves.WalkMove(s=3), **kwargs) def test_uniform_walk(**kwargs): _test_uniform(moves.WalkMove(s=3), **kwar...
cafcaeb9696c008aa7f176ee33fa33138a12a1a39b7f5ce5d1b7f3f3cdead53e
Python
324
16
# MOFTransformer version 2.0.0 class CLICommand: """ Install package <GIRDAY> which calculated energy-grid. """ @staticmethod def add_arguments(parser): pass @staticmethod def run(args): from moftransformer.utils import install_griday install_griday...
6326b1f5374e8a9ac819c1af5a84e8aee4cb3ad5ec69b0360d321df07ba0ba6f
Python
325
11
from MM2SF.angular import mm2sf_angular as mm2sf_angular print( """ ################################################################################## ANALYSIS OF THE ANGULAR LOCAL ENVIRONMENTS ################################################################################## """ ) import MM2SF.ang...
6c9ba202462329b6fa66a4429c7b59e4a21dc5f54b082c01fd51f674e45a68d5
Python
325
16
import sys import re num = 0 for line in sys.stdin: num += 1 m = re.match("^([^ ]+) : ([^ ]+)$", line) if m != None: feat = m.group(1).strip() label = m.group(2).strip() feat = feat.replace("=1", "") featList = re.split(",", feat) # print label print str(num)+"\t"+label+"\t"+" ".join(featLis...
815d2e2775489e77478c8dad975b59b78263851437d2a57ce54db800379e639e
Python
326
14
#!/usr/bin/env python from setuptools import find_packages, setup if __name__ == '__main__': setup( name='tavr', version='1.0', description='', author='brdav', author_email='', url='', install_requires=['pytorch-lightning'], packages=find_packages(), ...
83e91e0c6ff1c8aad483f02c1a0c0bcc6b36955d47b0892e53f0416cea9a2dcd
Python
326
11
from gymnasium.envs.registration import register from .dm_control import dmControlGetTasks, dmControlGymWrapper # noqa from .frame_stack import FrameStack # noqa register( id="HumanoidRobot-v0", entry_point="rl_toolkit.core.wrappers.humanoid:HumanoidRobot", max_episode_steps=1000, reward_threshold=1...
cf681a5487c8ac18fe90f89e91c0093a940751e83cf01057c828b9a010f11f27
Python
326
10
import numpy as np import pumpprobe as pp funa = pp.Funatlas(merge_bilateral=True,merge_dorsoventral=False,merge_numbered=False) inx1 = np.around(funa.get_inx_exp_levels2("inx-1"),2) inx7 = np.around(funa.get_inx_exp_levels2("inx-7"),2) for ai in np.arange(funa.n_neurons): print(funa.neuron_ids[ai],inx1[ai],inx7...
92a3181ea1ad4619473e7c36bbe58ecbee51860e21a4845fee381201ab575156
Python
327
10
def compare_files(f1,f2, skip_lines=0): with open(f1,"rb") as newfile, open(f2, "rb") as oldfile: for x in range(skip_lines): newfile.readline() oldfile.readline() assert newfile.read() == oldfile.read() def compare_iterables(i1, i2): assert all(a == b for a,b in zip(i1,...
be0d2d0dcdc21ab15468f959deaa9f80ec6b3de7f4fdcfd1fe81587ae6c08be0
Python
327
11
import pandas as pd import pandas._testing as tm def test_pickle_preserves_object_dtype(temp_file): # GH#43188, GH#43155 don't infer numeric dtype index = pd.Index([1, 2, 3], dtype=object) result = tm.round_trip_pickle(index, temp_file) assert result.dtype == object tm.assert_index_equal(index, r...
33951d249501f0f7f669046068bbf9bdbbe8dd0f8cb86aa9f019f03e6337c178
Python
328
16
# MOFTransformer version 2.0.0 class CLICommand: """ Install package <GIRDAY> which calculated energy-grid. """ @staticmethod def add_arguments(parser): pass @staticmethod def run(args): from moftransformer.utils import uninstall_griday uninstall_gr...
bfe6d19c02ee0401a01516516c25657c84562cc394febc0aee2a4a1f89fa3a24
Python
329
15
# # Module for retrieving protein names from pdb files in a given directory # import os # get all protein names from the pdb files in a given directory def get_proteins_from_dir(protein_dir,suf='mmtf'): files = os.listdir(protein_dir) proteins = [x[:4] for x in files if suf in x[-1*len(suf):]] return pr...
ca6e7672b2f74f236829c1e79aeb4707325671eb5b674c318cce146f46a06ca9
Python
329
15
from dataknead.baseloader import BaseLoader import json class JsonLoader(BaseLoader): EXTENSIONS = ["json"] @staticmethod def read(f): data = f.read() return json.loads(data) @staticmethod def write(f, data, **kwargs): jsondata = json.dumps(data, **kwargs) f.write(...
dbca5e9328908a1122a4b9d83399bf7bb2f546a91a46e7172551ffd81f81696b
Python
329
12
def version(): from pycaret import version_ return version_ # Hack to lazy import __version__ from `pycaret`. # Needed to avoid a circular dependency. def __getattr__(name): if name in ("__version__", "version_"): return version() raise AttributeError(f"module '{__name__}' has no attribute '{...
49efe412f21e92fbdfe5d1f9585a3a0c415446d45fd295deb2ff8b0b90b16c19
Python
331
15
from .data import * from .inference import DatasetForInference from .lightning_train import * from .model import * from .networking import UploadCallback from .scvi_api import SIMS from .temperature_scaling import * __all__ = [ "SIMS", "SIMSClassifier", "DataModule", "UploadCallback", "DatasetForIn...
c374c89176f03e25b9431f4efbf1c888a1f862b97a1bfb80bc678d1ea46ce69e
Python
332
11
""" 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 .mri_module import MriModule from .unet_module import UnetModule from .varnet_module import VarNetModule from .data_module import FastMr...
6f54c08e23a66c1b14cf8c69e9411d737db451aaab05a1aa66c435a26c17f74a
Python
333
14
# -*- coding: utf-8 -*- # Import classes from sub directory # from sdna.sim.core import * # Add classes from directory # from sdna.sim.sim import * from sdna.sim.error_simulation import * from sdna.sim.error_detection import * __all__ = ['ErrorSource', 'Sim', 'ErrorDetection', 'Error...
1cca4a762dc4415f3f174d21cb525a60296c50008f5db4d55439ccdaee9dc9b9
Python
335
10
# flake8: noqa: F401 from .dlg_slot_reorder import DlgSlotReorder from .ana_basins import BasinsPanel from .ana_filter import FilterPanel from .ana_log import LogPanel from .ana_meta import MetaPanel from .ana_plot import PlotPanel from .ana_slot import SlotPanel from .ana_tables import TablesPanel from .ana_view impor...
6e9de48eed9d9b9f758ce8f43fdcb7fa796565cf5d8746a8a7d9668f1ea27e11
Python
336
22
#! /usr/bin/env python from sys import argv filein = argv[1] fileout = argv[2] with open(filein,'r') as f: d = {} for line in f: L = line.split() r = float(L[0]) for s in L[1:]: if not s in d: d[s] = r else: d[s] = max(r,d[s]) with open(fileout,'w') as f: for s in d: f.write(s + " " + str(d...
7c15cbdb0892b9f7e5c38aaa2f52919c63dfeddbf04aa9b5d636a2e06e668c4b
Python
336
7
from . import dask_to_categorized_msgpack Loader = dask_to_categorized_msgpack.Loader check = dask_to_categorized_msgpack.check def dump(obj, savedir, repartition = False, get = None, client = None): return dask_to_categorized_msgpack.dump(obj, savedir, repartition = repartition, get = get, categorize = False, ...
113d83ddb0dde6667937155044c4a6b82d825a7acdeb609365aa317e40c5824a
Python
338
8
from rl_games.envs.test_network import TestNetBuilder, TestNetAuxLossBuilder, SimpleNetBuilder from rl_games.algos_torch import model_builder model_builder.register_network('testnet', TestNetBuilder) model_builder.register_network('simplenet', SimpleNetBuilder) model_builder.register_network('testnet_aux_loss', Test...
e11b393b8dee4f66a3c29cbd307891142c176010d5ec7e02dd81ced51410c72d
Python
338
13
from pytorch_lightning.cli import LightningCLI from src.data_module import TAVRDataModule from src.model import ProbabilisticModel def cli_main(): cli = LightningCLI(ProbabilisticModel, TAVRDataModule, save_config_kwargs={'overwrite': True}) if __name__ == '__main__...
9e0dde84c870c5ed6436ab55ea2f33e2629e4f40e378855a4a2645e8d1e09f4a
Python
340
14
"""Optimizer Status base class.""" import torch from typing_extensions import TypedDict class OptimizerStatus(TypedDict): """Base class for OptimizerStatus.""" solution: tuple[torch.Tensor, ...] """Current estimate(s) of the solution. """ iteration_number: int """Current iteration of the (itera...
894af1ee69daf8f5ad2c22b4973901bbf0b30d20dcffe25faf621f0f3edfcdac
Python
341
8
from dissect.configs.config import config from dissect.PropsSimulator.simulator import simulate from dissect.prepare_data import * from dissect.config_info import config_info from dissect.utils import * from dissect.dissect_frac import run_dissect_frac from dissect.dissect_expr import run_dissect_expr from dissect.deco...
1b392bd175b244e2595fd2ef794294127323cd7157f2d0b61934fcb9b0d9c781
Python
342
11
import pandas as pd def test_interval_repr(): interval = pd.Interval(0, 1) assert repr(interval) == "Interval(0, 1, closed='right')" assert str(interval) == "(0, 1]" interval_left = pd.Interval(0, 1, closed="left") assert repr(interval_left) == "Interval(0, 1, closed='left')" assert str(inter...
8bb491f1143d1297f12c847df7ac9aeace34e8f2c401c8d0abe68c8e989f52be
Python
343
14
""" A quick script to output the top N words (1000 for now) in each language. You can send the output to a file and diff it to see changes between wordfreq versions. """ import wordfreq N = 1000 for lang in sorted(wordfreq.available_languages()): for word in wordfreq.top_n_list(lang, 1000): print('{}\t{...
d445a88e34f370bbd81f7e15bf2bc41f17330f2ef32f774c4f26b2147b154b36
Python
343
8
import pandas._testing as tm def test_head_tail(string_series): tm.assert_series_equal(string_series.head(), string_series[:5]) tm.assert_series_equal(string_series.head(0), string_series[0:0]) tm.assert_series_equal(string_series.tail(), string_series[-5:]) tm.assert_series_equal(string_series.tail(0...