Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:14:49+00:00 2026-06-11T10:14:49+00:00

This seems to have been beat to death on Stack Overflow but none of

  • 0

This seems to have been beat to death on Stack Overflow but none of the questions seem to match my problem. Anyway, straight to the code.

This is Edge.py

from __future__ import division
import sys
from numpy import *


class EdgeList:
    def __init__(self, mat):
        self.id1 = mat[:,0]
        self.id2 = mat[:,1]
        self.value = mat[:,2]
    def is_above(self):
        return self.value>average(self.value)
    def stats(self):
        pass #omitted; too long and irrelevant here.

This is AHsparse.py

from __future__ import division

import sys
from numpy import *
from Edge import EdgeList

class AHvector:
    def __init__(self, mat):
        self.el = EdgeList(mat)
    def multiply(self, other):
        v=zeros(max(len(self.el.val), len(other.el.val)))
        for index in self.id1:
            v[index] = self.el.val[index] * other.el.val[index]
        return v

This is some test code (other tests pass)

import sys
from numpy import *
from Edge import EdgeList
from AHsparse import AHvector

testmat =loadtxt('test.data', delimiter=';')
st = EdgeList(testmat)
stv = AHvector(st)
stv = stv.multiply(stv)
print(stv)

The error happens at the init method of class AHvector, but calls back to Edge.py:

Traceback (most recent call last):
  File "/Users/syntaxfree/Dropbox/nina/nina lives in objects/sparse_test.py", line 8, in <module>
    stv = AHvector(st)
  File "/Users/syntaxfree/Dropbox/nina/nina lives in objects/AHsparse.py", line 9, in __init__
    self.el = EdgeList(mat)
  File "/Users/syntaxfree/Dropbox/nina/nina lives in objects/Edge.py", line 7, in __init__
    self.id1 = mat[:,0]
AttributeError: EdgeList instance has no attribute '__getitem__'
[Finished in 0.6s with exit code 1]

I have nothing else to add, I’m afraid — except I’m able to initialize EdgeList on its own and run the stats method in other test code, and I’m thoroughly confused as why this wouldn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:14:50+00:00Added an answer on June 11, 2026 at 10:14 am

    When you run

     stv = AHvector(st)
    

    st is an Edgelist. Then AHvector’s init tries to make an Edgelist of st. Maybe AHvector should state

     self.el = mat # Instead of EdgeList(mat)?
    

    or maybe AHvector isn’t supposed to be receiving st, but rather testmat?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this seems like such a simple problem but I have been unable to find
This seems like a fairly simple problem to me but I have been having
This question seems to have been asked multiple times but none of the solutions
This seems to have been asked before: rails decimal precision and scale But when
This question seems to have been asked a lot, but I haven't seen an
I've checked through other questions and surprisingly this question doesn't seem to have been
This question seems to have been asked but without enough results for me. I
This question seems to have been asked many times in many different forms but
I know this topic has been beat to death but a lot of the
This seems to be something that have been discussed by many. But unfortunately, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.