日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python解决实际问题的过程_Python开发过程问题集锦(Continuous updating)

發(fā)布時間:2025/3/19 python 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python解决实际问题的过程_Python开发过程问题集锦(Continuous updating) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

def _normalize_shape(ndarray, shape, cast_to_int=True):"""Private function which does some checks and normalizes the possibly

much simpler representations of ‘pad_width‘, ‘stat_length‘,

‘constant_values‘, ‘end_values‘.

Parameters

----------

narray : ndarray

Input ndarray

shape : {sequence, array_like, float, int}, optional

The width of padding (pad_width), the number of elements on the

edge of the narray used for statistics (stat_length), the constant

value(s) to use when filling padded regions (constant_values), or the

endpoint target(s) for linear ramps (end_values).

((before_1, after_1), ... (before_N, after_N)) unique number of

elements for each axis where `N` is rank of `narray`.

((before, after),) yields same before and after constants for each

axis.

(constant,) or val is a shortcut for before = after = constant for

all axes.

cast_to_int : bool, optional

Controls if values in ``shape`` will be rounded and cast to int

before being returned.

Returns

-------

normalized_shape : tuple of tuples

val => ((val, val), (val, val), ...)

[[val1, val2], [val3, val4], ...] => ((val1, val2), (val3, val4), ...)

((val1, val2), (val3, val4), ...) => no change

[[val1, val2], ] => ((val1, val2), (val1, val2), ...)

((val1, val2), ) => ((val1, val2), (val1, val2), ...)

[[val , ], ] => ((val, val), (val, val), ...)

((val , ), ) => ((val, val), (val, val), ...)"""ndims=ndarray.ndim#Shortcut shape=None

if shape isNone:return ((None, None), ) *ndims#Convert any input `info` to a NumPy array

shape_arr =np.asarray(shape)try:

shape_arr= np.broadcast_to(shape_arr, (ndims, 2))exceptValueError:

fmt= "Unable to create correctly shaped tuple from %s"

raise ValueError(fmt %(shape,))#Cast if necessary

if cast_to_int isTrue:

shape_arr=np.round(shape_arr).astype(int)#Convert list of lists to tuple of tuples

return tuple(tuple(axis) for axis inshape_arr.tolist())def_validate_lengths(narray, number_elements):"""Private function which does some checks and reformats pad_width and

stat_length using _normalize_shape.

Parameters

----------

narray : ndarray

Input ndarray

number_elements : {sequence, int}, optional

The width of padding (pad_width) or the number of elements on the edge

of the narray used for statistics (stat_length).

((before_1, after_1), ... (before_N, after_N)) unique number of

elements for each axis.

((before, after),) yields same before and after constants for each

axis.

(constant,) or int is a shortcut for before = after = constant for all

axes.

Returns

-------

_validate_lengths : tuple of tuples

int => ((int, int), (int, int), ...)

[[int1, int2], [int3, int4], ...] => ((int1, int2), (int3, int4), ...)

((int1, int2), (int3, int4), ...) => no change

[[int1, int2], ] => ((int1, int2), (int1, int2), ...)

((int1, int2), ) => ((int1, int2), (int1, int2), ...)

[[int , ], ] => ((int, int), (int, int), ...)

((int , ), ) => ((int, int), (int, int), ...)"""normshp=_normalize_shape(narray, number_elements)for i innormshp:

chk= [1 if x is None else x for x ini]

chk= [1 if x >= 0 else -1 for x inchk]if (chk[0] < 0) or (chk[1] <0):

fmt= "%s cannot contain negative values."

raise ValueError(fmt %(number_elements,))return normshp

總結

以上是生活随笔為你收集整理的python解决实际问题的过程_Python开发过程问题集锦(Continuous updating)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。