一个很棒的矩阵索引工具。提出了一个新的概念“单索引”(如在Matlab中)来索引矩阵中的元素。用Matlab样式索引(从1开始)交换Python样式索引(从0开始)

pindex的Python项目详细描述


简介

摘要

一个用于索引矩阵的很棒的工具。提出了一个新的概念“单索引”(如在Matlab中)来索引矩阵中的元素。用Matlab样式索引(从1开始)交换Python样式索引(从0开始)

关键词

索引,矩阵,单索引,索引样式

新功能:

  1. fix some bugs

功能:

  1. propose single index
  2. change to (back from) matlab-style index
  3. arithmetic of the index

内容

课程:

SingleIndex: wrapper of int, list, slice
Index: array of SingleIndex

接口:

Arith: arithmetic of index

功能:

irange: interval-like index

语法

基本语法

导入:

import pindex   # python for index

示例:

ind = SingleIndex([1,2,3])  # construct a single index
s = ind('helloworld')   # index(array) == array[index]
print(s)

A = np.array([[1,2,6],[3,4,5]])
B = ind(A)
print(B)    # index matrix with single index as in matlab

ind.py2matlab()        # change to matlab style
s = ind('helloworld')
print(s)  # output: hel

ind = Index([1,2,3])    # for 1dim array, Index == SingleIndex
ss = ind('helloworld')
print(ss)

ind = Index(([1,2],[3,4]))  # construct multi-index
try:
    ss = ind(['hello', 'world'])
    print(ss)
except:
    ind.py2matlab()
    ss = ind(['hello', 'world'])
    print(ss)

注意:

ind = SingleIndex([1,2,3])
A = [[1,2,6],[3,4,5]]
B = ind(A)  # pindex.py thinks A is a list (of lists, with length 2) instead of matrix
ind = Index(([0,1],[0,1]))   # this is ok, since you use multi-index

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有x86javapath的x64机器上x86java上的java JNI未满足链接错误   java将Pixmap的一部分上传到GPU   图像Java位图RLE8格式   java Android studio谷歌广告崩溃应用程序   java如何创建包含未知数量对象的变量?   Java计算给定int数组的所有可能组合   java JDBC classnotfound异常   httpclient中的java将HttpEntity转换为字符串的最优雅/正确的方法是什么?   如何从Java程序运行nano?   java在安卓中调用自定义类/方法   调用方法和JOptionPane后,允许代码继续执行所需的java计时器或其他想法   关于侦听器的向量Java并发问题   线程池执行器Java线程池   java配置DTO上的Swagger javax验证约束   Java中用于按钮功能的swing操作命令   ServletOutputStream中的java设置状态代码   java打印输入数组的平均值