一个很棒的矩阵索引工具。提出了一个新的概念“单索引”(如在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第三方库


热门话题
将文本文件读取到java对象数组   不支持java PageNotFound请求方法“GET”   java JDBC未选择任何数据库   java正在获取ssl。SSLHandshakeException在使用带有标头的REST客户端时发生,但在使用PostMan时可以正常工作   java测试与junit 5的接口   多线程Java Publisher服务器聊天程序   java编译错误已尝试修复,但没有成功   在TIBCO上安装java Https证书   java如何解析一个困难的问题。txt文件?   java如何使用ApachePOI3.6和ApachePOIOXML3读取pptx文件的内容。15罐?   java使用Gradle运行特定于Android的检测测试   人工智能回溯Java   用java制作螺旋桨动画   spring hibernate查询中的java日期   java读取HDFS小型分区?