The pulse schedule should have a length attribute and return the number of instructions contained in the schedule. This will enable checking if a Schedule is empty and statements such as.
if not Schedule(): print('Empty')
A test should be included for this feature.
Hello, this looks very doable to me as my first issue for Qiskit! Can I be assigned to this?!
If so let me know what kind of additional help and prerequisites are needed from me.
Looking forward to it :).
Hi Nipun! Great to see around here! Assigned to you. Let me know if I can help.
Hey @taalexander and @1ucian0!
I think I am done with the code but need help to decide on a few things, which are:
__len__ work, which I think are right but correct me if I am wrong. Also, one of those two is a bit efficient since self.instructions gives back a sorted list while self._children is a property that just gives back the tuple that self.instructions uses. Code and some %timeit examples are below, and here is the example code I tried it on. I will finalize on either one of them after I hear from you. @abstractmethod __len__ to ScheduleComponent interface is a good idea? Then changes to the Instruction class would also be required. Let me know about that or maybe this can be another issue?"""Test __len__ method.""" inside 'test', but any more information on that would help me.Here are the images/code for reference:


Hey @1ucian0 @taalexander! Any comments/Updates? Should I move forward with a PR of just len(self.instructions) in the Schedule class?
Hi @neonipun, my apologies for the delay,
__len__ should be based on instructions. I agree it is inefficient, however, there is an upcoming refactor that will mitigate this problem.test__len__ in test/python/pulse/test_schedule.py seems fine. ScheduleComponent as this will be deprecated shortly.Fixed via #4394
Most helpful comment
Hi @neonipun, my apologies for the delay,
__len__should be based oninstructions. I agree it is inefficient, however, there is an upcoming refactor that will mitigate this problem.test__len__intest/python/pulse/test_schedule.pyseems fine.ScheduleComponentas this will be deprecated shortly.