basic algorithm in python
2017-03-11 14:47
513 查看
ASSERT
如何为assert断言语句添加异常参数
assert的异常参数,其实就是在断言表达式后添加字符串信息,用来解释断言并更好的知道是哪里出了问题。格式如下:
assert expression [, arguments]
assert 表达式 [, 参数]
assert len(lists) >=5,’列表元素个数小于5’
assert 2==1,’2不等于1’
np.sum 使用心得与参数详解
a : input matrix. array_like. axis: axis = 1 , 横着求和, axis = 0 列求和,for example: Examples
np.sum([0.5, 1.5])
2.0
np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)
1
np.sum([[0, 1], [0, 5]])
6
np.sum([[0, 1], [0, 5]], axis=0)
array([0, 6])
np.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])
If the accumulator is too small, overflow occurs:
np.ones(128, dtype=np.int8).sum(dtype=np.int8)
-128
相关文章推荐
- MD5 Message Digest Algorithm in Visual Basic 6
- Algorithm: quick sort implemented in python 算法导论 快速排序
- A Basic Website Crawler, in Python, in 12 Lines of Code. « Null Byte
- Basic OOP in Python
- Learning FP-Growth Algorithm in Python
- the basic operation of sequence in python
- A Basic Example of Threads Synchronization in Python, python中的线程同步示例
- algorithm: heap sort in python 算法导论 堆排序
- 6 Easy Steps to Learn Naive Bayes Algorithm (with code in Python)
- python basic configuration in linux
- Data Structure and Algorithm in Python 第一章 课后练习
- 6 Easy Steps to Learn Naive Bayes Algorithm (with code in Python)
- Implementing a perceptron learning algorithm in Python
- basic knowledge in python (1)
- Basic OOP in Python
- How To Implement The Decision Tree Algorithm From Scratch In Python (从零开始在Python中实现决策树算法)
- Algorithm in Python(1)
- emacs basic in action
- how to compile source code of "Data Structures & Algorithm Analysis in Java" writen by Mark Allen Weiss
- maze traversal in python(draft)