def test_view_mixin_copies_data(adata, array_type: type, attr):
    N = 100
    adata = ad.AnnData(
        obs=pd.DataFrame(index=np.arange(N)), var=pd.DataFrame(index=np.arange(N))
    )

    X = array_type(sparse.eye(N, N).multiply(np.arange(1, N + 1)))
    if attr == "X":
        adata.X = X
    else:
        getattr(adata, attr)["arr"] = X

    view = adata[:50]

    if attr == "X":
        arr_view = view.X
    else:
        arr_view = getattr(view, attr)["arr"]

    arr_view_copy = arr_view.copy()

    if sparse.issparse(X):
        assert not np.shares_memory(arr_view.indices, arr_view_copy.indices)
        assert not np.shares_memory(arr_view.indptr, arr_view_copy.indptr)
        assert not np.shares_memory(arr_view.data, arr_view_copy.data)

        arr_view_copy.data[0] = -5
        assert not np.array_equal(arr_view_copy.data, arr_view.data)
    else:
        assert not np.shares_memory(arr_view, arr_view_copy)

        arr_view_copy[0, 0] = -5
        assert not np.array_equal(arr_view_copy, arr_view)
def drawMe(self, g):
        self.g = g
        hole = 5
        radius = 10
        length = self.getR()
        # alert(length)
        # 儲存先前的繪圖狀態
        self.g.save()
        self.g.translate(self.p1.x,self.p1.y)
        #alert(str(self.p1.x)+","+str(self.p1.y))
        #self.g.rotate(-((math.pi/2)-self.getT()))
        self.g.rotate(-math.pi*0.5 + self.getT())
        #alert(str(self.getT()))
        #self.g.rotate(10*math.pi/180)
        #this.g.rotate(-(Math.PI/2-this.getT()));
        # 必須配合畫在 y 軸上的 Link, 進行座標轉換, 也可以改為畫在 x 軸上...
        self.g.beginPath()
        self.g.moveTo(0,0)
        self.g.arc(0, 0, hole, 0, 2*math.pi, true)
        self.g.stroke()
        self.g.moveTo(0,length)
        self.g.beginPath()
        self.g.arc(0,length, hole, 0, 2*math.pi, true)
        self.g.stroke()
        self.g.moveTo(0,0)
        self.g.beginPath()
        self.g.arc(0,0, radius, 0, math.pi, true)
        self.g.moveTo(0+radius,0)
        self.g.lineTo(0+radius,0+length)
        self.g.stroke()
        self.g.moveTo(0,0+length)
        self.g.beginPath()
        self.g.arc(0, 0+length, radius, math.pi, 0, true)
        self.g.moveTo(0-radius,0+length)
        self.g.lineTo(0-radius,0)
        self.g.stroke()
        self.g.restore()