repo_name stringlengths 7 65 | path stringlengths 5 185 | copies stringlengths 1 4 | size stringlengths 4 6 | content stringlengths 977 990k | license stringclasses 14
values | hash stringlengths 32 32 | line_mean float64 7.18 99.4 | line_max int64 31 999 | alpha_frac float64 0.25 0.95 | ratio float64 1.5 7.84 | autogenerated bool 1
class | config_or_test bool 2
classes | has_no_keywords bool 2
classes | has_few_assignments bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
scikit-learn/scikit-learn | sklearn/linear_model/_glm/tests/test_glm.py | 4 | 41485 | # Authors: Christian Lorentzen <lorentzen.ch@gmail.com>
#
# License: BSD 3 clause
from functools import partial
import itertools
import warnings
import numpy as np
from numpy.testing import assert_allclose
import pytest
import scipy
from scipy import linalg
from scipy.optimize import minimize, root
from sklearn.base... | bsd-3-clause | 4e03613467b77618e2c26114900d872c | 35.518486 | 88 | 0.625913 | 3.437034 | false | true | false | false |
scikit-learn/scikit-learn | examples/miscellaneous/plot_partial_dependence_visualization_api.py | 8 | 5363 | """
=========================================
Advanced Plotting With Partial Dependence
=========================================
The :class:`~sklearn.inspection.PartialDependenceDisplay` object can be used
for plotting without needing to recalculate the partial dependence. In this
example, we show how to plot partial ... | bsd-3-clause | b4fa6bc53b11de2d2ce5e9b04f1ec74e | 38.145985 | 92 | 0.701473 | 3.431222 | false | false | false | false |
scikit-learn/scikit-learn | examples/gaussian_process/plot_gpc_iris.py | 13 | 2219 | """
=====================================================
Gaussian process classification (GPC) on iris dataset
=====================================================
This example illustrates the predicted probability of GPC for an isotropic
and anisotropic RBF kernel on a two-dimensional version for the iris-dataset.
... | bsd-3-clause | 4eac018b8c0219b3c67838e2ef6b05bd | 34.790323 | 87 | 0.635872 | 3.023161 | false | false | false | false |
scikit-learn/scikit-learn | sklearn/utils/multiclass.py | 8 | 17679 | # Author: Arnaud Joly, Joel Nothman, Hamzeh Alsalhi
#
# License: BSD 3 clause
"""
Multi-class / multi-label utility function
==========================================
"""
from collections.abc import Sequence
from itertools import chain
import warnings
from scipy.sparse import issparse
from scipy.sparse import dok_ma... | bsd-3-clause | 166ddc7c1da004c4f839965af38aa5c0 | 32.932821 | 88 | 0.58363 | 3.708622 | false | false | false | false |
scikit-learn/scikit-learn | examples/compose/plot_digits_pipe.py | 11 | 2512 | # -*- coding: utf-8 -*-
"""
=========================================================
Pipelining: chaining a PCA and a logistic regression
=========================================================
The PCA does an unsupervised dimensionality reduction, while the logistic
regression does the prediction.
We use a GridSe... | bsd-3-clause | c1f940ce832b1fbb971d89d233f8c041 | 29.621951 | 88 | 0.702111 | 3.425648 | false | false | false | false |
scikit-learn/scikit-learn | examples/cluster/plot_affinity_propagation.py | 8 | 2180 | """
=================================================
Demo of affinity propagation clustering algorithm
=================================================
Reference:
Brendan J. Frey and Delbert Dueck, "Clustering by Passing Messages
Between Data Points", Science Feb. 2007
"""
import numpy as np
from sklearn.cluster i... | bsd-3-clause | f8ca295f3fb890e260ccd3fe44cdcc9e | 28.459459 | 86 | 0.634862 | 3.205882 | false | false | false | false |
scikit-learn/scikit-learn | sklearn/neighbors/_kde.py | 9 | 12346 | """
Kernel Density Estimation
-------------------------
"""
# Author: Jake Vanderplas <jakevdp@cs.washington.edu>
import itertools
from numbers import Integral, Real
import numpy as np
from scipy.special import gammainc
from ..base import BaseEstimator
from ..neighbors._base import VALID_METRICS
from ..utils import c... | bsd-3-clause | 439680ba9530c1b38f1c6a489db05502 | 32.917582 | 88 | 0.579864 | 4.207907 | false | false | false | false |
scikit-learn/scikit-learn | sklearn/ensemble/_iforest.py | 8 | 19672 | # Authors: Nicolas Goix <nicolas.goix@telecom-paristech.fr>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# License: BSD 3 clause
import numbers
import numpy as np
from scipy.sparse import issparse
from warnings import warn
from numbers import Integral, Real
from ..tree import ExtraTreeRegre... | bsd-3-clause | ad69eea3864c5ab2a7735a91c268c62a | 35.095413 | 88 | 0.609953 | 4.201623 | false | false | false | false |
kjung/scikit-learn | sklearn/metrics/tests/test_pairwise.py | 8 | 25509 | import numpy as np
from numpy import linalg
from scipy.sparse import dok_matrix, csr_matrix, issparse
from scipy.spatial.distance import cosine, cityblock, minkowski, wminkowski
from sklearn.utils.testing import assert_greater
from sklearn.utils.testing import assert_array_almost_equal
from sklearn.utils.testing impo... | bsd-3-clause | 00281808303150ca44f068886ec7e12c | 37.475113 | 78 | 0.636952 | 3.2339 | false | true | false | false |
kjung/scikit-learn | sklearn/metrics/cluster/bicluster.py | 352 | 2797 | from __future__ import division
import numpy as np
from sklearn.utils.linear_assignment_ import linear_assignment
from sklearn.utils.validation import check_consistent_length, check_array
__all__ = ["consensus_score"]
def _check_rows_and_columns(a, b):
"""Unpacks the row and column arrays and checks their shap... | bsd-3-clause | 1f3dac8cdbfc142531678c76f5d5a411 | 31.523256 | 73 | 0.618162 | 3.419315 | false | false | false | false |
kjung/scikit-learn | sklearn/tree/tree.py | 1 | 122456 | """
This module gathers tree-based methods, including decision, regression and
randomized trees. Single and multi-output problems are both handled.
"""
# Authors: Gilles Louppe <g.louppe@gmail.com>
# Peter Prettenhofer <peter.prettenhofer@gmail.com>
# Brian Holt <bdholt1@gmail.com>
# Noel Da... | bsd-3-clause | 28740cd88cbaecaefc6533eb2f248691 | 40.023786 | 112 | 0.568874 | 4.214918 | false | false | false | false |
kjung/scikit-learn | sklearn/manifold/spectral_embedding_.py | 3 | 20837 | """Spectral Embedding"""
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
# Wei LI <kuantkid@gmail.com>
# License: BSD 3 clause
import warnings
import numpy as np
from scipy import sparse
from scipy.linalg import eigh
from scipy.sparse.linalg import lobpcg
from ..base import BaseEstimator
from ..exter... | bsd-3-clause | 1928c5bc3abe2dd20ac38425d6de0348 | 39.776908 | 79 | 0.613428 | 4.270752 | false | false | false | false |
kjung/scikit-learn | sklearn/preprocessing/imputation.py | 28 | 14119 | # Authors: Nicolas Tresegnie <nicolas.tresegnie@gmail.com>
# License: BSD 3 clause
import warnings
import numpy as np
import numpy.ma as ma
from scipy import sparse
from scipy import stats
from ..base import BaseEstimator, TransformerMixin
from ..utils import check_array
from ..utils.fixes import astype
from ..utils... | bsd-3-clause | f3c4011d6f6f65c87e5bb9e0290d4fe5 | 36.650667 | 79 | 0.531907 | 4.275893 | false | false | false | false |
kjung/scikit-learn | sklearn/multiclass.py | 13 | 27844 | """
Multiclass and multilabel classification strategies
===================================================
This module implements multiclass learning algorithms:
- one-vs-the-rest / one-vs-all
- one-vs-one
- error correcting output codes
The estimators provided in this module are meta-estimators: they re... | bsd-3-clause | bf45709c2d3504e0253ad24d56dd9144 | 35.733509 | 88 | 0.612592 | 4.066005 | false | false | false | false |
kjung/scikit-learn | sklearn/metrics/ranking.py | 4 | 27716 | """Metrics to assess performance on classification task given scores
Functions named as ``*_score`` return a scalar value to maximize: the higher
the better
Function named as ``*_error`` or ``*_loss`` return a scalar value to minimize:
the lower the better
"""
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.... | bsd-3-clause | f91eb00eff6b220d8d2ff294ce550e12 | 35.372703 | 79 | 0.626173 | 3.854798 | false | false | false | false |
kjung/scikit-learn | examples/model_selection/plot_precision_recall.py | 72 | 6377 | """
================
Precision-Recall
================
Example of Precision-Recall metric to evaluate classifier output quality.
In information retrieval, precision is a measure of result relevancy, while
recall is a measure of how many truly relevant results are returned. A high
area under the curve represents both ... | bsd-3-clause | 4acc79a4effb871c7ed693a61a950f7c | 39.360759 | 80 | 0.713502 | 3.690394 | false | true | false | false |
kjung/scikit-learn | sklearn/decomposition/fastica_.py | 53 | 18240 | """
Python implementation of the fast ICA algorithms.
Reference: Tables 8.3 and 8.4 page 196 in the book:
Independent Component Analysis, by Hyvarinen et al.
"""
# Authors: Pierre Lafaye de Micheaux, Stefan van der Walt, Gael Varoquaux,
# Bertrand Thirion, Alexandre Gramfort, Denis A. Engemann
# License: BS... | bsd-3-clause | d038a6f1bc5ccf190520f240aee41a2f | 30.888112 | 79 | 0.584485 | 3.734644 | false | false | false | false |
kjung/scikit-learn | examples/linear_model/plot_polynomial_interpolation.py | 156 | 2088 | #!/usr/bin/env python
"""
========================
Polynomial interpolation
========================
This example demonstrates how to approximate a function with a polynomial of
degree n_degree by using ridge regression. Concretely, from n_samples 1d
points, it suffices to build the Vandermonde matrix, which is n_samp... | bsd-3-clause | 83b1c0f14524c3ade7dfa5fbb249b680 | 28 | 79 | 0.686782 | 3.324841 | false | false | false | false |
kjung/scikit-learn | benchmarks/bench_plot_svd.py | 322 | 2899 | """Benchmarks of Singular Value Decomposition (Exact and Approximate)
The data is mostly low rank but is a fat infinite tail.
"""
import gc
from time import time
import numpy as np
from collections import defaultdict
from scipy.linalg import svd
from sklearn.utils.extmath import randomized_svd
from sklearn.datasets.s... | bsd-3-clause | 8ae9391c7a3ba8b106722fb2a2359139 | 34.353659 | 75 | 0.575026 | 3.750323 | false | false | false | false |
kjung/scikit-learn | sklearn/datasets/olivetti_faces.py | 62 | 4699 | """Modified Olivetti faces dataset.
The original database was available from (now defunct)
http://www.uk.research.att.com/facedatabase.html
The version retrieved here comes in MATLAB format from the personal
web page of Sam Roweis:
http://www.cs.nyu.edu/~roweis/
There are ten different images of each of 40... | bsd-3-clause | feadc23ec0c37d152a677af2a047b210 | 32.564286 | 88 | 0.681634 | 3.873866 | false | false | false | false |
kjung/scikit-learn | examples/decomposition/plot_pca_iris.py | 28 | 1484 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
=========================================================
PCA example with Iris Data-set
=========================================================
Principal Component Analysis applied to the Iris dataset.
See `here <http://en.wikipedia.org/wiki/Iris_flower_data_set>`_ fo... | bsd-3-clause | c5828e19d18ee747b4c68528e92a6e13 | 24.135593 | 73 | 0.587997 | 3.002024 | false | false | false | false |
kjung/scikit-learn | sklearn/externals/odict.py | 54 | 9148 | # Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates.
# Copyright 2009 Raymond Hettinger
# http://code.activestate.com/recipes/576693/
"Ordered dictionary"
try:
from thread import get_ident as _get_ident
except Im... | bsd-3-clause | abae930781db79e25e7fec4f9cc19040 | 33.390977 | 87 | 0.551268 | 3.993016 | false | false | false | false |
kjung/scikit-learn | examples/applications/wikipedia_principal_eigenvector.py | 16 | 7819 | """
===============================
Wikipedia principal eigenvector
===============================
A classical way to assert the relative importance of vertices in a
graph is to compute the principal eigenvector of the adjacency matrix
so as to assign to each vertex the values of the components of the first
eigenvect... | bsd-3-clause | e634e05f27c61d6d5e1bf7e53120fd92 | 32.995652 | 79 | 0.650467 | 3.686469 | false | false | false | false |
kjung/scikit-learn | sklearn/datasets/svmlight_format.py | 28 | 16073 | """This module implements a loader and dumper for the svmlight format
This format is a text-based format, with one sample per line. It does
not store zero valued features hence is suitable for sparse dataset.
The first element of each line can be used to store a target variable to
predict.
This format is used as the... | bsd-3-clause | c9f504dd7685c3042513b05e6b25fb46 | 37.269048 | 79 | 0.635911 | 3.860918 | false | false | false | false |
kjung/scikit-learn | sklearn/linear_model/passive_aggressive.py | 58 | 10566 | # Authors: Rob Zinkov, Mathieu Blondel
# License: BSD 3 clause
from .stochastic_gradient import BaseSGDClassifier
from .stochastic_gradient import BaseSGDRegressor
from .stochastic_gradient import DEFAULT_EPSILON
class PassiveAggressiveClassifier(BaseSGDClassifier):
"""Passive Aggressive Classifier
Read mor... | bsd-3-clause | e4b50ecfb96c4d164ea1720e5c367484 | 34.337793 | 79 | 0.583475 | 4.281199 | false | false | false | false |
kjung/scikit-learn | sklearn/gaussian_process/correlation_models.py | 51 | 7654 | # -*- coding: utf-8 -*-
# Author: Vincent Dubourg <vincent.dubourg@gmail.com>
# (mostly translation, see implementation details)
# Licence: BSD 3 clause
"""
The built-in correlation models submodule for the gaussian_process module.
"""
import numpy as np
def absolute_exponential(theta, d):
"""
Abs... | bsd-3-clause | d875d22e2538556db06cea2cc3e1976e | 25.950704 | 78 | 0.549125 | 3.606975 | false | false | false | false |
kjung/scikit-learn | sklearn/externals/joblib/parallel.py | 31 | 35665 | """
Helpers for embarrassingly parallel code.
"""
# Author: Gael Varoquaux < gael dot varoquaux at normalesup dot org >
# Copyright: 2010, Gael Varoquaux
# License: BSD 3 clause
from __future__ import division
import os
import sys
import gc
import warnings
from math import sqrt
import functools
import time
import thr... | bsd-3-clause | e50afb979c7cddc314c16f13cb2acc4f | 42.230303 | 104 | 0.562428 | 4.669416 | false | false | false | false |
kjung/scikit-learn | sklearn/ensemble/voting_classifier.py | 5 | 8545 | """
Soft Voting/Majority Rule classifier.
This module contains a Soft Voting/Majority Rule classifier for
classification estimators.
"""
# Authors: Sebastian Raschka <se.raschka@gmail.com>,
# Gilles Louppe <g.louppe@gmail.com>
#
# Licence: BSD 3 clause
import numpy as np
from ..base import BaseEstimator
f... | bsd-3-clause | 61e583e2c20e6d1a208baf5c63cf40fe | 35.054852 | 79 | 0.569573 | 4.106199 | false | false | false | false |
kjung/scikit-learn | examples/manifold/plot_compare_methods.py | 37 | 4036 | """
=========================================
Comparison of Manifold Learning methods
=========================================
An illustration of dimensionality reduction on the S-curve dataset
with various manifold learning methods.
For a discussion and comparison of these algorithms, see the
:ref:`manifold module... | bsd-3-clause | adce37532962e501276a1ac08aa065c8 | 31.813008 | 76 | 0.657582 | 2.969831 | false | false | false | false |
kjung/scikit-learn | benchmarks/bench_random_projections.py | 390 | 8900 | """
===========================
Random projection benchmark
===========================
Benchmarks for random projections.
"""
from __future__ import division
from __future__ import print_function
import gc
import sys
import optparse
from datetime import datetime
import collections
import numpy as np
import scipy.s... | bsd-3-clause | c707476c1ad28622ab69547ef8275e83 | 34.03937 | 80 | 0.488876 | 4.392892 | false | false | false | false |
kjung/scikit-learn | examples/linear_model/plot_logistic_l1_l2_sparsity.py | 377 | 2601 | """
==============================================
L1 Penalty and Sparsity in Logistic Regression
==============================================
Comparison of the sparsity (percentage of zero coefficients) of solutions when
L1 and L2 penalty are used for different values of C. We can see that large
values of C give mo... | bsd-3-clause | e5f364437ce01ac7b502fa891558405e | 31.924051 | 78 | 0.636294 | 3.010417 | false | false | false | false |
kjung/scikit-learn | examples/linear_model/plot_theilsen.py | 98 | 3846 | """
====================
Theil-Sen Regression
====================
Computes a Theil-Sen Regression on a synthetic dataset.
See :ref:`theil_sen_regression` for more information on the regressor.
Compared to the OLS (ordinary least squares) estimator, the Theil-Sen
estimator is robust against outliers. It has a breakd... | bsd-3-clause | a0214f05a7886b6a11c43927deba1667 | 33.648649 | 79 | 0.673427 | 3.332756 | false | false | false | false |
kjung/scikit-learn | sklearn/tree/tests/test_export.py | 30 | 9588 | """
Testing for export functions of decision trees (sklearn.tree.export).
"""
from re import finditer
from numpy.testing import assert_equal
from nose.tools import assert_raises
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
from sklearn.ensemble import GradientBoostingClassifier
from sklearn... | bsd-3-clause | 32b51bbada6fda898ad5cfbe93115337 | 39.455696 | 78 | 0.472361 | 3.173784 | false | true | false | false |
kjung/scikit-learn | examples/cluster/plot_face_segmentation.py | 70 | 2839 | """
===================================================
Segmenting the picture of a raccoon face in regions
===================================================
This example uses :ref:`spectral_clustering` on a graph created from
voxel-to-voxel difference on an image to break this image into multiple
partly-homogeneous... | bsd-3-clause | 30a0040917d0282c410455c26247d8bc | 31.632184 | 79 | 0.667136 | 3.795455 | false | false | false | false |
kjung/scikit-learn | sklearn/feature_extraction/text.py | 7 | 50272 | # -*- coding: utf-8 -*-
# Authors: Olivier Grisel <olivier.grisel@ensta.org>
# Mathieu Blondel <mathieu@mblondel.org>
# Lars Buitinck <L.J.Buitinck@uva.nl>
# Robert Layton <robertlayton@gmail.com>
# Jochen Wersdörfer <jochen@wersdoerfer.de>
# Roman Sinayev <roman.sinayev@gma... | bsd-3-clause | a89a2613da16fb9a308a6ab89969350b | 36.627994 | 79 | 0.615623 | 4.438157 | false | false | false | false |
kjung/scikit-learn | examples/classification/plot_lda.py | 136 | 2419 | """
====================================================================
Normal and Shrinkage Linear Discriminant Analysis for classification
====================================================================
Shows how shrinkage improves classification.
"""
from __future__ import division
import numpy as np
import... | bsd-3-clause | 9be88cc7d0eb8edb282e719ae39e1155 | 33.070423 | 84 | 0.661844 | 3.465616 | false | false | false | false |
kjung/scikit-learn | examples/text/hashing_vs_dict_vectorizer.py | 282 | 3265 | """
===========================================
FeatureHasher and DictVectorizer Comparison
===========================================
Compares FeatureHasher and DictVectorizer by using both to vectorize
text documents.
The example demonstrates syntax and speed only; it doesn't actually do
anything useful with the e... | bsd-3-clause | 4fa0490a3dd57f024dfd8c93f01ed853 | 28.414414 | 73 | 0.693109 | 3.401042 | false | false | false | false |
kjung/scikit-learn | examples/decomposition/plot_image_denoising.py | 69 | 6249 | """
=========================================
Image denoising using dictionary learning
=========================================
An example comparing the effect of reconstructing noisy fragments
of a raccoon face image using firstly online :ref:`DictionaryLearning` and
various transform methods.
The dictionary is fi... | bsd-3-clause | 7069a6e1f1823997c66a36b310b8ce65 | 35.121387 | 79 | 0.647304 | 3.654386 | false | false | false | false |
kjung/scikit-learn | benchmarks/bench_plot_fastkmeans.py | 292 | 4676 | from __future__ import print_function
from collections import defaultdict
from time import time
import numpy as np
from numpy import random as nr
from sklearn.cluster.k_means_ import KMeans, MiniBatchKMeans
def compute_bench(samples_range, features_range):
it = 0
results = defaultdict(lambda: [])
chun... | bsd-3-clause | b5bf21059b8d85754418fa9671887377 | 32.884058 | 76 | 0.509624 | 3.594158 | false | false | false | false |
kjung/scikit-learn | sklearn/utils/tests/test_estimator_checks.py | 67 | 3894 | import scipy.sparse as sp
import numpy as np
import sys
from sklearn.externals.six.moves import cStringIO as StringIO
from sklearn.base import BaseEstimator, ClassifierMixin
from sklearn.utils.testing import assert_raises_regex, assert_true
from sklearn.utils.estimator_checks import check_estimator
from sklearn.utils.... | bsd-3-clause | 6300875b0e47a10cb59db94ac6ffe218 | 34.724771 | 81 | 0.704931 | 4.064718 | false | true | false | false |
kjung/scikit-learn | examples/mixture/plot_gmm_pdf.py | 282 | 1528 | """
=============================================
Density Estimation for a mixture of Gaussians
=============================================
Plot the density estimation of a mixture of two Gaussians. Data is
generated from two Gaussians with different centers and covariance
matrices.
"""
import numpy as np
import ma... | bsd-3-clause | 4bacfeed60ae10da691085db51c57def | 29.56 | 69 | 0.667539 | 3.131148 | false | false | false | false |
pytorch/text | examples/tutorials/t5_demo.py | 1 | 24935 | """
T5-Base Model for Summarization, Sentiment Classification, and Translation
==========================================================================
**Author**: `Pendo Abbo <pabbo@fb.com>`__
"""
######################################################################
# Overview
# --------
#
# This tutorial demons... | bsd-3-clause | c74eee3c62ede11e71b7ff4ca9b28870 | 40.673913 | 147 | 0.672284 | 3.463655 | false | false | false | false |
pytorch/text | benchmark/benchmark_bert_tokenizer.py | 1 | 1773 | from argparse import ArgumentParser
from benchmark.utils import Timer
from tokenizers import Tokenizer as hf_tokenizer_lib
from torchtext.datasets import EnWik9
from torchtext.transforms import BERTTokenizer as tt_bert_tokenizer
from transformers import BertTokenizer as hf_bert_tokenizer_slow
VOCAB_FILE = "https://h... | bsd-3-clause | 92509feae1bf56268bffb7294e078ed4 | 35.183673 | 83 | 0.684715 | 3.618367 | false | false | false | false |
pytorch/text | torchtext/datasets/yelpreviewpolarity.py | 1 | 3186 | import os
from functools import partial
from typing import Union, Tuple
from torchdata.datapipes.iter import FileOpener, IterableWrapper
from torchtext._download_hooks import GDriveReader
from torchtext._internal.module_utils import is_module_available
from torchtext.data.datasets_utils import (
_wrap_split_argume... | bsd-3-clause | e48fa498b662e89d3285bf40a4fe1dd5 | 32.536842 | 119 | 0.696798 | 3.284536 | false | true | false | false |
pytorch/text | torchtext/prototype/vocab_factory.py | 1 | 3001 | from typing import Callable, Optional
import torch
from torchtext._torchtext import (
_build_vocab_from_text_file,
_build_vocab_from_text_file_using_python_tokenizer,
_load_vocab_from_file,
)
from torchtext.vocab import Vocab
__all__ = [
"build_vocab_from_text_file",
"load_vocab_from_file",
]
de... | bsd-3-clause | 3f81ef3558cf4e7513ee52d03f43945b | 36.987342 | 143 | 0.664445 | 3.72795 | false | false | false | false |
pytorch/text | test/torchtext_unittest/datasets/test_cnndm.py | 1 | 3647 | import hashlib
import os
import tarfile
from collections import defaultdict
from unittest.mock import patch
from parameterized import parameterized
from torchtext.datasets import CNNDM
from ..common.case_utils import TempDirMixin, zip_equal, get_random_unicode
from ..common.torchtext_test_case import TorchtextTestCas... | bsd-3-clause | b265d0cb46ddbf810d70489363286155 | 35.838384 | 110 | 0.603784 | 3.647 | false | true | false | false |
pallets/click | src/click/globals.py | 1 | 1961 | import typing as t
from threading import local
if t.TYPE_CHECKING:
import typing_extensions as te
from .core import Context
_local = local()
@t.overload
def get_current_context(silent: "te.Literal[False]" = False) -> "Context":
...
@t.overload
def get_current_context(silent: bool = ...) -> t.Optional[... | bsd-3-clause | 3ece3cdc0ed547ae084dd6e6c3bc4eec | 27.838235 | 78 | 0.654768 | 4.002041 | false | false | false | false |
pytorch/text | examples/vocab/fairseq_vocab.py | 1 | 2387 | from collections import OrderedDict
from typing import Dict, List, Optional
from fairseq.data.dictionary import Dictionary
from torchtext.vocab import Vocab
def build_fairseq_vocab(
vocab_file: str,
dictionary_class: Dictionary = Dictionary,
special_token_replacements: Dict[str, str] = None,
unk_toke... | bsd-3-clause | f54419c10419c63ec032477f0cf75fc5 | 35.166667 | 107 | 0.620444 | 3.913115 | false | false | false | false |
pallets/click | tests/test_imports.py | 1 | 1374 | import json
import subprocess
import sys
from click._compat import WIN
IMPORT_TEST = b"""\
import builtins
found_imports = set()
real_import = builtins.__import__
import sys
def tracking_import(module, locals=None, globals=None, fromlist=None,
level=0):
rv = real_import(module, locals, glob... | bsd-3-clause | ca72938f3020ac427ecf835bcbeb08ab | 19.205882 | 76 | 0.606259 | 3.587467 | false | false | false | false |
scipy/scipy | scipy/fftpack/_helper.py | 10 | 3354 | import operator
from numpy.fft.helper import fftshift, ifftshift, fftfreq
import scipy.fft._pocketfft.helper as _helper
import numpy as np
__all__ = ['fftshift', 'ifftshift', 'fftfreq', 'rfftfreq', 'next_fast_len']
def rfftfreq(n, d=1.0):
"""DFT sample frequencies (for usage with rfft, irfft).
The returned f... | bsd-3-clause | 74cb0333fc4267156f23d291818008ff | 28.946429 | 78 | 0.592725 | 3.41896 | false | false | false | false |
scipy/scipy | scipy/odr/_add_newdocs.py | 24 | 1090 | from numpy import add_newdoc
add_newdoc('scipy.odr', 'odr',
"""
odr(fcn, beta0, y, x, we=None, wd=None, fjacb=None, fjacd=None, extra_args=None, ifixx=None, ifixb=None, job=0, iprint=0, errfile=None, rptfile=None, ndigit=0, taufac=0.0, sstol=-1.0, partol=-1.0, maxit=-1, stpb=None, stpd=None, sclb=None, scld=No... | bsd-3-clause | ea77bf3fbce1dc8f08fc4af1ae72f77b | 35.333333 | 292 | 0.673394 | 3.234421 | false | false | false | false |
scipy/scipy | benchmarks/benchmarks/common.py | 18 | 3954 | """
Airspeed Velocity benchmark utilities
"""
import sys
import os
import re
import time
import textwrap
import subprocess
import itertools
import random
class Benchmark:
"""
Base class with sensible options
"""
pass
def is_xslow():
try:
return int(os.environ.get('SCIPY_XSLOW', '0'))
... | bsd-3-clause | bd3f207be3c0fd0fd689717cf8cb7b79 | 23.867925 | 76 | 0.595346 | 3.903258 | false | false | false | false |
scipy/scipy | scipy/stats/tests/test_mstats_extras.py | 10 | 6066 | import numpy as np
import numpy.ma as ma
import scipy.stats.mstats as ms
from numpy.testing import (assert_equal, assert_almost_equal, assert_,
assert_allclose)
def test_compare_medians_ms():
x = np.arange(7)
y = x + 10
assert_almost_equal(ms.compare_medians_ms(x, y), 0)
y2 = np.linspace(0, 1, n... | bsd-3-clause | a195ef98c572595e42eb79552bc6aee8 | 39.44 | 82 | 0.628586 | 2.564905 | false | true | false | false |
scipy/scipy | scipy/spatial/tests/test_qhull.py | 9 | 44147 | import os
import copy
import numpy as np
from numpy.testing import (assert_equal, assert_almost_equal,
assert_, assert_allclose, assert_array_equal)
import pytest
from pytest import raises as assert_raises
import scipy.spatial._qhull as qhull
from scipy.spatial import cKDTree as KDTree
from... | bsd-3-clause | 3274653af028bb8e125d064008a45f0d | 36.476231 | 98 | 0.522255 | 3.269906 | false | true | false | false |
scipy/scipy | scipy/sparse/_csc.py | 13 | 7925 | """Compressed Sparse Column matrix format"""
__docformat__ = "restructuredtext en"
__all__ = ['csc_matrix', 'isspmatrix_csc']
import numpy as np
from ._base import spmatrix
from ._sparsetools import csc_tocsr, expandptr
from ._sputils import upcast, get_index_dtype
from ._compressed import _cs_matrix
class csc_m... | bsd-3-clause | b23579f9db1f5724e13e5b0433b7e2ce | 29.480769 | 78 | 0.55836 | 3.713683 | false | false | false | false |
scipy/scipy | scipy/signal/_arraytools.py | 27 | 7489 | """
Functions for acting on a axis of an array.
"""
import numpy as np
def axis_slice(a, start=None, stop=None, step=None, axis=-1):
"""Take a slice along axis 'axis' from 'a'.
Parameters
----------
a : numpy.ndarray
The array to be sliced.
start, stop, step : int or None
The slic... | bsd-3-clause | 83dca6943ef1511ae043dad01413a0a1 | 30.074689 | 79 | 0.52517 | 3.246207 | false | false | false | false |
scipy/scipy | scipy/sparse/_sputils.py | 8 | 13136 | """ Utility functions for sparse matrix module
"""
import sys
import operator
import numpy as np
from scipy._lib._util import prod
import scipy.sparse as sp
__all__ = ['upcast', 'getdtype', 'getdata', 'isscalarlike', 'isintlike',
'isshape', 'issequence', 'isdense', 'ismatrix', 'get_sum_dtype']
supported_... | bsd-3-clause | 7787577de369a012c390f005d07fc417 | 30.806295 | 80 | 0.584881 | 3.918854 | false | false | false | false |
scipy/scipy | tools/write_release_and_log.py | 11 | 4038 | """
Standalone script for writing release doc and logs::
python tools/write_release_and_log.py <LOG_START> <LOG_END>
Example::
python tools/write_release_and_log.py v1.7.0 v1.8.0
Needs to be run from the root of the repository.
"""
import os
import sys
import subprocess
from hashlib import md5
from hashli... | bsd-3-clause | 5914e5b3f095711eaa103f437fbb0727 | 25.220779 | 79 | 0.607479 | 3.436596 | false | false | false | false |
scipy/scipy | scipy/sparse/__init__.py | 13 | 8636 | """
=====================================
Sparse matrices (:mod:`scipy.sparse`)
=====================================
.. currentmodule:: scipy.sparse
SciPy 2-D sparse array package for numeric data.
.. note::
This package is switching to an array interface, compatible with
NumPy arrays, from the older matrix ... | bsd-3-clause | f339be2609078986d77c4744c8470708 | 27.979866 | 92 | 0.698819 | 3.65313 | false | false | false | false |
scipy/scipy | benchmarks/benchmarks/go_benchmark_functions/go_funcs_D.py | 25 | 17840 | # -*- coding: utf-8 -*-
import numpy as np
from numpy import abs, cos, exp, arange, pi, sin, sqrt, sum, zeros, tanh
from numpy.testing import assert_almost_equal
from .go_benchmark import Benchmark
class Damavandi(Benchmark):
r"""
Damavandi objective function.
This class defines the Damavandi [1]_ global... | bsd-3-clause | 2fdb4e90e01892bc83655ec2c90632d7 | 30.408451 | 95 | 0.539686 | 2.840312 | false | false | false | false |
scipy/scipy | scipy/stats/_kde.py | 8 | 24412 | #-------------------------------------------------------------------------------
#
# Define classes for (uni/multi)-variate kernel density estimation.
#
# Currently, only Gaussian kernels are implemented.
#
# Written by: Robert Kern
#
# Date: 2004-08-09
#
# Modified: 2005-02-10 by Robert Kern.
# Contr... | bsd-3-clause | a79965a7b1b7d12290c3fbcf871f590e | 33.142657 | 90 | 0.56677 | 4.153113 | false | false | false | false |
scipy/scipy | scipy/optimize/_milp.py | 1 | 14580 | import warnings
import numpy as np
from scipy.sparse import csc_array, vstack
from ._highs._highs_wrapper import _highs_wrapper # type: ignore[import]
from ._constraints import LinearConstraint, Bounds
from ._optimize import OptimizeResult
from ._linprog_highs import _highs_to_scipy_status_message
def _constraints_t... | bsd-3-clause | d0ea3f944233ffc311879ad28874a381 | 37.167539 | 79 | 0.627778 | 4.05902 | false | false | false | false |
scipy/scipy | scipy/integrate/_ivp/base.py | 20 | 9550 | import numpy as np
def check_arguments(fun, y0, support_complex):
"""Helper function for checking arguments common to all solvers."""
y0 = np.asarray(y0)
if np.issubdtype(y0.dtype, np.complexfloating):
if not support_complex:
raise ValueError("`y0` is complex, but the chosen solver doe... | bsd-3-clause | 07a887cf5b40905406b8a9911edd07d7 | 33.854015 | 79 | 0.579372 | 4.26149 | false | false | false | false |
scipy/scipy | scipy/sparse/tests/test_sparsetools.py | 8 | 10441 | import sys
import os
import gc
import threading
import numpy as np
from numpy.testing import assert_equal, assert_, assert_allclose
from scipy.sparse import (_sparsetools, coo_matrix, csr_matrix, csc_matrix,
bsr_matrix, dia_matrix)
from scipy.sparse._sputils import supported_dtypes
from scipy... | bsd-3-clause | cfde609624509b5ea208d26ad9fad661 | 29.982196 | 95 | 0.544488 | 3.272015 | false | true | false | false |
scipy/scipy | scipy/stats/_warnings_errors.py | 10 | 1195 | # Warnings
class DegenerateDataWarning(RuntimeWarning):
"""Warns when data is degenerate and results may not be reliable."""
def __init__(self, msg=None):
if msg is None:
msg = ("Degenerate data encountered; results may not be reliable.")
self.args = (msg,)
class ConstantInputWar... | bsd-3-clause | fef62d5d8cb4b445979c30623d01a7e3 | 30.447368 | 79 | 0.609205 | 4.298561 | false | false | false | false |
scipy/scipy | scipy/optimize/_shgo_lib/triangulation.py | 10 | 21439 | import numpy as np
import copy
class Complex:
def __init__(self, dim, func, func_args=(), symmetry=False, bounds=None,
g_cons=None, g_args=()):
self.dim = dim
self.bounds = bounds
self.symmetry = symmetry # TODO: Define the functions to be used
# here in init... | bsd-3-clause | 984ad94cff54d69c795adff1ea23eb09 | 31.434191 | 86 | 0.497131 | 3.771152 | false | false | false | false |
scipy/scipy | scipy/io/matlab/_mio5.py | 12 | 33426 | ''' Classes for read / write of matlab (TM) 5 files
The matfile specification last found here:
https://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
(as of December 5 2008)
'''
'''
=================================
Note on functions and mat files
=================================
The doc... | bsd-3-clause | 4abfb4cbc76cc2bbf9dc412ee75211af | 36.473094 | 84 | 0.581553 | 4.044773 | false | false | false | false |
scipy/scipy | scipy/optimize/tests/test_zeros.py | 15 | 28443 | import pytest
from math import sqrt, exp, sin, cos
from functools import lru_cache
from numpy.testing import (assert_warns, assert_,
assert_allclose,
assert_equal,
assert_array_equal,
suppress_warnings)
import ... | bsd-3-clause | 9a051f9084d151c45cf610e8a61b4138 | 35.938961 | 112 | 0.557149 | 3.05379 | false | true | false | false |
scipy/scipy | scipy/stats/_levy_stable/__init__.py | 8 | 43857 | # -*- coding: utf-8 -*-
#
import warnings
from functools import partial
import numpy as np
from scipy import optimize
from scipy import integrate
from scipy.integrate._quadrature import _builtincoeffs
from scipy import interpolate
from scipy.interpolate import RectBivariateSpline
import scipy.special as sc
from scip... | bsd-3-clause | 0ee8e691fff1002d2ba97c47238fc3b7 | 35.546667 | 79 | 0.536415 | 3.226367 | false | false | false | false |
scipy/scipy | scipy/optimize/_trustregion_constr/equality_constrained_sqp.py | 27 | 8592 | """Byrd-Omojokun Trust-Region SQP method."""
from scipy.sparse import eye as speye
from .projections import projections
from .qp_subproblem import modified_dogleg, projected_cg, box_intersections
import numpy as np
from numpy.linalg import norm
__all__ = ['equality_constrained_sqp']
def default_scaling(x):
n, =... | bsd-3-clause | f8b4b316d9e6e25f76ca7f522f251b2b | 38.59447 | 79 | 0.554004 | 3.544554 | false | false | false | false |
scipy/scipy | scipy/optimize/_linprog_ip.py | 11 | 45914 | """Interior-point method for linear programming
The *interior-point* method uses the primal-dual path following algorithm
outlined in [1]_. This algorithm supports sparse constraint matrices and
is typically faster than the simplex methods, especially for large, sparse
problems. Note, however, that the solution return... | bsd-3-clause | b6721458147900c2e44fc11f27eea40f | 39.703901 | 143 | 0.600666 | 3.936048 | false | false | false | false |
scipy/scipy | scipy/fft/_pocketfft/helper.py | 10 | 5725 | from numbers import Number
import operator
import os
import threading
import contextlib
import numpy as np
# good_size is exposed (and used) from this import
from .pypocketfft import good_size
_config = threading.local()
_cpu_count = os.cpu_count()
def _iterable_of_int(x, name=None):
"""Convert ``x`` to an iter... | bsd-3-clause | 073920be125e0f5d5ed992a58021aec2 | 25.50463 | 79 | 0.580611 | 3.776385 | false | false | false | false |
scipy/scipy | benchmarks/benchmarks/go_benchmark_functions/go_funcs_H.py | 25 | 11278 | # -*- coding: utf-8 -*-
import numpy as np
from numpy import abs, arctan2, asarray, cos, exp, arange, pi, sin, sqrt, sum
from .go_benchmark import Benchmark
class Hansen(Benchmark):
r"""
Hansen objective function.
This class defines the Hansen [1]_ global optimization problem. This is a
multimodal m... | bsd-3-clause | bef1d1c7cb03efb108e1673e8085d696 | 29.074667 | 80 | 0.51667 | 2.773051 | false | false | false | false |
scipy/scipy | scipy/signal/tests/mpsig.py | 21 | 3308 | """
Some signal functions implemented using mpmath.
"""
try:
import mpmath
except ImportError:
mpmath = None
def _prod(seq):
"""Returns the product of the elements in the sequence `seq`."""
p = 1
for elem in seq:
p *= elem
return p
def _relative_degree(z, p):
"""
Return rela... | bsd-3-clause | 49bcb629d78fa93d2895f012cfdd7e55 | 26.114754 | 78 | 0.604595 | 3.091589 | false | false | false | false |
scipy/scipy | scipy/integrate/tests/test_quadpack.py | 1 | 27947 | import sys
import math
import numpy as np
from numpy import sqrt, cos, sin, arctan, exp, log, pi, Inf
from numpy.testing import (assert_,
assert_allclose, assert_array_less, assert_almost_equal)
import pytest
from scipy.integrate import quad, dblquad, tplquad, nquad
from scipy.special import erf, erfc
from sci... | bsd-3-clause | cf70ba4550126005f4c6b93e7a4f19d8 | 40.402963 | 84 | 0.465703 | 2.939933 | false | true | false | false |
scipy/scipy | scipy/stats/_ksstats.py | 9 | 20086 | # Compute the two-sided one-sample Kolmogorov-Smirnov Prob(Dn <= d) where:
# D_n = sup_x{|F_n(x) - F(x)|},
# F_n(x) is the empirical CDF for a sample of size n {x_i: i=1,...,n},
# F(x) is the CDF of a probability distribution.
#
# Exact methods:
# Prob(D_n >= d) can be computed via a matrix algorithm of Durbin... | bsd-3-clause | 264c86af90a6593085c4467eefbc15b4 | 32.701342 | 84 | 0.554267 | 2.672432 | false | false | false | false |
scipy/scipy | scipy/optimize/_nonlin.py | 2 | 49030 | # Copyright (C) 2009, Pauli Virtanen <pav@iki.fi>
# Distributed under the same license as SciPy.
import sys
import numpy as np
from scipy.linalg import norm, solve, inv, qr, svd, LinAlgError
from numpy import asarray, dot, vdot
import scipy.sparse.linalg
import scipy.sparse
from scipy.linalg import get_blas_funcs
impo... | bsd-3-clause | ebf11bff8f5ae4e84cbc5a6a9bf272e4 | 30.309068 | 104 | 0.543484 | 3.686466 | false | false | false | false |
scipy/scipy | scipy/sparse/linalg/_isolve/minres.py | 10 | 11425 | from numpy import inner, zeros, inf, finfo
from numpy.linalg import norm
from math import sqrt
from .utils import make_system
__all__ = ['minres']
def minres(A, b, x0=None, shift=0.0, tol=1e-5, maxiter=None,
M=None, callback=None, show=False, check=False):
"""
Use MINimum RESidual iteration to so... | bsd-3-clause | db05e97b1fe86b1d3de08c86435fac15 | 28.145408 | 85 | 0.498206 | 3.40435 | false | false | false | false |
scipy/scipy | scipy/optimize/_trustregion_constr/tests/test_report.py | 17 | 1088 | import numpy as np
from scipy.optimize import minimize, Bounds
def test_gh10880():
# checks that verbose reporting works with trust-constr for
# bound-contrained problems
bnds = Bounds(1, 2)
opts = {'maxiter': 1000, 'verbose': 2}
minimize(lambda x: x**2, x0=2., method='trust-constr',
b... | bsd-3-clause | 57ce8f267153742d9a20ce5584c94e53 | 33 | 63 | 0.602941 | 3.378882 | false | true | false | false |
scipy/scipy | tools/lint_diff.py | 12 | 2676 | #!/usr/bin/env python
import os
import sys
import subprocess
from argparse import ArgumentParser
CONFIG = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'lint_diff.ini',
)
def rev_list(branch, num_commits):
"""List commits in reverse chronological order.
Only the first `num_commits` are s... | bsd-3-clause | add1e5b02775861c6106f586cbbda514 | 25.235294 | 87 | 0.589312 | 3.817404 | false | false | false | false |
scipy/scipy | scipy/fft/_pocketfft/tests/test_basic.py | 16 | 35706 | # Created by Pearu Peterson, September 2002
from numpy.testing import (assert_, assert_equal, assert_array_almost_equal,
assert_array_almost_equal_nulp, assert_array_less,
assert_allclose)
import pytest
from pytest import raises as assert_raises
from scipy.fft._poc... | bsd-3-clause | 9bb716cf3064c9011a4566267076ea6c | 33.937378 | 80 | 0.507814 | 3.094376 | false | true | false | false |
scipy/scipy | scipy/interpolate/_rgi.py | 1 | 28186 | __all__ = ['RegularGridInterpolator', 'interpn']
import itertools
import numpy as np
from .interpnd import _ndim_coords_from_arrays
from ._cubic import PchipInterpolator
from ._rgi_cython import evaluate_linear_2d, find_indices
from ._bsplines import make_interp_spline
from ._fitpack2 import RectBivariateSpline
de... | bsd-3-clause | ef2c5d2751858a77a25f1c500a579dbc | 39.323319 | 112 | 0.569396 | 3.954265 | false | false | false | false |
scipy/scipy | scipy/optimize/_linprog_doc.py | 1 | 61967 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 19:49:17 2020
@author: matth
"""
def _linprog_highs_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None,
bounds=None, method='highs', callback=None,
maxiter=None, disp=False, presolve=True,
time_limit... | bsd-3-clause | dc654454a971be029d40d9eff6bbe7c5 | 42.182578 | 143 | 0.629351 | 4.172581 | false | false | false | false |
scipy/scipy | scipy/special/_orthogonal.py | 1 | 73921 | """
A collection of functions to find the weights and abscissas for
Gaussian Quadrature.
These calculations are done by finding the eigenvalues of a
tridiagonal matrix whose entries are dependent on the coefficients
in the recursion formula for the orthogonal polynomials with the
corresponding weighting function over ... | bsd-3-clause | 5deb35f597b2aba073e4ed9233968b86 | 27.909269 | 139 | 0.558935 | 3.09086 | false | false | false | false |
scipy/scipy | scipy/signal/_bsplines.py | 8 | 19753 | from numpy import (logical_and, asarray, pi, zeros_like,
piecewise, array, arctan2, tan, zeros, arange, floor)
from numpy.core.umath import (sqrt, exp, greater, less, cos, add, sin,
less_equal, greater_equal)
# From splinemodule.c
from ._spline import cspline2d, sepfir2... | bsd-3-clause | 829591a7aae9de5285e8b77c90b954ac | 27.920937 | 89 | 0.568116 | 3.250987 | false | false | false | false |
scipy/scipy | scipy/sparse/tests/test_array_api.py | 10 | 7480 | import pytest
import numpy as np
import numpy.testing as npt
import scipy.sparse
import scipy.sparse.linalg as spla
sparray_types = ('bsr', 'coo', 'csc', 'csr', 'dia', 'dok', 'lil')
sparray_classes = [
getattr(scipy.sparse, f'{T}_array') for T in sparray_types
]
A = np.array([
[0, 1, 2, 0],
[2, 0, 0, 3],... | bsd-3-clause | adca84dbb17b08ce332747a56f71cf80 | 21.064897 | 78 | 0.590909 | 2.834407 | false | true | false | false |
scipy/scipy | scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py | 5 | 24890 | import time
import numpy as np
from scipy.sparse.linalg import LinearOperator
from .._differentiable_functions import VectorFunction
from .._constraints import (
NonlinearConstraint, LinearConstraint, PreparedConstraint, strict_bounds)
from .._hessian_update_strategy import BFGS
from .._optimize import OptimizeResu... | bsd-3-clause | 1775531a513f3bafb362bad6bb1a860a | 44.669725 | 86 | 0.595661 | 4.435929 | false | false | false | false |
scipy/scipy | scipy/special/_generate_pyx.py | 10 | 52332 | """
python _generate_pyx.py
Generate Ufunc definition source files for scipy.special. Produces
files '_ufuncs.c' and '_ufuncs_cxx.c' by first producing Cython.
This will generate both calls to PyUFunc_FromFuncAndData and the
required ufunc inner loops.
The functions signatures are contained in 'functions.json', the ... | bsd-3-clause | bd71c018bdb541b7d6858a013fd0d59b | 33.451613 | 108 | 0.543644 | 3.561454 | false | false | false | false |
scipy/scipy | scipy/linalg/_cython_signature_generator.py | 10 | 10595 | """
A script that uses f2py to generate the signature files used to make
the Cython BLAS and LAPACK wrappers from the fortran source code for
LAPACK and the reference BLAS.
To generate the BLAS wrapper signatures call:
python _cython_signature_generator.py blas <blas_directory> <out_file>
To generate the LAPACK wrapp... | bsd-3-clause | b1d65a17ed835c7849f95fd34c441e7e | 56.27027 | 297 | 0.59849 | 2.719456 | false | false | false | false |
scipy/scipy | scipy/special/_spfun_stats.py | 8 | 3806 | # Last Change: Sat Mar 21 02:00 PM 2009 J
# Copyright (c) 2001, 2002 Enthought, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# a. Redistributions of source code must retain the abov... | bsd-3-clause | 58b0d8bb01637337f179ea128b511163 | 34.570093 | 79 | 0.665791 | 3.738703 | false | false | false | false |
scipy/scipy | scipy/signal/_max_len_seq.py | 8 | 5062 | # Author: Eric Larson
# 2014
"""Tools for MLS generation"""
import numpy as np
from ._max_len_seq_inner import _max_len_seq_inner
__all__ = ['max_len_seq']
# These are definitions of linear shift register taps for use in max_len_seq()
_mls_taps = {2: [1], 3: [2], 4: [3], 5: [3], 6: [5], 7: [6], 8: [7, 6, 1],
... | bsd-3-clause | dd5883d12b82548d55f2b271ebd4de2f | 35.417266 | 154 | 0.571711 | 3.236573 | false | false | false | false |
scipy/scipy | scipy/special/_spherical_bessel.py | 1 | 10217 | from ._ufuncs import (_spherical_jn, _spherical_yn, _spherical_in,
_spherical_kn, _spherical_jn_d, _spherical_yn_d,
_spherical_in_d, _spherical_kn_d)
def spherical_jn(n, z, derivative=False):
r"""Spherical Bessel function of the first kind or its derivative.
Defined... | bsd-3-clause | 0ea146f8a6664a19231be29bd0aba706 | 28.275072 | 80 | 0.585593 | 3.202821 | false | false | false | false |
scipy/scipy | scipy/ndimage/_interpolation.py | 8 | 35437 | # Copyright (C) 2003-2005 Peter J. Verveer
#
# 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 conditions and the following d... | bsd-3-clause | df4194e07d6f4c28ee74c5d6aed2b61c | 35.913542 | 79 | 0.612354 | 4.061547 | false | false | false | false |
scipy/scipy | scipy/_lib/_finite_differences.py | 9 | 4172 | from numpy import arange, newaxis, hstack, prod, array
def _central_diff_weights(Np, ndiv=1):
"""
Return weights for an Np-point central derivative.
Assumes equally-spaced function points.
If weights are in the vector w, then
derivative is w[0] * f(x-ho*dx) + ... + w[-1] * f(x+h0*dx)
Parame... | bsd-3-clause | 6a6224780f18433f5600e11254eadbf4 | 27.772414 | 78 | 0.52325 | 3.476667 | false | false | false | false |
scipy/scipy | scipy/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.py | 8 | 16524 | """ Test functions for the sparse.linalg._eigen.lobpcg module
"""
import itertools
import platform
import sys
import numpy as np
from numpy.testing import (assert_almost_equal, assert_equal,
assert_allclose, assert_array_less)
import pytest
from numpy import ones, r_, diag
from scipy.lina... | bsd-3-clause | 2a2829470975a98af80baf77fbbf6f87 | 33.21118 | 80 | 0.577463 | 3.078815 | false | true | false | false |
scipy/scipy | scipy/sparse/_extract.py | 15 | 4648 | """Functions to extract parts of sparse matrices
"""
__docformat__ = "restructuredtext en"
__all__ = ['find', 'tril', 'triu']
from ._coo import coo_matrix
def find(A):
"""Return the indices and values of the nonzero elements of a matrix
Parameters
----------
A : dense or sparse matrix
Mat... | bsd-3-clause | a45a2d9584b12b32b5acbe7991287a73 | 26.502959 | 90 | 0.523666 | 3.294118 | false | false | false | false |
scipy/scipy | benchmarks/benchmarks/cutest/dfoxs.py | 1 | 2637 | # This is a python implementation of dfoxs.m,
# provided at https://github.com/POptUS/BenDFO
import numpy as np
def dfoxs(n, nprob, factor):
x = np.zeros(n)
if nprob == 1 or nprob == 2 or nprob == 3: # Linear functions.
x = np.ones(n)
elif nprob == 4: # Rosenbrock function.
x[0] = -1.2
... | bsd-3-clause | 5bef1f9c1e1e830ec3bf8dbf3b4fc9c1 | 27.053191 | 74 | 0.423967 | 2.674442 | false | false | false | false |
scipy/scipy | scipy/integrate/_ode.py | 10 | 47945 | # Authors: Pearu Peterson, Pauli Virtanen, John Travers
"""
First-order ODE integrators.
User-friendly interface to various numerical integrators for solving a
system of first order ODEs with prescribed initial conditions::
d y(t)[i]
--------- = f(t,y(t))[i],
d t
y(t=0)[i] = y0[i],
where::
... | bsd-3-clause | 0a87c769d5051abd08ae0ccd8697b270 | 33.945335 | 90 | 0.5416 | 3.790119 | false | false | false | false |
scipy/scipy | scipy/io/wavfile.py | 10 | 26642 | """
Module to read / write wav files using NumPy arrays
Functions
---------
`read`: Return the sample rate (in samples/sec) and data from a WAV file.
`write`: Write a NumPy array as a WAV file.
"""
import io
import sys
import numpy
import struct
import warnings
from enum import IntEnum
__all__ = [
'WavFileWarn... | bsd-3-clause | 52c5a471cbaafb1694583f00c381982f | 30.716667 | 94 | 0.578635 | 3.138045 | false | false | false | false |
scipy/scipy | scipy/signal/_wavelets.py | 2 | 14047 | import numpy as np
from scipy.linalg import eig
from scipy.special import comb
from scipy.signal import convolve
__all__ = ['daub', 'qmf', 'cascade', 'morlet', 'ricker', 'morlet2', 'cwt']
def daub(p):
"""
The coefficients for the FIR low-pass filter producing Daubechies wavelets.
p>=1 gives the order of... | bsd-3-clause | 16d9139c934e8101c775a78081129be3 | 27.550813 | 84 | 0.536413 | 3.24561 | false | false | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.