当前位置:网站首页>Numpy | insert variable length character array test OK
Numpy | insert variable length character array test OK
2022-06-21 13:19:00 【yantuguiguziPGJ】
Test code
import numpy.matlib
import numpy as np
import sys
numpy.set_printoptions(threshold=sys.maxsize)
print("\n********************************************OK*************************************")
data_type={'names':('name', 'a', 'b'), 'formats':('S100', 'S100','S100')}
data1=np.rec.array([('http',"1","1")],dtype=data_type)
data2=np.rec.array([('sjtv-bid-hoisin.coocaa.com/v1/bid','{content-length}','ghi')],dtype=data_type)
print(data1)
print("\n")
print(data2)
print("\n")
result = np.insert(data1, 1, data2, axis = 0)
print(result)
print("\n********************************************OK END*************************************")
print("\n******************************************** The following is a blind test Insert character array truncated test *************************************")
Z = np.array([("Hello1234567890", 2.51234567890, 3),
("World", 3.6, 2)])
R8 = np.core.records.fromarrays(Z.T,
names='col1, col2, col3',
formats = 'S8, f8, i8')
print("\nR8--->formats = 'S8, f8, i8': ")
print(R8)
R15 = np.core.records.fromarrays(Z.T,
names='col1, col2, col3',
formats = 'S15, f8, i8')
print("\nR15--->formats = 'S15, f8, i8': ")
print(R15)
# A = np.ones(3)*1
# B = np.ones(3)*2
# np.add(A,B,out=B)
# np.divide(A,2,out=A)
# np.negative(A,out=A)
# np.multiply(A,B,out=A)
a = np.array([['http',1,1]])
print ("\na: ")
print(a)
# a = np.array([['http',1,1]],
# names='col1, col2, col3',
# formats = 'S15, S15, S15')
# a = np.array([['http',1,1]],dtype = np.string_)
ccc = np.array(['abc','def','ghi'])
print ("\nccc: ")
print(ccc)
print (ccc.itemsize)
print ("\nnp.insert(a, 1, ccc, axis = 0): ")
print(np.insert(a, 1, ccc, axis = 0))
ddd = np.array(['sjtv-bid-hoisin.coocaa.com/v1/bid','{content-length}','ghi'])
print ("\nddd: ")
print(ddd)
print (ddd.itemsize)
print ("\nnp.insert(a, 1, ddd, axis = 0): ")
print(np.insert(a, 1, ddd, axis = 0))
eee = np.array(['sjtv-bid','{content-length}','ghi'])
print ("\neee: ")
print(eee)
print (eee.itemsize)
print ("\nnp.insert(a, 1, eee, axis = 0): ")
print(np.insert(a, 1, eee, axis = 0))
fff = np.array([['sjtv-bid-hoisin.coocaa.com/v1/bid','content-length','ghi']])
print ("\nfff: ")
print(fff)
print (fff.itemsize)
print ("\nnp.insert(a, 1, fff, axis = 0): ")
result = np.insert(a, 1, fff, axis = 0)
print(result)
resultR = np.core.records.fromarrays(result.T,
names='col1, col2, col3',
formats = 'S15, S15, S15')
print ("\nresultR--->np.core.records.fromarrays: ")
print(resultR)test result
PS C:\Users\pgjgg\Desktop\python_learn> & C:/Users/pgjgg/AppData/Local/Programs/Python/Python39/python.exe c:/Users/pgjgg/Desktop/python_learn/numpy_demo.py
********************************************OK*************************************
[(b'http', b'1', b'1')]
[(b'sjtv-bid-hoisin.coocaa.com/v1/bid', b'{content-length}', b'ghi')]
[(b'http', b'1', b'1')
(b'sjtv-bid-hoisin.coocaa.com/v1/bid', b'{content-length}', b'ghi')]
********************************************OK END*************************************
******************************************** The following is a blind test Insert character array truncated test *************************************
R8--->formats = 'S8, f8, i8':
[(b'Hello123', 2.51234568, 3) (b'World', 3.6 , 2)]
R15--->formats = 'S15, f8, i8':
[(b'Hello1234567890', 2.51234568, 3) (b'World', 3.6 , 2)]
a:
[['http' '1' '1']]
ccc:
['abc' 'def' 'ghi']
12
np.insert(a, 1, ccc, axis = 0):
[['http' '1' '1']
['abc' 'def' 'ghi']]
ddd:
['sjtv-bid-hoisin.coocaa.com/v1/bid' '{content-length}' 'ghi']
132
np.insert(a, 1, ddd, axis = 0):
[['http' '1' '1']
['sjtv-bid-ho' '{content-le' 'ghi']]
eee:
['sjtv-bid' '{content-length}' 'ghi']
64
np.insert(a, 1, eee, axis = 0):
[['http' '1' '1']
['sjtv-bid' '{content-le' 'ghi']]
fff:
[['sjtv-bid-hoisin.coocaa.com/v1/bid' 'content-length' 'ghi']]
132
np.insert(a, 1, fff, axis = 0):
[['http' '1' '1']
['sjtv-bid-ho' 'content-len' 'ghi']]
resultR--->np.core.records.fromarrays:
[(b'http', b'1', b'1') (b'sjtv-bid-ho', b'content-len', b'ghi')]边栏推荐
- CP 指令学习
- 3. operator
- Analysis on the wallet system architecture of Baidu trading platform
- 如何使用搜索引擎?
- Matplotlib drawing tips
- Six possible challenges when practicing Devops
- Pingcap was selected as the "voice of customers" of Gartner cloud database in 2022, and won the highest score of "outstanding performer"
- Eureka的TimedSupervisorTask类(自动调节间隔的周期性任务)
- 7. pointer
- 应用配置管理,基础原理分析
猜你喜欢

Machine learning explores the metastable phase diagram of covalent carbon, which can be used to discover or design metastable materials in the future
![[upgraded student information management system] + file operation + more details](/img/a3/de30e67e1ad73262a9e2cf38e6520c.png)
[upgraded student information management system] + file operation + more details
Collection reference type in JS

Analysis on the wallet system architecture of Baidu trading platform

Memcached (high performance memory object cache)

Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection

分布式事务,原理简单,写起来全是坑

分布式事务处理方案大 PK

Pingcap was selected as the "voice of customers" of Gartner cloud database in 2022, and won the highest score of "outstanding performer"

塔米狗项目解读:济宁华源项目管理有限公司34%股权转让
随机推荐
Questions and answers No. 43: application performance probe monitoring principle PHP probe
百度交易中台之钱包系统架构浅析
处理接口幂等性的两种常见方案
对app和微信小程序进行接口测试
How to read AI summit papers?
百问百答第43期:应用性能探针监测原理-PHP探针
Apache ShardingSphere 5.1.2 发布|全新驱动 API + 云原生部署,打造高性能数据网关
小程序直播互动功能运行在App里?
Kubernets Rapid Practical fighting and Core Principle Analysis
Kube Prometheus grafana installation plug-in and grafana image renderer
修修补补一时爽,果断重构有担当——聊聊CRM分布式缓存优化
Two common schemes for handling interface idempotence
[安洵杯 2019]easy_web-1
Deep learning practice (10): 3D medical image segmentation using pytorch
Using slurm cluster computing node debugger in vscode
爱可可AI前沿推介(6.21)
Memcached (high performance memory object cache)
【深入理解TcaplusDB技术】Tmonitor系统升级
Data types in redis
分布式事务处理方案大 PK