Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Array API

未关闭
#22 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
data

调研方向

首先复现所提供的图像处理示例,并检查报告所指的第 145 行附近的 _asarray 实现,尤其是对 Array._array 的访问。确认为什么 ndarray 路径会引发 AttributeError,并将 done 定义为能够处理所示输入而不出现该异常;issue 中没有指定 repository 测试或源文件。

由索引模型根据 Issue 内容生成。

描述

I believe there's an issue with passing in any value to _asarray. The function refuses to create this image's values despite tedious restructuring. I can provide more code and details if you like, but here is the general code implementation below.

filename = "godfather.jpg"
img = mpimg.imread(filename)
img = rgb2gray(img)
plt.imshow(img, cmap='gray')
def flatten_comprehension(matrix):
    return [item for row in matrix for item in row]
imgL = flatten_comprehension(img)
image = np.reshape(np.asarray(imgL, dtype=np.float32), (600, 900), copy=True)
gradient_magnitude, gradient_direction = sobel_filters(image)

img when implemented here is just an nparray from .imread, have to do a lot of weird tricks to get around the first error (worked w @syurkevi on this)
here's the error stack trace

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[42], line 11
      7 image = np.reshape(np.asarray(imgL, dtype=np.float32), (600, 900), copy=True)
      8 # print(image.shape)
      9 # print(type(image))
     10 # print(image)
---> 11 gradient_magnitude, gradient_direction = sobel_filters(image)
     13 # Display the gradient magnitude as an image
     14 plt.figure(figsize=(10, 5))

Cell In[40], line 19
     16 Ky = np.asarray([[1, 2, 1], [0, 0, 0], [-1, -2, -1]])
     18 # Convolve with Kx and Ky using custom convolve2d function
---> 19 Ix = convolve2d(img, Kx)
     20 Iy = convolve2d(img, Ky)
     22 # Compute gradient magnitude and direction

Cell In[40], line 5
      1 def convolve2d(image, kernel):
      2     """
      3     Apply a 2D convolution operation without padding.
      4     """
----> 5     newImg = np.asarray(image, dtype=np.float32)
      6     output = np.zeros_like(newImg)  # Prepare the output array
...
--> 145     afarray = Array._array if not copy else af.copy_array(Array._array)
    146 elif isinstance(obj, list | tuple):
    147     afarray = _process_nested_sequence(obj)

AttributeError: type object 'Array' has no attribute '_array'

主要语言
Python
星标
2
派生
5
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

arrayfire/arrayfire-py 的其他 Issue

查看 arrayfire/arrayfire-py 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。