本文整理汇总了Python中numpy.deprecate函数的典型用法代码示例。如果您正苦于以下问题:Python deprecate函数的具体用法?Python deprecate怎么用?Python deprecate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deprecate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exec
the same name as the module.
"""
dir,filename = os.path.split(module.__file__)
filebase = filename.split('.')[0]
fn = os.path.join(dir, filebase)
f = dumb_shelve.open(fn, "r")
#exec( 'import ' + module.__name__)
for i in f.keys():
exec( 'import ' + module.__name__+ ';' +
module.__name__+'.'+i + '=' + 'f["' + i + '"]')
# print i, 'loaded...'
# print 'done'
load = deprecate(_load, message="""
This is an internal function used with scipy.io.save_as_module
If you are saving arrays into a module, you should think about using
HDF5 or .npz files instead.
""")
def _create_module(file_name):
""" Create the module file.
"""
if not os.path.exists(file_name+'.py'): # don't clobber existing files
module_name = os.path.split(file_name)[-1]
f = open(file_name+'.py','w')
f.write('import scipy.io.data_store as data_store\n')
f.write('import %s\n' % module_name)
f.write('data_store._load(%s)' % module_name)
f.close()
示例2: ksstat
d_ks = ksstat(z, stats.norm.cdf, alternative='two_sided')
if pvalmethod == 'approx':
pval = pval_lf(d_ks, nobs)
elif pvalmethod == 'table':
#pval = pval_lftable(d_ks, nobs)
pval = lilliefors_table.prob(d_ks, nobs)
return d_ks, pval
lilliefors = kstest_normal
lillifors = np.deprecate(lilliefors, 'lillifors', 'lilliefors',
"Use lilliefors, lillifors will be "
"removed in 0.9 \n(Note: misspelling missing 'e')")
#old version:
#------------
tble = '''\
00 20 15 10 05 01 .1
4 .303 .321 .346 .376 .413 .433
5 .289 .303 .319 .343 .397 .439
6 .269 .281 .297 .323 .371 .424
7 .252 .264 .280 .304 .351 .402
8 .239 .250 .265 .288 .333 .384
9 .227 .238 .252 .274 .317 .365
10 .217 .228 .241 .262 .304 .352
示例3: _create_module
This function is deprecated in scipy 0.11 and will be removed for 0.12
Parameters
----------
file_name : str, optional
File name of the module to save.
data : dict, optional
The dictionary to store in the module.
"""
_create_module(file_name)
_create_shelf(file_name,data)
save_as_module = np.deprecate(save_as_module)
def _load(module):
""" Load data into module from a shelf with
the same name as the module.
"""
dir,filename = os.path.split(module.__file__)
filebase = filename.split('.')[0]
fn = os.path.join(dir, filebase)
f = dumb_shelve.open(fn, "r")
#exec( 'import ' + module.__name__)
for i in f.keys():
exec( 'import ' + module.__name__+ ';' +
module.__name__+'.'+i + '=' + 'f["' + i + '"]')
示例4: irfft2
def irfft2(a, s=None, axes=(-2,-1)):
"""
Compute the 2-dimensional inverse fft of a real array.
Parameters
----------
a : array (real)
input array
s : sequence (int)
shape of the inverse fft
axis : int
axis over which to compute the inverse fft
Notes
-----
This is really irfftn with different default.
"""
return irfftn(a, s, axes)
# Deprecated names
from numpy import deprecate
refft = deprecate(rfft, 'refft', 'rfft')
irefft = deprecate(irfft, 'irefft', 'irfft')
refft2 = deprecate(rfft2, 'refft2', 'rfft2')
irefft2 = deprecate(irfft2, 'irefft2', 'irfft2')
refftn = deprecate(rfftn, 'refftn', 'rfftn')
irefftn = deprecate(irfftn, 'irefftn', 'irfftn')
示例5: import
__all__ = ['who', 'source', 'info', 'doccer', 'pade',
'comb', 'factorial', 'factorial2', 'factorialk', 'logsumexp']
from . import doccer
from .common import *
from numpy import who as _who, source as _source, info as _info
import numpy as np
from scipy.interpolate._pade import pade as _pade
from scipy.special import (comb as _comb, logsumexp as _lsm,
factorial as _fact, factorial2 as _fact2, factorialk as _factk)
import sys
_msg = ("Importing `%(name)s` from scipy.misc is deprecated in scipy 1.0.0. Use "
"`scipy.special.%(name)s` instead.")
comb = np.deprecate(_comb, message=_msg % {"name": _comb.__name__})
logsumexp = np.deprecate(_lsm, message=_msg % {"name": _lsm.__name__})
factorial = np.deprecate(_fact, message=_msg % {"name": _fact.__name__})
factorial2 = np.deprecate(_fact2, message=_msg % {"name": _fact2.__name__})
factorialk = np.deprecate(_factk, message=_msg % {"name": _factk.__name__})
_msg = ("Importing `pade` from scipy.misc is deprecated in scipy 1.0.0. Use "
"`scipy.interpolate.pade` instead.")
pade = np.deprecate(_pade, message=_msg)
_msg = ("Importing `%(name)s` from scipy.misc is deprecated in scipy 1.0.0. Use "
"`numpy.%(name)s` instead.")
who = np.deprecate(_who, message=_msg % {"name": "who"})
source = np.deprecate(_source, message=_msg % {"name": "source"})
@np.deprecate(message=_msg % {"name": "info.(..., toplevel='scipy')"})
示例6: _gen_unique_rand
while id.size < k:
gk *= 1.05
id = _gen_unique_rand(gk)
j = np.floor(id * 1. / m).astype(tp)
i = (id - j * m).astype(tp)
vals = np.random.rand(k).astype(dtype)
return coo_matrix((vals, (i, j)), shape=(m, n)).asformat(format)
#################################
# Deprecated functions
################################
__all__ += [ 'speye','spidentity', 'spkron', 'lil_eye', 'lil_diags' ]
spkron = np.deprecate(kron, old_name='spkron', new_name='scipy.sparse.kron')
speye = np.deprecate(eye, old_name='speye', new_name='scipy.sparse.eye')
spidentity = np.deprecate(identity, old_name='spidentity',
new_name='scipy.sparse.identity')
def lil_eye((r,c), k=0, dtype='d'):
"""Generate a lil_matrix of dimensions (r,c) with the k-th
diagonal set to 1.
Parameters
----------
r,c : int
row and column-dimensions of the output.
k : int
示例7: type
# Use this to add a new axis to an array
# compatibility only
NewAxis = None
# deprecated
UFuncType = type(um.sin)
UfuncType = type(um.sin)
ArrayType = mu.ndarray
arraytype = mu.ndarray
LittleEndian = sys.byteorder == "little"
from numpy import deprecate
# backward compatibility
arrayrange = deprecate(functions.arange, "arrayrange", "arange")
# deprecated names
matrixmultiply = deprecate(mu.dot, "matrixmultiply", "dot")
def DumpArray(m, fp):
m.dump(fp)
def LoadArray(fp):
import cPickle
return cPickle.load(fp)
示例8: _DeprecatedImport
clapack = _DeprecatedImport("scipy.linalg.blas.clapack", "scipy.linalg.lapack")
flapack = _DeprecatedImport("scipy.linalg.blas.flapack", "scipy.linalg.lapack")
# Expose all functions (only flapack --- clapack is an implementation detail)
empty_module = None
from scipy.linalg._flapack import *
del empty_module
_dep_message = """The `*gegv` family of routines has been deprecated in
LAPACK 3.6.0 in favor of the `*ggev` family of routines.
The corresponding wrappers will be removed from SciPy in
a future release."""
cgegv = _np.deprecate(cgegv, old_name="cgegv", message=_dep_message)
dgegv = _np.deprecate(dgegv, old_name="dgegv", message=_dep_message)
sgegv = _np.deprecate(sgegv, old_name="sgegv", message=_dep_message)
zgegv = _np.deprecate(zgegv, old_name="zgegv", message=_dep_message)
# Modyfy _flapack in this scope so the deprecation warnings apply to
# functions returned by get_lapack_funcs.
_flapack.cgegv = cgegv
_flapack.dgegv = dgegv
_flapack.sgegv = sgegv
_flapack.zgegv = zgegv
# some convenience alias for complex functions
_lapack_alias = {
"corghr": "cunghr",
"zorghr": "zunghr",
示例9: _create_shelf
using HDF5 or .npz files instead.
""")(_create_module)
def _create_shelf(file_name,data):
"""Use this to write the data to a new file
"""
shelf_name = file_name.split('.')[0]
f = dumb_shelve.open(shelf_name,'w')
for i in data.keys():
# print 'saving...',i
f[i] = data[i]
# print 'done'
f.close()
create_shelf = deprecate_with_doc("""
This is an internal function used with scipy.io.save_as_module
If you are saving arrays into a module, you should think about using
HDF5 or .npz files instead.
""")(_create_shelf)
def save_as_module(file_name=None,data=None):
""" Save the dictionary "data" into
a module and shelf named save
"""
_create_module(file_name)
_create_shelf(file_name,data)
save = deprecate(save_as_module, 'save', 'save_as_module')
示例10: import
from .sf_error import SpecialFunctionWarning, SpecialFunctionError
from ._ufuncs import *
from .basic import *
from ._logsumexp import logsumexp, softmax
from . import specfun
from . import orthogonal
from .orthogonal import *
from .spfun_stats import multigammaln
from ._ellip_harm import ellip_harm, ellip_harm_2, ellip_normal
from .lambertw import lambertw
from ._spherical_bessel import (spherical_jn, spherical_yn, spherical_in,
spherical_kn)
from numpy import deprecate
hyp2f0 = deprecate(hyp2f0, message="hyp2f0 is deprecated in SciPy 1.2")
hyp1f2 = deprecate(hyp1f2, message="hyp1f2 is deprecated in SciPy 1.2")
hyp3f0 = deprecate(hyp3f0, message="hyp3f0 is deprecated in SciPy 1.2")
del deprecate
__all__ = [s for s in dir() if not s.startswith('_')]
from numpy.dual import register_func
register_func('i0',i0)
del register_func
from scipy._lib._testutils import PytestTester
test = PytestTester(__name__)
del PytestTester
示例11: DAMAGES
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import numpy
from filters import *
from fourier import *
from interpolation import *
from measurements import *
from morphology import *
from io import *
# doccer is moved to scipy.misc in scipy 0.8
from scipy.misc import doccer
doccer = numpy.deprecate(doccer, old_name='doccer',
new_name='scipy.misc.doccer')
from info import __doc__
__version__ = '2.0'
from numpy.testing import Tester
test = Tester().test
示例12: deprecated
from info import __doc__
from numpy import deprecate
# These are all deprecated (until the end deprecated tag)
from npfile import npfile
from data_store import save, load, create_module, create_shelf
from array_import import read_array, write_array
from pickler import objload, objsave
from numpyio import packbits, unpackbits, bswap, fread, fwrite, \
convert_objectarray
fread = deprecate(fread, message="""
scipy.io.fread can be replaced with NumPy I/O routines such as
np.load, np.fromfile as well as NumPy's memory-mapping capabilities.
""")
fwrite = deprecate(fwrite, message="""
scipy.io.fwrite can be replaced with NumPy I/O routines such as np.save,
np.savez and x.tofile. Also, files can be directly memory-mapped into NumPy
arrays which is often a better way of reading large files.
""")
bswap = deprecate(bswap, message="""
scipy.io.bswap can be replaced with the byteswap method on an array.
out = scipy.io.bswap(arr) --> out = arr.byteswap(True)
""")
packbits = deprecate(packbits, message="""
The functionality of scipy.io.packbits is now available as numpy.packbits
示例13: np_matrix_rank
"""
if r is None:
r = np_matrix_rank(X)
V, D, U = L.svd(X, full_matrices=0)
order = np.argsort(D)
order = order[::-1]
value = []
for i in range(r):
value.append(V[:, order[i]])
return np.asarray(np.transpose(value)).astype(np.float64)
StepFunction = np.deprecate(StepFunction,
old_name='statsmodels.tools.tools.StepFunction',
new_name='statsmodels.distributions.StepFunction')
monotone_fn_inverter = np.deprecate(monotone_fn_inverter,
old_name='statsmodels.tools.tools'
'.monotone_fn_inverter',
new_name='statsmodels.distributions'
'.monotone_fn_inverter')
ECDF = np.deprecate(ECDF,
old_name='statsmodels.tools.tools.ECDF',
new_name='statsmodels.distributions.ECDF')
def unsqueeze(data, axis, oldshape):
"""
Unsqueeze a collapsed array
示例14: ValueError
else:
raise ValueError('1D option "%s" is strange'
% oned_as)
return shape
class ByteOrder(object):
''' Namespace for byte ordering '''
little_endian = boc.sys_is_le
native_code = boc.native_code
swapped_code = boc.swapped_code
to_numpy_code = boc.to_numpy_code
ByteOrder = np.deprecate(ByteOrder, message="""
We no longer use the ByteOrder class, and deprecate it; we will remove
it in future versions of scipy. Please use the
scipy.io.matlab.byteordercodes module instead.
""")
class MatVarReader(object):
''' Abstract class defining required interface for var readers'''
def __init__(self, file_reader):
pass
def read_header(self):
''' Returns header '''
pass
def array_from_header(self, header):
''' Reads array given header '''
示例15: ValueError
if obs.ndim != code_book.ndim:
raise ValueError("Observation and code_book should have the same rank")
if obs.ndim == 1:
obs = obs[:, np.newaxis]
code_book = code_book[:, np.newaxis]
dist = cdist(obs, code_book)
code = dist.argmin(axis=1)
min_dist = dist[np.arange(len(code)), code]
return code, min_dist
# py_vq2 was equivalent to py_vq
py_vq2 = np.deprecate(py_vq, old_name='py_vq2', new_name='py_vq')
def _kmeans(obs, guess, thresh=1e-5):
""" "raw" version of k-means.
Returns
-------
code_book
the lowest distortion codebook found.
avg_dist
the average distance a observation is from a code in the book.
Lower means the code_book matches the data better.
See Also
--------