from numpy\core_multiarray_umath.py

def view(self, dtype=None, type=None): # real signature unknown; restored from __doc__"""a.view(dtype=None, type=None)New view of array with the same data.具有相同数据的数组的新视图。Parameters----------dtype : data-type or ndarray sub-class, optionalData-type descriptor of the returned view, e.g., float32 or int16. Thedefault, None, results in the view having the same data-type as `a`.This argument can also be specified as an ndarray sub-class, whichthen specifies the type of the returned object (this is equivalent tosetting the ``type`` parameter).数据类型或ndarray子类,可选返回视图的数据类型描述符,例如float32或int16。 默认值为None(无),导致视图具有与a相同的数据类型。 此参数也可以指定为ndarray子类,然后指定返回对象的类型(这等效于设置“ type”参数)。type : Python type, optionalType of the returned view, e.g., ndarray or matrix.  Again, thedefault None results in type preservation.返回视图的类型,例如ndarray或matrix。 同样,默认值None将导致类型保留。Notes-----``a.view()`` is used two different ways:``a.view(some_dtype)`` or ``a.view(dtype=some_dtype)`` constructs a viewof the array's memory with a different data-type.  This can cause areinterpretation of the bytes of memory.``a.view(ndarray_subclass)`` or ``a.view(type=ndarray_subclass)`` justreturns an instance of `ndarray_subclass` that looks at the same array(same shape, dtype, etc.)  This does not cause a reinterpretation of thememory.For ``a.view(some_dtype)``, if ``some_dtype`` has a different number ofbytes per entry than the previous dtype (for example, converting aregular array to a structured array), then the behavior of the viewcannot be predicted just from the superficial appearance of ``a`` (shownby ``print(a)``). It also depends on exactly how ``a`` is stored inmemory. Therefore if ``a`` is C-ordered versus fortran-ordered, versusdefined as a slice or transpose, etc., the view may give differentresults.a.view()有两种不同的用法:a.view(some_dtype)或a.view(dtype = some_dtype)构造具有不同数据类型的阵列内存视图。 这可能导致对内存字节的重新解释。a.view(ndarray_subclass)或a.view(type = ndarray_subclass)只是返回一个ndarray_subclass实例,该实例看相同的数组(形状,dtype等)。这不会导致 记忆的重新诠释。对于a.view(some_dtype),如果some_dtype每个条目的字节数与上一个dtype不同(例如,将常规数组转换为结构化数组),则视图的行为 不能仅从``a''的表面外观(由``print(a)``所示)来预测。 这也完全取决于``a''在内存中的存储方式。 因此,如果``a''是C顺序相对于fortran顺序,相对于定义为切片或转置等,则视图可能会给出不同的结果。Examples-------->>> x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])Viewing array data using a different type and dtype:使用不同的type和dtype查看数组数据:>>> y = x.view(dtype=np.int16, type=np.matrix)>>> ymatrix([[513]], dtype=int16)>>> print(type(y))<class 'numpy.matrix'>(↑↑↑↑↑ 啥玩意,没看懂???)Creating a view on a structured array so it can be used in calculations在结构化数组上创建视图,以便可以在计算中使用它>>> x = np.array([(1, 2),(3,4)], dtype=[('a', np.int8), ('b', np.int8)])>>> xv = x.view(dtype=np.int8).reshape(-1,2)>>> xvarray([[1, 2],[3, 4]], dtype=int8)>>> xv.mean(0)array([2.,  3.])Making changes to the view changes the underlying array对视图进行更改会更改基础数组>>> xv[0,1] = 20>>> xarray([(1, 20), (3,  4)], dtype=[('a', 'i1'), ('b', 'i1')])Using a view to convert an array to a recarray:使用视图将数组转换为RecArray:>>> z = x.view(np.recarray)>>> z.aarray([1, 3], dtype=int8)Views share data:视图共享数据:>>> x[0] = (9, 10)>>> z[0](9, 10)Views that change the dtype size (bytes per entry) should normally beavoided on arrays defined by slices, transposes, fortran-ordering, etc.:通常应在由切片,转置,fortran顺序等定义的数组上避免更改dtype大小(每个条目的字节数)的视图:>>> x = np.array([[1,2,3],[4,5,6]], dtype=np.int16)>>> y = x[:, 0:2]>>> yarray([[1, 2],[4, 5]], dtype=int16)>>> y.view(dtype=[('width', np.int16), ('length', np.int16)])Traceback (most recent call last):...ValueError: To change to a dtype of a different size, the array must be C-contiguous>>> z = y.copy()>>> z.view(dtype=[('width', np.int16), ('length', np.int16)])array([[(1, 2)],[(4, 5)]], dtype=[('width', '<i2'), ('length', '<i2')])"""pass

numpy.ndarray.view()(懵逼,看不太懂???)(view不会开辟新的内存空间)相关推荐

  1. php删除图片按钮代码,jquery 按钮预览图片功能的代码,我看不太懂。应该怎么学...

    摘要:<?phpnamespace app\admin\controller;use app\admin\controller\Common;use app\admin\model\NewsMo ...

  2. matlab在sin处出现解析错误,用matlab function时出现一些错误,看不太懂

    我调用了4次matlab function,但是出现了一些错误,可能是变量定义有问题,但是我不太会在matlab function中修改变量.版本为2017a 这是function中代码: 第一段 f ...

  3. 浙大MBA提前批面试有点看不太懂了……

           昨天浙大MBA提前批面试杭州第二批结果正式公布,直观的感觉是提前批面试的风向在变,标准在调整,原因是以往达立易考能够做到六成上下的优秀率已经可以成为业界天花板,但第二批达到了83%优秀率 ...

  4. 【朝花夕拾】Android自定义View之(一)手把手教你看懂View绘制流程——向源码要答案

    前言 原文:Android自定义View之(一)手把手教你看懂View绘制流程--向源码要答案 View作为整个app的颜值担当,在Android体系中占有重要的地位.深入理解Android View ...

  5. python3 多维数组 NumPy ndarray 简介

    目录 基础 重要属性 创建 Converting Python array_like Objects to NumPy Arrays 多维数组 一维 通用数学函数 基础 NumPy 的主要对象是齐次多 ...

  6. 使用网站模板快速建站_建站工具使用教程看了就懂网站建设

    做网站敲代码早已是过去式,使用建站工具制作网站以是主流,初次接触建站工具难免对它有所不了解,广州半岛网络科技有限公司就以"云建站"为使用案例,把操作建站过程梳理写成教程,方便大家看 ...

  7. [转载] 详解 Numpy.ndarray

    参考链接: Python中的numpy.ndarray.flat 向量.矩阵 & 多维数组是数值计算中必不可少的工具:通过对数组数据进行批量处理,避免了对数组元素显式地进行循环操作,这样做的结 ...

  8. python数据分析 - numpy | ndarray数组 | numpy常用函数

    文章目录 数据分析 numpy概述 numpy历史 numpy的核心:多维数组 numpy基础 ndarray数组 内存中的ndarray对象 ndarray数组对象的特点 ndarray数组对象的创 ...

  9. 【解决报错原因分析】画图plt.contourf(X,Y,Z)报错TypeError: unhashable type: ‘numpy.ndarray‘(含详细示例讲解)

    今天简化画图代码的时候发现了很奇怪的报错现象,经过一系列尝试找到了根源,希望帮助后来人,主要问题出现在如下语句中(为了体现问题.方便比对,特意在这改变了x为xx,如果你不想看这冗长的示例,可以直接按照 ...

最新文章

  1. 我的笔记本电脑有一个自带的摄像头 可是开机后在我的电脑里没有这个图标
  2. git分支/标签操作
  3. mongo:(2)mongoDB简介
  4. Spring Boot 1.5.x新特性:动态修改日志级别
  5. TensorFlow——共享变量的使用方法
  6. 补习系列(2)-springboot mime类型处理
  7. easymock使用方法_EasyMock无效方法– ExpectLastCall()
  8. 【转】HTTP响应报文与工作原理详解
  9. AsyncTask--源码心得
  10. delphi xe android 黑屏,Delphi XE之路(3)解决启动时短暂的黑屏
  11. X1000 SPI 时钟获取失败
  12. MySQL从字符串提取数字
  13. 【leetcode729:我的日程安排表】
  14. Devcpp、Codeblocks如何设置支持c++11
  15. 顺丰软件显示无法联系服务器,顺丰可以云服务器吗
  16. [OpenCV实战]39 在OpenCV中使用ArUco标记的增强现实
  17. MATLAB fprintf 函数输出希腊字母/特殊字符
  18. 基金投资入门教程-----基金入门
  19. Oracle中的chr()函数 和 ascii()函数
  20. Foundations of Machine Learning———PAC

热门文章

  1. tcpdump抓包命令_tcpdump实战
  2. 【评估价格】采购申请中的价格
  3. 【Smartform】开发中报SSFCOMPOSER154错误原因分析
  4. Notepad++中高亮显示ABAP代码方法
  5. Eclipse集成Groovy插件
  6. 浅析SAP EWM与WMS的差异
  7. SAP AUT10 查看修改记录
  8. 会计记忆总结之七:财产清查
  9. SAP Control Framework 丢失事件?
  10. 高端第一后,卡萨帝又将靠场景化引领冰箱行业