-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
The CremonaDatabase class does not work correctly. #39072
Comments
Since LargeCremonaDatabase is a subclass of MiniCremonaDatabase, I should have added one more test:
|
The fix is pretty simple… if set_global is not None:
from sage.misc.superseded import deprecation
deprecation(25825, "the set_global argument for CremonaDatabase is deprecated and ignored")
+ input_mini = mini
if name is None:
if DatabaseCremona().is_present():
name = 'cremona'
@@ -1697,6 +1731,8 @@ def CremonaDatabase(name=None, mini=None, set_global=None):
mini = True
if mini is None:
raise ValueError('mini must be set as either True or False')
+ if (name == 'cremona' and input_mini is True) or (name == 'cremona mini' and input_mini is False):
+ raise ValueError(f'wrong value of mini, database {name!r} must have mini={mini}')
if mini:
return MiniCremonaDatabase(name) but the doctest is difficult to implement. +
+ Verify that :issue:`39072` has been resolved::
+
+ sage: # optional - NOT database_cremona_ellcurve
+ sage: c = CremonaDatabase(mini=True) # without database_cremona_ellcurve, this will select name = 'cremona mini'
+ sage: isinstance(c, sage.databases.cremona.MiniCremonaDatabase)
+ True
+ sage: c = CremonaDatabase(mini=False) # same as above but invalid value of ``mini`` raises error
+ Traceback (most recent call last):
+ ...
+ ValueError: wrong value of mini, database 'cremona mini' must have mini=True
+ sage: c = CremonaDatabase(name='cremona mini', mini=False)
+ Traceback (most recent call last):
+ ...
+ ValueError: wrong value of mini, database 'cremona mini' must have mini=True
+
+ ::
+
+ sage: # optional - database_cremona_ellcurve
+ sage: c = CremonaDatabase(mini=False)
+ sage: isinstance(c, sage.databases.cremona.LargeCremonaDatabase)
+ True
+ sage: c = CremonaDatabase(mini=True) # with database_cremona_ellcurve, this will select name = 'cremona'
+ Traceback (most recent call last):
+ ...
+ ValueError: wrong value of mini, database 'cremona' must have mini=False
+ sage: c = CremonaDatabase(name='cremona', mini=True)
+ Traceback (most recent call last):
+ ...
+ ValueError: wrong value of mini, database 'cremona' must have mini=False
+ sage: c = CremonaDatabase(name='cremona', mini=False)
+ sage: isinstance(c, sage.databases.cremona.LargeCremonaDatabase)
+ True the current doctest framework does not support Opinion: what should the doctest format be? Is |
That's great that there is a simple fix. I do wonder, however, why it is considered a good idea to make the user jump through these hoops, i.e. to be forced to provide redundant information and to be punished for doing so in an inconsistent way. A more straightforward design would drop the name and mini arguments altogether and have one keyword option "size" which defaults to "auto" but can also be "large" or "mini". Then the CremonaDatabase function would return an instance of MiniCremonaDatabase if the "size" option is "mini", and either return an instance of LargeCremonaDatabase or raise a FeatureNotPresentError if the option is "large" . The default would be to provide the best available. A doctest should be able to test if the feature exists in order to know which result is expected. This would differ from the current implementation and would therefore create a backwards incompatibility. But the current implementation is broken. A partial remedy would be to generate a deprecation warning if the keywords "name", "mini" or "setglobal" are used and to return a MiniCremonaDatabase in those cases unless mini is False and the large database is installed. |
#39179 fixes the issue as expected, keeping the original semantics of arguments. |
Steps To Reproduce
Expected Behavior
Sage should report that the database_cremona_ellcurve spkg is not installed and advise using mini=True.
Sage should not silently replace the large database by the mini database when the large database was specifically requested.
Actual Behavior
Additional Information
No response
Environment
Checklist
The text was updated successfully, but these errors were encountered: