Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Array initialization and indexing is inconsistent with official numpy  #16991

@Alicia1529

Description

@Alicia1529

Description

Two consistencies with official Numpy

  1. when initializing a ndarray, the data type of official Numpy array will be casted to the input data type. DeepNumpy will set the default data type to be float32 unless the dtype parameter is explicitly declared.
>>> import numpy as onp
>>> from mxnet import numpy as np
>>> a = np.array([1, 2, 3, 4, 5])
>>> a
array([1., 2., 3., 4., 5.])
>>> a.dtype
dtype('float32')
>>> oa = onp.array([1, 2, 3, 4, 5])
>>> oa
array([1, 2, 3, 4, 5])
>>> oa.dtype
dtype('int64')
  1. when indexing a 1-d array, the return type of numpy array is a value, while the return type of deenumpy array is still a deenumpy array.
a[0] # array([12.])
oa[0] # 12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions