matplotlib / matplotlib/matplotlib
plt.hist() fails with TensorFlow Numpy emulation
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 23.2k
- 分支
- 8.5k
- 平均合併
- 1 天 6 小時
- 30 天內合併 PR
- 66
描述
### Bug report
**Bug summary**
Generating `np.random.randn(1000)` values, visualizing them with `plt.hist()`. Works fine with Numpy.
When I replace Numpy with tensorflow.experimental.numpy, Matplotlib 3.3.4 fails to display the histogram correctly. Matplotlib 3.2.2 works fine.
**Code for reproduction**
```python
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
import tensorflow.experimental.numpy as tnp
# bad image
labels1 = 15 + 2 * tnp.random.randn(1000)
_ = plt.hist(labels1)
# good image
labels2 = 15 + 2 * np.random.randn(1000)
_ = plt.hist(labels2)
```
**Actual outcome**

**Expected outcome**

**Matplotlib version**
* Operating system: Windows 10
* Matplotlib version (`import matplotlib; print(matplotlib.__version__)`): 3.3.4
* Matplotlib backend (`print(matplotlib.get_backend())`): module://ipykernel.pylab.backend_inline
* Python version: 3.8.7
* Jupyter version (if applicable): see below
* Other libraries: see below
TensorFlow 2.4.1
```
jupyter --version
jupyter core : 4.7.0
jupyter-notebook : 6.1.6
qtconsole : 5.0.1
ipython : 7.20.0
ipykernel : 5.4.2
jupyter client : 6.1.7
jupyter lab : not installed
nbconvert : 6.0.7
ipywidgets : 7.6.3
nbformat : 5.0.8
traitlets : 5.0.5
```
Python installed from python.org as an exe installer. Everything else is `pip install --user`
Bug opened with TensorFlow on this same issue:
https://github.com/tensorflow/tensorflow/issues/46274
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
The issue names the plt.hist() entry point but no repository files or tests. First run the supplied reproduction with TensorFlow 2.4.1 and Matplotlib 3.3.4, then compare how the histogram input is handled against Matplotlib 3.2.2. Done means TensorFlow NumPy arrays produce the same correctly scaled histogram as regular NumPy arrays, with a regression test.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- jupyter, python, tensorflow
- 領域
- data-visualization
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100