repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
mmdetection
configs/hrnet/faster-rcnn_hrnetv2p-w18-1x_coco.py
.py
_base_ = './faster-rcnn_hrnetv2p-w32-1x_coco.py' # model settings model = dict( backbone=dict( extra=dict( stage2=dict(num_channels=(18, 36)), stage3=dict(num_channels=(18, 36, 72)), stage4=dict(num_channels=(18, 36, 72, 144))), init_cfg=dict( type='Pr...
12
455
mmdetection
configs/hrnet/htc_x101-64x4d_fpn_16xb1-28e_coco.py
.py
_base_ = '../htc/htc_x101-64x4d_fpn_16xb1-20e_coco.py' # learning policy max_epochs = 28 train_cfg = dict(max_epochs=max_epochs) param_scheduler = [ dict( type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500), dict( type='MultiStepLR', begin=0, end=max_epochs, ...
17
392
mmdetection
configs/hrnet/htc_hrnetv2p-w18_20e_coco.py
.py
_base_ = './htc_hrnetv2p-w32_20e_coco.py' model = dict( backbone=dict( extra=dict( stage2=dict(num_channels=(18, 36)), stage3=dict(num_channels=(18, 36, 72)), stage4=dict(num_channels=(18, 36, 72, 144))), init_cfg=dict( type='Pretrained', checkpoint='o...
11
431
mmdetection
configs/hrnet/fcos_hrnetv2p-w40-gn-head_ms-640-800-4xb4-2x_coco.py
.py
_base_ = './fcos_hrnetv2p-w32-gn-head_ms-640-800-4xb4-2x_coco.py' model = dict( backbone=dict( type='HRNet', extra=dict( stage2=dict(num_channels=(40, 80)), stage3=dict(num_channels=(40, 80, 160)), stage4=dict(num_channels=(40, 80, 160, 320))), init_cfg=di...
12
480
mmdetection
configs/hrnet/faster-rcnn_hrnetv2p-w32_2x_coco.py
.py
_base_ = './faster-rcnn_hrnetv2p-w32-1x_coco.py' # learning policy max_epochs = 24 train_cfg = dict(max_epochs=max_epochs) param_scheduler = [ dict( type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500), dict( type='MultiStepLR', begin=0, end=max_epochs, ...
17
386
mmdetection
configs/hrnet/cascade-mask-rcnn_hrnetv2p-w32_20e_coco.py
.py
_base_ = '../cascade_rcnn/cascade-mask-rcnn_r50_fpn_1x_coco.py' model = dict( backbone=dict( _delete_=True, type='HRNet', extra=dict( stage1=dict( num_modules=1, num_branches=1, block='BOTTLENECK', num_blocks=(4, ), ...
52
1,528
mmdetection
configs/hrnet/htc_hrnetv2p-w40_28e_coco.py
.py
_base_ = './htc_hrnetv2p-w40_20e_coco.py' # learning policy max_epochs = 28 train_cfg = dict(max_epochs=max_epochs) param_scheduler = [ dict( type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500), dict( type='MultiStepLR', begin=0, end=max_epochs, by_epo...
17
379
mmdetection
configs/hrnet/mask-rcnn_hrnetv2p-w40-2x_coco.py
.py
_base_ = './mask-rcnn_hrnetv2p-w40_1x_coco.py' # learning policy max_epochs = 24 train_cfg = dict(max_epochs=max_epochs) param_scheduler = [ dict( type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500), dict( type='MultiStepLR', begin=0, end=max_epochs, b...
17
384
mmdetection
configs/hrnet/cascade-rcnn_hrnetv2p-w40-20e_coco.py
.py
_base_ = './cascade-rcnn_hrnetv2p-w32-20e_coco.py' # model settings model = dict( backbone=dict( type='HRNet', extra=dict( stage2=dict(num_channels=(40, 80)), stage3=dict(num_channels=(40, 80, 160)), stage4=dict(num_channels=(40, 80, 160, 320))), init_cfg=...
13
482
mmdetection
configs/hrnet/fcos_hrnetv2p-w18-gn-head_4xb4-1x_coco.py
.py
_base_ = './fcos_hrnetv2p-w32-gn-head_4xb4-1x_coco.py' model = dict( backbone=dict( extra=dict( stage2=dict(num_channels=(18, 36)), stage3=dict(num_channels=(18, 36, 72)), stage4=dict(num_channels=(18, 36, 72, 144))), init_cfg=dict( type='Pretrained', ...
11
444
mmdetection
configs/swin/mask-rcnn_swin-t-p4-w7_fpn_amp-ms-crop-3x_coco.py
.py
_base_ = './mask-rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py' # Enable automatic-mixed-precision training with AmpOptimWrapper. optim_wrapper = dict(type='AmpOptimWrapper')
4
170
mmdetection
configs/swin/retinanet_swin-t-p4-w7_fpn_1x_coco.py
.py
_base_ = [ '../_base_/models/retinanet_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth' # noqa model = dict( bac...
32
1,058
mmdetection
configs/swin/mask-rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py
.py
_base_ = [ '../_base_/models/mask-rcnn_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth' # noqa model = dict( ty...
100
3,297
mmdetection
configs/swin/mask-rcnn_swin-s-p4-w7_fpn_amp-ms-crop-3x_coco.py
.py
_base_ = './mask-rcnn_swin-t-p4-w7_fpn_amp-ms-crop-3x_coco.py' pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_small_patch4_window7_224.pth' # noqa model = dict( backbone=dict( depths=[2, 2, 18, 2], init_cfg=dict(type='Pretrained', checkpoint=pretrained)))
7
317
mmdetection
configs/swin/mask-rcnn_swin-t-p4-w7_fpn_1x_coco.py
.py
_base_ = [ '../_base_/models/mask-rcnn_r50_fpn.py', '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth' # noqa model = dict( type...
61
1,648
mmdetection
configs/fsaf/fsaf_r50_fpn_1x_coco.py
.py
_base_ = '../retinanet/retinanet_r50_fpn_1x_coco.py' # model settings model = dict( type='FSAF', bbox_head=dict( type='FSAFHead', num_classes=80, in_channels=256, stacked_convs=4, feat_channels=256, reg_decoded_bbox=True, # Only anchor-free branch is imple...
48
1,459
mmdetection
configs/fsaf/fsaf_r101_fpn_1x_coco.py
.py
_base_ = './fsaf_r50_fpn_1x_coco.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
7
192
mmdetection
configs/fsaf/fsaf_x101-64x4d_fpn_1x_coco.py
.py
_base_ = './fsaf_r50_fpn_1x_coco.py' model = dict( backbone=dict( type='ResNeXt', depth=101, groups=64, base_width=4, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), style='pytorch', ...
15
414
mmdetection
configs/foveabox/fovea_r101_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py
.py
_base_ = './fovea_r50_fpn_4xb4-1x_coco.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')), bbox_head=dict( with_deform=True, norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) train_...
35
1,042
mmdetection
configs/foveabox/fovea_r50_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py
.py
_base_ = './fovea_r50_fpn_4xb4-1x_coco.py' model = dict( bbox_head=dict( with_deform=True, norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) train_pipeline = [ dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), ...
31
901
mmdetection
configs/foveabox/fovea_r50_fpn_4xb4-2x_coco.py
.py
_base_ = './fovea_r50_fpn_4xb4-1x_coco.py' # learning policy max_epochs = 24 param_scheduler = [ dict( type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500), dict( type='MultiStepLR', begin=0, end=max_epochs, by_epoch=True, milestones=[16, 22], ...
16
379
mmdetection
configs/foveabox/fovea_r101_fpn_4xb4-1x_coco.py
.py
_base_ = './fovea_r50_fpn_4xb4-1x_coco.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
7
198
mmdetection
configs/foveabox/fovea_r101_fpn_4xb4-2x_coco.py
.py
_base_ = './fovea_r50_fpn_4xb4-2x_coco.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
7
198
mmdetection
configs/foveabox/fovea_r50_fpn_gn-head-align_4xb4-2x_coco.py
.py
_base_ = './fovea_r50_fpn_4xb4-1x_coco.py' model = dict( bbox_head=dict( with_deform=True, norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) # learning policy max_epochs = 24 param_scheduler = [ dict( type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500), ...
21
572
mmdetection
configs/foveabox/fovea_r50_fpn_4xb4-1x_coco.py
.py
_base_ = [ '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] # model settings model = dict( type='FOVEA', data_preprocessor=dict( type='DetDataPreprocessor', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], ...
60
1,836
mmdetection
configs/foveabox/fovea_r101_fpn_gn-head-align_4xb4-2x_coco.py
.py
_base_ = './fovea_r50_fpn_4xb4-1x_coco.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')), bbox_head=dict( with_deform=True, norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) # lear...
24
650
mmdetection
configs/nas_fpn/retinanet_r50_nasfpn_crop640-50e_coco.py
.py
_base_ = './retinanet_r50_fpn_crop640-50e_coco.py' # model settings model = dict( # `pad_size_divisor=128` ensures the feature maps sizes # in `NAS_FPN` won't mismatch. data_preprocessor=dict(pad_size_divisor=128), neck=dict( _delete_=True, type='NASFPN', in_channels=[256, 512, ...
17
480
mmdetection
configs/nas_fpn/retinanet_r50_fpn_crop640-50e_coco.py
.py
_base_ = [ '../_base_/models/retinanet_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] norm_cfg = dict(type='BN', requires_grad=True) model = dict( data_preprocessor=dict( type='DetDataPreprocessor', mean=[123.6...
79
2,521
mmdetection
configs/reid/reid_r50_8xb32-6e_mot20train80_test-mot20val20.py
.py
_base_ = ['./reid_r50_8xb32-6e_mot17train80_test-mot17val20.py'] model = dict(head=dict(num_classes=1701)) # data data_root = 'data/MOT20/' train_dataloader = dict(dataset=dict(data_root=data_root)) val_dataloader = dict(dataset=dict(data_root=data_root)) test_dataloader = val_dataloader # train, val, test setting tra...
11
392
mmdetection
configs/reid/reid_r50_8xb32-6e_mot16train80_test-mot16val20.py
.py
_base_ = ['./reid_r50_8xb32-6e_mot17train80_test-mot17val20.py'] model = dict(head=dict(num_classes=371)) # data data_root = 'data/MOT16/' train_dataloader = dict(dataset=dict(data_root=data_root)) val_dataloader = dict(dataset=dict(data_root=data_root)) test_dataloader = val_dataloader
8
288
mmdetection
configs/reid/reid_r50_8xb32-6e_mot15train80_test-mot15val20.py
.py
_base_ = ['./reid_r50_8xb32-6e_mot17train80_test-mot17val20.py'] model = dict(head=dict(num_classes=368)) # data data_root = 'data/MOT15/' train_dataloader = dict(dataset=dict(data_root=data_root)) val_dataloader = dict(dataset=dict(data_root=data_root)) test_dataloader = val_dataloader
8
288
mmdetection
configs/reid/reid_r50_8xb32-6e_mot17train80_test-mot17val20.py
.py
_base_ = [ '../_base_/datasets/mot_challenge_reid.py', '../_base_/default_runtime.py' ] model = dict( type='BaseReID', data_preprocessor=dict( type='ReIDDataPreprocessor', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), backbone=dict( ty...
62
1,748
mmdetection
configs/dcnv2/mask-rcnn_r50-mdconv-c3-c5_fpn_amp-1x_coco.py
.py
_base_ = '../mask_rcnn/mask-rcnn_r50_fpn_1x_coco.py' model = dict( backbone=dict( dcn=dict(type='DCNv2', deform_groups=1, fallback_on_stride=False), stage_with_dcn=(False, True, True, True))) # MMEngine support the following two ways, users can choose # according to convenience # optim_wrapper = di...
11
393
mmdetection
configs/dcnv2/faster-rcnn_r50_fpn_mdpool_1x_coco.py
.py
_base_ = '../faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py' model = dict( roi_head=dict( bbox_roi_extractor=dict( type='SingleRoIExtractor', roi_layer=dict( _delete_=True, type='ModulatedDeformRoIPoolPack', output_size=7, o...
13
417
mmdetection
configs/dcnv2/faster-rcnn_r50-mdconv-c3-c5_fpn_1x_coco.py
.py
_base_ = '../faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py' model = dict( backbone=dict( dcn=dict(type='DCNv2', deform_groups=1, fallback_on_stride=False), stage_with_dcn=(False, True, True, True)))
6
216
mmdetection
configs/dcnv2/faster-rcnn_r50-mdconv-group4-c3-c5_fpn_1x_coco.py
.py
_base_ = '../faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py' model = dict( backbone=dict( dcn=dict(type='DCNv2', deform_groups=4, fallback_on_stride=False), stage_with_dcn=(False, True, True, True)))
6
216
mmdetection
configs/dcnv2/mask-rcnn_r50-mdconv-c3-c5_fpn_1x_coco.py
.py
_base_ = '../mask_rcnn/mask-rcnn_r50_fpn_1x_coco.py' model = dict( backbone=dict( dcn=dict(type='DCNv2', deform_groups=1, fallback_on_stride=False), stage_with_dcn=(False, True, True, True)))
6
212
mmdetection
configs/queryinst/queryinst_r101_fpn_300-proposals_crop-ms-480-800-3x_coco.py
.py
_base_ = './queryinst_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
8
228
mmdetection
configs/queryinst/queryinst_r101_fpn_ms-480-800-3x_coco.py
.py
_base_ = './queryinst_r50_fpn_ms-480-800-3x_coco.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
8
209
mmdetection
configs/queryinst/queryinst_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py
.py
_base_ = './queryinst_r50_fpn_ms-480-800-3x_coco.py' num_proposals = 300 model = dict( rpn_head=dict(num_proposals=num_proposals), test_cfg=dict( _delete_=True, rpn=None, rcnn=dict(max_per_img=num_proposals, mask_thr_binary=0.5))) # augmentation strategy originates from DETR. train_pipe...
46
1,896
mmdetection
configs/queryinst/queryinst_r50_fpn_ms-480-800-3x_coco.py
.py
_base_ = './queryinst_r50_fpn_1x_coco.py' train_pipeline = [ dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', scales=[(480, 1333), (512, 1333), (544, 1333), (576, 1333), ...
33
967
mmdetection
configs/queryinst/queryinst_r50_fpn_1x_coco.py
.py
_base_ = [ '../_base_/datasets/coco_instance.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] num_stages = 6 num_proposals = 100 model = dict( type='QueryInst', data_preprocessor=dict( type='DetDataPreprocessor', mean=[123.675, 116.28, 103.53], std=[58....
156
5,345
mmdetection
configs/pafpn/faster-rcnn_r50_pafpn_1x_coco.py
.py
_base_ = '../faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py' model = dict( neck=dict( type='PAFPN', in_channels=[256, 512, 1024, 2048], out_channels=256, num_outs=5))
9
200
numpy
tools/write_release.py
.py
""" Standalone script for writing release doc:: python tools/write_release <version> Example:: python tools/write_release.py 1.7.0 Needs to be run from the root of the repository and assumes that the output is in `release` and wheels and sdist in `release/installers`. Translation from rst to md markdown re...
69
1,722
numpy
tools/check_installed_files.py
.py
""" Check if all the test and .pyi files are installed after building. Examples:: $ python check_installed_files.py install_dirname install_dirname: the relative path to the directory where NumPy is installed after building and running `meson install`. Notes ===== The script wil...
119
3,858
numpy
tools/check_openblas_version.py
.py
""" Checks related to the OpenBLAS version used in CI. Options: 1. Check that the BLAS used at build time is (a) scipy-openblas, and (b) its version is higher than a given minimum version. Note: this method only seems to give the first 3 version components, so 0.3.30.0.7 gets translated to 0.3.30 when reading ...
108
3,523
numpy
tools/get_submodule_paths.py
.py
import glob import os.path def get_submodule_paths(): ''' Get paths to submodules so that we can exclude them from things like check_test_name.py, check_unicode.py, etc. ''' root_directory = os.path.dirname(os.path.dirname(__file__)) gitmodule_file = os.path.join(root_directory, '.gitmodules')...
32
1,083
numpy
tools/changelog.py
.py
#!/usr/bin/env python3 """ Script to generate contributor and pull request lists This script generates contributor and pull request lists for release changelogs using Github v3 protocol. Use requires an authentication token in order to have sufficient bandwidth, you can get one following the directions at `<https://he...
188
5,769
numpy
tools/refguide_check.py
.py
#!/usr/bin/env python3 """ refguide_check.py [OPTIONS] [-- ARGS] - Check for a NumPy submodule whether the objects in its __all__ dict correspond to the objects included in the reference guide. - Check docstring examples - Check example blocks in RST files Example of usage:: $ python tools/refguide_check.py N...
673
19,123
numpy
tools/functions_missing_types.py
.py
#!/usr/bin/env python """Find the functions in a module missing type annotations. To use it run ./functions_missing_types.py <module> and it will print out a list of functions in the module that don't have types. """ import argparse import ast import importlib import os NUMPY_ROOT = os.path.dirname(os.path.join( ...
126
2,982
numpy
tools/check_python_h_first.py
.py
#!/usr/bin/env python """Check that Python.h is included before any stdlib headers. May be a bit overzealous, but it should get the job done. """ import argparse import fnmatch import os.path import re import subprocess import sys from get_submodule_paths import get_submodule_paths HEADER_PATTERN = re.compile( r...
255
8,545
numpy
tools/linter.py
.py
import os import subprocess import sys from argparse import ArgumentParser CWD = os.path.abspath(os.path.dirname(__file__)) class DiffLinter: def __init__(self) -> None: self.repository_root = os.path.realpath(os.path.join(CWD, "..")) def run_ruff(self, fix: bool) -> tuple[int, str]: """ ...
92
2,609
numpy
tools/swig/test/testSuperTensor.py
.py
#!/usr/bin/env python3 import sys import unittest import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError import SuperTensor ###################################################################### class SuperTe...
396
17,096
numpy
tools/swig/test/testFlat.py
.py
#!/usr/bin/env python3 import struct import sys import unittest import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError import Flat ###################################################################### class ...
198
7,084
numpy
tools/swig/test/setup.py
.py
#!/usr/bin/env python3 from distutils.core import Extension, setup import numpy # Obtain the numpy include directory. numpy_include = numpy.get_include() # Array extension module _Array = Extension("_Array", ["Array_wrap.cxx", "Array1.cxx", "Array2.cxx", ...
67
1,951
numpy
tools/swig/test/testVector.py
.py
#!/usr/bin/env python3 import sys import unittest import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError import Vector ###################################################################### class VectorTestCa...
380
15,145
numpy
tools/swig/test/testFortran.py
.py
#!/usr/bin/env python3 import sys import unittest import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError import Fortran ###################################################################### class FortranTest...
162
5,943
numpy
tools/swig/test/testMatrix.py
.py
#!/usr/bin/env python3 import sys import unittest import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError import Matrix ###################################################################### class MatrixTestCa...
361
14,439
numpy
tools/swig/test/testFarray.py
.py
#!/usr/bin/env python3 import os import sys import unittest from distutils.util import get_platform import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError # Add the distutils-generated build directory to the p...
161
5,123
numpy
tools/swig/test/testArray.py
.py
#!/usr/bin/env python3 import sys import unittest import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError import Array ###################################################################### class Array1TestCas...
391
13,051
numpy
tools/swig/test/testTensor.py
.py
#!/usr/bin/env python3 import sys import unittest from math import sqrt import numpy as np major, minor = [int(d) for d in np.__version__.split(".")[:2]] if major == 0: BadListError = TypeError else: BadListError = ValueError import Tensor ####################################################################...
401
16,541
numpy
tools/c_coverage/c_coverage_report.py
.py
#!/usr/bin/env python3 """ A script to create C code-coverage reports based on the output of valgrind's callgrind tool. """ import os import re import sys from xml.sax.saxutils import escape, quoteattr try: import pygments if tuple(int(x) for x in pygments.__version__.split('.')) < (0, 11): raise Impo...
182
5,988
numpy
tools/ci/push_docs_to_repo.py
.py
#!/usr/bin/env python3 import argparse import os import shutil import subprocess import sys import tempfile parser = argparse.ArgumentParser( description='Upload files to a remote repo, replacing existing content' ) parser.add_argument('dir', help='directory of which content will be uploaded') parser.add_argument...
76
2,597
numpy
tools/ci/test_all_newsfragments_used.py
.py
#!/usr/bin/env python3 import os import sys import toml def main(): path = toml.load("pyproject.toml")["tool"]["towncrier"]["directory"] fragments = os.listdir(path) fragments.remove("README.rst") fragments.remove("template.rst") if fragments: print("The following files were not found ...
24
445
numpy
tools/ci/check_c_api_usage.py
.py
#!/usr/bin/env python3 from __future__ import annotations import argparse import os import re import sys import tempfile from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path from re import Pattern """ Borrow-ref C API linter (Python version). - Recursively scans source files under...
266
8,593
numpy
benchmarks/asv_pip_nopep517.py
.py
""" This file is used by asv_compare.conf.json.tpl. """ import subprocess import sys # pip ignores '--global-option' when pep517 is enabled therefore we disable it. cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517'] try: output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True) except Exc...
18
499
numpy
benchmarks/benchmarks/bench_records.py
.py
import numpy as np from .common import Benchmark class Records(Benchmark): def setup(self): self.l50 = np.arange(1000) self.fields_number = 10000 self.arrays = [self.l50 for _ in range(self.fields_number)] self.formats = [self.l50.dtype.str for _ in range(self.fields_number)] ...
41
1,391
numpy
benchmarks/benchmarks/bench_ufunc_strides.py
.py
import numpy as np from .common import Benchmark, get_data UFUNCS = [obj for obj in np._core.umath.__dict__.values() if isinstance(obj, np.ufunc)] UFUNCS_UNARY = [uf for uf in UFUNCS if "O->O" in uf.types] class _AbstractBinary(Benchmark): params = [] param_names = ['ufunc', 'stride_in0', 'stride_i...
230
7,396
numpy
benchmarks/benchmarks/bench_reduce.py
.py
import numpy as np from .common import TYPES1, Benchmark, get_squares class AddReduce(Benchmark): def setup(self): self.squares = get_squares().values() def time_axis_0(self): [np.add.reduce(a, axis=0) for a in self.squares] def time_axis_1(self): [np.add.reduce(a, axis=1) for a...
138
3,220
numpy
benchmarks/benchmarks/bench_ufunc.py
.py
import itertools import operator from packaging import version import numpy as np from .common import DLPACK_TYPES, TYPES1, Benchmark, get_squares_ ufuncs = ['abs', 'absolute', 'add', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'bitwise_and', 'bitwise_count', 'bitwise_not', ...
618
18,218
numpy
benchmarks/benchmarks/bench_array_coercion.py
.py
import numpy as np from .common import Benchmark class ArrayCoercionSmall(Benchmark): # More detailed benchmarks for array coercion, # some basic benchmarks are in `bench_core.py`. params = [[range(3), [1], 1, np.array([5], dtype=np.int64), np.int64(5)]] param_names = ['array_like'] int64 = np.dt...
55
1,665
numpy
benchmarks/benchmarks/bench_clip.py
.py
import numpy as np from .common import Benchmark class ClipFloat(Benchmark): param_names = ["dtype", "size"] params = [ [np.float32, np.float64, np.longdouble], [100, 100_000] ] def setup(self, dtype, size): rnd = np.random.RandomState(994584855) self.array = rnd.rand...
36
926
numpy
benchmarks/benchmarks/bench_shape_base.py
.py
import numpy as np from .common import Benchmark class Block(Benchmark): params = [1, 10, 100] param_names = ['size'] def setup(self, n): self.a_2d = np.ones((2 * n, 2 * n)) self.b_1d = np.ones(2 * n) self.b_2d = 2 * self.a_2d self.a = np.ones(3 * n) self.b = np....
171
5,211
numpy
benchmarks/benchmarks/bench_ma.py
.py
import numpy as np from .common import Benchmark class MA(Benchmark): def setup(self): self.l100 = range(100) self.t100 = ([True] * 100) def time_masked_array(self): np.ma.masked_array() def time_masked_array_l100(self): np.ma.masked_array(self.l100) def time_masked...
313
9,962
numpy
benchmarks/benchmarks/bench_core.py
.py
import numpy as np from .common import Benchmark class Core(Benchmark): def setup(self): self.l100 = range(100) self.l50 = range(50) self.float_l1000 = [float(i) for i in range(1000)] self.float64_l1000 = [np.float64(i) for i in range(1000)] self.int_l1000 = list(range(100...
356
9,231
numpy
benchmarks/benchmarks/bench_scalar.py
.py
import numpy as np from .common import TYPES1, Benchmark class ScalarMath(Benchmark): # Test scalar math, note that each of these is run repeatedly to offset # the function call overhead to some degree. params = [TYPES1] param_names = ["type"] def setup(self, typename): self.num = np.dty...
81
2,338
numpy
benchmarks/benchmarks/bench_io.py
.py
from io import SEEK_SET, BytesIO, StringIO import numpy as np from .common import Benchmark, get_squares, get_squares_ class Copy(Benchmark): params = ["int8", "int16", "float32", "float64", "complex64", "complex128"] param_names = ['type'] def setup(self, typename): dtype = np.dt...
281
8,665
numpy
benchmarks/benchmarks/__init__.py
.py
import os import sys from . import common def show_cpu_features(): from numpy.lib._utils_impl import _opt_info info = _opt_info() info = "NumPy CPU features: " + (info or 'nothing enabled') # ASV wrapping stdout & stderr, so we assume having a tty here if 'SHELL' in os.environ and sys.platform !=...
56
1,852
numpy
benchmarks/benchmarks/bench_datetime.py
.py
import numpy as np from .common import Benchmark class DatetimeAsString(Benchmark): """ISO string formatting from datetime64 — exercises set_datetimestruct_days on every element for every output unit. """ params = [ [10_000, 1_000_000], ['datetime64[D]', 'datetime64[s]', 'datetime64[m...
83
2,796
numpy
benchmarks/benchmarks/bench_import.py
.py
from subprocess import call from sys import executable from timeit import default_timer from .common import Benchmark class Import(Benchmark): timer = default_timer def execute(self, command): call((executable, '-c', command)) def time_numpy(self): self.execute('import numpy') def ...
35
838
numpy
benchmarks/benchmarks/bench_strings.py
.py
import operator import numpy as np from .common import Benchmark _OPERATORS = { '==': operator.eq, '!=': operator.ne, '<': operator.lt, '<=': operator.le, '>': operator.gt, '>=': operator.ge, } class StringComparisons(Benchmark): # Basic string comparison speed tests params = [ ...
44
1,233
numpy
benchmarks/benchmarks/bench_searchsorted.py
.py
import numpy as np from .common import Benchmark class SearchSorted(Benchmark): params = [ [100, 10_000, 1_000_000, 100_000_000], # array sizes [1, 10, 100_000], # number of query elements ['ordered', 'random'], # query order [False, True], ...
36
1,209
numpy
benchmarks/benchmarks/bench_random.py
.py
import numpy as np from .common import Benchmark try: from numpy.random import Generator except ImportError: pass class Random(Benchmark): params = ['normal', 'uniform', 'weibull 1', 'binomial 10 0.5', 'poisson 10'] def setup(self, name): items = name.split() name = it...
187
5,377
numpy
benchmarks/benchmarks/bench_trim_zeros.py
.py
import numpy as np from .common import Benchmark _FLOAT = np.dtype('float64') _COMPLEX = np.dtype('complex128') _INT = np.dtype('int64') _BOOL = np.dtype('bool') class TrimZeros(Benchmark): param_names = ["dtype", "size"] params = [ [_INT, _FLOAT, _COMPLEX, _BOOL], [3000, 30_000, 300_000] ...
28
607
numpy
benchmarks/benchmarks/bench_indexing.py
.py
import shutil from os.path import join as pjoin from tempfile import mkdtemp import numpy as np from numpy import array, float32, memmap from .common import TYPES1, Benchmark, get_indexes_, get_indexes_rand_, get_square_ class Indexing(Benchmark): params = [TYPES1 + ["object", "O,i"], ["indexes_",...
181
4,845
numpy
benchmarks/benchmarks/bench_ndindex.py
.py
from itertools import product import numpy as np from .common import Benchmark class NdindexBenchmark(Benchmark): """ Benchmark comparing numpy.ndindex() and itertools.product() for different multi-dimensional shapes. """ # Fix: Define each dimension separately, not as tuples # ASV will pas...
55
1,629
numpy
benchmarks/benchmarks/bench_app.py
.py
import numpy as np from .common import Benchmark class LaplaceInplace(Benchmark): params = ['inplace', 'normal'] param_names = ['update'] def setup(self, update): N = 150 Niter = 1000 dx = 0.1 dy = 0.1 dx2 = (dx * dx) dy2 = (dy * dy) def num_updat...
86
2,669
numpy
benchmarks/benchmarks/bench_overrides.py
.py
from .common import Benchmark try: from numpy._core.overrides import array_function_dispatch except ImportError: # Don't fail at import time with old Numpy versions def array_function_dispatch(*args, **kwargs): def wrap(*args, **kwargs): return None return wrap import numpy as ...
68
1,786
numpy
benchmarks/benchmarks/common.py
.py
import random from functools import lru_cache from pathlib import Path import numpy as np # Various pre-crafted datasets/variables for testing # !!! Must not be changed -- only appended !!! # while testing numpy we better not rely on numpy to produce random # sequences random.seed(1) # but will seed it nevertheless n...
216
5,558
numpy
benchmarks/benchmarks/bench_creation.py
.py
import numpy as np from .common import TYPES1, Benchmark, get_squares_ class MeshGrid(Benchmark): """ Benchmark meshgrid generation """ params = [[16, 32], [2, 3, 4], ['ij', 'xy'], TYPES1] param_names = ['size', 'ndims', 'ind', 'ndtype'] timeout = 10 def setup(sel...
75
2,015
numpy
benchmarks/benchmarks/bench_manipulate.py
.py
from collections import deque import numpy as np from .common import TYPES1, Benchmark class BroadcastArrays(Benchmark): params = [[(16, 32), (128, 256), (512, 1024)], TYPES1] param_names = ['shape', 'ndtype'] timeout = 10 def setup(self, shape, ndtype): self.xarg = np.random....
112
3,178
numpy
benchmarks/benchmarks/bench_lib.py
.py
"""Benchmarks for `numpy.lib`.""" import string from asv_runner.benchmarks.mark import SkipNotImplemented import numpy as np from .common import Benchmark class Pad(Benchmark): """Benchmarks for `numpy.pad`. When benchmarking the pad function it is useful to cover scenarios where the ratio between th...
256
9,917
numpy
benchmarks/benchmarks/bench_itemselection.py
.py
import numpy as np from .common import TYPES1, Benchmark class Take(Benchmark): params = [ [(1000, 1), (2, 1000, 1), (1000, 3)], ["raise", "wrap", "clip"], TYPES1 + ["O", "i,O"]] param_names = ["shape", "mode", "dtype"] def setup(self, shape, mode, dtype): self.arr = np.o...
62
1,730
numpy
benchmarks/benchmarks/bench_function_base.py
.py
import numpy as np from .common import Benchmark try: # SkipNotImplemented is available since 6.0 from asv_runner.benchmarks.mark import SkipNotImplemented except ImportError: SkipNotImplemented = NotImplementedError class Linspace(Benchmark): def setup(self): self.d = np.array([1, 2, 3]) ...
424
11,682
numpy
benchmarks/benchmarks/bench_linalg.py
.py
import numpy as np from .common import TYPES1, Benchmark, get_indexes_rand, get_squares_ class Eindot(Benchmark): def setup(self): self.a = np.arange(60000.0).reshape(150, 400) self.ac = self.a.copy() self.at = self.a.T self.atc = self.a.T.copy() self.b = np.arange(240000....
276
9,060
numpy
benchmarks/benchmarks/bench_polynomial.py
.py
import numpy as np from .common import Benchmark class Polynomial(Benchmark): def setup(self): self.polynomial_degree2 = np.polynomial.Polynomial(np.array([1, 2])) self.array3 = np.linspace(0, 1, 3) self.array1000 = np.linspace(0, 1, 10_000) self.float64 = np.float64(1.0) de...
28
803
numpy
benchmarks/benchmarks/bench_alloc_cache.py
.py
"""Benchmarks for the NumPy small-allocation cache. NumPy caches data allocations smaller than 1024 bytes (up to 7 per size bucket) to avoid repeated malloc/free calls. For float64 arrays this means arrays with fewer than 128 elements hit the cache. These benchmarks measure tight create-and-discard loops so that the...
46
1,353
numpy
doc/preprocess.py
.py
#!/usr/bin/env python3 import os from string import Template def main(): doxy_gen(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) def doxy_gen(root_path): """ Generate Doxygen configuration file. """ confs = doxy_config(root_path) build_path = os.path.join(root_path, "doc", "b...
52
1,565
numpy
doc/postprocess.py
.py
#!/usr/bin/env python3 """ Post-processes HTML and Latex files output by Sphinx. """ def main(): import argparse parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('mode', help='file mode', choices=('html', 'tex')) parser.add_argument('file', nargs='+', help='input file(s)') ...
51
1,306
numpy
doc/conftest.py
.py
""" Pytest configuration and fixtures for the Numpy test suite. """ import doctest import matplotlib import pytest import numpy matplotlib.use('agg', force=True) # Ignore matplotlib output such as `<matplotlib.image.AxesImage at # 0x7f956908c280>`. doctest monkeypatching inspired by # https://github.com/wooyek/pyte...
34
943