-
Notifications
You must be signed in to change notification settings - Fork 37
Defining the public API #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ks; base object removed; repr method created
| 'name': self.name | ||
| } | ||
|
|
||
| class_name = '{0.__class__.__name__!s}'.format(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than requiring each class do this manually, could we change create_repr_from_attributes to take the object itself and do this formatting internally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that too; in that case we can also supply a list of attributes instead of dicts; we then collect both the name and the attribute values from the object (and using the list)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated for review
qctrlopencontrols/dynamic_decoupling_sequences/dynamic_decoupling_sequence.py
Outdated
Show resolved
Hide resolved
| new_corpse_in_scrofulous_control) | ||
| from .predefined import new_predefined_driven_control | ||
|
|
||
| __all__ = ['UPPER_BOUND_RABI_RATE', 'UPPER_BOUND_DETUNING_RATE', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it'd be best to have one item per line, in alphabetical order. Makes scanning the code a little easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated; Made the list with one liberty [ALL CONSTANTS, AllClasses, all_methods] within each, alphabetical order in maintained.
| new_corpse_in_scrofulous_control) | ||
| from .predefined import new_predefined_driven_control | ||
|
|
||
| __all__ = ['UPPER_BOUND_RABI_RATE', 'UPPER_BOUND_DETUNING_RATE', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember what we decided for all in subpackages -- did we decide it was necessary, or just that the API of qctrlopencontrols is just the contents of the top-level all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot remember either; However, though it might be useful to declare all for sub-packages; Can decide otherwise too;
qctrlopencontrols/__init__.py
Outdated
| from .cirq import (convert_dds_to_cirq_circuit, | ||
| convert_dds_to_cirq_schedule) | ||
| from . import dynamic_decoupling_sequences | ||
| from .dynamic_decoupling_sequences import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this -- it means the user has to look into the sub-packages to see the API. Although I suppose they have to do that anyway, to look at the method documentation...
How verbose will it be if we list out all the imports explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to the other 2 comments [above and below this one]; if we decide all goes only in the top level, this should take care of this problem; Otherwise, I was following numpy case e.g. https://github.com/numpy/numpy/blob/master/numpy/__init__.py; again happy to go with either decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, happy to be consistent with numpy. If we find it awkward going forwards we can always change it.
qctrlopencontrols/__init__.py
Outdated
| from . import cirq | ||
| from .cirq import * | ||
|
|
||
| __all__ = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, this would be more explicit if we could just list out all the appropriate methods/constants/classes.
# This is the 1st commit message: starting pyquil support # This is the commit message #1: pyquil support added # This is the commit message #2: first version of pyquil notebook added # This is the commit message #3: pyquil dependency added to setup # This is the commit message #4: trying gcc install for pyquil # This is the commit message #5: replacing gcc install with build-essential # This is the commit message #6: forcing yes to install anything # This is the commit message #7: ignoring blocks in pyquil notebook for tests # This is the commit message #8: linted; unnecessary import removed from notebook # This is the commit message #9: removed all references of circuits and replaced those with programs; pyquil removed from method names # This is the commit message #10: notebook rerun after changes # This is the commit message #11: pyquil program conversion removes unnecessary method
# This is the 1st commit message: starting pyquil support # This is the commit message #1: pyquil support added # This is the commit message #2: first version of pyquil notebook added # This is the commit message #3: pyquil dependency added to setup # This is the commit message #4: trying gcc install for pyquil # This is the commit message #5: replacing gcc install with build-essential # This is the commit message #6: forcing yes to install anything # This is the commit message #7: ignoring blocks in pyquil notebook for tests # This is the commit message #8: linted; unnecessary import removed from notebook # This is the commit message #9: removed all references of circuits and replaced those with programs; pyquil removed from method names # This is the commit message #10: notebook rerun after changes # This is the commit message #11: pyquil program conversion removes unnecessary method # This is the commit message #12: Public methods are bundled as __all__; changed ported over to notebooks; base object removed; repr method created # This is the commit message #13: additional error handling for new repr method # This is the commit message #14: repr method updated with class instance as input
…__ of sub-package
35e39b1 to
20f32f9
Compare
|
|
Nice, looks good. The explicit relative paths used internally feel good to me -- nice and clear, and also mean that "qctrlopencontrols.foo" should only appear when foo is part of the public API, and that's true both inside and outside the package. |
Major changes
QCtrlObjectremoved from packagecreate_repr_from_attributes(..)inbase.utilsmodule__all__introduced in package and sub-packagenew_predefined_ddsornew_predefined_driven_controlare publicqiskitpackage method renamed tocovert_dd_to_qiskit_quantum_circuit