0

I'm using a not-well-known framework called IPKISS; hopefully, this does not matter.

from ipkiss.all import *    

class ElectrodePair(Structure):
    """An electrode component to be used for a PPLN design."""

    __name_prefix__ = "ELECTRODE_PAIR"

    width = PositiveNumberProperty(required = True)
    height = PositiveNumberProperty(required = True)
    seperation = PositiveNumberProperty(required = True)

    lay1 = Layer(number = 1, name = "boundaries")

    def define_elements(self, elems):
        left = ShapeRectangle(center = (-self.seperation*0.5,0.), box_size = (self.width, self.height))
        right = ShapeRectangle(center = (self.seperation*0.5,0.), box_size = (self.width, self.height)) 

        elems += Boundary(layer = self.lay1, shape = left)
        elems += Boundary(layer = self.lay1, shape = right)
        return elems



class ElectrodeStructure(ElectrodePair):
    """An array of electrodes."""

    __name_prefix__ = "ELECTRODE_STRUCTURE"

    amount = PositiveNumberProperty(required = True)
    spacing = PositiveNumberProperty(required = True)

    def define_elements(self, elems):
        electrodePair = ElectrodePair.__init__(self)
        elems += ARefX(reference = electrodePair, origin = (0,0), period_1d = self.spacing, n_o_periods_1d = self.amount)
        return elems



def main():
    FILE_NAME = "ElectrodeArray.gds"
    electrodeArray = ElectrodeStructure(amount = 10, height = 100., seperation = 20, spacing = 10., width = 2.)

    electrodeArray.write_gdsii(FILE_NAME)


if __name__ == "__main__":
    main()

I have no idea why this is erroring. The error is:

File "/usr/local/lib/python2.7/dist-packages/IPKISS-2.4_ce-py2.7.egg/ipcore/properties/initializer.py",
line 327, in __init__ raise IpcoreAttributeException("Required property '%s' is not found in keyword arguments of '%s' initialization." % (p, str(type(self))))
ipcore.exceptions.exc.IpcoreAttributeException: Required property 'amount' is not found in keyword arguments of '<class '__main__.ElectrodeStructure'>' initialization.

It seems as though it's not happy with how I've passed my arguments, I've tried heaps of stuff and cannot get it to work. Advice would be much appreciated.

I suspect the error is due to electrodePair = ElectrodePair.__init__(self).

Thank you for your time.

1
  • Yes, you must specify an amount in your ElectrodePair initializer Commented Jan 7, 2014 at 7:01

2 Answers 2

1

You have to add __init__ method to your ElectrodeStructure class, that - as @hd1 has pointed out - has to set amount:

class ElectrodeStructure(ElectrodePair):
    def __init__(self, amount):
        ElectrodePair.__init__(self)

The way you call ElectrodePair.__init__ is wrong, since in the absence of ElectrodeStructure.__init__ in your class the former will be called automatically

EDIT:

Couple of things I've noticed on re-reading - you inherit from a class, and then within a class method you create an object of the parent class. Something is wrong here

Sign up to request clarification or add additional context in comments.

Comments

0
class ElectrodeStructure(ElectrodePair):
    [...]

    def define_elements(self, elems):
        electrodePair = ElectrodePair.__init__(self)
        [...]

When you create a new ElectrodeStructure in main(), you're passing keword arguments. Becuase you're not defining an __init__ function in ElectrodeStructure, the super's __init__ is being called with those arguments (including amount, so there's no error).

Then in define_elements, you're calling __init__ again, except you aren't passing in any arguments, which is causing the error.

Additionally, this statement:

        electrodePair = ElectrodePair.__init__(self)

Is assigning the return value (likely None) of ElectrodePair.__init__(self) to electrodePair. I suspect you want something more like the following:

        electrodePair = ElectrodePair(amount=1, etc.)

It looks like you want composition, not inheritance; you could initialize your subclass in a proper __init__ function (as @volcano describes), or just create an ElectrodePair class member, and not inherit at all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.