-
Notifications
You must be signed in to change notification settings - Fork 1
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
.info() method in class Sequence #49
Comments
If we were using e.g., class Fibonacci():
_tags = {
"name": "Fibonacci Sequence",
"OEIS": True,
"OEIS_ID": "A000045",
"is_finite": False,
"is_periodic": False,
"is_monotonic_increasing": True,
} The benefit is, for a new property, a new tag is added easily. I am also thinking about Things I would not make tags or methods:
|
Taking inspiration from this discussion, here's an experimental design that allows tags to be accessed as attributes, in Reviews of the idea appreciated. This would allow sth like fi = Fibonacci()
fi.is_periodic
# False if the tags are set in the dict, as above. The advantage above attributes, or properties:
Disadvantage is that it is more custom, and not entirely "python zen". Not too strong arguments either way imo, opinions welcome (especially critical ones). |
I see your point. The problem is that I don't know if it is scalable. Let's say we want to delete the property
The problem is that a sequence of number can have different names. For example, the sequence |
Can you explain that? I agree that if there is some default logic that infers the property, it's probably not good to make it a tag. In case you are worried about inheritance: the tag system in |
I would be extra cautious and would strongly recommend not to introduce different class names. Yes, an object can have different names in literature, that's the same in stats/ML, e.g., Kriging, Gaussian process regression, kernel ridge regression with error variance fitting, all refer to the same algorithm (including parameters) up to renaming of symbols. I think dealing with different names is more a matter of documentation and tagging, rather than creating multiple classes though, because classes live on the software architecture level, and proliferating references is anti-DRY. Where I could understand different classes for the same mathematical object is OEIS vs Fibonacci, but here I would argue that the logical object differs, in parameterization. That is, |
Ah ok i didn't know. Is there a documentation for this class?
The idea was just to make the package more user-firendly. |
I get that, but I would argue that proliferation of names makes it less user friendly actually. See https://peps.python.org/pep-0020/ Violates "There should be one-- and preferably only one --obvious way to do it." The "why" goes along the lines, users will be confused about which one to pick, and will start wondering whether these are indeed just aliases. There is also a higher risk of errors as you allow inconsistency of imports across different locations. For classes identity matters too, so either you have multiple distinct classes (which is bad as identical objects can arise from non-identical classes, how do you check instances), or all except one of the classes will point to one other class, which users will not expect, in which case one can easily argue for leaving just that one special class in place. |
Add a
.info()
method to the classSequence
which print all the relevant information about the chose sequence.Infornation to include:
...
Open question:
API:
The text was updated successfully, but these errors were encountered: