Reputation: 509
I am creating an object in python. I have a numpy array from an H5 file that I would like to define within it. The numpy array is coordinates
. I was poking around online and found tons of information about creating numpy arrays, or creating objects in numpy arrays.. but I can't find anything on defining an already made numpy array inside an object.
class Node(object):
def __init__(self, globalIndex, coordinates):
#Useful things to record
self.globalIndex = globalIndex
self.coordinates = numpy.coordinates
#Dictionaries to be used
self.localIndices ={}
self.GhostLayer = {}
My question: is there a specific way to define my numpy array within this class? If not (the fact that I couldn't find anything about it makes me think that it can't be done), how else could I import a numpy array?
Upvotes: 0
Views: 135
Reputation: 142216
class Node(object):
def __init__(self, globalIndex, coordinates):
#Useful things to record
self.globalIndex = globalIndex
self.coordinates = coordinates # now self.coordinates is just another name for your array
Assuming n = Node(some_index, numpy_coordinate_array_name)
Upvotes: 2