-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add better support for custom generators #250
Conversation
3d41e66
to
978a987
Compare
The failing checks will be successful as soon as PR #248 is merged. |
I like this. We should have an abstract base class for generators, since they don't need to be based on the randomization method. In this ABC we could then define all needed methods and properties that should be provided for the SRF classes. This should be tested. |
And one problem I noticed: |
f327e81
to
de2e6f6
Compare
Just added the mentioned enhancements:
|
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.
@LSchueler I think this looks good now.
Thanks for the input! The only thing I don't agree with, is your naming convention of the abstract Generator class. I think I have never seen them with a capital A and I don't think that we need do have extra naming conventions for ABCs. Do you agree? - If yes, I would merge this PR. |
I just copied this naming convention from another project, where I am collaborating and I thought this was a thing. But I agree that |
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.
LGTM
At the moment it is very difficult to use own or modified random generators in the
SRF
andCondSRF
classes, because we only support using the lookup tablesGENERATORS
. This PR adds the possibility again to hand over own classes. I added some error checking, ensuring that the class is a subclass ofRandMeth
. This is not very pythonic, but using duck typing here is pretty tricky. For example, handing overSRF
as the generator gives this error only when trying to actually create an srf:That's why I opted for the strick instance checking. What are your thoughts in this approach?