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

Data comparison is inconsistent with numpy #16964

Closed
marongxing opened this issue Dec 3, 2019 · 6 comments
Closed

Data comparison is inconsistent with numpy #16964

marongxing opened this issue Dec 3, 2019 · 6 comments

Comments

@marongxing
Copy link

In [88]: nd.array([0],dtype='int') < 1e-3
Out[88]:

[0]
<NDArray 1 @cpu(0)>

In [89]: np.array([0],dtype='int') < 1e-3
Out[89]: array([ True])

In [90]:

@haojin2
Copy link
Contributor

haojin2 commented Dec 4, 2019

Hi,
The behavior of nd is not guaranteed to be consistent as official NumPy.
If you're looking for NumPy-compatible behaviors, please try out the new NumPy-compatible interface, available in latest nightly versions & soon to be available in 1.6.0 release version:

>>> from mxnet import np
>>> np.array([0],dtype='int') < 1e-3
array([False])

@haojin2 haojin2 added the Numpy label Dec 4, 2019
@ptrendx
Copy link
Member

ptrendx commented Dec 5, 2019

@haojin2 But the problem is not the datatype, but the result - 0 is less than 1e-3 ;-).

@haojin2
Copy link
Contributor

haojin2 commented Dec 5, 2019

@ptrendx I think it's a data type issue:

>>> from mxnet import np
>>> np.array([0],dtype='float') < 1e-3
array([ True])

I guess 1e-3 was casted to integer in the backend...

@sxjscience
Copy link
Member

I think the root cause would be the same as #16653

@yzhliu yzhliu added the v2.0 label Apr 29, 2020
@yzhliu
Copy link
Member

yzhliu commented Apr 30, 2020

@Tommliu is working on this.

@yzhliu yzhliu added the WIP label Apr 30, 2020
Tommliu added a commit to Tommliu/incubator-mxnet that referenced this issue May 11, 2020
Tommliu added a commit to Tommliu/incubator-mxnet that referenced this issue May 19, 2020
Tommliu added a commit to Tommliu/incubator-mxnet that referenced this issue May 21, 2020
yzhliu pushed a commit that referenced this issue May 22, 2020
* add boolean support for concatenate (#18213)

* fix binary scalar logic dtype (#16964)

* common_expr test remove

* binary scalar op support scalar dtype

Co-Authored-By: Wentao Xu <[email protected]>

* test_error_fix

Co-authored-by: Wentao Xu <[email protected]>
@yzhliu
Copy link
Member

yzhliu commented May 22, 2020

closed by #18277

@yzhliu yzhliu closed this as completed May 22, 2020
AntiZpvoh pushed a commit to AntiZpvoh/incubator-mxnet that referenced this issue Jul 6, 2020
* add boolean support for concatenate (apache#18213)

* fix binary scalar logic dtype (apache#16964)

* common_expr test remove

* binary scalar op support scalar dtype

Co-Authored-By: Wentao Xu <[email protected]>

* test_error_fix

Co-authored-by: Wentao Xu <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants