diff --git a/.ci/retrofit-worktree.sh b/.ci/retrofit-worktree.sh
index f926e59059e..b9c880a839f 100755
--- a/.ci/retrofit-worktree.sh
+++ b/.ci/retrofit-worktree.sh
@@ -12,6 +12,10 @@ export GIT_AUTHOR_EMAIL="ci-sage@example.com"
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
+# Set globally for other parts of the workflow
+git config --global user.name "$GIT_AUTHOR_NAME"
+git config --global user.email "$GIT_AUTHOR_EMAIL"
+
set -ex
# If actions/checkout downloaded our source tree using the GitHub REST API
diff --git a/.github/sync_labels.py b/.github/sync_labels.py
index 799b4985c5d..97ddf039a16 100755
--- a/.github/sync_labels.py
+++ b/.github/sync_labels.py
@@ -25,6 +25,7 @@
from subprocess import check_output, CalledProcessError
datetime_format = '%Y-%m-%dT%H:%M:%SZ'
+default_bot = 'github-actions'
class Action(Enum):
@@ -42,21 +43,41 @@ class Action(Enum):
converted_to_draft = 'converted_to_draft'
submitted = 'submitted'
-class RevState(Enum):
+class AuthorAssociation(Enum):
r"""
- Enum for GitHub event ``review_state``.
+ Enum for GitHub ``authorAssociation``.
"""
- commented = 'commented'
- approved = 'approved'
- changes_requested = 'changes_requested'
+ def is_valid(self):
+ r"""
+ Return whether ``self`` has valid permissions.
+ """
+ c = self.__class__
+ return self in [c.collaborator, c.member, c.owner]
+
+ collaborator = 'COLLABORATOR' # Author has been invited to collaborate on the repository.
+ contributor = 'CONTRIBUTOR' # Author has previously committed to the repository.
+ first_timer = 'FIRST_TIMER' # Author has not previously committed to GitHub.
+ first_time_contributor = 'FIRST_TIME_CONTRIBUTOR' # Author has not previously committed to the repository.
+ mannequin = 'MANNEQUIN' # Author is a placeholder for an unclaimed user.
+ member = 'MEMBER' # Author is a member of the organization that owns the repository.
+ none = 'NONE' # Author has no association with the repository.
+ owner = 'OWNER' # Author is the owner of the repository.
-class ReviewDecision(Enum):
+class RevState(Enum):
r"""
- Enum for ``gh pr view`` results for ``reviewDecision``.
+ Enum for GitHub event ``review_state``.
"""
+ def is_proper(self):
+ r"""
+ Return whether ``self`` is a proper review state.
+ """
+ c = self.__class__
+ return self in [c.changes_requested, c.approved]
+
+ commented = 'COMMENTED'
changes_requested = 'CHANGES_REQUESTED'
approved = 'APPROVED'
- unclear = 'UNCLEAR'
+ dismissed = 'DISMISSED'
class Priority(Enum):
r"""
@@ -68,9 +89,9 @@ class Priority(Enum):
minor = 'p: minor /4'
trivial = 'p: trivial /5'
-class State(Enum):
+class Status(Enum):
r"""
- Enum for state labels.
+ Enum for status labels.
"""
positive_review = 's: positive review'
needs_work = 's: needs work'
@@ -90,7 +111,7 @@ def selection_list(label):
r"""
Return the selection list to which ``label`` belongs to.
"""
- for sel_list in [Priority, State, Resolution]:
+ for sel_list in [Priority, Status, Resolution]:
for item in sel_list:
if label == item.value:
return sel_list
@@ -108,22 +129,32 @@ def __init__(self, url, actor):
self._url = url
self._actor = actor
self._warning_prefix = 'Label Sync Warning:'
+ self._hint_prefix = 'Label Sync Hint:'
self._labels = None
self._author = None
self._draft = None
self._open = None
self._review_decision = None
self._reviews = None
+ self._reviews_from_rest_api = None
+ self._review_requests = None
self._commits = None
self._commit_date = None
+ self._bot_login = None
+
+ s = url.split('/')
+ self._owner = s[3]
+ self._repo = s[4]
+ self._number = os.path.basename(url)
- number = os.path.basename(url)
self._pr = True
- self._issue = 'pull request #%s' % number
+ self._issue = 'pull request #%s' % self._number
if url.rfind('issue') != -1:
- self._issue = 'issue #%s' % number
+ self._issue = 'issue #%s' % self._number
self._pr = False
info('Create label handler for %s and actor %s' % (self._issue, self._actor))
+
+ self.bot_login()
self.clean_warnings()
# -------------------------------------------------------------------------
@@ -198,6 +229,30 @@ def is_draft(self):
info('Issue %s is draft %s' % (self._issue, self._draft))
return self._draft
+ def bot_login(self):
+ r"""
+ Return the login name of the bot.
+ """
+ if self._bot_login:
+ return self._bot_login
+ cmd = 'gh auth status'
+ from subprocess import run
+ capt = run(cmd, shell=True, capture_output=True)
+ l = str(capt.stderr).split()
+ if not 'as' in l:
+ l = str(capt.stdout).split()
+ self._bot_login = l[l.index('as')+1]
+ if self._bot_login.endswith('[bot]'):
+ self._bot_login = self._bot_login.split('[bot]')[0]
+ info('Bot is %s' % self._bot_login)
+ return self._bot_login
+
+ def is_this_bot(self, login):
+ r"""
+ Check whether login is the bot itself.
+ """
+ return login.startswith(self.bot_login())
+
def is_auth_team_member(self, login):
r"""
Return ``True`` if the user with given login belongs to an authorized
@@ -224,9 +279,43 @@ def verify_membership(team):
def actor_authorized(self):
r"""
- Return ``True`` if the actor belongs to an authorized team.
+ Return ``True`` if the actor has sufficient permissions.
+ """
+ if self.is_this_bot(default_bot):
+ # since the default bot is not a member of the SageMath
+ # organization it cannot test membership for private members.
+ # Therefore, we check here for public organization membership.
+ rev = self.get_latest_review()
+ if not rev:
+ return False
+
+ if rev['author']['login'] == self._actor:
+ ass = rev['authorAssociation']
+ info('Actor %s has association %s' % (self._actor, ass))
+ return AuthorAssociation(ass).is_valid()
+ info('Actor %s did not create latest review' % self._actor)
+ return False
+ else:
+ return self.is_auth_team_member(self._actor)
+
+ def query_multi_pages(self, path_args, since=None):
+ r"""
+ Query data from REST api from multiple pages.
"""
- return self.is_auth_team_member(self._actor)
+ per_page = 100
+ if since:
+ query = '-f per_page=%s -f page={} -f since=%s' % (per_page, since.strftime(datetime_format))
+ else:
+ query = '-f per_page=%s -f page={}' % per_page
+ page = 1
+ results = []
+ while True:
+ results_page = self.rest_api(path_args, query=query.format(page))
+ results += results_page
+ if len(results_page) < per_page:
+ break
+ page += 1
+ return results
def clean_warnings(self):
r"""
@@ -235,22 +324,10 @@ def clean_warnings(self):
"""
warning_lifetime = timedelta(minutes=5)
time_frame = timedelta(minutes=730) # timedelta to search for comments including 10 minutes overlap with cron-cycle
- per_page = 100
today = datetime.today()
since = today - time_frame
- query = '-F per_page=%s -F page={} -f since=%s' % (per_page, since.strftime(datetime_format))
- s = self._url.split('/')
- owner = s[3]
- repo = s[4]
- path_args = '/repos/%s/%s/issues/comments' % (owner, repo)
- page = 1
- comments = []
- while True:
- comments_page = self.rest_api(path_args, query=query.format(page))
- comments += comments_page
- if len(comments_page) < per_page:
- break
- page += 1
+ path_args = '/repos/%s/%s/issues/comments' % (self._owner, self._repo)
+ comments = self.query_multi_pages(path_args, since=since)
info('Cleaning warning comments since %s (total found %s)' % (since, len(comments)))
@@ -260,12 +337,17 @@ def clean_warnings(self):
comment_id = c['id']
issue = c['issue_url'].split('/').pop()
created_at = c['created_at']
- if login.startswith('github-actions'):
- debug('github-actions comment %s created at %s on issue %s found' % (comment_id, created_at, issue))
+ if self.is_this_bot(login):
+ debug('%s comment %s created at %s on issue %s found' % (self.bot_login(), comment_id, created_at, issue))
+ prefix = None
if body.startswith(self._warning_prefix):
+ prefix = self._warning_prefix
+ if body.startswith(self._hint_prefix):
+ prefix = self._hint_prefix
+ if prefix:
created = datetime.strptime(created_at, datetime_format)
lifetime = today - created
- debug('github-actions %s %s is %s old' % (self._warning_prefix, comment_id, lifetime))
+ debug('%s %s %s is %s old' % (self.bot_login(), prefix, comment_id, lifetime))
if lifetime > warning_lifetime:
try:
self.rest_api('%s/%s' % (path_args, comment_id), method='DELETE')
@@ -311,26 +393,18 @@ def get_commits(self):
info('Commits until %s for %s: %s' % (self._commit_date, self._issue, self._commits))
return self._commits
- def get_review_decision(self):
+ def get_review_requests(self):
r"""
- Return the reviewDecision of the PR.
+ Return the list of review request of the PR.
"""
if not self.is_pull_request():
return None
- if self._review_decision is not None:
- if self._review_decision == ReviewDecision.unclear:
- return None
- return self._review_decision
+ if self._review_requests is None:
+ self._review_requests = self.view('reviewRequests')
+ debug('Review requests for %s: %s' % (self._issue, self._review_requests))
- data = self.view('reviewDecision')
- if data:
- self._review_decision = ReviewDecision(data)
- else:
- # To separate a not supplied value from not cached (see https://github.com/sagemath/sage/pull/36177#issuecomment-1704022893 ff)
- self._review_decision = ReviewDecision.unclear
- info('Review decision for %s: %s' % (self._issue, self._review_decision.value))
- return self._review_decision
+ return self._review_requests
def get_reviews(self, complete=False):
r"""
@@ -358,6 +432,28 @@ def get_reviews(self, complete=False):
info('Proper reviews after %s for %s: %s' % (date, self._issue, proper_new_revs))
return proper_new_revs
+ def get_latest_review(self, complete=False):
+ r"""
+ Return the latest review of the PR. Per default only those proper reviews
+ are considered which have been submitted after the most recent commit. Use
+ keyword ``complete`` to get the latest of all.
+ """
+ revs = self.get_reviews(complete=complete)
+ if not revs:
+ return
+ res = revs[0]
+ max_date = res['submittedAt']
+ for rev in revs:
+ cur_date = rev['submittedAt']
+ if cur_date > max_date:
+ max_date = cur_date
+ res = rev
+ fill_in = ''
+ if not complete:
+ fill_in = ' proper'
+ info('PR %s had latest%s review at %s: %s' % (self._issue, fill_in, max_date, res))
+ return res
+
def active_partners(self, item):
r"""
Return the list of other labels from the selection list
@@ -369,47 +465,60 @@ def active_partners(self, item):
return partners
# -------------------------------------------------------------------------
- # methods to validate the issue state
+ # methods to validate the issue status
# -------------------------------------------------------------------------
- def review_comment_to_state(self):
+ def review_comment_to_status(self):
r"""
- Return a State label if the most recent review comment
+ Return a status label if the most recent review comment
starts with its value.
"""
- revs = self.get_reviews(complete=True)
- date = max(rev['submittedAt'] for rev in revs)
-
- for rev in revs:
- if rev['submittedAt'] == date:
- for stat in State:
- body = rev['body']
- if body.startswith(stat.value):
- return stat
- return None
-
- def needs_work_valid(self):
+ rev = self.get_latest_review(complete=True)
+ ass = AuthorAssociation(rev['authorAssociation'])
+ for status in Status:
+ body = rev['body']
+ if body.startswith(status.value):
+ info('Latest review comment contains status label %s' % status)
+ return status, ass
+ return None, ass
+
+ def review_by_actor(self):
r"""
- Return ``True`` if the PR needs work. This is the case if
- there are reviews more recent than any commit and the review
- decision requests changes or if there is any review reqesting
- changes.
+ Return ``True`` if the actor authored the latest review directly or indirectly.
"""
- revs = self.get_reviews()
- if not revs:
+ rev = self.get_latest_review()
+ if not rev:
# no proper review since most recent commit.
return False
+ answer = False
+ auth = rev['author']['login']
+ if self._actor == auth:
+ answer = True
+ if self.is_this_bot(auth):
+ if rev['body'].find(self._actor) > 0:
+ answer = True
+ if answer:
+ node_id = rev['id']
+ info('Ignore actor\'s review %s' % node_id)
+ self.dismiss_bot_reviews('@%s reverted decision.' % self._actor, node_id=node_id)
+ return answer
+
+ def check_review_decision(self, rev_decision):
+ r"""
+ Return ``True`` if the latest proper review of the PR has the
+ given decision.
+ """
+ rev = self.get_latest_review()
+ if not rev:
+ # no proper review since most recent commit.
+ return False
+ return rev['state'] == rev_decision.value
- ch_req = ReviewDecision.changes_requested
- rev_dec = self.get_review_decision()
- if rev_dec:
- if rev_dec == ch_req:
- info('PR %s needs work (by decision)' % self._issue)
- return True
- else:
- info('PR %s doesn\'t need work (by decision)' % self._issue)
- return False
-
- if any(rev['state'] == ch_req.value for rev in revs):
+ def needs_work_valid(self):
+ r"""
+ Return ``True`` if the PR needs work. This is the case if
+ the latest proper review request changes.
+ """
+ if self.check_review_decision(RevState.changes_requested):
info('PR %s needs work' % self._issue)
return True
info('PR %s doesn\'t need work' % self._issue)
@@ -417,27 +526,10 @@ def needs_work_valid(self):
def positive_review_valid(self):
r"""
- Return ``True`` if the PR has positive review. This is the
- case if there are reviews more recent than any commit and the
- review decision is approved or if there is any approved review
- but no changes requesting one.
+ Return ``True`` if the PR is positively reviewed. This is the case if
+ the latest proper review is approved.
"""
- revs = self.get_reviews()
- if not revs:
- # no proper review since most recent commit.
- return False
-
- appr = ReviewDecision.approved
- rev_dec = self.get_review_decision()
- if rev_dec:
- if rev_dec == appr:
- info('PR %s has positve review (by decision)' % self._issue)
- return True
- else:
- info('PR %s doesn\'t have positve review (by decision)' % self._issue)
- return False
-
- if all(rev['state'] == appr.value for rev in revs):
+ if self.check_review_decision(RevState.approved):
info('PR %s has positve review' % self._issue)
return True
info('PR %s doesn\'t have positve review' % self._issue)
@@ -451,6 +543,10 @@ def needs_review_valid(self):
if self.is_draft():
return False
+ if self.review_by_actor():
+ info('PR %s needs review (because of actor review)' % self._issue)
+ return True
+
if self.needs_work_valid():
info('PR %s already under review (needs work)' % self._issue)
return False
@@ -467,13 +563,12 @@ def approve_allowed(self):
Return if the actor has permission to approve this PR.
"""
revs = self.get_reviews()
- revs = [rev for rev in revs if rev['author']['login'] != self._actor]
- ch_req = ReviewDecision.changes_requested
+ revs = [rev for rev in revs if not self.review_by_actor()]
+ ch_req = RevState.changes_requested
if any(rev['state'] == ch_req.value for rev in revs):
info('PR %s can\'t be approved by %s since others reqest changes' % (self._issue, self._actor))
return False
-
- return self.actor_valid()
+ return True
def actor_valid(self):
r"""
@@ -486,19 +581,26 @@ def actor_valid(self):
return True
revs = self.get_reviews()
- revs = [rev for rev in revs if rev['author']['login'] != 'github-actions']
+ revs = [rev for rev in revs if not self.is_this_bot(rev['author']['login'])]
if not revs:
info('PR %s can\'t be approved by the author %s since no other person reviewed it' % (self._issue, self._actor))
return False
coms = self.get_commits()
- authors = sum(com['authors'] for com in coms)
- authors = [auth for auth in authors if not auth['login'] in (self._actor, 'github-actions')]
+ authors = []
+ for com in coms:
+ for auth in com['authors']:
+ login = auth['login']
+ if not login in authors:
+ if not self.is_this_bot(login) and login != author:
+ debug('PR %s has recent commit by %s' % (self._issue, login))
+ authors.append(login)
+
if not authors:
info('PR %s can\'t be approved by the author %s since no other person commited to it' % (self._issue, self._actor))
return False
- info('PR %s can be approved by the author %s as co-author' % (self._issue, self._actor))
+ info('PR %s can be approved by the author %s as co-author' % (self._issue, author))
return True
# -------------------------------------------------------------------------
@@ -511,7 +613,10 @@ def gh_cmd(self, cmd, arg, option):
issue = 'issue'
if self._pr:
issue = 'pr'
- cmd_str = 'gh %s %s %s %s "%s"' % (issue, cmd, self._url, option, arg)
+ if arg:
+ cmd_str = 'gh %s %s %s %s "%s"' % (issue, cmd, self._url, option, arg)
+ else:
+ cmd_str = 'gh %s %s %s %s' % (issue, cmd, self._url, option)
debug('Execute command: %s' % cmd_str)
ex_code = os.system(cmd_str)
if ex_code:
@@ -529,26 +634,70 @@ def mark_as_ready(self):
"""
self.gh_cmd('ready', '', '')
- def review(self, arg, text):
+ def review(self, arg, text=None):
r"""
Perform a system call to ``gh`` to review a PR.
"""
- self.gh_cmd('review', arg, '-b \"%s\"' % text)
+ if text:
+ self.gh_cmd('review', arg, '-b \"%s\"' % text)
+ else:
+ self.gh_cmd('review', arg, '')
def approve(self):
r"""
Approve the PR by the actor.
"""
- self.review('--approve', '%s approved this PR' % self._actor)
+ self.review('--approve')
info('PR %s approved by %s' % (self._issue, self._actor))
def request_changes(self):
r"""
Request changes for this PR by the actor.
"""
- self.review('--request-changes', '%s requested changes for this PR' % self._actor)
+ self.review('--request-changes', '@%s requested changes for this PR' % self._actor)
info('Changes requested for PR %s by %s' % (self._issue, self._actor))
+ def dismiss_bot_reviews(self, message, node_id=None, state=None, actor=None):
+ r"""
+ Dismiss all reviews of the bot matching the given features (``node_id``, ...).
+ """
+ path_args = '/repos/%s/%s/pulls/%s/reviews' % (self._owner, self._repo, self._number)
+ if not self._reviews_from_rest_api:
+ # since the reviews queried with `gh pr view` don't contain the id
+ # we need to obtain them form REST api.
+ self._reviews_from_rest_api = self.query_multi_pages(path_args)
+ reviews = self._reviews_from_rest_api
+
+ options = '-f message=\"%s\" -f event=\"DISMISS\"' % message
+ for rev in reviews:
+ rev_login = rev['user']['login']
+ rev_id = rev['id']
+ rev_node_id = rev['node_id']
+ rev_state = RevState(rev['state'])
+
+ if not self.is_this_bot(rev_login):
+ continue
+ if not rev_state.is_proper():
+ continue
+
+ debug('Bot review with node_id %s has id %s' % (rev_node_id, rev_id))
+ if node_id:
+ if rev_node_id != node_id:
+ continue
+ if state:
+ if rev_state != state:
+ continue
+ if actor:
+ if not rev['body'].find(actor):
+ continue
+ path_args_dismiss = '%s/%s/dismissals' % (path_args, rev_id)
+ try:
+ self.rest_api(path_args_dismiss, method='PUT', query=options)
+ info('Review %s (node_id %s, state %s) on PR %s dismissed' % (rev_id, rev_node_id, rev_state, self._issue))
+ except CalledProcessError:
+ # the comment may have been deleted by a bot running in parallel
+ info('Review %s (node_id %s, state %s) on PR %s cannot be dismissed' % (rev_id, rev_node_id, rev_state, self._issue))
+
def review_comment(self, text):
r"""
Add a review comment.
@@ -569,6 +718,12 @@ def add_warning(self, text):
"""
self.add_comment('%s %s' % (self._warning_prefix, text))
+ def add_hint(self, text):
+ r"""
+ Perform a system call to ``gh`` to add a hint to an issue or PR.
+ """
+ self.add_comment('%s %s' % (self._hint_prefix, text))
+
def add_label(self, label):
r"""
Add the given label to the issue or PR.
@@ -604,29 +759,35 @@ def remove_label(self, label):
def reject_label_addition(self, item):
r"""
- Post a comment that the given label can not be added and select
- a corresponding other one.
+ Post a comment that the given label can not be added and remove
+ it again.
+ """
+ if item is Status.positive_review:
+ self.add_warning('Label *%s* cannot be added by the author of the PR.' % item.value)
+ self.remove_label(item.value)
+ return
+
+ def warning_about_label_addition(self, item):
+ r"""
+ Post a comment that the given label my be incorrect.
"""
if not self.is_pull_request():
- self.add_warning('Label *%s* can not be added to an issue. Please use it on the corresponding PR' % item.value)
- elif item is State.needs_review:
- self.add_warning('Label *%s* can not be added, since there are unresolved reviews' % item.value)
+ self.add_warning('Label *%s* is not suitable for an issue. Please use it on the corresponding PR.' % item.value)
+ elif item is Status.needs_review:
+ self.add_warning('Label *%s* may be incorrect, since there are unresolved reviews.' % item.value)
else:
- self.add_warning('Label *%s* can not be added. Please use the GitHub review functionality' % item.value)
- self.remove_label(item.value)
+ self.add_warning('Label *%s* does not match the state of GitHub\'s review system.' % item.value)
return
- def reject_label_removal(self, item):
+ def hint_about_label_removal(self, item):
r"""
- Post a comment that the given label can not be removed and select
- a corresponding other one.
+ Post a comment that the given label must not be removed any more.
"""
- if type(item) == State:
- sel_list = 'state'
+ if type(item) == Status:
+ sel_list = 'status'
else:
sel_list = 'priority'
- self.add_warning('Label *%s* can not be removed. Please add the %s-label which should replace it' % (item.value, sel_list))
- self.add_label(item.value)
+ self.add_hint('You don\'t need to remove %s labels any more. You\'d better just add the label which replaces it.' % sel_list)
return
# -------------------------------------------------------------------------
@@ -635,7 +796,7 @@ def reject_label_removal(self, item):
def on_label_add(self, label):
r"""
Check if the given label belongs to a selection list. If so, remove
- all other labels of that list. In case of a state label reviews are
+ all other labels of that list. In case of a status label reviews are
booked accordingly.
"""
sel_list = selection_list(label)
@@ -655,13 +816,13 @@ def on_label_add(self, label):
warning('Label %s of %s not found!' % (label, self._issue))
return
- if sel_list is State:
+ if sel_list is Status:
if not self.is_pull_request():
- if item != State.needs_info:
- self.reject_label_addition(item)
+ if item != Status.needs_info:
+ self.warning_about_label_addition(item)
return
- if item == State.needs_review:
+ if item == Status.needs_review:
if self.needs_review_valid():
# here we come for example after a sequence:
# needs review -> needs info -> needs review
@@ -669,10 +830,10 @@ def on_label_add(self, label):
elif self.is_draft():
self.mark_as_ready()
else:
- self.reject_label_addition(item)
+ self.warning_about_label_addition(item)
return
- if item == State.needs_work:
+ if item == Status.needs_work:
if self.needs_work_valid():
# here we come for example after a sequence:
# needs work -> needs info -> needs work
@@ -680,18 +841,21 @@ def on_label_add(self, label):
elif not self.is_draft():
self.request_changes()
else:
- self.reject_label_addition(item)
+ self.warning_about_label_addition(item)
return
- if item == State.positive_review:
+ if item == Status.positive_review:
if self.positive_review_valid():
# here we come for example after a sequence:
# positive review -> needs info -> positive review
pass
+ elif not self.actor_valid():
+ self.reject_label_addition(item)
+ return
elif self.approve_allowed():
self.approve()
else:
- self.reject_label_addition(item)
+ self.warning_about_label_addition(item)
return
if sel_list is Resolution:
@@ -703,22 +867,25 @@ def on_label_add(self, label):
def on_label_removal(self, label):
r"""
- Check if the given label belongs to a selection list. If so, the
- removement is rejected and a comment is posted to instead add a
- replacement for ``label`` from the list. Exceptions are State labels
- on issues and State.needs_info on a PR.
+ Check if the given label belongs to a selection list. If so, a comment
+ is posted to instead add a replacement for ``label`` from the list.
+ Exceptions are status labels on issues and Status.needs_info on a PR.
"""
sel_list = selection_list(label)
if not sel_list:
return
item = sel_list(label)
- if sel_list is State:
+
+ if len(self.active_partners(item)) > 0:
+ return
+
+ if sel_list is Status:
if self.is_pull_request():
- if item != State.needs_info:
- self.reject_label_removal(item)
+ if item != Status.needs_info:
+ self.hint_about_label_removal(item)
elif sel_list is Priority:
- self.reject_label_removal(item)
+ self.hint_about_label_removal(item)
return
def on_review_comment(self):
@@ -729,10 +896,21 @@ def on_review_comment(self):
have permission to add labels (i.e. aren't a member of the
Triage team).
"""
- rev_state = self.review_comment_to_state()
- if rev_state in (State.needs_info, State.needs_review):
- self.select_label(rev_state)
- self.run(Action.labeled, label=rev_state.value)
+ status, ass = self.review_comment_to_status()
+ if ass is AuthorAssociation.owner:
+ if status is Status.positive_review:
+ # allow the repository owner to approve his own PR for testing
+ # the bot
+ info('Owner approves PR %s for testing the bot' % self._issue)
+ self.dismiss_bot_reviews('@%s approved the PR.' % self._actor, state=RevState.changes_requested, actor=self._actor)
+ self.approve()
+ elif ass.is_valid() or ass is Author.Assoziation.contributor:
+ if status in (Status.needs_info, Status.needs_review):
+ # allow contributors who are not Triage members to set
+ # these labels
+ info('Simulate label addition of %s for %s' % (label, self._issue))
+ self.select_label(status)
+ self.run(Action.labeled, label=status.value)
def remove_all_labels_of_sel_list(self, sel_list):
r"""
@@ -747,12 +925,16 @@ def run(self, action, label=None, rev_state=None):
"""
self.reset_view() # this is just needed for run_tests
+ if self.is_this_bot(self._actor):
+ info('Trigger %s of the bot %s is ignored' % (action, self._actor))
+ return
+
if action is Action.opened and self.is_pull_request():
if not self.is_draft():
- self.add_default_label(State.needs_review)
+ self.add_default_label(Status.needs_review)
if action in (Action.closed, Action.reopened, Action.converted_to_draft):
- self.remove_all_labels_of_sel_list(State)
+ self.remove_all_labels_of_sel_list(Status)
if action is Action.labeled:
self.on_label_add(label)
@@ -761,21 +943,27 @@ def run(self, action, label=None, rev_state=None):
self.on_label_removal(label)
if action in (Action.ready_for_review, Action.synchronize):
+ self.dismiss_bot_reviews('New changes ready for review.')
if self.needs_review_valid():
- self.select_label(State.needs_review)
+ self.select_label(Status.needs_review)
if action is Action.review_requested:
- self.select_label(State.needs_review)
+ self.select_label(Status.needs_review)
if action is Action.submitted:
- rev_state = RevState(rev_state)
+ rev_state = RevState(rev_state.upper())
if rev_state is RevState.approved:
- if self.actor_authorized() and self.positive_review_valid():
- self.select_label(State.positive_review)
+ self.dismiss_bot_reviews('@%s approved the PR.' % self._actor, state=RevState.changes_requested, actor=self._actor)
+ rev_req = self.get_review_requests()
+ if rev_req:
+ info('Waiting on pending review requests: %s' % rev_req)
+ elif self.actor_authorized() and self.positive_review_valid():
+ self.select_label(Status.positive_review)
if rev_state is RevState.changes_requested:
+ self.dismiss_bot_reviews('@%s requested changes.' % self._actor, state=RevState.approved)
if self.needs_work_valid():
- self.select_label(State.needs_work)
+ self.select_label(Status.needs_work)
if rev_state is RevState.commented:
self.on_review_comment()
@@ -794,12 +982,12 @@ def run_tests(self):
for action in Action:
self.add_comment('Test action %s' % action.value)
if action in (Action.labeled, Action.unlabeled):
- for stat in State:
+ for status in Status:
if action is Action.labeled:
- self.add_label(stat.value)
+ self.add_label(status.value)
else:
- self.remove_label(stat.value)
- self.run(action, label=stat.value)
+ self.remove_label(status.value)
+ self.run(action, label=status.value)
for prio in Priority:
if action is Action.labeled:
self.add_label(prio.value)
@@ -811,17 +999,17 @@ def run_tests(self):
self.add_label(res.value)
self.run(action, label=prio.value)
elif action == Action.submitted and self.is_pull_request():
- for rev_stat in RevState:
- if rev_stat is RevState.approved:
+ for rev_state in RevState:
+ if rev_state is RevState.approved:
self.approve()
- self.run(action, rev_state=rev_stat.value)
- elif rev_stat is RevState.changes_requested:
+ self.run(action, rev_state=rev_state.value)
+ elif rev_state is RevState.changes_requested:
self.request_changes()
- self.run(action, rev_state=rev_stat.value)
- elif rev_stat is RevState.commented:
- for stat in State:
- self.review_comment(stat.value)
- self.run(action, rev_state=rev_stat.value)
+ self.run(action, rev_state=rev_state.value)
+ elif rev_state is RevState.commented:
+ for status in Status:
+ self.review_comment(status.value)
+ self.run(action, rev_state=rev_state.value)
elif self.is_pull_request():
self.run(action)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5242dfc06f9..7ac9c6154d0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -103,21 +103,30 @@ jobs:
MAKE: make -j2 --output-sync=recurse
SAGE_NUM_THREADS: 2
- - name: Set up node to install pyright
+ - name: Static code check with pyright
if: always() && steps.worktree.outcome == 'success'
- uses: actions/setup-node@v3
+ uses: jakebailey/pyright-action@v1
with:
- node-version: '12'
-
- - name: Install pyright
- if: always() && steps.worktree.outcome == 'success'
- # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239
- run: npm install -g pyright@1.1.232
-
- - name: Static code check with pyright
+ version: 1.1.332
+ # Many warnings issued by pyright are not yet helpful because there is not yet enough type information.
+ no-comments: true
+ working-directory: ./worktree-image
+ env:
+ # To avoid out of memory errors
+ NODE_OPTIONS: --max-old-space-size=8192
+
+ - name: Static code check with pyright (annotated)
if: always() && steps.worktree.outcome == 'success'
- run: pyright
- working-directory: ./worktree-image
+ uses: jakebailey/pyright-action@v1
+ with:
+ version: 1.1.332
+ # Issue errors
+ no-comments: false
+ level: error
+ working-directory: ./worktree-image
+ env:
+ # To avoid out of memory errors
+ NODE_OPTIONS: --max-old-space-size=8192
- name: Clean (fallback to non-incremental)
id: clean
diff --git a/.github/workflows/ci-linux-incremental.yml b/.github/workflows/ci-linux-incremental.yml
index a4aa9ae99c7..7887597845c 100644
--- a/.github/workflows/ci-linux-incremental.yml
+++ b/.github/workflows/ci-linux-incremental.yml
@@ -24,6 +24,9 @@ on:
- reopened
# When a CI label is added
- labeled
+ paths:
+ - 'build/pkgs/**'
+ - 'pkgs/**'
workflow_dispatch:
concurrency:
diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml
index de49bbc69a3..fb2229ba7b4 100644
--- a/.github/workflows/dist.yml
+++ b/.github/workflows/dist.yml
@@ -111,11 +111,11 @@ jobs:
fail-fast: false
matrix:
include:
- - os: ubuntu-20.04
+ - os: ubuntu-latest
arch: x86_64
- - os: ubuntu-20.04
+ - os: ubuntu-latest
arch: i686
- - os: macos-10.15
+ - os: macos-latest
arch: auto
env:
# SPKGs to install as system packages
@@ -128,7 +128,7 @@ jobs:
#
CIBW_ARCHS: ${{ matrix.arch }}
# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python
- CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
+ CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9, <3.12"
# Environment during wheel build
CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal"
# Use 'build', not 'pip wheel'
@@ -156,7 +156,7 @@ jobs:
mkdir -p unpacked
for pkg in sagemath-objects sagemath-categories; do
(cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz
- pipx run cibuildwheel==2.7.0 unpacked/$pkg*
+ pipx run cibuildwheel==2.16.2 unpacked/$pkg*
done
- uses: actions/upload-artifact@v3
diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml
index dbd8c99ff30..5eb3998feee 100644
--- a/.github/workflows/doc-build.yml
+++ b/.github/workflows/doc-build.yml
@@ -56,9 +56,23 @@ jobs:
git config --global --add safe.directory $(pwd)
git config --global user.email "ci-sage@example.com"
git config --global user.name "Build & Test workflow"
+ # mathjax path in old doc
+ mathjax_path_from=$(SAGE_USE_CDNS=no /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)")
.ci/retrofit-worktree.sh worktree-image /sage
- # Keep track of changes to built HTML
- new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old")
+ # mathjax path in new doc
+ mathjax_path_to=$(SAGE_USE_CDNS=yes /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)")
+ new_version=$(cat src/VERSION.txt)
+ # Wipe out chronic diffs between old doc and new doc
+ (cd /sage/local/share/doc/sage/html/en && \
+ find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '"$new_version"' /' \
+ -e 's;'"$mathjax_path_from"';'"$mathjax_path_to"';' \
+ -e '\;; d')
+ # Create git repo from old doc
+ (cd /sage/local/share/doc/sage/html/en && \
+ git init && \
+ (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && \
+ (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; \
+ git add -A && git commit --quiet -m "old")
- name: Download upstream artifact
uses: actions/download-artifact@v3
@@ -77,7 +91,7 @@ jobs:
id: incremental
run: |
# Now re-bootstrap and build. The build is incremental because we were careful with the timestamps.
- ./bootstrap && make build
+ ./bootstrap && make sagemath_doc_html-build-deps
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
@@ -88,7 +102,7 @@ jobs:
if: always() && steps.worktree.outcome == 'success' && steps.incremental.outcome != 'success'
run: |
set -ex
- make sagelib-clean && git clean -fx src/sage && ./config.status && make build
+ make sagelib-clean && git clean -fx src/sage && ./config.status && make sagemath_doc_html-build-deps
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
@@ -105,7 +119,7 @@ jobs:
mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc
make doc-clean doc-uninstall
mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git
- ./config.status && make doc-html
+ ./config.status && make sagemath_doc_html-no-deps
working-directory: ./worktree-image
env:
MAKE: make -j2 --output-sync=recurse
@@ -117,12 +131,58 @@ jobs:
run: |
set -ex
mkdir -p ./docs
- # Create changelog
- echo '## Preview of CHANGES.html'
- (cd /sage/local/share/doc/sage/html/en && git diff --name-only) | tee ./docs/CHANGES.txt
- (cd /sage/local/share/doc/sage/html/en && git diff; rm -rf .git) > ./docs/html.diff
- echo '## Preview of html.diff'; head -n 400 ./docs/html.diff
- (echo '
')
+ output_text = '\n'.join(out_blocks)
+ with open('./docs/diff.html', 'w') as f:
+ f.write(output_text)
+ EOF
+ cat ./docs/diff.html >> ./docs/CHANGES.html
+ echo '' >> ./docs/CHANGES.html
+ echo '' >>./docs/CHANGES.html
+ rm ./docs/diff.txt ./docs/diff.html
+ (cd /sage/local/share/doc/sage/html/en && git reset --hard HEAD)
# For some reason the deploy step below cannot find /sage/...
# So copy everything from there to local folder
# We also need to replace the symlinks because netlify is not following them
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index afd0406341c..41560674b49 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -33,13 +33,17 @@ jobs:
python-version: 3.9
- name: Install dependencies
- run: pip install tox pycodestyle relint
+ id: deps
+ run: pip install tox
- name: Code style check with pycodestyle
+ if: always() && steps.deps.outcome == 'success'
run: tox -e pycodestyle-minimal
- name: Code style check with relint
+ if: always() && steps.deps.outcome == 'success'
run: tox -e relint -- src/sage/
- name: Validate docstring markup as RST
+ if: always() && steps.deps.outcome == 'success'
run: tox -e rst
diff --git a/.github/workflows/sync_labels.yml b/.github/workflows/sync_labels.yml
index f9378d1fe9d..56fe526eb8e 100644
--- a/.github/workflows/sync_labels.yml
+++ b/.github/workflows/sync_labels.yml
@@ -29,6 +29,15 @@ jobs:
with:
files: .github/sync_labels.py
+ # Set special sync_labels bot token
+ - name: Get Tocken
+ run: |
+ TOKEN="${{ secrets.SYNC_LABELS_BOT_TOKEN }}"
+ if [ -z "$TOKEN" ]; then
+ TOKEN="${{ secrets.GITHUB_TOKEN }}"
+ fi
+ echo "TOKEN=$TOKEN" >> $GITHUB_ENV
+
# Perform synchronization
- name: Call script for synchronization
if: github.event.schedule == ''
@@ -36,7 +45,7 @@ jobs:
chmod a+x .github/sync_labels.py
.github/sync_labels.py $ACTION $ISSUE_URL $PR_URL $ACTOR "$LABEL" "$REV_STATE" $LOG_LEVEL
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ env.TOKEN }}
ACTION: ${{ github.event.action }}
ISSUE_URL: ${{ github.event.issue.html_url }}
PR_URL: ${{ github.event.pull_request.html_url }}
@@ -52,6 +61,6 @@ jobs:
chmod a+x .github/sync_labels.py
.github/sync_labels.py $REPO_URL $LOG_LEVEL
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ env.TOKEN }}
REPO_URL: ${{ github.event.repository.html_url }}
LOG_LEVEL: ${{ vars.SYNC_LABELS_LOG_LEVEL }} # variable from repository settings, values can be "--debug", "--info" or "--warning"
diff --git a/.vscode/settings.json b/.vscode/settings.json
index be90c535c32..050be4ca5e5 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -8,13 +8,14 @@
"src/**/*.so": true
},
"search.exclude": {
- "build/pkgs/sagemath_categories/src": true,
- "build/pkgs/sagemath_objects/src": true,
- "build/pkgs/sagelib/src": true,
- "pkgs/sage-conf_pypi/sage_root/build": true,
- "pkgs/sagemath-categories/sage": true,
- "pkgs/sagemath-objects/sage": true,
- "pkgs/sagemath-standard/sage": true
+ // Exclude symbolic links into SAGE_ROOT/pkgs/
+ "build/pkgs/*/src": true,
+ // Exclude symbolic links into SAGE_ROOT/src/
+ "pkgs/sage-conf_conda/sage_root": true,
+ "pkgs/sage-conf_pypi/sage_root": true,
+ "pkgs/sage-docbuild/sage_docbuild": true,
+ "pkgs/sage-setup/sage_setup": true,
+ "pkgs/sagemath-*/sage": true
},
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
diff --git a/CITATION.cff b/CITATION.cff
index 59a1b01420e..27438597f31 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -4,8 +4,8 @@ title: SageMath
abstract: SageMath is a free open-source mathematics software system.
authors:
- name: "The SageMath Developers"
-version: 10.2.beta8
+version: 10.2.beta9
doi: 10.5281/zenodo.593563
-date-released: 2023-10-21
+date-released: 2023-10-30
repository-code: "https://github.com/sagemath/sage"
url: "https://www.sagemath.org/"
diff --git a/README.md b/README.md
index 533e7ac54c7..495365af6eb 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ below](#sagemath-docker-images)) or other virtualization solutions.
If your Mac uses the Apple Silicon (M1, M2, arm64) architecture:
-- If you set up your Mac by transfering files from an older Mac, make sure
+- If you set up your Mac by transferring files from an older Mac, make sure
that the directory ``/usr/local`` does not contain an old copy of Homebrew
(or other software) for the x86_64 architecture that you may have copied
over. Note that Homebrew for the M1 is installed in ``/opt/homebrew``, not
diff --git a/VERSION.txt b/VERSION.txt
index 6c7fa387f09..b2bf34c0be8 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-SageMath version 10.2.beta8, Release Date: 2023-10-21
+SageMath version 10.2.beta9, Release Date: 2023-10-30
diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini
index 99e471b97f6..5b7360aa36d 100644
--- a/build/pkgs/configure/checksums.ini
+++ b/build/pkgs/configure/checksums.ini
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
-sha1=aa7054a0e6a582d2db1475dc47f63a54e6ac569f
-md5=40eab024557ad51e08dfb08e2753a465
-cksum=802824779
+sha1=0f90c993748bfc21ae382ac3ce6c19b434edb36c
+md5=b8d9355c732997566f68b60c8a8eb9cc
+cksum=2280021929
diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt
index f8291b5f3d7..d63934749a3 100644
--- a/build/pkgs/configure/package-version.txt
+++ b/build/pkgs/configure/package-version.txt
@@ -1 +1 @@
-c47788b02a42ef4907a0e61e702fbe9bbef27590
+c0221f90a86e4b4bea4b45ff8de54727313bd755
diff --git a/build/pkgs/cypari/checksums.ini b/build/pkgs/cypari/checksums.ini
index 998c8a5e962..3f87b3fabb8 100644
--- a/build/pkgs/cypari/checksums.ini
+++ b/build/pkgs/cypari/checksums.ini
@@ -1,5 +1,5 @@
tarball=cypari2-VERSION.tar.gz
-sha1=7208fd9d0b636ca7704d3b7d1167bc7c9af2637c
-md5=605b157123bd8a498d53572e8096bb8c
-cksum=2809951255
-upstream_url=https://pypi.io/packages/source/c/cypari2/cypari2-VERSION.tar.gz
+sha1=0af00b66e3f1b77e932ad9cade6e4e9dc6f21eaa
+md5=34c919aedb0a470c8b4e4b0c0ec788e3
+cksum=2760761148
+upstream_url=https://github.com/sagemath/cypari2/releases/download/VERSION/cypari2-VERSION.tar.gz
diff --git a/build/pkgs/cypari/package-version.txt b/build/pkgs/cypari/package-version.txt
index ac2cdeba013..7d2ed7c7020 100644
--- a/build/pkgs/cypari/package-version.txt
+++ b/build/pkgs/cypari/package-version.txt
@@ -1 +1 @@
-2.1.3
+2.1.4
diff --git a/build/pkgs/cypari/patches/cython3-legacy.patch b/build/pkgs/cypari/patches/cython3-legacy.patch
deleted file mode 100644
index 41392fe80d7..00000000000
--- a/build/pkgs/cypari/patches/cython3-legacy.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-commit 8ef356a4eb936c37f55a5c501f3a955e6740c0c5
-Author: Gonzalo Tornaría
-Date: Wed Jul 19 19:45:23 2023 -0300
-
- cython3 support using legacy directives
-
-diff --git a/cypari2/gen.pyx b/cypari2/gen.pyx
-index 247b1ad..75050a0 100644
---- a/cypari2/gen.pyx
-+++ b/cypari2/gen.pyx
-@@ -329,7 +329,7 @@ cdef class Gen(Gen_base):
- >>> pari = Pari()
- >>> L = pari("vector(10,i,i^2)")
- >>> L.__iter__()
--
-+ <...generator object at ...>
- >>> [x for x in L]
- [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
- >>> list(L)
-diff --git a/setup.py b/setup.py
-index 2188711..455337f 100755
---- a/setup.py
-+++ b/setup.py
-@@ -36,6 +36,8 @@ class build_ext(_build_ext):
- "binding": True,
- "cdivision": True,
- "language_level": 2,
-+ "legacy_implicit_noexcept": True,
-+ "c_api_binop_methods": True,
- }
-
- _build_ext.finalize_options(self)
diff --git a/build/pkgs/cython/checksums.ini b/build/pkgs/cython/checksums.ini
index 5d0bc66c242..a728e447c9b 100644
--- a/build/pkgs/cython/checksums.ini
+++ b/build/pkgs/cython/checksums.ini
@@ -1,5 +1,5 @@
tarball=Cython-VERSION.tar.gz
-sha1=08eb99f7c95b7ca667b1547575e7369d8064b4b3
-md5=00def3f2b96c393098e01eb2f1f169ad
-cksum=2321746451
+sha1=9924cb41152a854124c264e2046b3d48ec8207a5
+md5=9bafc611be35748b17a62f47bc479b35
+cksum=1074764487
upstream_url=https://pypi.io/packages/source/C/Cython/Cython-VERSION.tar.gz
diff --git a/build/pkgs/cython/package-version.txt b/build/pkgs/cython/package-version.txt
index b5021469305..b0f2dcb32fc 100644
--- a/build/pkgs/cython/package-version.txt
+++ b/build/pkgs/cython/package-version.txt
@@ -1 +1 @@
-3.0.2
+3.0.4
diff --git a/build/pkgs/cython/patches/5690.patch b/build/pkgs/cython/patches/5690.patch
deleted file mode 100644
index cc927879e1f..00000000000
--- a/build/pkgs/cython/patches/5690.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-diff --git a/Cython/Debugger/DebugWriter.py b/Cython/Debugger/DebugWriter.py
-index 8b1fb75b027..2c3c310fc64 100644
---- a/Cython/Debugger/DebugWriter.py
-+++ b/Cython/Debugger/DebugWriter.py
-@@ -18,6 +18,21 @@
- etree = None
-
- from ..Compiler import Errors
-+from ..Compiler.StringEncoding import EncodedString
-+
-+
-+def is_valid_tag(name):
-+ """
-+ Names like '.0' are used internally for arguments
-+ to functions creating generator expressions,
-+ however they are not identifiers.
-+
-+ See https://github.com/cython/cython/issues/5552
-+ """
-+ if isinstance(name, EncodedString):
-+ if name.startswith(".") and name[1:].isdecimal():
-+ return False
-+ return True
-
-
- class CythonDebugWriter(object):
-@@ -39,14 +54,17 @@ def __init__(self, output_dir):
- self.start('cython_debug', attrs=dict(version='1.0'))
-
- def start(self, name, attrs=None):
-- self.tb.start(name, attrs or {})
-+ if is_valid_tag(name):
-+ self.tb.start(name, attrs or {})
-
- def end(self, name):
-- self.tb.end(name)
-+ if is_valid_tag(name):
-+ self.tb.end(name)
-
- def add_entry(self, name, **attrs):
-- self.tb.start(name, attrs)
-- self.tb.end(name)
-+ if is_valid_tag(name):
-+ self.tb.start(name, attrs)
-+ self.tb.end(name)
-
- def serialize(self):
- self.tb.end('Module')
diff --git a/build/pkgs/fpylll/distros/conda.txt b/build/pkgs/fpylll/distros/conda.txt
index 8a3e3a7ecd0..aa483930c7a 100644
--- a/build/pkgs/fpylll/distros/conda.txt
+++ b/build/pkgs/fpylll/distros/conda.txt
@@ -1 +1 @@
-fpylll
+fpylll>=0.5.9
diff --git a/build/pkgs/fpylll/install-requires.txt b/build/pkgs/fpylll/install-requires.txt
index c97d0c2c71e..e040e7daa1e 100644
--- a/build/pkgs/fpylll/install-requires.txt
+++ b/build/pkgs/fpylll/install-requires.txt
@@ -1 +1 @@
-fpylll >=0.5.9, <=0.5.9
+fpylll >=0.5.9
diff --git a/build/pkgs/ipywidgets/distros/conda.txt b/build/pkgs/ipywidgets/distros/conda.txt
index f943f9d4979..162744f2841 100644
--- a/build/pkgs/ipywidgets/distros/conda.txt
+++ b/build/pkgs/ipywidgets/distros/conda.txt
@@ -1 +1 @@
-ipywidgets<8.0.0
+ipywidgets>=7.5.1
diff --git a/build/pkgs/jupyter_sphinx/checksums.ini b/build/pkgs/jupyter_sphinx/checksums.ini
index f53c5af453a..14f1bdf7594 100644
--- a/build/pkgs/jupyter_sphinx/checksums.ini
+++ b/build/pkgs/jupyter_sphinx/checksums.ini
@@ -1,5 +1,5 @@
tarball=jupyter_sphinx-VERSION.tar.gz
-sha1=241f6dfcd3aae4f44f330e2ba76480011b382d3d
-md5=e7ab370d9793be5b20bce5447ccbd45b
-cksum=2021246952
+sha1=fb2abdd5e35da0886b12d45a6373c4dbcc24b244
+md5=130daa6be810976c9f8e30aa04011e50
+cksum=2882523000
upstream_url=https://pypi.io/packages/source/j/jupyter_sphinx/jupyter_sphinx-VERSION.tar.gz
diff --git a/build/pkgs/jupyter_sphinx/package-version.txt b/build/pkgs/jupyter_sphinx/package-version.txt
index d15723fbe8d..8af2848288a 100644
--- a/build/pkgs/jupyter_sphinx/package-version.txt
+++ b/build/pkgs/jupyter_sphinx/package-version.txt
@@ -1 +1 @@
-0.3.2
+0.4.0.p0
diff --git a/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch
new file mode 100644
index 00000000000..afbb0c1273f
--- /dev/null
+++ b/build/pkgs/jupyter_sphinx/patches/0001-Patch-for-sage-live-doc.patch
@@ -0,0 +1,57 @@
+From 5bffbe38302c695123779f87300d84090b4bd118 Mon Sep 17 00:00:00 2001
+From: Kwankyu Lee
+Date: Mon, 28 Aug 2023 00:18:59 +0900
+Subject: [PATCH] Patch for sage live doc
+
+---
+ jupyter_sphinx/__init__.py | 4 ++--
+ jupyter_sphinx/execute.py | 11 +++++++++++
+ 2 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/jupyter_sphinx/__init__.py b/jupyter_sphinx/__init__.py
+index 34af884..b7ca8ee 100644
+--- a/jupyter_sphinx/__init__.py
++++ b/jupyter_sphinx/__init__.py
+@@ -31,7 +31,7 @@ from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSource
+ REQUIRE_URL_DEFAULT = (
+ "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"
+ )
+-THEBELAB_URL_DEFAULT = "https://unpkg.com/thebelab@^0.4.0"
++THEBELAB_URL_DEFAULT = "https://unpkg.com/thebe@latest/lib/index.js"
+
+ logger = logging.getLogger(__name__)
+
+@@ -186,7 +186,7 @@ def setup(app):
+ app.add_config_value("jupyter_sphinx_embed_url", None, "html")
+
+ # thebelab config, can be either a filename or a dict
+- app.add_config_value("jupyter_sphinx_thebelab_config", None, "html")
++ app.add_config_value("jupyter_sphinx_thebelab_config", None, "env")
+ app.add_config_value("jupyter_sphinx_thebelab_url", THEBELAB_URL_DEFAULT, "html")
+
+ # linenos config
+diff --git a/jupyter_sphinx/execute.py b/jupyter_sphinx/execute.py
+index 558a26b..de44455 100644
+--- a/jupyter_sphinx/execute.py
++++ b/jupyter_sphinx/execute.py
+@@ -152,6 +152,17 @@ class ExecuteJupyterCells(SphinxTransform):
+ kernel_name = default_kernel
+ file_name = next(default_names)
+
++ # Save time when jupyter notebook execution is not necessary
++ if not any(not "execute" in node or node["execute"] for node in nodes):
++ # mimics empty cell output for each node
++ for node in nodes:
++ source = node.children[0]
++ source.attributes["classes"].append("code_cell")
++ node.attributes["cm_language"] = kernel_name
++ node += CellOutputNode(classes=["cell_output"])
++ apply_styling(node, thebe_config)
++ continue
++
+ # Add empty placeholder cells for non-executed nodes so nodes
+ # and cells can be zipped and the provided input/output
+ # can be inserted later
+--
+2.42.0
+
diff --git a/build/pkgs/meson/checksums.ini b/build/pkgs/meson/checksums.ini
index 97e3fe2c251..bbb4661c960 100644
--- a/build/pkgs/meson/checksums.ini
+++ b/build/pkgs/meson/checksums.ini
@@ -1,5 +1,5 @@
tarball=meson-VERSION.tar.gz
-sha1=39b8a4bff467fdaa5f9ee87e04715bd97a148378
-md5=702bfd8b0648521322d3f145a8fc70ea
-cksum=399123386
+sha1=97e766951553ec35315712f0a27d5554a010d4c3
+md5=69da4c63ef06c9d3bcc00ce89abb306f
+cksum=2424401184
upstream_url=https://pypi.io/packages/source/m/meson/meson-VERSION.tar.gz
diff --git a/build/pkgs/meson/package-version.txt b/build/pkgs/meson/package-version.txt
index 23aa8390630..0495c4a88ca 100644
--- a/build/pkgs/meson/package-version.txt
+++ b/build/pkgs/meson/package-version.txt
@@ -1 +1 @@
-1.2.2
+1.2.3
diff --git a/build/pkgs/meson/spkg-configure.m4 b/build/pkgs/meson/spkg-configure.m4
index dbc575650fc..d85bd144a07 100644
--- a/build/pkgs/meson/spkg-configure.m4
+++ b/build/pkgs/meson/spkg-configure.m4
@@ -1,11 +1,12 @@
SAGE_SPKG_CONFIGURE(
[meson], [
dnl scipy 1.11.2 needs meson >= 1.1.0
- AC_CACHE_CHECK([for meson >= 1.1.0], [ac_cv_path_MESON], [
+ dnl contourpy needs meson >= 1.2.0
+ AC_CACHE_CHECK([for meson >= 1.2.0], [ac_cv_path_MESON], [
AC_PATH_PROGS_FEATURE_CHECK([MESON], [meson], [
meson_version=`$ac_path_MESON --version 2>&1`
AS_IF([test -n "$meson_version"], [
- AX_COMPARE_VERSION([$meson_version], [ge], [1.1.0], [
+ AX_COMPARE_VERSION([$meson_version], [ge], [1.2.0], [
ac_cv_path_MESON="$ac_path_MESON"
ac_path_MESON_found=:
])
diff --git a/build/pkgs/nauty/checksums.ini b/build/pkgs/nauty/checksums.ini
index 644f4b75146..a9dd1246e91 100644
--- a/build/pkgs/nauty/checksums.ini
+++ b/build/pkgs/nauty/checksums.ini
@@ -1,5 +1,5 @@
tarball=nautyVERSION.tar.gz
-sha1=c9fd2b4c99b8c624e430f3f4e1492a4219e3495e
-md5=2ead635a417e20a18b3aabee83fac1ef
-cksum=718823455
-upstream_url=http://pallini.di.uniroma1.it/nauty27r1.tar.gz
+sha1=10c39117c55c69c18c6a107110e7c08f3d873652
+md5=7a82f4209f5d552da3078c67e5af872e
+cksum=2164796643
+upstream_url=https://pallini.di.uniroma1.it/nauty2_8_6.tar.gz
diff --git a/build/pkgs/nauty/package-version.txt b/build/pkgs/nauty/package-version.txt
index 9a8067baa68..b6b3dcc5aa0 100644
--- a/build/pkgs/nauty/package-version.txt
+++ b/build/pkgs/nauty/package-version.txt
@@ -1 +1 @@
-27r1.p1
+2.8.6.p0
diff --git a/build/pkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch b/build/pkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch
new file mode 100644
index 00000000000..322b25326ee
--- /dev/null
+++ b/build/pkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch
@@ -0,0 +1,144 @@
+From edb0474a4db8e69f971e4eebe18716309f5a7bb3 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky
+Date: Tue, 17 Jan 2023 19:44:49 -0500
+Subject: [PATCH 1/1] Upstream fixes for gentreeg and gentourng.
+
+https://mailman.anu.edu.au/pipermail/nauty/2023-January/000903.html
+---
+ gentourng.c | 2 +-
+ gentreeg.c | 95 ++++++++++++++++++++++++++++-------------------------
+ 2 files changed, 51 insertions(+), 46 deletions(-)
+
+diff --git a/gentourng.c b/gentourng.c
+index 634e5e8..5c7ffff 100644
+--- a/gentourng.c
++++ b/gentourng.c
+@@ -1408,7 +1408,7 @@ PLUGIN_INIT
+ (*outproc)(outfile,g,1);
+ }
+ }
+- else
++ else if (!connec || maxn != 2)
+ {
+ makeleveldata();
+
+diff --git a/gentreeg.c b/gentreeg.c
+index 946d5f8..15bf87b 100644
+--- a/gentreeg.c
++++ b/gentreeg.c
+@@ -1,4 +1,4 @@
+-/* gentree version 1.3; Brendan McKay Oct 2022 */
++/* gentree version 1.4; Brendan McKay Dec 2022 */
+ /* This program is a wrapper for the program FreeTrees.c written
+ * by Gang Li & Frank Ruskey. See below for their original
+ * comments. */
+@@ -32,49 +32,54 @@ Counts for n=1..45:
+ 1: 1
+ 2: 1
+ 3: 1
+- 4: 1
+- 5: 2
+- 6: 3
+- 7: 6
+- 8: 11
+- 9: 23
+-10: 47
+-11: 106
+-12: 235
+-13: 551
+-14: 1301
+-15: 3159
+-16: 7741
+-17: 19320
+-18: 48629
+-19: 123867
+-20: 317955
+-21: 823065
+-22: 2144505
+-23: 5623756
+-24: 14828074
+-25: 39299897
+-26: 104636890
+-27: 279793450
+-28: 751065460
+-29: 2023443032
+-30: 5469566585
+-31: 14830871802
+-32: 40330829030
+-33: 109972410221
+-34: 300628862480
+-35: 823779631721
+-36: 2262366343746
+-37: 6226306037178
+-38: 17169677490714
+-39: 47436313524262
+-40: 131290543779126
+-41: 363990257783343
+-42: 1010748076717151
+-43: 2810986483493475
+-44: 7828986221515605
+-45: 21835027912963086
+-********************************/
++ 4: 2
++ 5: 3
++ 6: 6
++ 7: 11
++ 8: 23
++ 9: 47
++10: 106
++11: 235
++12: 551
++13: 1301
++14: 3159
++15: 7741
++16: 19320
++17: 48629
++18: 123867
++19: 317955
++20: 823065
++21: 2144505
++22: 5623756
++23: 14828074
++24: 39299897
++25: 104636890
++26: 279793450
++27: 751065460
++28: 2023443032
++29: 5469566585
++30: 14830871802
++31: 40330829030
++32: 109972410221
++33: 300628862480
++34: 823779631721
++35: 2262366343746
++36: 6226306037178
++37: 17169677490714
++38: 47436313524262
++39: 131290543779126
++40: 363990257783343
++41: 1010748076717151
++42: 2810986483493475
++43: 7828986221515605
++44: 21835027912963086
++45: 60978390985918906
++46: 170508699155987862
++47: 477355090753926460
++48: 1337946100045842285
++49: 3754194185716399992
++50: 10545233702911509534
++*******************************/
+
+ /* Comments on original program by original authors */
+ /*==============================================================*/
+@@ -676,7 +681,7 @@ PLUGIN_INIT
+ }
+ else if (nv == 2)
+ {
+- if (res == 0 && maxdeg >= 1 && mindiam <= 1 && maxdiam >= 2)
++ if (res == 0 && maxdeg >= 1 && mindiam <= 1 && maxdiam >= 1)
+ {
+ par[1] = 0;
+ par[2] = 1;
+--
+2.38.2
+
diff --git a/build/pkgs/nauty/spkg-configure.m4 b/build/pkgs/nauty/spkg-configure.m4
index d986105f2e3..4d5bbcf2091 100644
--- a/build/pkgs/nauty/spkg-configure.m4
+++ b/build/pkgs/nauty/spkg-configure.m4
@@ -1,8 +1,12 @@
# We don't use the "converseg" program, but we need to ensure that we
# only detect nauty >= 2.6 because we use the digraph6 format from
# that version -- and converseg was added in nauty-2.6.
+#
+# We also don't use the "genposetg" program (added in nauty 2.8) yet.
+# We require it here to prepare Sage for the use of the major new features
+# added in 2.7 and 2.8 (https://pallini.di.uniroma1.it/changes24-28.txt).
AC_DEFUN([SAGE_TEST_NAUTY_PROGS], [
- m4_foreach([nautyprog], [directg, gentourng, geng, genbg, gentreeg, converseg], [
+ m4_foreach([nautyprog], [directg, gentourng, geng, genbg, gentreeg, converseg, genposetg], [
AC_PATH_PROG([$2]nautyprog, [[$1]nautyprog])
AS_IF([test x$[$2]nautyprog = x], [sage_spkg_install_nauty=yes])
])
diff --git a/build/pkgs/nauty/spkg-install.in b/build/pkgs/nauty/spkg-install.in
index 6b25ac9d2ea..cf685ba5370 100644
--- a/build/pkgs/nauty/spkg-install.in
+++ b/build/pkgs/nauty/spkg-install.in
@@ -7,10 +7,10 @@ sdh_make
# No install target so we resort to manual copy
PROGRAMS="
-addedgeg amtog biplabg catg complg converseg copyg countg cubhamg deledgeg
-delptg directg dreadnaut dretodot dretog genbg genbgL geng genquarticg genrang
-genspecialg gentourng gentreeg hamheuristic labelg linegraphg listg multig
-newedgeg pickg planarg ranlabg shortg showg subdivideg twohamg vcolg
+addedgeg addptg amtog ancestorg assembleg biplabg catg complg converseg copyg countg cubhamg deledgeg
+delptg dimacs2g directg dreadnaut dretodot dretog edgetransg genbg genbgL geng gengL genposetg genquarticg genrang
+genspecialg gentourng gentreeg hamheuristic labelg linegraphg listg multig nbrhoodg
+newedgeg pickg planarg productg ranlabg shortg showg subdivideg twohamg underlyingg vcolg
watercluster2 NRswitchg"
sdh_install $PROGRAMS "$SAGE_LOCAL/bin"
diff --git a/build/pkgs/networkx/distros/conda.txt b/build/pkgs/networkx/distros/conda.txt
index 67cbec89b21..96b0bbb2845 100644
--- a/build/pkgs/networkx/distros/conda.txt
+++ b/build/pkgs/networkx/distros/conda.txt
@@ -1 +1 @@
-networkx<3.0,>=2.4
+networkx<3.2,>=2.4
diff --git a/build/pkgs/numpy/checksums.ini b/build/pkgs/numpy/checksums.ini
index 886bc13768b..67c13061038 100644
--- a/build/pkgs/numpy/checksums.ini
+++ b/build/pkgs/numpy/checksums.ini
@@ -1,5 +1,5 @@
tarball=numpy-VERSION.tar.gz
-sha1=a3f9d79d7852f5d35ff35693fc31d17ea270d2d0
-md5=69bd28f07afbeed2bb6ecd467afcd469
-cksum=3599108965
+sha1=00f8e85fae2e2ccf8afa78e8da3a058831230ef1
+md5=2d770f4c281d405b690c4bcb3dbe99e2
+cksum=1663231076
upstream_url=https://pypi.io/packages/source/n/numpy/numpy-VERSION.tar.gz
diff --git a/build/pkgs/numpy/package-version.txt b/build/pkgs/numpy/package-version.txt
index 5ff8c4f5d2a..dd43a143f02 100644
--- a/build/pkgs/numpy/package-version.txt
+++ b/build/pkgs/numpy/package-version.txt
@@ -1 +1 @@
-1.26.0
+1.26.1
diff --git a/build/pkgs/openssl/checksums.ini b/build/pkgs/openssl/checksums.ini
index a443f001e4a..9a4767ed76c 100644
--- a/build/pkgs/openssl/checksums.ini
+++ b/build/pkgs/openssl/checksums.ini
@@ -1,5 +1,5 @@
tarball=openssl-VERSION.tar.gz
-sha1=580d8a7232327fe1fa6e7db54ac060d4321f40ab
-md5=61e017cf4fea1b599048f621f1490fbd
-cksum=1708357994
+sha1=b48e20c07facfdf6da9ad43a6c5126d51897699b
+md5=e6a199cdf867873eef2c6491b674edbc
+cksum=391245670
upstream_url=https://www.openssl.org/source/openssl-VERSION.tar.gz
diff --git a/build/pkgs/openssl/package-version.txt b/build/pkgs/openssl/package-version.txt
index 67786e246ef..f93fc9f42ea 100644
--- a/build/pkgs/openssl/package-version.txt
+++ b/build/pkgs/openssl/package-version.txt
@@ -1 +1 @@
-3.0.8
+3.0.12
diff --git a/build/pkgs/packaging/checksums.ini b/build/pkgs/packaging/checksums.ini
index 83ab122e324..7d9afce62d3 100644
--- a/build/pkgs/packaging/checksums.ini
+++ b/build/pkgs/packaging/checksums.ini
@@ -1,5 +1,5 @@
tarball=packaging-VERSION.tar.gz
-sha1=1245c28c10ae6cb80164f081daece224b6fa89bc
-md5=f7d5c39c6f92cc2dfa1293ba8f6c097c
-cksum=11867377
+sha1=603cbd6e3416f1f4b6c0f924216f96fe67d9f6da
+md5=d54eeff8c7ca86980528f4132f258d54
+cksum=307392791
upstream_url=https://pypi.io/packages/source/p/packaging/packaging-VERSION.tar.gz
diff --git a/build/pkgs/packaging/package-version.txt b/build/pkgs/packaging/package-version.txt
index a12b18e4372..3c8ce91a469 100644
--- a/build/pkgs/packaging/package-version.txt
+++ b/build/pkgs/packaging/package-version.txt
@@ -1 +1 @@
-23.1
+23.2
diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
index d72e5246cf7..b6fc05baa1a 100644
--- a/build/pkgs/pari/checksums.ini
+++ b/build/pkgs/pari/checksums.ini
@@ -1,5 +1,5 @@
tarball=pari-VERSION.tar.gz
-sha1=498e3cd0b7ded8be3fa1cba1125ca5213ed39453
-md5=562a6e973ca3980dc6c1eb2c4f252e92
-cksum=4081416981
+sha1=ae962671b5bf86849d2021113dfb5b2f59331a10
+md5=4ab5c81d93f4bccb94e483b8b48fc336
+cksum=598072677
upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
index c06afc0ba5f..86fbeafcc20 100644
--- a/build/pkgs/pari/package-version.txt
+++ b/build/pkgs/pari/package-version.txt
@@ -1 +1 @@
-2.15.2.p1
+2.15.4
diff --git a/build/pkgs/pari/patches/bug2441.patch b/build/pkgs/pari/patches/bug2441.patch
deleted file mode 100644
index 01047180d19..00000000000
--- a/build/pkgs/pari/patches/bug2441.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/src/basemath/ellsea.c b/src/basemath/ellsea.c
-index a6871fa6a7..05f148eadd 100644
---- a/src/basemath/ellsea.c
-+++ b/src/basemath/ellsea.c
-@@ -852,7 +852,8 @@ find_isogenous_from_Atkin(GEN a4, GEN a6, ulong ell, struct meqn *MEQN, GEN g, G
- GEN a4t, a6t, h;
- a4a6t(&a4t, &a6t, ell, E4t, E6t, T, p);
- h = find_kernel(a4, a6, ell, a4t, a6t, pp1, T, p, pp, e);
-- if (h) return gerepilecopy(ltop, mkvec3(a4t, a6t, h));
-+ if (h && signe(Fq_elldivpolmod(a4, a6, ell, h, T, pp))==0)
-+ return gerepilecopy(ltop, mkvec3(a4t, a6t, h));
- }
- }
- pari_err_BUG("find_isogenous_from_Atkin, kernel not found");
diff --git a/build/pkgs/pari/spkg-configure.m4 b/build/pkgs/pari/spkg-configure.m4
index e1a022a26ab..1404defc518 100644
--- a/build/pkgs/pari/spkg-configure.m4
+++ b/build/pkgs/pari/spkg-configure.m4
@@ -67,6 +67,25 @@ SAGE_SPKG_CONFIGURE([pari], [
AC_MSG_NOTICE([Otherwise Sage will build its own pari/GP.])
sage_spkg_install_pari=yes
fi
+
+ AC_MSG_CHECKING([whether factor() bug 2469 of pari 2.15.3 is fixed])
+ result=`echo "f=factor(2^2203-1); print(\"ok\")" | timeout 1 $GP -qf`
+ if test x"$result" = xok; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no; cannot use system pari/GP with known bug])
+ sage_spkg_install_pari=yes
+ fi
+
+ AC_MSG_CHECKING([whether qfbclassno() bug 2466 of pari 2.15.3 is fixed])
+ result=`echo "qfbclassno(33844)" | $GP -qf`
+ if test x"$result" = x3; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no; cannot use system pari/GP with known bug])
+ sage_spkg_install_pari=yes
+ fi
+
fi dnl end GP test
if test x$sage_spkg_install_pari = xno; then dnl main PARI test
diff --git a/build/pkgs/patchelf/distros/conda.txt b/build/pkgs/patchelf/distros/conda.txt
deleted file mode 100644
index fca4680084f..00000000000
--- a/build/pkgs/patchelf/distros/conda.txt
+++ /dev/null
@@ -1 +0,0 @@
-patchelf
diff --git a/build/pkgs/pip/checksums.ini b/build/pkgs/pip/checksums.ini
index 9b6376d1abb..52c2edb31f2 100644
--- a/build/pkgs/pip/checksums.ini
+++ b/build/pkgs/pip/checksums.ini
@@ -1,5 +1,5 @@
tarball=pip-VERSION.tar.gz
-sha1=4bdfd8e976b5122cf55f4f4740f7305f1ffa4310
-md5=e9b1226701a56ee3fcc81aba60d25d75
-cksum=1940746834
+sha1=d1400a4eb662e4741ac68957f47bc97d600743f8
+md5=f0c9fba61e9d9badcc9921062e993d84
+cksum=309527365
upstream_url=https://pypi.io/packages/source/p/pip/pip-VERSION.tar.gz
diff --git a/build/pkgs/pip/install-requires.txt b/build/pkgs/pip/install-requires.txt
index 5e76a10f694..25a92d4b832 100644
--- a/build/pkgs/pip/install-requires.txt
+++ b/build/pkgs/pip/install-requires.txt
@@ -1,3 +1,4 @@
-pip >=22.1
+pip >=23.1.0
# for use of the "in-tree-build" feature, default since 21.3, by the Sage distribution
# for use of --config-settings, 22.1
+# for use of -C as a shortcut for --config-settings, 23.1.0
diff --git a/build/pkgs/pip/package-version.txt b/build/pkgs/pip/package-version.txt
index 3f833b5b536..a9a57c82265 100644
--- a/build/pkgs/pip/package-version.txt
+++ b/build/pkgs/pip/package-version.txt
@@ -1 +1 @@
-23.2.1
+23.3.1
diff --git a/build/pkgs/platformdirs/checksums.ini b/build/pkgs/platformdirs/checksums.ini
index 288483e8fc2..99113c48626 100644
--- a/build/pkgs/platformdirs/checksums.ini
+++ b/build/pkgs/platformdirs/checksums.ini
@@ -1,5 +1,5 @@
tarball=platformdirs-VERSION.tar.gz
-sha1=c4e0f8486e67a97affbc1b6b267a1f196c4177fa
-md5=1c1c8c05e9bc370b78e0a95103523b75
-cksum=4231977838
+sha1=82e215dc9c45eedf9168584fede36d795714f677
+md5=a6ba3a442347fac346982acb597c8bf8
+cksum=2465457023
upstream_url=https://pypi.io/packages/source/p/platformdirs/platformdirs-VERSION.tar.gz
diff --git a/build/pkgs/platformdirs/package-version.txt b/build/pkgs/platformdirs/package-version.txt
index 30291cba223..afad818663d 100644
--- a/build/pkgs/platformdirs/package-version.txt
+++ b/build/pkgs/platformdirs/package-version.txt
@@ -1 +1 @@
-3.10.0
+3.11.0
diff --git a/build/pkgs/sage_conf/install-requires.txt b/build/pkgs/sage_conf/install-requires.txt
index af1494990e7..1387216d0d4 100644
--- a/build/pkgs/sage_conf/install-requires.txt
+++ b/build/pkgs/sage_conf/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-conf ~= 10.2b8
+sage-conf ~= 10.2b9
diff --git a/build/pkgs/sage_docbuild/install-requires.txt b/build/pkgs/sage_docbuild/install-requires.txt
index 3cd4fa3a1cc..530594cb2f7 100644
--- a/build/pkgs/sage_docbuild/install-requires.txt
+++ b/build/pkgs/sage_docbuild/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-docbuild ~= 10.2b8
+sage-docbuild ~= 10.2b9
diff --git a/build/pkgs/sage_setup/install-requires.txt b/build/pkgs/sage_setup/install-requires.txt
index 513270bef9b..5a9a50b1773 100644
--- a/build/pkgs/sage_setup/install-requires.txt
+++ b/build/pkgs/sage_setup/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-setup ~= 10.2b8
+sage-setup ~= 10.2b9
diff --git a/build/pkgs/sage_sws2rst/install-requires.txt b/build/pkgs/sage_sws2rst/install-requires.txt
index 59a489617cb..8f0dd4150d7 100644
--- a/build/pkgs/sage_sws2rst/install-requires.txt
+++ b/build/pkgs/sage_sws2rst/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-sws2rst ~= 10.2b8
+sage-sws2rst ~= 10.2b9
diff --git a/build/pkgs/sagelib/install-requires.txt b/build/pkgs/sagelib/install-requires.txt
index 254cd68ca8b..fe389de2e2e 100644
--- a/build/pkgs/sagelib/install-requires.txt
+++ b/build/pkgs/sagelib/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-standard ~= 10.2b8
+sagemath-standard ~= 10.2b9
diff --git a/build/pkgs/sagemath_bliss/install-requires.txt b/build/pkgs/sagemath_bliss/install-requires.txt
index eb77a2780ee..dabe7e52643 100644
--- a/build/pkgs/sagemath_bliss/install-requires.txt
+++ b/build/pkgs/sagemath_bliss/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-bliss ~= 10.2b8
+sagemath-bliss ~= 10.2b9
diff --git a/build/pkgs/sagemath_categories/install-requires.txt b/build/pkgs/sagemath_categories/install-requires.txt
index e087dd7435e..eab5b455322 100644
--- a/build/pkgs/sagemath_categories/install-requires.txt
+++ b/build/pkgs/sagemath_categories/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-categories ~= 10.2b8
+sagemath-categories ~= 10.2b9
diff --git a/build/pkgs/sagemath_coxeter3/install-requires.txt b/build/pkgs/sagemath_coxeter3/install-requires.txt
index 5fbdb88a3e4..c07ca4d5a32 100644
--- a/build/pkgs/sagemath_coxeter3/install-requires.txt
+++ b/build/pkgs/sagemath_coxeter3/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-coxeter3 ~= 10.2b8
+sagemath-coxeter3 ~= 10.2b9
diff --git a/build/pkgs/sagemath_environment/install-requires.txt b/build/pkgs/sagemath_environment/install-requires.txt
index 16b0a20b583..7745d13c50c 100644
--- a/build/pkgs/sagemath_environment/install-requires.txt
+++ b/build/pkgs/sagemath_environment/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-environment ~= 10.2b8
+sagemath-environment ~= 10.2b9
diff --git a/build/pkgs/sagemath_mcqd/install-requires.txt b/build/pkgs/sagemath_mcqd/install-requires.txt
index cc5aee92b75..34d46c650c9 100644
--- a/build/pkgs/sagemath_mcqd/install-requires.txt
+++ b/build/pkgs/sagemath_mcqd/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-mcqd ~= 10.2b8
+sagemath-mcqd ~= 10.2b9
diff --git a/build/pkgs/sagemath_meataxe/install-requires.txt b/build/pkgs/sagemath_meataxe/install-requires.txt
index 952fc3c6fa8..3012f831c3a 100644
--- a/build/pkgs/sagemath_meataxe/install-requires.txt
+++ b/build/pkgs/sagemath_meataxe/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-meataxe ~= 10.2b8
+sagemath-meataxe ~= 10.2b9
diff --git a/build/pkgs/sagemath_objects/install-requires.txt b/build/pkgs/sagemath_objects/install-requires.txt
index 1c578b75a97..35022da8fde 100644
--- a/build/pkgs/sagemath_objects/install-requires.txt
+++ b/build/pkgs/sagemath_objects/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-objects ~= 10.2b8
+sagemath-objects ~= 10.2b9
diff --git a/build/pkgs/sagemath_repl/install-requires.txt b/build/pkgs/sagemath_repl/install-requires.txt
index b2037903a68..4c33d1b3eb0 100644
--- a/build/pkgs/sagemath_repl/install-requires.txt
+++ b/build/pkgs/sagemath_repl/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-repl ~= 10.2b8
+sagemath-repl ~= 10.2b9
diff --git a/build/pkgs/sagemath_sirocco/install-requires.txt b/build/pkgs/sagemath_sirocco/install-requires.txt
index c62e361e6aa..bd55a958d68 100644
--- a/build/pkgs/sagemath_sirocco/install-requires.txt
+++ b/build/pkgs/sagemath_sirocco/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-sirocco ~= 10.2b8
+sagemath-sirocco ~= 10.2b9
diff --git a/build/pkgs/sagemath_tdlib/install-requires.txt b/build/pkgs/sagemath_tdlib/install-requires.txt
index 745ea5ccfe1..2e291c70e25 100644
--- a/build/pkgs/sagemath_tdlib/install-requires.txt
+++ b/build/pkgs/sagemath_tdlib/install-requires.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-tdlib ~= 10.2b8
+sagemath-tdlib ~= 10.2b9
diff --git a/build/pkgs/sagenb_export/install-requires.txt b/build/pkgs/sagenb_export/install-requires.txt
index 0592ab651b1..9c94d6990d1 100644
--- a/build/pkgs/sagenb_export/install-requires.txt
+++ b/build/pkgs/sagenb_export/install-requires.txt
@@ -1 +1 @@
-sagenb_export >=3.3
+git+https://github.com/vbraun/ExportSageNB.git#egg=sagenb_export
diff --git a/build/pkgs/scipy/distros/conda.txt b/build/pkgs/scipy/distros/conda.txt
index 21b2670008a..175cd197f8c 100644
--- a/build/pkgs/scipy/distros/conda.txt
+++ b/build/pkgs/scipy/distros/conda.txt
@@ -1 +1 @@
-scipy<1.11,>=1.5
+scipy<1.12,>=1.5
diff --git a/build/pkgs/wheel/checksums.ini b/build/pkgs/wheel/checksums.ini
index b01f275c477..b12a1973b0c 100644
--- a/build/pkgs/wheel/checksums.ini
+++ b/build/pkgs/wheel/checksums.ini
@@ -1,5 +1,5 @@
tarball=wheel-VERSION.tar.gz
-sha1=ff9a5efeabf8e73e8b1a8646eaa829154f834726
-md5=83bb4e7bd4d687d398733f341a64ab91
-cksum=518943238
+sha1=34a787f7069762e267e5ed62ed31cc9c87ea910b
+md5=06271a9e90c948b7e93dd7ce0fd90272
+cksum=444550709
upstream_url=https://pypi.io/packages/source/w/wheel/wheel-VERSION.tar.gz
diff --git a/build/pkgs/wheel/package-version.txt b/build/pkgs/wheel/package-version.txt
index 87f0b954e35..6599454d402 100644
--- a/build/pkgs/wheel/package-version.txt
+++ b/build/pkgs/wheel/package-version.txt
@@ -1 +1 @@
-0.38.4
+0.41.2
diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sage-conf/VERSION.txt
+++ b/pkgs/sage-conf/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sage-conf_conda/VERSION.txt
+++ b/pkgs/sage-conf_conda/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sage-conf_pypi/VERSION.txt
+++ b/pkgs/sage-conf_pypi/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sage-docbuild/VERSION.txt
+++ b/pkgs/sage-docbuild/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sage-setup/VERSION.txt
+++ b/pkgs/sage-setup/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sage-sws2rst/VERSION.txt
+++ b/pkgs/sage-sws2rst/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-bliss/MANIFEST.in b/pkgs/sagemath-bliss/MANIFEST.in
index 6d981b9d30e..2572c2b46f7 100644
--- a/pkgs/sagemath-bliss/MANIFEST.in
+++ b/pkgs/sagemath-bliss/MANIFEST.in
@@ -1,6 +1,9 @@
+prune sage
+
include VERSION.txt
graft sage/graphs/bliss_cpp
+include sage/graphs/bliss.p*
global-exclude *.c
global-exclude *.cpp
diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-bliss/VERSION.txt
+++ b/pkgs/sagemath-bliss/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-categories/VERSION.txt
+++ b/pkgs/sagemath-categories/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-coxeter3/VERSION.txt
+++ b/pkgs/sagemath-coxeter3/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-environment/VERSION.txt
+++ b/pkgs/sagemath-environment/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-mcqd/VERSION.txt
+++ b/pkgs/sagemath-mcqd/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-meataxe/VERSION.txt
+++ b/pkgs/sagemath-meataxe/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-objects/VERSION.txt
+++ b/pkgs/sagemath-objects/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-repl/VERSION.txt
+++ b/pkgs/sagemath-repl/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-sirocco/MANIFEST.in b/pkgs/sagemath-sirocco/MANIFEST.in
index 815a868524d..8ac89baa796 100644
--- a/pkgs/sagemath-sirocco/MANIFEST.in
+++ b/pkgs/sagemath-sirocco/MANIFEST.in
@@ -1,5 +1,9 @@
+prune sage
+
include VERSION.txt
+include sage/libs/sirocco.p*
+
global-exclude *.c
global-exclude *.cpp
diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-sirocco/VERSION.txt
+++ b/pkgs/sagemath-sirocco/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/pkgs/sagemath-tdlib/MANIFEST.in b/pkgs/sagemath-tdlib/MANIFEST.in
index 614186d89ab..156e1c3b85a 100644
--- a/pkgs/sagemath-tdlib/MANIFEST.in
+++ b/pkgs/sagemath-tdlib/MANIFEST.in
@@ -1,9 +1,12 @@
+prune sage
+
include VERSION.txt
global-exclude *.c
global-exclude *.cpp
include sage/graphs/graph_decompositions/sage_tdlib.cpp
+include sage/graphs/graph_decompositions/tdlib.p*
global-exclude all__sagemath_*.*
global-include all__sagemath_tdlib.py
diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/pkgs/sagemath-tdlib/VERSION.txt
+++ b/pkgs/sagemath-tdlib/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/src/MANIFEST.in b/src/MANIFEST.in
index bbed8838199..07a135dbf07 100644
--- a/src/MANIFEST.in
+++ b/src/MANIFEST.in
@@ -49,6 +49,7 @@ prune sage/graphs/bliss_cpp
prune sage/libs/coxeter3
exclude sage/graphs/mcqd.p*
exclude sage/libs/meataxe.p*
+exclude sage/libs/sirocco.p*
exclude sage/matrix/matrix_gfpn_dense.p*
exclude sage/graphs/graph_decomposition/tdlib.p*
diff --git a/src/VERSION.txt b/src/VERSION.txt
index 66f8b2a93e1..d0cd2bc56e3 100644
--- a/src/VERSION.txt
+++ b/src/VERSION.txt
@@ -1 +1 @@
-10.2.beta8
+10.2.beta9
diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
index 2e8b12e1a1c..801b0a6a6a3 100755
--- a/src/bin/sage-notebook
+++ b/src/bin/sage-notebook
@@ -29,7 +29,12 @@ class NotebookJupyter():
def __init__(self, argv):
self.print_banner()
try:
- from notebook.notebookapp import main
+ try:
+ # notebook 6
+ from notebook.notebookapp import main
+ except ImportError:
+ # notebook 7
+ from notebook.app import main
except ImportError:
import traceback
traceback.print_exc()
diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh
index e627d6e96d2..392f585e5de 100644
--- a/src/bin/sage-version.sh
+++ b/src/bin/sage-version.sh
@@ -4,6 +4,6 @@
# which stops "setup.py develop" from rewriting it as a Python file.
:
# This file is auto-generated by the sage-update-version script, do not edit!
-SAGE_VERSION='10.2.beta8'
-SAGE_RELEASE_DATE='2023-10-21'
-SAGE_VERSION_BANNER='SageMath version 10.2.beta8, Release Date: 2023-10-21'
+SAGE_VERSION='10.2.beta9'
+SAGE_RELEASE_DATE='2023-10-30'
+SAGE_VERSION_BANNER='SageMath version 10.2.beta9, Release Date: 2023-10-30'
diff --git a/src/doc/common/static/custom-codemirror-monokai.css b/src/doc/common/static/custom-codemirror-monokai.css
new file mode 100644
index 00000000000..3489e3d61e5
--- /dev/null
+++ b/src/doc/common/static/custom-codemirror-monokai.css
@@ -0,0 +1,42 @@
+/* from https://codemirror.net/5/theme/monokai.css */
+/* Based on Sublime Text's Monokai theme */
+
+.cm-s-monokai.CodeMirror { background: #272822; color: #f8f8f2; }
+.cm-s-monokai div.CodeMirror-selected { background: #49483E; }
+.cm-s-monokai .CodeMirror-line::selection, .cm-s-monokai .CodeMirror-line > span::selection, .cm-s-monokai .CodeMirror-line > span > span::selection { background: rgba(73, 72, 62, .99); }
+.cm-s-monokai .CodeMirror-line::-moz-selection, .cm-s-monokai .CodeMirror-line > span::-moz-selection, .cm-s-monokai .CodeMirror-line > span > span::-moz-selection { background: rgba(73, 72, 62, .99); }
+.cm-s-monokai .CodeMirror-gutters { background: #272822; border-right: 0px; }
+.cm-s-monokai .CodeMirror-guttermarker { color: white; }
+.cm-s-monokai .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
+.cm-s-monokai .CodeMirror-linenumber { color: #d0d0d0; }
+.cm-s-monokai .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }
+
+.cm-s-monokai span.cm-comment { color: #75715e; }
+.cm-s-monokai span.cm-atom { color: #ae81ff; }
+.cm-s-monokai span.cm-number { color: #ae81ff; }
+
+.cm-s-monokai span.cm-comment.cm-attribute { color: #97b757; }
+.cm-s-monokai span.cm-comment.cm-def { color: #bc9262; }
+.cm-s-monokai span.cm-comment.cm-tag { color: #bc6283; }
+.cm-s-monokai span.cm-comment.cm-type { color: #5998a6; }
+
+.cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute { color: #a6e22e; }
+.cm-s-monokai span.cm-keyword { color: #f92672; }
+.cm-s-monokai span.cm-builtin { color: #66d9ef; }
+.cm-s-monokai span.cm-string { color: #e6db74; }
+
+.cm-s-monokai span.cm-variable { color: #f8f8f2; }
+.cm-s-monokai span.cm-variable-2 { color: #9effff; }
+.cm-s-monokai span.cm-variable-3, .cm-s-monokai span.cm-type { color: #66d9ef; }
+.cm-s-monokai span.cm-def { color: #fd971f; }
+.cm-s-monokai span.cm-bracket { color: #f8f8f2; }
+.cm-s-monokai span.cm-tag { color: #f92672; }
+.cm-s-monokai span.cm-header { color: #ae81ff; }
+.cm-s-monokai span.cm-link { color: #ae81ff; }
+.cm-s-monokai span.cm-error { background: #f92672; color: #f8f8f0; }
+
+.cm-s-monokai .CodeMirror-activeline-background { background: #373831; }
+.cm-s-monokai .CodeMirror-matchingbracket {
+ text-decoration: underline;
+ color: white !important;
+}
diff --git a/src/doc/common/static/custom-jupyter-sphinx.css b/src/doc/common/static/custom-jupyter-sphinx.css
new file mode 100644
index 00000000000..a68a5cb05aa
--- /dev/null
+++ b/src/doc/common/static/custom-jupyter-sphinx.css
@@ -0,0 +1,140 @@
+div.jupyter_container {
+ margin: .5rem 0;
+}
+
+div.jupyter_container + div.jupyter_container {
+ margin: 0 0 .5rem 0;
+}
+
+div.jupyter_container div.cell_input pre {
+ margin: .5rem;
+}
+
+div.jupyter_container div.cell_output div.output {
+ margin: .5rem;
+}
+
+.thebelab-cell .jp-OutputArea {
+ margin: 0 .5rem;
+}
+
+.thebelab-cell .jp-OutputArea-output {
+ margin: 0 0 .5rem 0;
+ overflow-x: auto;
+}
+
+.thebelab-button {
+ margin: .5rem 0 .5rem .5rem;
+ padding: 0 .5rem;
+ min-width: 2rem;
+}
+
+.thebelab-button:active {
+ color: #0f0fff;
+}
+
+.thebelab-busy {
+ margin-left: .5rem;
+}
+
+#thebelab-activate-button {
+ position: fixed;
+ right: -5.1rem;
+ top: calc(50% - 1.5rem);
+ width: 6rem;
+ border-radius: 1rem;
+ transition-property: right;
+ transition-duration: 300ms;
+ transition-timing-function: ease-out;
+ z-index: 100;
+}
+
+#thebelab-activate-button:hover {
+ right: .4rem;
+}
+
+#thebelab-activate-button:active {
+ color: #0f0fff;
+}
+
+body[data-theme="dark"] {
+ .jupyter_container {
+ color: white;
+ background-color: black;
+ }
+
+ .jupyter_container .highlight {
+ background-color: black;
+ }
+
+ .thebelab-button {
+ color: #d0d0d0;
+ background-color: #383838;
+ }
+
+ .thebelab-button:active {
+ color: #368ce2;
+ }
+
+ #thebelab-activate-button {
+ background-color: #383838;
+ }
+
+ #thebelab-activate-button:active {
+ color: #368ce2;
+ }
+
+ .thebelab-cell .jp-OutputArea-output {
+ color: white;
+ background-color: black;
+ }
+
+ .thebelab-cell .jp-OutputArea-output pre {
+ color: white;
+ background-color: black;
+ }
+}
+
+@media (prefers-color-scheme: dark) {
+ body[data-theme="auto"] { /* the same styles with body[data-theme="dark"] */
+ .jupyter_container {
+ color: white;
+ background-color: black;
+ }
+
+ .jupyter_container .highlight {
+ background-color: black;
+ }
+
+ .thebelab-button {
+ color: #d0d0d0;
+ background-color: #383838;
+ }
+
+ .thebelab-button:active {
+ color: #368ce2;
+ }
+
+ #thebelab-activate-button {
+ background-color: #383838;
+ }
+
+ #thebelab-activate-button:active {
+ color: #368ce2;
+ }
+
+ .thebelab-cell .jp-OutputArea-output {
+ color: white;
+ background-color: black;
+ }
+
+ .thebelab-cell .jp-OutputArea-output pre {
+ color: white;
+ background-color: black;
+ }
+ }
+}
+
+
+
+
diff --git a/src/doc/common/static/jupyter-sphinx-furo.js b/src/doc/common/static/jupyter-sphinx-furo.js
new file mode 100644
index 00000000000..5194ff470fc
--- /dev/null
+++ b/src/doc/common/static/jupyter-sphinx-furo.js
@@ -0,0 +1,114 @@
+// Change the editor theme according to the furo light/dark/auto mode
+function changeTheme(editor, theme) {
+ if (theme === 'dark') {
+ editor.setOption('theme', 'monokai'); // the same with pygments dark style in conf.py
+ } else if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
+ editor.setOption('theme', 'monokai');
+ } else {
+ editor.setOption('theme', 'default');
+ }
+}
+
+// Change the editor theme of all CodeMirror cells
+function changeThemeAll(theme) {
+ const querySet = document.querySelectorAll('.CodeMirror');
+ for (var i = 0; i < querySet.length; i++) {
+ changeTheme(querySet[i].CodeMirror, theme);
+ }
+}
+
+// Use the theme data of the body element set by setTheme function
+// defined in https://github.com/pradyunsg/furo/blob/main/src/furo/assets/scripts/furo.js
+const body = document.body;
+const observer1 = new MutationObserver((mutationsList) => {
+ for (let mutation of mutationsList) {
+ if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') {
+ const theme = body.dataset.theme;
+ changeThemeAll(theme);
+ }
+ }
+});
+observer1.observe(body, { attributes: true });
+
+
+// In the furo auto mode, we watch prefers-color-scheme and use the theme data
+// of the body element to change the CodeMirror editor theme
+const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)');
+
+function handlePrefersColorSchemeChange(e) {
+ const theme = body.dataset.theme;
+ if (theme === 'auto') {
+ changeThemeAll(theme);
+ }
+}
+
+prefersDarkMode.addEventListener('change', handlePrefersColorSchemeChange);
+
+
+// Change the editor theme of a new CodeMirror cell.
+const callback = function(mutationsList, observer) {
+ for(const mutation of mutationsList) {
+ if (mutation.type === 'childList') {
+ const theme = body.dataset.theme;
+ for (const addedNode of mutation.addedNodes) {
+ if (addedNode.classList && addedNode.classList.contains('CodeMirror')) {
+ changeTheme(addedNode.CodeMirror, theme);
+ }}}}};
+const observer2 = new MutationObserver(callback);
+observer2.observe(document.getElementsByClassName("content")[0], { childList: true, subtree: true });
+
+
+// Listen to the kernel status changes
+// https://thebe.readthedocs.io/en/stable/events.html
+thebelab.on("status", function (evt, data) {
+ if (data.status === 'building') {
+ const elements = document.querySelectorAll('.thebelab-cell');
+ elements.forEach(element => {
+ element.style.filter = 'opacity(50%)';
+ });
+ const element = document.getElementById("thebelab-activate-button");
+ element.innerHTML = "Building";
+ element.style.right = '.4rem';
+ }
+ else if (data.status === 'built') {
+ const elements = document.querySelectorAll('.thebelab-cell');
+ elements.forEach(element => {
+ element.style.filter = 'opacity(60%)';
+ });
+ const element = document.getElementById("thebelab-activate-button");
+ element.innerHTML = "Built";
+ element.style.right = '.4rem';
+ }
+ else if (data.status === 'launching') {
+ const elements = document.querySelectorAll('.thebelab-cell');
+ elements.forEach(element => {
+ element.style.filter = 'opacity(70%)';
+ });
+ const element = document.getElementById("thebelab-activate-button");
+ element.innerHTML = "Launching";
+ element.style.right = '.4rem';
+ }
+ else if (data.status === 'failed') {
+ const elements = document.querySelectorAll('.thebelab-cell');
+ elements.forEach(element => {
+ element.style.filter = 'opacity(50%)';
+ });
+ const element = document.getElementById("thebelab-activate-button");
+ element.innerHTML = 'Failed: ' + data.message;
+ element.style.right = '.4rem';
+ element.style.width = 'auto';
+ element.style.color = 'red';
+ }
+ else if (data.status === 'ready') {
+ const elements = document.querySelectorAll('.thebelab-cell');
+ elements.forEach(element => {
+ element.style.filter = 'opacity(100%)';
+ });
+ const element = document.getElementById("thebelab-activate-button");
+ element.innerHTML = "Ready";
+ element.style.right = null;
+ // Run custom code when the kernel is ready
+ const kernel = data.kernel;
+ kernel.requestExecute({code: "%display latex"});
+ }
+});
diff --git a/src/doc/common/static/thebe-sage.js b/src/doc/common/static/thebe-sage.js
deleted file mode 100644
index 567e3488802..00000000000
--- a/src/doc/common/static/thebe-sage.js
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * @overview
- * This file aims at replacing the document's Sage code blocks by executable
- * notebook cells. Users are presented a dedicated button in the top right
- * corner. When they click on it, each code block is appended a "Run" button
- * to execute the corresponding code.
- *
- * This is based on the Thebe library (https://github.com/oreillymedia/thebe/)
- * installed in ${SAGE_ROOT}/local/share/thebe/thebe.js by Sage's thebe package.
- */
-
-$(function() {
-
- /**
- * Build and return the Thebe instance that will communicate with the
- * Jupyter notebook (or tmpnb server).
- *
- * This function categorizes the cells lines into "code" and "result"
- * categories to refine the given cell selector and pass only the code
- * lines to Thebe.
- *
- * @param {String} cellSelector - A jQuery selector that matches the cells
- * @param {Object} thebeOptions - Thebe options, must not contain "selector"
- */
- function setupThebeSage(cellSelector, thebeOptions) {
- var lineClass = 'sage-cell-line',
- codeClass = 'sage-code',
- codeBlockClass = 'sage-code-block',
- resultClass = 'sage-expected-result',
- resultBlockClass = 'sage-expect-result-block';
- $(cellSelector).each(function() {
- wrapEachCellLine(this, lineClass);
- categorizeCellLines(this, lineClass, codeClass, resultClass);
- wrapLineBlocks(this, lineClass, codeClass, codeBlockClass);
- wrapLineBlocks(this, lineClass, resultClass, resultBlockClass);
- $('.' + resultBlockClass, this).hide();
- sanitizeCode(this, codeClass);
- });
- thebeOptions.selector = '.' + codeBlockClass;
- return new Thebe(thebeOptions);
- }
-
- /**
- * Sanitize the code before executing. For now, transforms the code line
- * into pure text, also stripping out the Sage prompts and continuation
- * characters at line start, if any.
- *
- * @param {Element} cellNode - The DOM element of the cell
- * @param {String} codeClass - The class name associated to code line
- */
- function sanitizeCode(cellNode, codeClass) {
- var rgx = /^(sage: )|(\.\.\.\.: )|(\.\.\. )/;
- var codeLines = cellNode.getElementsByClassName(codeClass);
- Array.prototype.forEach.call(codeLines, function(line) {
- line.textContent = line.textContent.replace(rgx, '');
- });
- }
-
- /**
- * Wrap consecutive lines of the same type in a given cell in line blocks.
- *
- * @param {Element} cellNode - The DOM element of the cell
- * @param {String} lineClass - The class name that identifies all cell lines
- * @param {String} specificClass - The class name that identifies the lines
- * to be wrapped
- * @param {String} blockClass - The class name to be given to the add
- * wrapper blocks
- */
- function wrapLineBlocks(cellNode, lineClass, specificClass, blockClass) {
- var wrapper,
- lines = cellNode.getElementsByClassName(lineClass);
- Array.prototype.forEach.call(lines, function(line) {
- if (line.classList.contains(specificClass)) {
- if (! wrapper) {
- wrapper = document.createElement('span');
- wrapper.classList.add(blockClass);
- cellNode.insertBefore(wrapper, line);
- }
- wrapper.appendChild(line);
- } else {
- wrapper = null;
- }
- });
- }
-
- /**
- * Add a class on each line of a cell to categorize them as code or result.
- *
- * @param {Element} cellNode - The DOM element of the cell to categorize the
- * lines of
- * @param {String} lineClass - A class name to identify each cell line
- * @param {String} codeClass - A class name to be added on code lines
- * @param {String} resultClass - A class name to be added on result lines
- */
- function categorizeCellLines(cellNode, lineClass, codeClass, resultClass) {
- var lines = cellNode.getElementsByClassName(lineClass);
- var previousCategory;
- Array.prototype.forEach.call(lines, function(line) {
- var lineText = line.textContent;
- if (lineText.startsWith('sage: ')) {
- line.classList.add(codeClass);
- previousCategory = 'code';
- return;
- }
- if (previousCategory === 'code'
- && (lineText.startsWith('....: ')
- || lineText.startsWith('... '))) {
- line.classList.add(codeClass);
- return;
- }
- line.classList.add(resultClass);
- previousCategory = 'result';
- });
- }
-
- /**
- * Add a (span) DOM element around each line of an executable cell
- *
- * @param {Element} cellNode - cell to wrap the lines of
- * @param {String} lineClass - class attribute value for the added span tags
- */
- function wrapEachCellLine(cellNode, lineClass) {
- var html = '';
- cellNode.innerHTML.split('\n').forEach(function(htmlLine) {
- html += '' + htmlLine + '\n';
- });
- cellNode.innerHTML = html;
- }
-
- if (window.location.protocol.startsWith('http')) {
- var cellSelector = "pre:contains('sage: ')";
- if ($(cellSelector).length > 0) {
- $('')
- .css({position: 'absolute', right: 0})
- .click(function() {
- setupThebeSage(cellSelector, {
- tmpnb_mode: false,
- load_css: false,
- url: window.location.origin,
- kernel_name: "sagemath"
- });
- $(this).attr('disabled', 'disabled');
- })
- .prependTo('div.body');
- }
- }
-});
diff --git a/src/doc/common/themes/sage-classic/layout.html b/src/doc/common/themes/sage-classic/layout.html
index ab9a05261aa..1cea7f178a9 100644
--- a/src/doc/common/themes/sage-classic/layout.html
+++ b/src/doc/common/themes/sage-classic/layout.html
@@ -17,8 +17,6 @@
{% block extrahead %}
-
-
{% endblock %}
{%- block footer %}
diff --git a/src/doc/en/a_tour_of_sage/index.rst b/src/doc/en/a_tour_of_sage/index.rst
index 15e9d2aae46..8f638378130 100644
--- a/src/doc/en/a_tour_of_sage/index.rst
+++ b/src/doc/en/a_tour_of_sage/index.rst
@@ -1,38 +1,35 @@
.. _a-tour-of-sage:
-=========================
-Welcome to a Tour of Sage
-=========================
+===============
+Welcome to Sage
+===============
-This is a tour of Sage that closely follows the tour of Mathematica
-that is at the beginning of the Mathematica Book.
+This is a short tour of Sage as a calculator.
-
-Sage as a Calculator
-====================
-
-The Sage command line has a ``sage:`` prompt; you do not have to add
-it. If you use the Sage notebook, then put everything after the
-``sage:`` prompt in an input cell, and press shift-enter to compute the
-corresponding output.
+The Sage command line has a prompt "``sage:``". To experiment with the
+following examples, you only enter the part after the prompt.
::
sage: 3 + 5
8
+If you use Sage on the Jupyter notebook, then likewise put everything after the
+prompt in an input cell, and press :kbd:`Shift-Enter` to get the corresponding
+output.
+
The caret symbol means "raise to a power".
::
- sage: 57.1 ^ 100
+ sage: 57.1^100
4.60904368661396e175
We compute the inverse of a :math:`2 \times 2` matrix in Sage.
::
- sage: matrix([[1,2], [3,4]])^(-1)
+ sage: matrix([[1, 2], [3, 4]])^(-1)
[ -2 1]
[ 3/2 -1/2]
@@ -41,11 +38,11 @@ Here we integrate a simple function.
::
sage: x = var('x') # create a symbolic variable
- sage: integrate(sqrt(x)*sqrt(1+x), x)
- 1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1)
+ sage: integrate(sqrt(x) * sqrt(1 + x), x)
+ 1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1)
+ - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1)
-This asks Sage to solve a quadratic equation. The symbol ``==``
-represents equality in Sage.
+This asks Sage to solve a quadratic equation. The symbol ``==`` represents equality in Sage.
::
@@ -59,10 +56,10 @@ The result is a list of equalities.
::
- sage: S[0].rhs()
+ sage: S[0].rhs() # right hand side of the equation
-1/2*sqrt(4*a + 1) - 1/2
-Naturally, Sage can plot various useful functions.
+Sage can plot various useful functions, of course.
::
@@ -71,39 +68,39 @@ Naturally, Sage can plot various useful functions.
.. image:: sin_plot.*
-Power Computing with Sage
-=========================
-
-First we create a :math:`500 \times 500` matrix of random
-numbers.
+Sage is a very powerful calculator. To experience it, first we create a :math:`500 \times 500`
+matrix of random numbers.
::
- sage: m = random_matrix(RDF,500)
+ sage: m = random_matrix(RDF, 500)
-It takes Sage a few seconds to compute the eigenvalues of the
-matrix and plot them.
+It takes Sage a second to compute the eigenvalues of the matrix and plot them.
.. link
::
- sage: e = m.eigenvalues() #about 2 seconds
+ sage: e = m.eigenvalues() # about 1 second
sage: w = [(i, abs(e[i])) for i in range(len(e))]
sage: show(points(w))
.. image:: eigen_plot.*
-Thanks to the GNU Multiprecision Library (GMP), Sage can handle
-very large numbers, even numbers with millions or billions of
+Sage can handle very large numbers, even numbers with millions or billions of
digits.
::
sage: factorial(100)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
- sage: n = factorial(1000000) #about 2.5 seconds
+
+::
+
+ sage: n = factorial(1000000) # about 1 second
+ sage: len(n.digits())
+ 5565709
This computes at least 100 digits of :math:`\pi`.
@@ -131,17 +128,13 @@ This asks Sage to factor a polynomial in two variables.
sage: F.expand()
x^99 + y^99
-Sage takes just under 5 seconds to compute the numbers of ways to
-partition one hundred million as a sum of positive integers.
+Sage takes less than 1 second to compute the numbers of ways to partition one
+hundred million as a sum of positive integers.
::
- sage: z = Partitions(10^8).cardinality() #about 4.5 seconds
- sage: str(z)[:40]
- '1760517045946249141360373894679135204009'
-
-Accessing Algorithms in Sage
-============================
+ sage: z = Partitions(10^8).cardinality() # about .1 second
+ sage: z
+ 1760517045946249141360373894679135204009...
-Whenever you use Sage you are accessing one of the world's largest
-collections of open source computational algorithms.
+Sage is the world's most advanced open source math software.
diff --git a/src/doc/en/developer/packaging_sage_library.rst b/src/doc/en/developer/packaging_sage_library.rst
index abda71bbed8..0244d96e5ac 100644
--- a/src/doc/en/developer/packaging_sage_library.rst
+++ b/src/doc/en/developer/packaging_sage_library.rst
@@ -190,9 +190,6 @@ The technique of using symbolic links pointing into ``SAGE_ROOT/src``
has allowed the modularization effort to keep the ``SAGE_ROOT/src``
tree monolithic: Modularization has been happening behind the scenes
and will not change where Sage developers find the source files.
-When adding a new distribution package that uses a symbolic link pointing into
-``SAGE_ROOT/src``, please update ``search.exclude`` in
-``SAGE_ROOT/.vscode/settings.json``.
Some of these files may actually be generated from source files with suffix ``.m4`` by the
``SAGE_ROOT/bootstrap`` script via the ``m4`` macro processor.
@@ -472,6 +469,17 @@ requiring all of Sage to be present.
mechanism mentioned above can also be used for this.
+Dependencies of the Sage documentation
+--------------------------------------
+
+The documentation will not be modularized.
+
+However, some parts of the Sage reference manual may depend on functionality
+provided by optional packages. These portions of the reference manual
+should be conditionalized using the Sphinx directive ``.. ONLY::``,
+as explained in :ref:`section-documentation-conditional`.
+
+
Version constraints of dependencies
-----------------------------------
diff --git a/src/doc/en/developer/sage_manuals.rst b/src/doc/en/developer/sage_manuals.rst
index 30e8114175d..578419384c7 100644
--- a/src/doc/en/developer/sage_manuals.rst
+++ b/src/doc/en/developer/sage_manuals.rst
@@ -166,6 +166,32 @@ procedure is different:
* Add your file to the index contained in
``SAGE_ROOT/src/doc/en/reference/combinat/module_list.rst``.
+.. _section-documentation-conditional:
+
+Making portions of the reference manual conditional on optional features
+========================================================================
+
+For every dynamically detectable feature such as :class:`graphviz
+<~sage.features.graphviz.Graphviz>` or :class:`sage.symbolic
+` (see :mod:`sage.features`),
+Sage defines a Sphinx tag that can be used with the `Sphinx
+directive ".. ONLY::"
+`_.
+Because Sphinx tags have to use Python identifier syntax, Sage uses
+the format ``feature_``, followed by the feature name where dots are
+replaced by underscores. Hence, conditionalizing on the features of
+the previous examples would look as follows:
+
+.. CODE-BLOCK:: rest
+
+ .. ONLY:: feature_graphviz
+
+and:
+
+.. CODE-BLOCK:: rest
+
+ .. ONLY:: feature_sage_symbolic
+
.. _section-building-manuals:
Building the manuals
diff --git a/src/doc/en/developer/tools.rst b/src/doc/en/developer/tools.rst
index 20878a6175d..fca5d5ef4c1 100644
--- a/src/doc/en/developer/tools.rst
+++ b/src/doc/en/developer/tools.rst
@@ -327,7 +327,10 @@ Pyright
- Tox: Run ``./sage -tox -e pyright path/to/the/file.py``
-- Manual: Run ``pyright path/to/the/file.py``
+- Manual: Run ``pyright path/to/the/file.py``. If you want to check the whole Sage library, you most likely run out of memory with the default settings.
+ You can use the following command to check the whole library::
+
+ NODE_OPTIONS="--max-old-space-size=8192" pyright
- VS Code: Install the `Pylance `__ extension.
diff --git a/src/doc/en/installation/binary.rst b/src/doc/en/installation/binary.rst
index 5fcce7d5943..4943245a845 100644
--- a/src/doc/en/installation/binary.rst
+++ b/src/doc/en/installation/binary.rst
@@ -1,6 +1,6 @@
.. _sec-installation-from-binaries:
-Install from Pre-built Binaries
+Install from Pre-Built Binaries
===============================
Linux
diff --git a/src/doc/en/installation/index.rst b/src/doc/en/installation/index.rst
index 9baf654f457..50d0af27341 100644
--- a/src/doc/en/installation/index.rst
+++ b/src/doc/en/installation/index.rst
@@ -127,16 +127,17 @@ Linux
In the cloud
============
-- `CoCalc `_: an online service that provides SageMath and
- many other tools.
+- `Sage Binder repo `_ provides a
+ Binder badge to launch JupyterLab environment with Sage.
+
+- `Sage Cell Server `_ is a free online service for
+ quick computations with Sage.
-- On any system that allows you to bring your own Docker images to run
- in a container: Use the `Docker image sagemathinc/cocalc
- `_ or :trac:`another Docker
- image providing SageMath `.
+- `CoCalc `_ is an online commercial service that provides Sage and
+ many other tools.
-- `Sage Cell Server `_: an online service for
- elementary SageMath computations.
+- `Docker image sagemathinc/cocalc
+ `_ can be used on any system with Docker to run CoCalc locally.
More information:
diff --git a/src/doc/en/installation/linux.rst b/src/doc/en/installation/linux.rst
index ec3b5e07ecf..2b2e7bafe2b 100644
--- a/src/doc/en/installation/linux.rst
+++ b/src/doc/en/installation/linux.rst
@@ -1,6 +1,6 @@
.. _sec-GNU-Linux:
-Linux package managers
+Linux Package Managers
======================
SageMath is available from various distributions and can be installed
diff --git a/src/doc/en/installation/source.rst b/src/doc/en/installation/source.rst
index b156165778b..b16fd8e7295 100644
--- a/src/doc/en/installation/source.rst
+++ b/src/doc/en/installation/source.rst
@@ -1,9 +1,3 @@
-.. comment:
- ***************************************************************************
- If you alter this document, please change the last line:
- **This page was last updated in MONTH YEAR (Sage X.Y).**
- ***************************************************************************
-
.. HIGHLIGHT:: shell-session
.. _sec-installation-from-sources:
@@ -11,27 +5,23 @@
Install from Source Code
========================
-.. contents:: Table of contents
- :depth: 2
- :class: this-will-duplicate-information-and-it-is-still-useful-here
-
-Some familiarity with the use of the Unix command line may be required to
-build Sage from the :wikipedia:`source code `.
-
-Building Sage from the source code has the major advantage that your install
-will be optimized for your particular computer and should therefore offer
-better performance and compatibility than a binary install.
+Building Sage from the :wikipedia:`source code ` has the major
+advantage that your install will be optimized for your particular computer and
+should therefore offer better performance and compatibility than a binary
+install.
-Moreover, it offers you full development capabilities:
-you can change absolutely any part of Sage or the programs on which it depends,
-and recompile the modified parts.
+Moreover, it offers you full development capabilities: you can change
+absolutely any part of Sage or the packages on which it depends, and recompile
+the modified parts.
See the file `README.md `_
in ``SAGE_ROOT`` for information on supported platforms and
step-by-step instructions.
-The following sections provide some additional details. Most users
-will not need to read them.
+The following sections provide some additional details. Most users will not
+need to read them. Some familiarity with the use of the Unix command line may
+be required to build Sage from the source code.
+
.. _section-prereqs:
@@ -436,7 +426,6 @@ On other systems, check the documentation for your particular operating system.
.. _section_conda_compilers:
-
Notes on using conda
^^^^^^^^^^^^^^^^^^^^
@@ -457,70 +446,12 @@ If you don't want conda to be used by sage, deactivate conda (for the current sh
operating system, or its own compilers.
-Additional software
--------------------
-
-Recommended programs
-^^^^^^^^^^^^^^^^^^^^
-
-The following programs are recommended.
-They are not strictly required at build time or at run time,
-but provide additional capabilities:
-
-- **dvipng**.
-- **ffmpeg**.
-- **ImageMagick**.
-- **LaTeX**: highly recommended.
-
-It is highly recommended that you have
-:wikipedia:`LaTeX `
-installed, but it is not required.
-The most popular packaging is `TeX Live `_,
-which can be installed following the directions on their web site.
-On Linux systems you can alternatively install your distribution's
-texlive packages::
-
- $ sudo apt-get install texlive # debian
- $ sudo yum install texlive # redhat
-
-or similar commands. In addition to the base TeX Live install, you may
-need some optional TeX Live packages, for example
-country-specific babel packages for the localized Sage
-documentation.
-
-If you don't have either ImageMagick or ffmpeg, you won't be able to
-view animations.
-ffmpeg can produce animations in more different formats than ImageMagick,
-and seems to be faster than ImageMagick when creating animated GIFs.
-Either ImageMagick or dvipng is used for displaying some LaTeX output in the
-Sage notebook.
-
-On Debian/Ubuntu, the following system packages are recommended.
-
-- ``texlive-generic-extra`` (to generate pdf documentation)
-
-- ``texlive-xetex`` (to convert Jupyter notebooks to pdf)
-
-- ``latexmk`` (to generate pdf documentation)
-
-- ``pandoc`` (to convert Jupyter notebooks to pdf)
-
-- ``dvipng`` (to render text with LaTeX in Matplotlib)
-
-- ``default-jdk`` (to run the Jmol 3D viewer from the console and generate images for 3D plots in the documentation)
-
-- ``ffmpeg`` (to produce animations)
-
-- ``libavdevice-dev`` (to produce animations)
-
Tcl/Tk
^^^^^^
-If you want to use `Tcl/Tk `_ libraries in Sage,
-you need to install the Tcl/Tk and its development headers before building
-Sage.
-Sage's Python will then automatically recognize your system's install of
-Tcl/Tk.
+If you want to use `Tcl/Tk `_ libraries in Sage, you need
+to install the Tcl/Tk and its development headers before building Sage. Sage's
+Python will then automatically recognize your system's install of Tcl/Tk.
On Linux systems, these are usually provided by the **tk** and **tk-dev**
(or **tk-devel**) packages which can be installed using::
@@ -548,13 +479,11 @@ If
does not raise an :class:`ImportError`, then it worked.
-.. _build-from-source-step-by-step:
-Step-by-step installation procedure
------------------------------------
+.. _build-from-source-step-by-step:
-General procedure
-^^^^^^^^^^^^^^^^^
+Installation steps
+------------------
#. Follow the procedure in the file `README.md `_
in ``SAGE_ROOT``.
@@ -936,23 +865,6 @@ Here are some of the more commonly used variables affecting the build process:
Python-level profiling is always available; This option enables
profiling in Cython modules.
-- :envvar:`SAGE_SPKG_INSTALL_DOCS` - if set to ``yes``, then install
- package-specific documentation to
- :file:`$SAGE_ROOT/local/share/doc/PACKAGE_NAME/` when an spkg is
- installed.
- This option may not be supported by all spkgs.
- Some spkgs might also assume that certain programs are available on the
- system (for example, ``latex`` or ``pdflatex``).
-
-- :envvar:`SAGE_DOCBUILD_OPTS` - the value of this variable is passed as an
- argument to ``sage --docbuild all html`` or ``sage --docbuild all pdf`` when
- you run ``make``, ``make doc``, or ``make doc-pdf``.
- For example, you can add ``--no-plot`` to this variable to avoid building
- the graphics coming from the ``.. PLOT`` directive within the documentation,
- or you can add ``--include-tests-blocks`` to include all "TESTS" blocks in the
- reference manual. Run ``sage --docbuild help`` to see the full list
- of options.
-
- :envvar:`SAGE_BUILD_DIR` - the default behavior is to build each spkg in a
subdirectory of :file:`$SAGE_ROOT/local/var/tmp/sage/build/`; for
example, build version 7.27.0 of
@@ -1034,6 +946,67 @@ Here are some of the more commonly used variables affecting the build process:
supports :envvar:`SAGE_SUDO`, into a root-owned installation
hierarchy (:envvar:`SAGE_LOCAL`).
+Environment variables for documentation build:
+
+- :envvar:`SAGE_DOCBUILD_OPTS` - the value of this variable is passed as an
+ argument to ``sage --docbuild all html`` or ``sage --docbuild all pdf`` when
+ you run ``make``, ``make doc``, or ``make doc-pdf``. For example, you can
+ add ``--no-plot`` to this variable to avoid building the graphics coming from
+ the ``.. PLOT`` directive within the documentation, or you can add
+ ``--include-tests-blocks`` to include all "TESTS" blocks in the reference
+ manual. Run ``sage --docbuild help`` to see the full list of options.
+
+- :envvar:`SAGE_SPKG_INSTALL_DOCS` - if set to ``yes``, then install
+ package-specific documentation to
+ :file:`$SAGE_ROOT/local/share/doc/PACKAGE_NAME/` when an spkg is installed.
+ This option may not be supported by all spkgs. Some spkgs might also assume
+ that certain programs are available on the system (for example, ``latex`` or
+ ``pdflatex``).
+
+- :envvar:`SAGE_USE_CDNS` -- if set to ``yes``, then build the documentation
+ using CDNs (Content Distribution Networks) for scripts necessary for HTML
+ documentation, such as `MathJax `_.
+
+- :envvar:`SAGE_LIVE_DOC` -- if set to ``yes``, then build live Sage
+ documentation. If the ``Make live`` button on any webpage of the live doc is
+ clicked, every example code gets a `CodeMirror `_
+ code cell runnable via `Thebe `_.
+ Thebe is responsible in sending the code to the Sage computing environment
+ built by `Binder `_ and showing the output result.
+ The Sage computing environment can be specified to either a Binder repo or a
+ local Jupyter server. The environment variable :envvar:`SAGE_JUPYTER_SERVER`
+ is used for this purpose.
+
+ :envvar:`SAGE_JUPYTER_SERVER` - set this to either ``binder``,
+ ``binder:repo`` with ``repo`` specifying a Binder repo or the URL to a local
+ Jupyter server.
+
+ - ``binder`` refers to `Sage's official Binder repo
+ `_. This is assumed if the
+ environment variable :envvar:`SAGE_JUPYTER_SERVER` is not set.
+
+ - ``binder:repo`` specifies a Binder repo with ``repo``, which is a GitHub
+ repository name, optionally added with a branch name with ``/`` separator.
+
+ - To use a local Jupyter server instead of Binder, then set the URL to
+ :envvar:`SAGE_JUPYTER_SERVER` and the secret token to environment variable
+ :envvar:`SAGE_JUPYTER_SERVER_TOKEN`, which can be left unset if the default
+ token ``secret`` is used. If the live doc was built with
+ ``SAGE_JUPYTER_SERVER=http://localhost:8889``, run a local Jupyter server
+ by
+
+ .. CODE-BLOCK:: bash
+
+ ./sage --notebook=jupyterlab \
+ --ServerApp.token='secret' \
+ --ServerApp.allow_origin='null' \
+ --ServerApp.disable_check_xsrf=true \
+ --ServerApp.port=8889 \
+ --ServerApp.open_browser=false
+
+ before opening the Sage documentation webpage.
+
+
Environment variables dealing with specific Sage packages:
- :envvar:`SAGE_MATPLOTLIB_GUI` - if set to anything non-empty except ``no``,
@@ -1045,14 +1018,14 @@ Environment variables dealing with specific Sage packages:
support (which is disabled by default). See the file
:file:`build/pkgs/pari/spkg-install` for more information.
-- :envvar:`SAGE_TUNE_PARI`: If yes, enable PARI self-tuning. Note that
+- :envvar:`SAGE_TUNE_PARI` - if yes, enable PARI self-tuning. Note that
this can be time-consuming. If you set this variable to "yes", you
will also see this: ``WARNING: Tuning PARI/GP is unreliable. You may
find your build of PARI fails, or PARI/GP does not work properly
once built. We recommend to build this package with
SAGE_CHECK="yes".``
-- :envvar:`PARI_MAKEFLAGS`: The value of this variable is passed as an
+- :envvar:`PARI_MAKEFLAGS` - The value of this variable is passed as an
argument to the ``$MAKE`` command when compiling PARI.
Some standard environment variables which are used by Sage:
@@ -1094,7 +1067,7 @@ Some standard environment variables which are used by Sage:
- :envvar:`OPENBLAS_CONFIGURE` - adds additional configuration flags for
the OpenBLAS package that gets added to the make command. (see :trac:`23272`)
-Variables dealing with doctesting:
+Environment variables dealing with doctesting:
- :envvar:`SAGE_TIMEOUT` - used for Sage's doctesting: the number of seconds
to allow a doctest before timing it out.
@@ -1105,7 +1078,7 @@ Variables dealing with doctesting:
``sage -t --long``.
If this isn't set, the default is 1800 seconds (30 minutes).
-- :envvar:`SAGE_TEST_GLOBAL_ITER`, :envvar:`SAGE_TEST_ITER`: these can
+- :envvar:`SAGE_TEST_GLOBAL_ITER`, :envvar:`SAGE_TEST_ITER` - these can
be used instead of passing the flags ``--global-iterations`` and
``--file-iterations``, respectively, to ``sage -t``. Indeed, these
variables are only used if the flags are unset. Run ``sage -t -h``
@@ -1146,7 +1119,7 @@ see a list, execute ``sage.env.[TAB]`` while running Sage.
***************************************************************************
-Installation in a Multiuser Environment
+Installation in a multiuser environment
---------------------------------------
This section addresses the question of how a system administrator can install
@@ -1183,4 +1156,54 @@ a single copy of Sage in a multi-user computer network.
$ sudo chown -R root SAGE_LOCAL
-**This page was last updated in September 2022 (Sage 9.8).**
+Additional software
+-------------------
+
+The following programs are not strictly required at build time or at run time,
+but provide additional capabilities to Sage. We highly recommend a Sage user to
+install them.
+
+LaTeX
+^^^^^
+
+It is highly recommended that you have :wikipedia:`LaTeX ` installed,
+but it is not required. The most popular packaging is `TeX Live
+`_, which can be installed following the
+directions on their web site. On Linux systems you can alternatively install
+your distribution's texlive packages::
+
+ $ sudo apt-get install texlive # debian
+ $ sudo yum install texlive # redhat
+
+or similar commands. In addition to the base TeX Live install, you may
+need some optional TeX Live packages, for example
+country-specific Babel packages for the localized Sage
+documentation.
+
+Additionally, the following system packages are recommended on Debian/Ubuntu:
+
+- ``texlive-generic-extra`` (to generate pdf documentation)
+
+- ``texlive-xetex`` (to convert Jupyter notebooks to pdf)
+
+- ``latexmk`` (to generate pdf documentation)
+
+- ``dvipng`` (to render text with LaTeX in Matplotlib)
+
+pandoc
+^^^^^^
+
+This is useful to convert Jupyter notebooks to pdf.
+
+ffmpeg, ImageMagick
+^^^^^^^^^^^^^^^^^^^
+
+If you don't have either ImageMagick or ffmpeg, you won't be able to view
+animations. ffmpeg can produce animations in more different formats than
+ImageMagick, and seems to be faster than ImageMagick when creating animated
+GIFs.
+
+``libavdevice-dev`` is a component of ffmpeg to produce animations, and
+recommended to install on Debian/Ubuntu.
+
+
diff --git a/src/doc/en/reference/polynomial_rings/index.rst b/src/doc/en/reference/polynomial_rings/index.rst
index b03fa4279ca..0035c50021f 100644
--- a/src/doc/en/reference/polynomial_rings/index.rst
+++ b/src/doc/en/reference/polynomial_rings/index.rst
@@ -65,9 +65,11 @@ Infinite Polynomial Rings
Boolean Polynomials
-------------------
-.. toctree::
- :maxdepth: 1
+.. ONLY:: feature_sage_rings_polynomial_pbori
+
+ .. toctree::
+ :maxdepth: 1
- sage/rings/polynomial/pbori/pbori
+ sage/rings/polynomial/pbori/pbori
.. include:: ../footer.txt
diff --git a/src/doc/en/tutorial/latex.rst b/src/doc/en/tutorial/latex.rst
index aafaaea6ac5..a173afd75c5 100644
--- a/src/doc/en/tutorial/latex.rst
+++ b/src/doc/en/tutorial/latex.rst
@@ -1,71 +1,99 @@
-*********************************
+***********************
Sage, LaTeX and Friends
-*********************************
+***********************
Sage and the LaTeX dialect of TeX have an intensely synergistic relationship.
This section aims to introduce the variety of interactions, beginning with the
most basic and proceeding to the more unusual.
-Overview
-========
-
-It may be easiest to understand the various uses of LaTeX with a
-brief overview of the mechanics of the three principal methods
-employed by Sage.
-
- #. Every "object" in Sage is required to have a LaTeX representation. You
- can access this representation by executing ``latex(foo)`` where
- ``foo`` is some object in Sage. The output is a string that should
- render a reasonably accurate representation of ``foo`` when used in
- TeX's math-mode (for example, when enclosed between a pair of single
- dollar signs). Some examples of this follow below.
-
- In this way, Sage can be used effectively for constructing portions of
- a LaTeX document: create or compute an object in Sage, print ``latex()``
- of the object and cut/paste it into your document.
-
- #. The Jupyter notebook interface uses `MathJax `_
- to render mathematics cleanly in a web browser. You can start this
- automatic rendering by executing ``%display latex`` (and stop by
- executing ``%display plain``).
-
- MathJax is an open source JavaScript display engine for mathematics that
- works in all modern browsers. It is able to render a large, but not
- totally complete, subset of TeX. It has no support for things like
- complicated tables, sectioning or document management, as it is oriented
- towards accurately rendering "snippets" of TeX. Seemingly automatic
- rendering of math in the notebook is provided by converting the
- ``latex()`` representation of an object (as described above) into a form
- of HTML palatable to MathJax.
-
- #. A system-wide installation of LaTeX can be employed. Sage includes
- almost everything you need to build and use Sage, but a significant
- exception is TeX itself. So in these situations you need to have
- TeX installed, along with some associated conversion utilities, to
- utilize the full power.
-
-Here we demonstrate some basic uses of the ``latex()`` function. ::
+Basic Use
+=========
+
+Every "object" in Sage is required to have a LaTeX representation. You can
+access this representation by executing ``latex(foo)`` where ``foo`` is some
+object in Sage. The output is a string that should render a reasonably
+accurate representation of ``foo`` when used in TeX's math-mode (for example,
+when enclosed between a pair of single dollar signs). Some examples of this
+follow below. ::
sage: var('z')
z
sage: latex(z^12)
z^{12}
- sage: latex(integrate(z^4, z))
- \frac{1}{5} \, z^{5}
+ sage: latex(sqrt(z^2 + 1/2))
+ \sqrt{z^{2} + \frac{1}{2}}
sage: latex('a string')
\text{\texttt{a{ }string}}
sage: latex(QQ)
\Bold{Q}
+ sage: latex(ZZ['x'])
+ \Bold{Z}[x]
sage: latex(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]]))
\left(\begin{array}{rrr}
2 & 4 & 6 \\
-1 & -1 & -1
\end{array}\right)
-Basic MathJax functionality is largely automatic in the notebook, but we can
-partially demonstrate this support with the ``MathJax`` class. The object of
-this class converts a Sage object to its LaTeX representation and then wraps it
-in HTML. ::
+In this way, Sage can be used effectively for constructing portions of
+a LaTeX document: create or compute an object in Sage, do ``latex(foo)``
+of the object ``foo`` and cut/paste the LaTeX string into your document.
+
+The command ``view(foo)`` will show the rendered LaTeX
+representation of ``foo``. In the background, the command runs ``latex(foo)``
+and incorporates the LaTeX string into a simple LaTeX document, processes that
+document with the system-wide TeX installation, and finally an appropriate
+viewer will be called to display the output.
+
+In the Jupyter notebook, you can see the rendered LaTeX representation of the
+output of the entered commands automatically. You can start this
+automatic rendering by executing ``%display latex`` (and stop by executing
+``%display plain``).
+
+.. ONLY:: html
+
+ Thus, in the Jupyter notebook, you get
+
+ .. JUPYTER-EXECUTE::
+
+ %display latex
+ var('z')
+ z^12
+
+ .. JUPYTER-EXECUTE::
+
+ sqrt(z^2 + 1/2)
+
+ .. JUPYTER-EXECUTE::
+
+ 'a string'
+
+ .. JUPYTER-EXECUTE::
+
+ QQ
+
+ .. JUPYTER-EXECUTE::
+
+ ZZ['x']
+
+ .. JUPYTER-EXECUTE::
+
+ matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]])
+
+ .. JUPYTER-EXECUTE::
+
+ %display plain
+
+The Jupyter notebook uses `MathJax `_ to render
+mathematics cleanly in a web browser. MathJax is an open source JavaScript
+display engine for mathematics that works in all modern browsers. It is able
+to render a large, but not totally complete, subset of LaTeX. It has no
+support for things like complicated tables, sectioning or document management,
+as it is oriented towards accurately rendering math snippets of LaTeX.
+
+The automatic LaTeX rendering in the Jupyter notebook (with ``%display latex``
+on) is internally done via the :class:`sage.misc.html.MathJax` class. The
+object of this class converts a Sage object through ``latex()`` to a form of
+HTML palatable to MathJax and then wraps it in HTML. ::
sage: from sage.misc.html import MathJax
sage: mj = MathJax()
@@ -73,28 +101,22 @@ in HTML. ::
z
sage: mj(z^12)
\[z^{12}\]
+ sage: mj(sqrt(z^2 + 1/2))
+ \[\sqrt{z^{2} + \frac{1}{2}}\]
+ sage: mj('a string')
+ \[\verb|a|\verb| |\verb|string|\]
sage: mj(QQ)
\[\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}\]
sage: mj(ZZ['x'])
\[\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]\]
- sage: mj(integrate(z^4, z))
- \[\frac{1}{5} \, z^{5}\]
-
-Basic Use
-=========
+ sage: mj(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]]))
+ \[\left(\begin{array}{rrr}
+ 2 & 4 & 6 \\
+ -1 & -1 & -1
+ \end{array}\right)\]
-As indicated in the overview, the simplest way to exploit Sage's support of
-LaTeX is to use the ``latex()`` function to create legitimate LaTeX code to
-represent mathematical objects. These strings can then be incorporated into
-standalone LaTeX documents.
+This is useful to know if you need to understand the LaTeX rendering of a Sage object.
-At the other extreme is the ``view()`` command. The command ``view(foo)`` will
-create the LaTeX representation of ``foo``, incorporate this into a simple
-LaTeX document, and then process that document with your system-wide TeX
-installation. Finally, the appropriate viewer will be called to display the
-output from the TeX command. Which version of TeX is used, and therefore the
-nature of the output and associated viewer, can be customized (see
-:ref:`sec-custom-processing`).
.. _sec-custom-generation:
@@ -152,30 +174,74 @@ done in written work. This is accomplished by redefining the
\[\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}\]
sage: latex.blackboard_bold(False)
-It is possible to take advantage of the extensible nature of TeX by adding in
-new macros and new packages. First, individual macros can be added so that
-they are used when MathJax interprets a snippet of TeX in the notebook. ::
+.. ONLY:: html
+ In the Jupyter notebook,
+
+ .. JUPYTER-EXECUTE::
+
+ %display latex
+ QQ
+
+ .. JUPYTER-EXECUTE::
+
+ latex.blackboard_bold(True)
+ QQ
+
+ .. JUPYTER-EXECUTE::
+
+ latex.blackboard_bold(False)
+ %display plain
+
+It is possible to take advantage of the extensible nature of LaTeX by adding in
+new macros. Individual macros can be added so that they are used when MathJax
+interprets a LaTeX snippet. ::
+
+ sage: latex.add_macro(r"\newcommand{\sqrt}[1]{(#1)^\frac{1}{2}}")
sage: latex.extra_macros()
- ''
- sage: latex.add_macro("\\newcommand{\\foo}{bar}")
- sage: latex.extra_macros()
- '\\newcommand{\\foo}{bar}'
+ '\\newcommand{\\sqrt}[1]{(#1)^\\frac{1}{2}}'
sage: var('x y')
(x, y)
- sage: latex(x+y)
- x + y
+ sage: latex(sqrt(x+y))
+ \sqrt{x + y}
sage: from sage.misc.html import MathJax
sage: mj = MathJax()
- sage: mj(x+y)
- \[\newcommand{\foo}{bar}x + y\]
+ sage: mj(sqrt(x + y))
+ \[\newcommand{\sqrt}[1]{(#1)^\frac{1}{2}}\sqrt{x + y}\]
+ sage: latex.extra_macros('')
+
+.. ONLY:: html
+
+ In the Jupyter notebook,
-Additional macros added this way will also be used in the event that the
-system-wide version of TeX is called on something larger than MathJax can
-handle. The command ``latex_extra_preamble`` is used to build the preamble of
-a complete LaTeX document, so the following illustrates how this is
-accomplished. As usual note the need for the double-backslashes in the Python
-strings. ::
+ .. JUPYTER-EXECUTE::
+
+ %display latex
+ var('x y')
+ sqrt(x + y)
+
+ .. JUPYTER-EXECUTE::
+
+ latex.add_macro(r"\newcommand{\sqrt}[1]{(#1)^\frac{1}{2}}")
+ sqrt(x + y)
+
+ .. JUPYTER-EXECUTE::
+
+ latex.extra_macros('')
+ %display plain
+
+
+.. _sec-custom-processing:
+
+Customizing LaTeX Processing
+============================
+
+The system-wide TeX is called to process a complete LaTeX document, such as
+when you ``view(foo)``, where ``foo`` is a complicated Sage object, too
+complicated for ``MathJax`` to handle. The command ``latex_extra_preamble`` is
+used to build the preamble of the complete LaTeX document, so the following
+illustrates how this is accomplished. As usual note the need for the
+double-backslashes in the Python strings. ::
sage: latex.extra_macros('')
sage: latex.extra_preamble('')
@@ -229,38 +295,40 @@ package that presumably does not exist. ::
sage: latex.extra_preamble()
'\\usepackage{foo-bar-unchecked}'
-.. _sec-custom-processing:
+Which dialect of TeX is used, and therefore the nature of the output and
+associated viewer, can also be customized.
-Customizing LaTeX Processing
-============================
+.. NOTE::
-It is also possible to control which variant of TeX is used for system-wide
-invocations, thus also influencing the nature of the output.
+ Sage includes almost everything you need to build and use Sage, but a
+ significant exception is TeX itself. So in the following situations you
+ need to have a full TeX system installed, along with some associated
+ conversion utilities. Many versions of Linux have packages based on
+ TeXLive, for macOS there is MacTeX and for Windows there is MiKTeX.
The ``latex.engine()`` command can be used to control if the system-wide
-executables ``latex``, ``pdflatex`` or ``xelatex`` are employed for more
-complicated LaTeX expressions. When ``view()`` is called and the engine is set
-to ``latex``, a dvi file is produced and Sage will use a dvi viewer (like xdvi)
-to display the result. In contrast, using ``view()`` when the engine is set to
-``pdflatex`` will produce a PDF as the result and Sage will call your system's
-utility for displaying PDF files (acrobat, okular, evince, etc.).
-
-For a concrete example of how complicated LaTeX expressions can be processed,
-see the example in the next section (:ref:`sec-tkz-graph`) for using the LaTeX
-``tkz-graph`` package to produce high-quality renderings of combinatorial
-graphs. For other examples, there are some pre-packaged test cases. To use
-these, it is necessary to import the ``sage.misc.latex.latex_examples`` object,
-which is an instance of the ``sage.misc.latex.LatexExamples`` class, as
-illustrated below. This class currently has examples of commutative diagrams,
-combinatorial graphs, knot theory and pstricks, which respectively exercise the
-following packages: xy, tkz-graph, xypic, pstricks. After the import, use
-tab-completion on ``latex_examples`` to see the pre-packaged examples. Calling
-each example will give you back some explanation about what is required to make
-the example render properly. To actually see the examples, it is necessary to
-use ``view()`` (once the preamble, engine, etc are all set properly). ::
+executables ``latex``, ``pdflatex`` or ``xelatex`` are employed. When
+``view()`` is called and the engine is set to ``latex``, a dvi file is produced
+and Sage will use a dvi viewer (like xdvi) to display the result. In contrast,
+using ``view()`` when the engine is set to ``pdflatex`` will produce a PDF as
+the result and Sage will call your system's utility for displaying PDF files
+(acrobat, okular, evince, etc.).
+
+For your exercises with these facilities, there are some pre-packaged examples.
+To use these, it is necessary to import the ``sage.misc.latex.latex_examples``
+object, which is an instance of the :class:`sage.misc.latex.LatexExamples`
+class, as illustrated below. This class currently has examples of commutative
+diagrams, combinatorial graphs, knot theory and pstricks, which respectively
+exercise the following packages: xy, tkz-graph, xypic, pstricks. After the
+import, use tab-completion on ``latex_examples`` to see the pre-packaged
+examples. Calling each example will give you back some explanation about what
+is required to make the example render properly. To actually see the examples,
+it is necessary to use ``view(foo)`` (once the preamble, engine, etc are all set
+properly). ::
sage: from sage.misc.latex import latex_examples
- sage: latex_examples.diagram()
+ sage: foo = latex_examples.diagram()
+ sage: foo
LaTeX example for testing display of a commutative diagram produced
by xypic.
@@ -269,63 +337,47 @@ use ``view()`` (once the preamble, engine, etc are all set properly). ::
and try viewing again. You should get a picture (a part of the diagram arising
from a filtered chain complex).
-.. _sec-tkz-graph:
-
-An Example: Combinatorial Graphs with tkz-graph
-===============================================
-
-High-quality illustrations of combinatorial graphs (henceforth just "graphs")
-are possible with the ``tkz-graph`` package. This package is built on top of
-the ``tikz`` front-end to the ``pgf`` library. So all of these components need
-to be part of a system-wide TeX installation, and it may be possible that these
-components may not be at their most current versions as packaged in some TeX
-implementations. So for best results, it could be necessary or advisable to
-install these as part of your personal texmf tree. Creating, maintaining and
-customizing a system-wide or personal TeX installation is beyond the scope of
-this document, but it should be easy to find instructions. The necessary files
-are listed in :ref:`sec-system-wide-tex`.
-
-Thus, to start we need to insure that the relevant packages are included by
-adding them to the preamble of the eventual LaTeX document. The images of
-graphs do not form properly when a dvi file is used as an intermediate format,
-so it is best to set the latex engine to the ``pdflatex`` executable. At this
-point a command like ``view(graphs.CompleteGraph(4))`` should produce a PDF
-with an appropriate image of the complete graph `K_4`.
+For an example of how complicated LaTeX expressions can be processed, let us see the
+example of combinatorial graphs, that use ``tkz-graph`` LaTeX package.
+
+.. NOTE::
+
+ ``tkz-graph`` LaTeX package is built on top of the ``tikz`` front-end to
+ the ``pgf`` library. Rendering combinatorial graphs requires the ``pgf``
+ library, and the files ``tkz-graph.sty`` and ``tkz-berge.sty``. It is
+ highly likely that they are already part of your system-wide TeX
+ installation. Even if not, it should be easy to find instructions to
+ install them.
+
+First, we ensure that the relevant packages are included by adding them to the
+preamble of the LaTeX document. ::
+
+ sage: latex.extra_preamble('\\usepackage{tikz}\n\\usepackage{tkz-graph}\n'
+ ....: '\\usepackage{tkz-berge}\n\\usetikzlibrary{arrows,shapes}')
+
+The images of graphs do not form properly when a dvi file is used as an
+intermediate format, so it is best to set the latex engine to the ``pdflatex``
+executable::
+
+ sage: latex.engine('pdflatex')
+
+At this point a command like ``view(graphs.CompleteGraph(4))`` should produce a
+PDF with an appropriate image of the complete graph `K_4`.
+
+Actually the preliminary steps could be omitted as the preamble is
+automatically set up properly for graphs and ``pdflatex`` is the default LaTeX
+engine in Sage. Try the command again after restarting Sage.
Note that there is a variety of options to affect how a graph is rendered in
-LaTeX via ``tkz-graph``, which is again outside the scope of this section, see
-the section of the Reference manual titled "LaTeX Options for Graphs" for
-instructions and details.
-
-.. _sec-system-wide-tex:
-
-A Fully Capable TeX Installation
-================================
-
-Many of the more advanced features of the integration of TeX with Sage requires
-a system-wide installation of TeX. Many versions of Linux have base TeX
-packages based on TeX Live, for macOS there is TeXShop and for Windows there is
-MiKTeX. The ``convert`` utility is part of the `ImageMagick
-`_ suite (which should be a package or an easy
-download), and the three programs ``dvipng``, ``ps2pdf``, and ``dvips`` may be
-included with your TeX distribution. The first two may also be obtained,
-respectively, from http://sourceforge.net/projects/dvipng/ and as part of
-`Ghostscript `_.
-
-Rendering combinatorial graphs requires a recent version of the PGF library,
-the file ``tkz-graph.sty`` from https://www.ctan.org/pkg/tkz-graph, and the
-files ``tkz-arith.sty`` and perhaps ``tkz-berge.sty`` from
-https://www.ctan.org/pkg/tkz-berge.
+LaTeX via ``tkz-graph``, which is outside the scope of this section. See the
+section :ref:`sage.graphs.graph_latex` of the Reference Manual for instructions
+and details.
+
SageTeX
=======
-SageTeX is a program available to further integrate TeX and Sage. A concise
-description of SageTeX is that it is a collection of TeX macros that allow a
-LaTeX document to include instructions to have Sage compute various objects
-and/or format objects using the ``latex()`` support built into Sage. So as an
-intermediate step of compiling a LaTeX document, all of the computational and
-LaTeX-formatting features of Sage can be handled automatically. As an example,
-a mathematics examination can maintain a correct correspondence between
-questions and answers by using SageTeX to have Sage compute one from the other.
+SageTeX is a program available to further integrate TeX and Sage. It is a
+collection of TeX macros that allow a LaTeX document to include instructions to
+have Sage compute various objects and format objects using the ``latex()``.
See :ref:`sec-sagetex` for more information.
diff --git a/src/doc/en/website/templates/index_furo.html b/src/doc/en/website/templates/index_furo.html
index ae70b6ea4df..922068b9b52 100644
--- a/src/doc/en/website/templates/index_furo.html
+++ b/src/doc/en/website/templates/index_furo.html
@@ -49,9 +49,7 @@
- This is a tour of Sage that closely follows the tour of
- Mathematica that is at the beginning of the Mathematica
- Book.
+ A one page introduction to Sage as a handy calculator.
@@ -85,7 +83,7 @@
- This tutorial is the best way to become familiar with Sage
+ The best way to become familiar with Sage
in only a few hours.
diff --git a/src/doc/it/faq/faq-contribute.rst b/src/doc/it/faq/faq-contribute.rst
index 0acda9b03da..63c67a8e264 100644
--- a/src/doc/it/faq/faq-contribute.rst
+++ b/src/doc/it/faq/faq-contribute.rst
@@ -21,7 +21,7 @@ Voglio contribuire a Sage. Da dove inizio?
Dai un'occhiata alla
`guida ufficiale per lo sviluppo `_
di Sage. Come minimo, la lettura del primo capitolo è richiesta per ogni
-svilluppatore di Sage. Inoltre sii molto attento alle
+sviluppatore di Sage. Inoltre sii molto attento alle
`linee guida per trac `_.
Puoi entrare nella lista email
`sage-devel `_.
@@ -29,7 +29,7 @@ Mentre inizi a conoscere la comunità prendi una copia del codice sorgente di Sa
e familiarizza con `git `_, un software per il controllo
versione.
-Il migiol mode per diventare familiare con il processo di sviluppo di Sage
+Il miglior modo per diventare familiare con il processo di sviluppo di Sage
è quello di scegliere un ticket dal
`server trac `_
ed esaminare i cambiamenti proposti in quel ticket.
@@ -70,11 +70,11 @@ di Steven F. Lott è adatto a chiunque sia già a suo agio nel programmare.
Se desideri, puoi iniziare a imparare Python usando Sage.
Tuttavia, è utile sapere cosa è semplice Python e quando Sage sta usando la
-sua "magia". Ci sono molte cose che funzionano in Phyton, ma non in Sage e
+sua "magia". Ci sono molte cose che funzionano in Python, ma non in Sage e
vice versa. Per di più anche quando la sintassi è identica, molti concetti
di programmazione sono spiegati più dettagliatamente in risorse focalizzate
su Python piuttosto che in risorse centrate su Sage; in quest'ultime,
-la prioirità viene data alla matematica.
+la priorità viene data alla matematica.
Non sono un programmatore. C'è qualche altro modo in cui posso aiutare?
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -158,7 +158,7 @@ Consulta anche la Guida dello Sviluppo Sage, specialmente il capitolo
`Convenzioni per scrivere codice sorgente in Sage `_.
-Ho inviato al server trac una correzione molte settimane fa. Perchè la state ignorando?
+Ho inviato al server trac una correzione molte settimane fa. Perché la state ignorando?
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Non stiamo cercando di ignorare la tua correzione.
@@ -190,7 +190,7 @@ Se la tua correzione non ha la possibilità di essere aggiunta nell'albero dei
sorgenti di Sage, non la ignoreremo ma semplicemente chiuderemo il ticket
relativo con una spiegazione sul perché non possiamo includerla.
-Come e quando posso ricordardare alla comunità di Sage una correzione a cui tengo?
+Come e quando posso ricordare alla comunità di Sage una correzione a cui tengo?
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Ti suggeriamo di fare uno sforzo ulteriore sul come ricordare alla comunità di
@@ -221,7 +221,7 @@ preparser di Sage) e la necessità di importare quello che ti serve.
primalità e la fattorizzazione.
- Dovresti anche notare che ``2 / 3`` non significa più
``Integer(2) / Integer(3)`` che restituisce ``2/3``, ma invece
- ``int(2) / int(3)``, e pertanto restituisce ``0`` poichè la divisione è
+ ``int(2) / int(3)``, e pertanto restituisce ``0`` poiché la divisione è
intera e trascura il resto. Se stai lavorando con i tipi ``Integer``
ma in realtà hai bisogno di eseguire una divisione intera puoi usare
``Integer(2) // Integer(3)``.
diff --git a/src/doc/it/faq/faq-general.rst b/src/doc/it/faq/faq-general.rst
index 39ae0070bf9..85ea1c1ad38 100644
--- a/src/doc/it/faq/faq-general.rst
+++ b/src/doc/it/faq/faq-general.rst
@@ -13,13 +13,13 @@ La missione fissata per Sage è di essere un'alternativa open-source a Magma,
Maple, Mathematica e Matlab. I predecessori di Sage, noti come HECKE e Manin,
furono creati perché William Stein ebbe bisogno di scriverli come parte della
sua ricerca sulla Teoria dei Numeri. Iniziato da William nel 2005 quando era
-all'università di Harvard, Sage combina alcuni fra i miglori software open-source
-per la matematica in un'unica intefaccia comune.
+all'università di Harvard, Sage combina alcuni fra i migliori software open-source
+per la matematica in un'unica interfaccia comune.
Da allora Sage viene utilizzato non solo da ricercatori nel campo della Teoria
dei Numeri, ma da ricercatori in tutte le scienze matematiche.
Sage si avvale ed estende le funzionalità di molti dei pacchetti inglobati.
-Anche dal principio, quando Sage veiniva usato principalmente per la Teoria dei
+Anche dal principio, quando Sage veniva usato principalmente per la Teoria dei
Numeri, includeva:
`Givaro `_,
`GMP `_,
@@ -30,7 +30,7 @@ professori universitari, ricercatori di tutto il mondo usano Sage perché voglio
un pacchetto open-source comprensivo per la matematica che offra calcolo sia
simbolico che numerico. Perlopiù le persone sono contente di quanto offre Sage.
-Com'é comune nell'ambito del software open-source (FOSS), spesso ci sono persone
+Come é comune nell'ambito del software open-source (FOSS), spesso ci sono persone
che individuano casi in cui Sage non dispone delle funzionalità richiesta da loro.
Quindi si immergono nel codice sorgente di Sage per estenderlo per il loro scopo,
o ancora per esporre delle funzionalità dei pacchetti inglobati in Sage in modo
@@ -73,7 +73,7 @@ all'opera gratuita di una grande squadra internazionale di studenti, insegnanti,
professori universitari, ricercatori, ingegneri informatici e persone che
lavorano in vari ambiti della matematica, delle scienze, dell'ingegneria, dello
sviluppo software e a tutti i livelli della scuola. Lo sviluppo di Sage ha potuto
-usufruire di fondi asegnati da numerose istituzioni e ha potuto includere sia
+usufruire di fondi assegnati da numerose istituzioni e ha potuto includere sia
componenti preesistenti che in corso di sviluppo da parte di numerosi autori.
Una lista di coloro che hanno dato un contributo diretto è reperibile al link
@@ -144,7 +144,7 @@ ed in particolare nella seguente citazione::
I computer non sono una minaccia per i matematici più di quanto i robot da
cucina lo siano per i cuochi. Poiché la matematica diviene sempre più complessa
- mentre il ritmo delle nostre vite accellera, dobbiamo delegare il più possibile
+ mentre il ritmo delle nostre vite accelera, dobbiamo delegare il più possibile
alle macchine. Ed intendo sia il lavoro in campo numerico che in quello
simbolico. Alcune persone possono andare avanti senza lavastoviglie, ma penso
che le dimostrazioni vengano fuori molto più pulite quando il lavoro di
@@ -153,7 +153,7 @@ ed in particolare nella seguente citazione::
Questo porta con sè parecchie questioni. Non sono un esperto ma penso che
abbiamo bisogno di uno standard a livello di calcolo simbolico per rendere le
manipolazioni al computer più facili da documentare e verificare. Con tutto il
- rispetto per il libero mercato, forse in questo non dobbiam essere dipendenti
+ rispetto per il libero mercato, forse in questo non dobbiamo essere dipendenti
da un software commerciale. Un progetto open-source potrebbe, forse, trovare
risposte migliori a problemi ovvi come la disponibilità, i bug, la
compatibilità all'indietro, l'indipendenza dalla piattaforma, le librerie
diff --git a/src/doc/it/faq/faq-usage.rst b/src/doc/it/faq/faq-usage.rst
index 13a2e0b7e5a..a13048eb71d 100644
--- a/src/doc/it/faq/faq-usage.rst
+++ b/src/doc/it/faq/faq-usage.rst
@@ -31,7 +31,7 @@ vai al link http://www.sagemath.org/download-source.html
per scaricare l'archivio TAR di qualunque rilascio di Sage.
Le sessioni di lavoro Notebook di Sage sono eseguite all'interno di
-un browser web. Puoi lancianer il Notebook di sage attraverso il
+un browser web. Puoi lanciare il Notebook di sage attraverso il
seguente comando purché ``sage`` sia nella variabile ``PATH``
.. CODE-BLOCK:: shell-session
@@ -45,7 +45,7 @@ Quali sono i prerequisiti di Sage?
La maggior parte delle dipendenze sono incluse all'interno di Sage.
Nella maggior parte dei casi puoi scaricare il binario precompilato
ed usarlo senza dover installare alcun pacchetto dipendente. Se usi
-Windows avrai bisogno di intallare
+Windows avrai bisogno di installare
`VirtualBox `_,
che puoi scaricare dal link http://www.virtualbox.org/wiki/Downloads.
Dopo aver installato VirtualBox devi scaricare una distribuzione di
@@ -68,7 +68,7 @@ questi prerequisiti come segue::
sudo apt-get install build-essential m4
Se hai un sistema multiprocessore puoi scegliere una
-copilazione parallela di Sage. Il comando ::
+compilazione parallela di Sage. Il comando ::
export MAKE='make -j8'
@@ -87,7 +87,7 @@ Tcl/Tk. Su Ubuntu lancia, da riga di comando::
sudo apt-get install tk8.5-dev
-o qualcosa di simile. Poi reinstalla l'iterprete Python di Sage con::
+o qualcosa di simile. Poi reinstalla l'interprete Python di Sage con::
sage -f python
@@ -128,7 +128,7 @@ Puoi poi lanciare tale script Sage in questo modo::
sage /path/to/my/script.sage
-Questo si occuperà di caricare le variabili d'ambiente necesssarie
+Questo si occuperà di caricare le variabili d'ambiente necessarie
ed eseguire gli import di default al posto tuo.
@@ -189,7 +189,7 @@ o qualunque fallimento nei doctest.
Le funzionalità di base di Sage dovrebbero risultare facili da imparare
quanto le basi di Python. Molti tutorial sono disponibili in rete
per aiutarti ad imparare Sage. Per trarre il massimo da Sage
-ti consigliamo di impararare qualche elemento del linguaggio Python.
+ti consigliamo di imparare qualche elemento del linguaggio Python.
Segue una lista, incompleta, di risorse su Python.
Altre risorse possono essere trovate cercando sul web.
@@ -270,7 +270,7 @@ successiva nell'elenco. Questa funzionalità ti permette di recuperare
dalla "history" tante righe consecutive quante vuoi.
Ma Sage non ha una funzionalità simile: la riga di comando
`IPython `_ utilizza la libreria "readline"
-(via pyreadline), che evidentemente non supporta questa funzionalit.
+(via pyreadline), che evidentemente non supporta questa funzionalità.
Magma ha una sua propria libreria personalizzata simile alla
"readline" che invece supporta questa funzionalità.
(Dal momento che moltissime persone hanno richiesto questa
@@ -292,7 +292,7 @@ anello base, come puoi vedere facendo::
sage: preparse("stats.uniform(0,15).ppf([0.5,0.7])")
"stats.uniform(Integer(0),Integer(15)).ppf([RealNumber('0.5'),RealNumber('0.7')])"
-Sfortunamente il supporto che NumPy fornisce a questi tipi avanzati di
+Sfortunatamente il supporto che NumPy fornisce a questi tipi avanzati di
Sage, quali ``Integer`` o ``RealNumber``
(numeri reali di precisione arbitraria), non è del 100%.
Per risolvere ridefinisci ``Integer`` e/o ``RealNumber`` per cambiare
@@ -475,7 +475,7 @@ La visualizzazione 3D in tempo reale per Sage dalla versione 6.4 in
avanti usa il pacchetto `Jmol/JSmol `_.
Dalla linea di comando viene utilizzata l'applicazione Java Jmol,
mentre per la visualizzazione dal browser viene usato puro javascript
-oppura una Java applet. In genere nei browser è usato javascript puro
+oppure una Java applet. In genere nei browser è usato javascript puro
per evitare problemi con quei browser che non supportano i plugin per
le applet Java (ad esempio Chrome). In ogni worksheet su browser c'è
una casella da spuntare prima di generare una vista tridimensionale
@@ -548,7 +548,7 @@ Per saperne di più digita quanto segue al prompt di Sage ::
sage.rings.finite_field_givaro.FiniteField_givaro.
-Poi premi TAB, ed usa ``??`` per avere più informationi su ogni
+Poi premi TAB, ed usa ``??`` per avere più informazioni su ogni
funzione. Ad esempio::
sage.rings.finite_field_givaro.FiniteField_givaro.one??
@@ -698,10 +698,10 @@ accessibili tramite la linea di comando IPython con il comando ``??``::
Source:
...
-Tuttabia gli oggetti che sono construiti in Python o IPython sono
+Tuttavia gli oggetti che sono costruiti in Python o IPython sono
compilati e non verranno visualizzati. Ci sono molte funzioni in Sage
-construite come funzioni simboliche, i.e. possono essere usate come
+costruite come funzioni simboliche, i.e. possono essere usate come
parte di espressioni simboliche senza dover essere calcolate.
Il loro codice sorgente potrebbe non essere accessibile dalla linea di
-comando, sopratutto per le funzioni elementaru, poiché sono scritte
+comando, sopratutto per le funzioni elementari, poiché sono scritte
in C++ (per ragioni di efficienza).
diff --git a/src/doc/it/tutorial/introduction.rst b/src/doc/it/tutorial/introduction.rst
index 7e388e04dfc..856aa26d484 100644
--- a/src/doc/it/tutorial/introduction.rst
+++ b/src/doc/it/tutorial/introduction.rst
@@ -66,7 +66,7 @@ Qui vengono fatti solamente due commenti.
#. Il file di download di Sage arrive con le "batterie incluse".
In altre parole, nonostante Sage usi Python, IPython, PARI, GAP,
Singular, Maxima, NTL, GMP e così via, non è necessario installarli
- separatemente siccome sono incluse con la distribuzione di Sage.
+ separatamente siccome sono incluse con la distribuzione di Sage.
Comunque, per usare certe feature di \sage, ad es. Macaulay o KASH,
bisogna installare il pacchetto opzionale Sage che interessa o almeno
avere i programmi in questioni gia installati sul proprio computer.
@@ -76,7 +76,7 @@ Qui vengono fatti solamente due commenti.
#. Le versioni binarie precompilate di Sage (che si trovano sul sito web di
Sage) possono essere più facili e più veloci da installare invece che la
- versione da codice sorgente. Basta solo spachettare il file e eseguire "sage".
+ versione da codice sorgente. Basta solo spacchettare il file e eseguire "sage".
Modi di usare Sage
==================
@@ -100,7 +100,7 @@ Obiettivi di lungo periodo per Sage
===================================
- **Utile**: il pubblico per Sage il quale sage è stato pensato sono gli
- studentu di matematica (dalla scuola superiore all'università), gli insegnanti
+ studenti di matematica (dalla scuola superiore all'università), gli insegnanti
e i ricercatori in matematica. Lo scopo è di fornire software che possa essere
usato per esplorare e sperimentare le costruzioni matematiche in algebra,
geometria, teoria dei numeri, calcolo, calcolo numerico, ecc. Sage aiuta a
@@ -111,11 +111,11 @@ Obiettivi di lungo periodo per Sage
operazioni.
- **Libero e open source:** il codice sorgente deve essere liberamente disponibile
- e leggibile, così che gli utenti posssano capire cosa stia facendo veramente il
+ e leggibile, così che gli utenti possano capire cosa stia facendo veramente il
sistema e possano estenderlo più facilmente. Così come i matematici acquisiscono
- una comprensione più profonda di un teorema leggendo attentamete o almeno scorrendo
+ una comprensione più profonda di un teorema leggendo attentamente o almeno scorrendo
velocemente la dimostrazione, le persone che fanno calcoli dovrebbero essere capaci
- di capire come funzionano i calcoli leggengo il codice sorgente documentato. Se
+ di capire come funzionano i calcoli leggendo il codice sorgente documentato. Se
si usa Sage per fare calcoli in un articolo che si pubblica, si può essere rassicurati
dal fatto che i lettori avranno sempre libero accesso a Sage e a tutto il suo codice
sorgente ed è persino concesso di archiviare la versione di Sage che si è utilizzata.
diff --git a/src/doc/it/tutorial/tour_algebra.rst b/src/doc/it/tutorial/tour_algebra.rst
index cde427d3090..4c301d7b1b2 100644
--- a/src/doc/it/tutorial/tour_algebra.rst
+++ b/src/doc/it/tutorial/tour_algebra.rst
@@ -71,7 +71,7 @@ l'argomento è il numero di bit di precisione.)
Differenziazione, Integrazione, etc.
------------------------------------
-Sage è in grado di differenziae ed integrare molte funzioni. Per
+Sage è in grado di differenziare ed integrare molte funzioni. Per
esempio, per differenziare :math:`\sin(u)` rispetto a :math:`u`,
si procede come nelle righe seguenti:
@@ -379,7 +379,7 @@ e "Funzioni speciali", rispettivamente) del manuale di Sage.
0.167089499251049
A questo punto, Sage ha soltanto incorporato queste funzioni per l'uso numerico.
-Per l'uso simbolico, si usi direttamente l'intefaccia di Maxima, come
+Per l'uso simbolico, si usi direttamente l'interfaccia di Maxima, come
nell'esempio seguente::
sage: maxima.eval("f:bessel_y(v, w)")
diff --git a/src/sage/algebras/clifford_algebra_element.pxd b/src/sage/algebras/clifford_algebra_element.pxd
index 14d5a7a625c..be08e06f922 100644
--- a/src/sage/algebras/clifford_algebra_element.pxd
+++ b/src/sage/algebras/clifford_algebra_element.pxd
@@ -5,8 +5,8 @@ from sage.modules.with_basis.indexed_element cimport IndexedFreeModuleElement
from sage.data_structures.bitset cimport FrozenBitset
cdef class CliffordAlgebraElement(IndexedFreeModuleElement):
- cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff)
- cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff)
+ cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff) noexcept
+ cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff) noexcept
cdef class ExteriorAlgebraElement(CliffordAlgebraElement):
pass
diff --git a/src/sage/algebras/clifford_algebra_element.pyx b/src/sage/algebras/clifford_algebra_element.pyx
index 046ee44c8e9..0a1a4adb681 100644
--- a/src/sage/algebras/clifford_algebra_element.pyx
+++ b/src/sage/algebras/clifford_algebra_element.pyx
@@ -64,7 +64,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement):
"""
return repr_from_monomials(self.list(), self._parent._latex_term, True)
- cdef _mul_(self, other):
+ cdef _mul_(self, other) noexcept:
"""
Return ``self`` multiplied by ``other``.
@@ -175,7 +175,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement):
return self.__class__(self.parent(), d)
- cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff):
+ cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff) noexcept:
r"""
Multiply ``self * term`` with the ``term`` having support ``supp``
and coefficient ``coeff``.
@@ -223,7 +223,7 @@ cdef class CliffordAlgebraElement(IndexedFreeModuleElement):
return type(self)(self._parent, {supp: coeff}) * self
- cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff):
+ cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff) noexcept:
r"""
Multiply ``term * self`` with the ``term`` having support ``supp``
and coefficient ``coeff``.
@@ -399,7 +399,7 @@ cdef class ExteriorAlgebraElement(CliffordAlgebraElement):
"""
An element of an exterior algebra.
"""
- cdef _mul_(self, other):
+ cdef _mul_(self, other) noexcept:
"""
Return ``self`` multiplied by ``other``.
@@ -519,7 +519,7 @@ cdef class ExteriorAlgebraElement(CliffordAlgebraElement):
return self.__class__(P, d)
- cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff):
+ cdef CliffordAlgebraElement _mul_self_term(self, FrozenBitset supp, coeff) noexcept:
r"""
Multiply ``self * term`` with the ``term`` having support ``supp``
and coefficient ``coeff``.
@@ -609,7 +609,7 @@ cdef class ExteriorAlgebraElement(CliffordAlgebraElement):
del d[k]
return type(self)(self._parent, d)
- cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff):
+ cdef CliffordAlgebraElement _mul_term_self(self, FrozenBitset supp, coeff) noexcept:
r"""
Multiply ``term * self`` with the ``term`` having support ``supp``
and coefficient ``coeff``.
@@ -938,7 +938,7 @@ cdef class CohomologyRAAGElement(CliffordAlgebraElement):
:class:`~sage.groups.raag.CohomologyRAAG`
"""
- cdef _mul_(self, other):
+ cdef _mul_(self, other) noexcept:
"""
Return ``self`` multiplied by ``other``.
diff --git a/src/sage/algebras/exterior_algebra_groebner.pxd b/src/sage/algebras/exterior_algebra_groebner.pxd
index 28cea102be7..bf5ee24ea22 100644
--- a/src/sage/algebras/exterior_algebra_groebner.pxd
+++ b/src/sage/algebras/exterior_algebra_groebner.pxd
@@ -7,8 +7,8 @@ from sage.algebras.clifford_algebra_element cimport CliffordAlgebraElement
from sage.structure.parent cimport Parent
from sage.structure.element cimport MonoidElement
-cdef long degree(FrozenBitset X)
-cdef CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp)
+cdef long degree(FrozenBitset X) noexcept
+cdef CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp) noexcept
cdef class GBElement:
cdef CliffordAlgebraElement elt
@@ -24,25 +24,25 @@ cdef class GroebnerStrategy:
cdef Integer rank
cdef public tuple groebner_basis
- cdef inline GBElement build_elt(self, CliffordAlgebraElement f)
- cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t)
- cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f)
- cdef inline bint build_S_poly(self, GBElement f, GBElement g)
+ cdef inline GBElement build_elt(self, CliffordAlgebraElement f) noexcept
+ cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t) noexcept
+ cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f) noexcept
+ cdef inline bint build_S_poly(self, GBElement f, GBElement g) noexcept
- cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f)
- cdef inline partial_S_poly_left(self, GBElement f, GBElement g)
- cdef inline partial_S_poly_right(self, GBElement f, GBElement g)
- cdef set preprocessing(self, list P, list G)
- cdef list reduction(self, list P, list G)
+ cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f) noexcept
+ cdef inline partial_S_poly_left(self, GBElement f, GBElement g) noexcept
+ cdef inline partial_S_poly_right(self, GBElement f, GBElement g) noexcept
+ cdef set preprocessing(self, list P, list G) noexcept
+ cdef list reduction(self, list P, list G) noexcept
- cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f)
+ cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f) noexcept
cdef bint reduce_single(self, CliffordAlgebraElement f, CliffordAlgebraElement g) except -1
cdef int reduced_gb(self, list G) except -1
# These are the methods that determine the ordering of the monomials.
# These must be implemented in subclasses. Declare them as "inline" there.
- cdef Integer bitset_to_int(self, FrozenBitset X)
- cdef FrozenBitset int_to_bitset(self, Integer n)
+ cdef Integer bitset_to_int(self, FrozenBitset X) noexcept
+ cdef FrozenBitset int_to_bitset(self, Integer n) noexcept
cdef class GroebnerStrategyNegLex(GroebnerStrategy):
pass
diff --git a/src/sage/algebras/exterior_algebra_groebner.pyx b/src/sage/algebras/exterior_algebra_groebner.pyx
index ba46a5f38b4..376eb454082 100644
--- a/src/sage/algebras/exterior_algebra_groebner.pyx
+++ b/src/sage/algebras/exterior_algebra_groebner.pyx
@@ -29,14 +29,14 @@ from sage.structure.richcmp cimport richcmp, rich_to_bool
from sage.data_structures.blas_dict cimport iaxpy
from copy import copy
-cdef inline long degree(FrozenBitset X):
+cdef inline long degree(FrozenBitset X) noexcept:
"""
Compute the degree of ``X``.
"""
return bitset_len(X._bitset)
-cdef inline CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp):
+cdef inline CliffordAlgebraElement build_monomial(Parent E, FrozenBitset supp) noexcept:
"""
Helper function for the fastest way to build a monomial.
"""
@@ -129,14 +129,14 @@ cdef class GroebnerStrategy:
else:
self.side = 2
- cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f):
+ cdef inline FrozenBitset leading_support(self, CliffordAlgebraElement f) noexcept:
"""
Return the leading support of the exterior algebra element ``f``.
"""
cdef dict mc = f._monomial_coefficients
return self.int_to_bitset(max(self.bitset_to_int(k) for k in mc))
- cdef inline partial_S_poly_left(self, GBElement f, GBElement g):
+ cdef inline partial_S_poly_left(self, GBElement f, GBElement g) noexcept:
r"""
Compute one half of the `S`-polynomial for ``f`` and ``g``.
@@ -153,7 +153,7 @@ cdef class GroebnerStrategy:
ret.elt._monomial_coefficients[k] *= inv
return ret
- cdef inline partial_S_poly_right(self, GBElement f, GBElement g):
+ cdef inline partial_S_poly_right(self, GBElement f, GBElement g) noexcept:
r"""
Compute one half of the `S`-polynomial for ``f`` and ``g``.
@@ -170,7 +170,7 @@ cdef class GroebnerStrategy:
ret.elt._monomial_coefficients[k] *= inv
return ret
- cdef inline GBElement build_elt(self, CliffordAlgebraElement f):
+ cdef inline GBElement build_elt(self, CliffordAlgebraElement f) noexcept:
"""
Convert ``f`` into a ``GBElement``.
"""
@@ -180,7 +180,7 @@ cdef class GroebnerStrategy:
cdef Integer r = max(self.bitset_to_int(k) for k in mc)
return GBElement(f, self.int_to_bitset(r), r)
- cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t):
+ cdef inline GBElement prod_GB_term(self, GBElement f, FrozenBitset t) noexcept:
"""
Return the GBElement corresponding to ``f * t``.
@@ -192,7 +192,7 @@ cdef class GroebnerStrategy:
cdef FrozenBitset ls = f.ls._union(t)
return GBElement( ret, ls, self.bitset_to_int(ls))
- cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f):
+ cdef inline GBElement prod_term_GB(self, FrozenBitset t, GBElement f) noexcept:
"""
Return the GBElement corresponding to ``t * f``.
@@ -204,7 +204,7 @@ cdef class GroebnerStrategy:
cdef FrozenBitset ls = f.ls._union(t)
return GBElement( ret, ls, self.bitset_to_int(ls))
- cdef inline bint build_S_poly(self, GBElement f, GBElement g):
+ cdef inline bint build_S_poly(self, GBElement f, GBElement g) noexcept:
r"""
Check to see if we should build the `S`-polynomial.
@@ -219,7 +219,7 @@ cdef class GroebnerStrategy:
return ( f.ls.intersection(g.ls)).isempty()
- cdef inline set preprocessing(self, list P, list G):
+ cdef inline set preprocessing(self, list P, list G) noexcept:
"""
Perform the preprocessing step.
"""
@@ -265,7 +265,7 @@ cdef class GroebnerStrategy:
break
return L
- cdef inline list reduction(self, list P, list G):
+ cdef inline list reduction(self, list P, list G) noexcept:
"""
Perform the reduction of ``P`` mod ``G`` in ``E``.
"""
@@ -450,7 +450,7 @@ cdef class GroebnerStrategy:
cdef list G = [self.build_elt(f) for f in self.groebner_basis]
self.reduced_gb(G)
- cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f):
+ cpdef CliffordAlgebraElement reduce(self, CliffordAlgebraElement f) noexcept:
"""
Reduce ``f`` modulo the ideal with Gröbner basis ``G``.
@@ -515,10 +515,10 @@ cdef class GroebnerStrategy:
iaxpy(-coeff, gp._monomial_coefficients, f._monomial_coefficients)
return was_reduced
- cdef Integer bitset_to_int(self, FrozenBitset X):
+ cdef Integer bitset_to_int(self, FrozenBitset X) noexcept:
raise NotImplementedError
- cdef FrozenBitset int_to_bitset(self, Integer n):
+ cdef FrozenBitset int_to_bitset(self, Integer n) noexcept:
raise NotImplementedError
def sorted_monomials(self, as_dict=False):
@@ -597,7 +597,7 @@ cdef class GroebnerStrategyNegLex(GroebnerStrategy):
"""
Gröbner basis strategy implementing neglex ordering.
"""
- cdef inline Integer bitset_to_int(self, FrozenBitset X):
+ cdef inline Integer bitset_to_int(self, FrozenBitset X) noexcept:
"""
Convert ``X`` to an :class:`Integer`.
"""
@@ -608,7 +608,7 @@ cdef class GroebnerStrategyNegLex(GroebnerStrategy):
elt = bitset_next(X._bitset, elt + 1)
return ret
- cdef inline FrozenBitset int_to_bitset(self, Integer n):
+ cdef inline FrozenBitset int_to_bitset(self, Integer n) noexcept:
"""
Convert a nonnegative integer ``n`` to a :class:`FrozenBitset`.
"""
@@ -628,7 +628,7 @@ cdef class GroebnerStrategyDegRevLex(GroebnerStrategy):
"""
Gröbner basis strategy implementing degree revlex ordering.
"""
- cdef inline Integer bitset_to_int(self, FrozenBitset X):
+ cdef inline Integer bitset_to_int(self, FrozenBitset X) noexcept:
"""
Convert ``X`` to an :class:`Integer`.
"""
@@ -647,7 +647,7 @@ cdef class GroebnerStrategyDegRevLex(GroebnerStrategy):
elt = bitset_next(X._bitset, elt + 1)
return Integer(sum(n.binomial(i) for i in range(deg+1)) - t - 1)
- cdef inline FrozenBitset int_to_bitset(self, Integer n):
+ cdef inline FrozenBitset int_to_bitset(self, Integer n) noexcept:
"""
Convert a nonnegative integer ``n`` to a :class:`FrozenBitset`.
"""
@@ -669,7 +669,7 @@ cdef class GroebnerStrategyDegLex(GroebnerStrategy):
"""
Gröbner basis strategy implementing degree lex ordering.
"""
- cdef inline Integer bitset_to_int(self, FrozenBitset X):
+ cdef inline Integer bitset_to_int(self, FrozenBitset X) noexcept:
"""
Convert ``X`` to an :class:`Integer`.
"""
@@ -688,7 +688,7 @@ cdef class GroebnerStrategyDegLex(GroebnerStrategy):
elt = bitset_next(X._bitset, elt + 1)
return Integer(sum(n.binomial(i) for i in range(deg+1)) - t - 1)
- cdef inline FrozenBitset int_to_bitset(self, Integer n):
+ cdef inline FrozenBitset int_to_bitset(self, Integer n) noexcept:
"""
Convert a nonnegative integer ``n`` to a :class:`FrozenBitset`.
"""
diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd
index c13b8dbab07..dd5f85be9fb 100644
--- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd
+++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd
@@ -6,4 +6,4 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
cdef Matrix __matrix
cdef FiniteDimensionalAlgebraElement __inverse
-cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat)
+cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat) noexcept
diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx
index 1fc0977ce10..e4901439e19 100644
--- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx
+++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx
@@ -20,7 +20,7 @@ from sage.rings.integer import Integer
from cpython.object cimport PyObject_RichCompare as richcmp
-cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat):
+cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A, vec, mat) noexcept:
"""
Helper for unpickling of finite dimensional algebra elements.
@@ -341,7 +341,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
return self._vector.ncols()
# (Rich) comparison
- cpdef _richcmp_(self, right, int op):
+ cpdef _richcmp_(self, right, int op) noexcept:
"""
EXAMPLES::
@@ -373,7 +373,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
"""
return richcmp(self._vector, right._vector, op)
- cpdef _add_(self, other):
+ cpdef _add_(self, other) noexcept:
"""
EXAMPLES::
@@ -383,7 +383,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
"""
return self._parent.element_class(self._parent, self._vector + other._vector)
- cpdef _sub_(self, other):
+ cpdef _sub_(self, other) noexcept:
"""
EXAMPLES::
@@ -393,7 +393,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
"""
return self._parent.element_class(self._parent, self._vector - other._vector)
- cpdef _mul_(self, other):
+ cpdef _mul_(self, other) noexcept:
"""
EXAMPLES::
@@ -403,7 +403,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
"""
return self._parent.element_class(self._parent, self._vector * (other)._matrix)
- cpdef _lmul_(self, Element other):
+ cpdef _lmul_(self, Element other) noexcept:
"""
TESTS::
@@ -417,7 +417,7 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement):
.format(self.parent(), other.parent()))
return self._parent.element_class(self._parent, self._vector * other)
- cpdef _rmul_(self, Element other):
+ cpdef _rmul_(self, Element other) noexcept:
"""
TESTS::
diff --git a/src/sage/algebras/free_algebra_quotient.py b/src/sage/algebras/free_algebra_quotient.py
index 81c7f5ad91e..b19884335c4 100644
--- a/src/sage/algebras/free_algebra_quotient.py
+++ b/src/sage/algebras/free_algebra_quotient.py
@@ -65,7 +65,7 @@
from sage.structure.unique_representation import UniqueRepresentation
-class FreeAlgebraQuotient(UniqueRepresentation, Algebra, object):
+class FreeAlgebraQuotient(UniqueRepresentation, Algebra):
@staticmethod
def __classcall__(cls, A, mons, mats, names):
"""
diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd
index e0908ab5884..19e98aa137d 100644
--- a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd
+++ b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd
@@ -1,4 +1,4 @@
-cdef _fmat(fvars, Nk_ij, one, a, b, c, d, x, y)
-cpdef _backward_subs(factory, bint flatten=*)
-cpdef executor(tuple params)
-cpdef _solve_for_linear_terms(factory, list eqns=*)
+cdef _fmat(fvars, Nk_ij, one, a, b, c, d, x, y) noexcept
+cpdef _backward_subs(factory, bint flatten=*) noexcept
+cpdef executor(tuple params) noexcept
+cpdef _solve_for_linear_terms(factory, list eqns=*) noexcept
diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx
index a9b7eb50fab..b79370c7f2c 100644
--- a/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx
+++ b/src/sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx
@@ -32,7 +32,7 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
# Fast class methods #
##########################
-cpdef _solve_for_linear_terms(factory, list eqns=None):
+cpdef _solve_for_linear_terms(factory, list eqns=None) noexcept:
r"""
Solve for a linear term occurring in a two-term equation, and for
variables appearing in univariate single-term equations.
@@ -107,7 +107,7 @@ cpdef _solve_for_linear_terms(factory, list eqns=None):
# assert _unflatten_coeffs(factory._field, factory.test_fvars[s]) == fvars[s], "OG value {}, Shared: {}".format(factory.test_fvars[s], fvars[s])
return linear_terms_exist
-cpdef _backward_subs(factory, bint flatten=True):
+cpdef _backward_subs(factory, bint flatten=True) noexcept:
r"""
Perform backward substitution on ``self.ideal_basis``, traversing
variables in reverse lexicographical order.
@@ -171,7 +171,7 @@ cpdef _backward_subs(factory, bint flatten=True):
fvars[sextuple] = res
-cdef _fmat(fvars, _Nk_ij, id_anyon, a, b, c, d, x, y):
+cdef _fmat(fvars, _Nk_ij, id_anyon, a, b, c, d, x, y) noexcept:
"""
Cython version of fmat class method. Using cdef for fastest dispatch
"""
@@ -214,7 +214,7 @@ cdef _fmat(fvars, _Nk_ij, id_anyon, a, b, c, d, x, y):
# Mappers #
###############
-cdef req_cy(tuple basis, r_matrix, dict fvars, Nk_ij, id_anyon, tuple sextuple):
+cdef req_cy(tuple basis, r_matrix, dict fvars, Nk_ij, id_anyon, tuple sextuple) noexcept:
"""
Given an FMatrix factory and a sextuple, return a hexagon equation
as a polynomial object.
@@ -232,7 +232,7 @@ cdef req_cy(tuple basis, r_matrix, dict fvars, Nk_ij, id_anyon, tuple sextuple):
@cython.wraparound(False)
@cython.nonecheck(False)
@cython.cdivision(True)
-cdef get_reduced_hexagons(factory, tuple mp_params):
+cdef get_reduced_hexagons(factory, tuple mp_params) noexcept:
"""
Set up and reduce the hexagon equations corresponding to this worker.
"""
@@ -282,7 +282,7 @@ cdef get_reduced_hexagons(factory, tuple mp_params):
return collect_eqns(worker_results)
-cdef MPolynomial_libsingular feq_cy(tuple basis, fvars, Nk_ij, id_anyon, zero, tuple nonuple, bint prune=False):
+cdef MPolynomial_libsingular feq_cy(tuple basis, fvars, Nk_ij, id_anyon, zero, tuple nonuple, bint prune=False) noexcept:
r"""
Given an FMatrix factory and a nonuple, return a pentagon equation
as a polynomial object.
@@ -301,7 +301,7 @@ cdef MPolynomial_libsingular feq_cy(tuple basis, fvars, Nk_ij, id_anyon, zero, t
@cython.wraparound(False)
@cython.nonecheck(False)
@cython.cdivision(True)
-cdef get_reduced_pentagons(factory, tuple mp_params):
+cdef get_reduced_pentagons(factory, tuple mp_params) noexcept:
r"""
Set up and reduce the pentagon equations corresponding to this worker.
"""
@@ -349,7 +349,7 @@ cdef get_reduced_pentagons(factory, tuple mp_params):
worker_results.append(red)
return collect_eqns(worker_results)
-cdef list update_reduce(factory, list eqns):
+cdef list update_reduce(factory, list eqns) noexcept:
r"""
Substitute known values, known squares, and reduce.
"""
@@ -381,7 +381,7 @@ cdef list update_reduce(factory, list eqns):
res.append(red)
return collect_eqns(res)
-cdef list compute_gb(factory, tuple args):
+cdef list compute_gb(factory, tuple args) noexcept:
r"""
Compute the reduced Groebner basis for given equations iterable.
"""
@@ -425,7 +425,7 @@ cdef list compute_gb(factory, tuple args):
# Reducers #
################
-cdef inline list collect_eqns(list eqns):
+cdef inline list collect_eqns(list eqns) noexcept:
r"""
Helper function for returning processed results back to parent process.
@@ -450,7 +450,7 @@ cdef dict mappers = {
"pent_verify": pent_verify
}
-cpdef executor(tuple params):
+cpdef executor(tuple params) noexcept:
r"""
Execute a function defined in this module
(``sage.algebras.fusion_rings.fast_parallel_fmats_methods``) in a worker
@@ -497,7 +497,7 @@ cpdef executor(tuple params):
# Verification #
####################
-cdef feq_verif(factory, worker_results, fvars, Nk_ij, id_anyon, tuple nonuple, float tol=5e-8):
+cdef feq_verif(factory, worker_results, fvars, Nk_ij, id_anyon, tuple nonuple, float tol=5e-8) noexcept:
r"""
Check the pentagon equation corresponding to the given nonuple.
"""
@@ -516,7 +516,7 @@ cdef feq_verif(factory, worker_results, fvars, Nk_ij, id_anyon, tuple nonuple, f
@cython.wraparound(False)
@cython.nonecheck(False)
@cython.cdivision(True)
-cdef pent_verify(factory, tuple mp_params):
+cdef pent_verify(factory, tuple mp_params) noexcept:
r"""
Generate all the pentagon equations assigned to this process,
and reduce them.
diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd
index a992f0339a4..9fde1f0c5e8 100644
--- a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd
+++ b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd
@@ -1,2 +1,2 @@
-cpdef _unflatten_entries(factory, list entries)
-cpdef executor(tuple params)
+cpdef _unflatten_entries(factory, list entries) noexcept
+cpdef executor(tuple params) noexcept
diff --git a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx
index 8fc054f50cd..9ba832c5124 100644
--- a/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx
+++ b/src/sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx
@@ -18,7 +18,7 @@ from sage.rings.qqbar import QQbar
# Mappers #
###############
-cdef mid_sig_ij(fusion_ring, row, col, a, b):
+cdef mid_sig_ij(fusion_ring, row, col, a, b) noexcept:
r"""
Compute the (xi, yi), (xj, yj) entry of generator braiding the middle two
strands in the tree b -> xi # yi -> (a # a) # (a # a), which results in
@@ -48,7 +48,7 @@ cdef mid_sig_ij(fusion_ring, row, col, a, b):
entry += f1 * f2 * r * f3 * f4
return entry
-cdef odd_one_out_ij(fusion_ring, xi, xj, a, b):
+cdef odd_one_out_ij(fusion_ring, xi, xj, a, b) noexcept:
r"""
Compute the `xi`, `xj` entry of the braid generator on the two right-most
strands, corresponding to the tree b -> (xi # a) -> (a # a) # a, which
@@ -76,7 +76,7 @@ cdef odd_one_out_ij(fusion_ring, xi, xj, a, b):
cdef odd_one_out_ij_cache = dict()
cdef mid_sig_ij_cache = dict()
-cdef cached_mid_sig_ij(fusion_ring, row, col, a, b):
+cdef cached_mid_sig_ij(fusion_ring, row, col, a, b) noexcept:
r"""
Cached version of :meth:`mid_sig_ij`.
"""
@@ -86,7 +86,7 @@ cdef cached_mid_sig_ij(fusion_ring, row, col, a, b):
mid_sig_ij_cache[row, col, a, b] = entry
return entry
-cdef cached_odd_one_out_ij(fusion_ring, xi, xj, a, b):
+cdef cached_odd_one_out_ij(fusion_ring, xi, xj, a, b) noexcept:
r"""
Cached version of :meth:`odd_one_out_ij`.
"""
@@ -99,7 +99,7 @@ cdef cached_odd_one_out_ij(fusion_ring, xi, xj, a, b):
@cython.nonecheck(False)
@cython.cdivision(True)
-cdef sig_2k(fusion_ring, tuple args):
+cdef sig_2k(fusion_ring, tuple args) noexcept:
r"""
Compute entries of the `2k`-th braid generator
"""
@@ -179,7 +179,7 @@ cdef sig_2k(fusion_ring, tuple args):
@cython.nonecheck(False)
@cython.cdivision(True)
-cdef odd_one_out(fusion_ring, tuple args):
+cdef odd_one_out(fusion_ring, tuple args) noexcept:
r"""
Compute entries of the rightmost braid generator, in case we have an
odd number of strands.
@@ -263,7 +263,7 @@ cdef dict mappers = {
"odd_one_out": odd_one_out
}
-cpdef executor(tuple params):
+cpdef executor(tuple params) noexcept:
r"""
Execute a function registered in this module's ``mappers``
in a worker process, and supply the ``FusionRing`` parameter by
@@ -305,7 +305,7 @@ cpdef executor(tuple params):
# Pickling circumvention helpers #
######################################
-cpdef _unflatten_entries(fusion_ring, list entries):
+cpdef _unflatten_entries(fusion_ring, list entries) noexcept:
r"""
Restore cyclotomic coefficient object from its tuple of rational
coefficients representation.
diff --git a/src/sage/algebras/fusion_rings/poly_tup_engine.pxd b/src/sage/algebras/fusion_rings/poly_tup_engine.pxd
index a4ddf9b92ae..ac2c5041de9 100644
--- a/src/sage/algebras/fusion_rings/poly_tup_engine.pxd
+++ b/src/sage/algebras/fusion_rings/poly_tup_engine.pxd
@@ -3,21 +3,21 @@ from sage.rings.number_field.number_field_element cimport NumberFieldElement_abs
from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular, MPolynomialRing_libsingular
from sage.rings.polynomial.polydict cimport ETuple
-cpdef tuple poly_to_tup(MPolynomial_libsingular poly)
-cpdef MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent)
-cpdef tuple resize(tuple eq_tup, dict idx_map, int nvars)
-cpdef list get_variables_degrees(list eqns, int nvars)
-cpdef list variables(tuple eq_tup)
-cpdef constant_coeff(tuple eq_tup, field)
-cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map)
+cpdef tuple poly_to_tup(MPolynomial_libsingular poly) noexcept
+cpdef MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent) noexcept
+cpdef tuple resize(tuple eq_tup, dict idx_map, int nvars) noexcept
+cpdef list get_variables_degrees(list eqns, int nvars) noexcept
+cpdef list variables(tuple eq_tup) noexcept
+cpdef constant_coeff(tuple eq_tup, field) noexcept
+cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map) noexcept
# cpdef bint tup_fixes_sq(tuple eq_tup)
-cdef bint tup_fixes_sq(tuple eq_tup)
-cdef dict subs_squares(dict eq_dict, KSHandler known_sq)
-cpdef dict compute_known_powers(max_degs, dict val_dict, one)
-cdef dict subs(tuple poly_tup, dict known_powers, one)
-cpdef tup_to_univ_poly(tuple eq_tup, univ_poly_ring)
-cpdef tuple poly_tup_sortkey(tuple eq_tup)
-cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one)
-cdef tuple _flatten_coeffs(tuple eq_tup)
-cpdef tuple _unflatten_coeffs(field, tuple eq_tup)
-cdef int has_appropriate_linear_term(tuple eq_tup)
+cdef bint tup_fixes_sq(tuple eq_tup) noexcept
+cdef dict subs_squares(dict eq_dict, KSHandler known_sq) noexcept
+cpdef dict compute_known_powers(max_degs, dict val_dict, one) noexcept
+cdef dict subs(tuple poly_tup, dict known_powers, one) noexcept
+cpdef tup_to_univ_poly(tuple eq_tup, univ_poly_ring) noexcept
+cpdef tuple poly_tup_sortkey(tuple eq_tup) noexcept
+cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one) noexcept
+cdef tuple _flatten_coeffs(tuple eq_tup) noexcept
+cpdef tuple _unflatten_coeffs(field, tuple eq_tup) noexcept
+cdef int has_appropriate_linear_term(tuple eq_tup) noexcept
diff --git a/src/sage/algebras/fusion_rings/poly_tup_engine.pyx b/src/sage/algebras/fusion_rings/poly_tup_engine.pyx
index 67176402134..5c3f54df9a6 100644
--- a/src/sage/algebras/fusion_rings/poly_tup_engine.pyx
+++ b/src/sage/algebras/fusion_rings/poly_tup_engine.pyx
@@ -12,7 +12,7 @@ Arithmetic Engine for Polynomials as Tuples
# API #
###########
-cpdef inline tuple poly_to_tup(MPolynomial_libsingular poly):
+cpdef inline tuple poly_to_tup(MPolynomial_libsingular poly) noexcept:
r"""
Convert a polynomial object into the internal representation as tuple of
``(ETuple exp, NumberFieldElement coeff)`` pairs.
@@ -28,7 +28,7 @@ cpdef inline tuple poly_to_tup(MPolynomial_libsingular poly):
"""
return tuple(poly.dict().items())
-cpdef inline MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent):
+cpdef inline MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_libsingular parent) noexcept:
r"""
Return a polynomial object from its tuple of pairs representation.
@@ -74,7 +74,7 @@ cpdef inline MPolynomial_libsingular _tup_to_poly(tuple eq_tup, MPolynomialRing_
"""
return parent._element_constructor_(dict(eq_tup), check=False)
-cdef inline tuple _flatten_coeffs(tuple eq_tup):
+cdef inline tuple _flatten_coeffs(tuple eq_tup) noexcept:
r"""
Flatten cyclotomic coefficients to a representation as a tuple of rational
coefficients.
@@ -88,7 +88,7 @@ cdef inline tuple _flatten_coeffs(tuple eq_tup):
flat.append((exp, tuple(cyc_coeff._coefficients())))
return tuple(flat)
-cpdef tuple _unflatten_coeffs(field, tuple eq_tup):
+cpdef tuple _unflatten_coeffs(field, tuple eq_tup) noexcept:
r"""
Restore cyclotomic coefficient object from its tuple of rational
coefficients representation.
@@ -118,7 +118,7 @@ cpdef tuple _unflatten_coeffs(field, tuple eq_tup):
# Useful private predicates #
#################################
-cdef inline int has_appropriate_linear_term(tuple eq_tup):
+cdef inline int has_appropriate_linear_term(tuple eq_tup) noexcept:
r"""
Determine whether the given tuple of pairs (of length 2) contains
an *appropriate* linear term.
@@ -149,7 +149,7 @@ cdef inline int has_appropriate_linear_term(tuple eq_tup):
# "Change rings" #
######################
-cpdef inline tup_to_univ_poly(tuple eq_tup, univ_poly_ring):
+cpdef inline tup_to_univ_poly(tuple eq_tup, univ_poly_ring) noexcept:
r"""
Given a tuple of pairs representing a univariate polynomial and a univariate
polynomial ring, return a univariate polynomial object.
@@ -177,7 +177,7 @@ cpdef inline tup_to_univ_poly(tuple eq_tup, univ_poly_ring):
cdef NumberFieldElement_absolute c
return univ_poly_ring({exp._data[1] if exp._nonzero else 0: c for exp, c in eq_tup})
-cpdef inline tuple resize(tuple eq_tup, dict idx_map, int nvars):
+cpdef inline tuple resize(tuple eq_tup, dict idx_map, int nvars) noexcept:
r"""
Return a tuple representing a polynomial in a ring with
``len(sorted_vars)`` generators.
@@ -218,7 +218,7 @@ cpdef inline tuple resize(tuple eq_tup, dict idx_map, int nvars):
# Convenience methods #
###########################
-cdef inline ETuple degrees(tuple poly_tup):
+cdef inline ETuple degrees(tuple poly_tup) noexcept:
r"""
Return the maximal degree of each variable in the polynomial.
"""
@@ -232,7 +232,7 @@ cdef inline ETuple degrees(tuple poly_tup):
max_degs = max_degs.emax( ( poly_tup[i])[0])
return max_degs
-cpdef list get_variables_degrees(list eqns, int nvars):
+cpdef list get_variables_degrees(list eqns, int nvars) noexcept:
r"""
Find maximum degrees for each variable in equations.
@@ -257,7 +257,7 @@ cpdef list get_variables_degrees(list eqns, int nvars):
dense[max_deg._data[2*i]] = max_deg._data[2*i+1]
return dense
-cpdef list variables(tuple eq_tup):
+cpdef list variables(tuple eq_tup) noexcept:
"""
Return indices of all variables appearing in eq_tup
@@ -277,7 +277,7 @@ cpdef list variables(tuple eq_tup):
"""
return degrees(eq_tup).nonzero_positions()
-cpdef constant_coeff(tuple eq_tup, field):
+cpdef constant_coeff(tuple eq_tup, field) noexcept:
r"""
Return the constant coefficient of the polynomial represented by
given tuple.
@@ -300,7 +300,7 @@ cpdef constant_coeff(tuple eq_tup, field):
return coeff
return field.zero()
-cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map):
+cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map) noexcept:
"""
Apply ``coeff_map`` to coefficients.
@@ -320,7 +320,7 @@ cpdef tuple apply_coeff_map(tuple eq_tup, coeff_map):
return tuple(new_tup)
# cpdef inline bint tup_fixes_sq(tuple eq_tup):
-cdef inline bint tup_fixes_sq(tuple eq_tup):
+cdef inline bint tup_fixes_sq(tuple eq_tup) noexcept:
r"""
Determine if given equation fixes the square of a variable.
@@ -342,7 +342,7 @@ cdef inline bint tup_fixes_sq(tuple eq_tup):
# Simplification #
######################
-cdef dict subs_squares(dict eq_dict, KSHandler known_sq):
+cdef dict subs_squares(dict eq_dict, KSHandler known_sq) noexcept:
r"""
Substitute for known squares into a given polynomial.
@@ -379,7 +379,7 @@ cdef dict subs_squares(dict eq_dict, KSHandler known_sq):
subbed[exp] = coeff
return subbed
-cdef dict remove_gcf(dict eq_dict, ETuple nonz):
+cdef dict remove_gcf(dict eq_dict, ETuple nonz) noexcept:
r"""
Return a dictionary of ``(ETuple, coeff)`` pairs describing the
polynomial ``eq / GCF(eq)``.
@@ -399,7 +399,7 @@ cdef dict remove_gcf(dict eq_dict, ETuple nonz):
ret[exp.esub(common_powers)] = c
return ret
-cdef tuple to_monic(dict eq_dict, one):
+cdef tuple to_monic(dict eq_dict, one) noexcept:
"""
Return tuple of pairs ``(ETuple, coeff)`` describing the monic polynomial
associated to ``eq_dict``.
@@ -422,7 +422,7 @@ cdef tuple to_monic(dict eq_dict, one):
ret.append((ord_monoms[n-2-i], inv_lc * eq_dict[ord_monoms[n-2-i]]))
return tuple(ret)
-cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one):
+cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, NumberFieldElement_absolute one) noexcept:
"""
Return a tuple describing a monic polynomial with no known nonzero
gcf and no known squares.
@@ -437,7 +437,7 @@ cdef tuple reduce_poly_dict(dict eq_dict, ETuple nonz, KSHandler known_sq, Numbe
# Substitution #
####################
-cpdef dict compute_known_powers(max_degs, dict val_dict, one):
+cpdef dict compute_known_powers(max_degs, dict val_dict, one) noexcept:
"""
Pre-compute powers of known values for efficiency when preparing to
substitute into a list of polynomials.
@@ -482,7 +482,7 @@ cpdef dict compute_known_powers(max_degs, dict val_dict, one):
known_powers[var_idx][power+1] = tup_mul(known_powers[var_idx][power], val_dict[var_idx])
return known_powers
-cdef dict subs(tuple poly_tup, dict known_powers, one):
+cdef dict subs(tuple poly_tup, dict known_powers, one) noexcept:
"""
Substitute given variables into a polynomial tuple.
"""
@@ -505,7 +505,7 @@ cdef dict subs(tuple poly_tup, dict known_powers, one):
subbed[shifted_exp] = coeff * c
return subbed
-cdef tuple tup_mul(tuple p1, tuple p2):
+cdef tuple tup_mul(tuple p1, tuple p2) noexcept:
r"""
Multiplication of two polynomial tuples using schoolbook multiplication.
"""
@@ -524,7 +524,7 @@ cdef tuple tup_mul(tuple p1, tuple p2):
# Sorting #
###############
-cdef tuple monom_sortkey(ETuple exp):
+cdef tuple monom_sortkey(ETuple exp) noexcept:
r"""
Produce a sortkey for a monomial exponent with respect to degree
reversed lexicographic ordering.
@@ -535,7 +535,7 @@ cdef tuple monom_sortkey(ETuple exp):
cdef ETuple rev = exp.reversed().emul(-1)
return (deg, rev)
-cpdef tuple poly_tup_sortkey(tuple eq_tup):
+cpdef tuple poly_tup_sortkey(tuple eq_tup) noexcept:
r"""
Return the sortkey of a polynomial represented as a tuple of
``(ETuple, coeff)`` pairs with respect to the degree
diff --git a/src/sage/algebras/fusion_rings/shm_managers.pxd b/src/sage/algebras/fusion_rings/shm_managers.pxd
index 8f4967d6d0a..f1e2ed74714 100644
--- a/src/sage/algebras/fusion_rings/shm_managers.pxd
+++ b/src/sage/algebras/fusion_rings/shm_managers.pxd
@@ -8,10 +8,10 @@ cdef class KSHandler:
cdef NumberField field
cdef public object shm
- cdef bint contains(self, int idx)
- cdef NumberFieldElement_absolute get(self, int idx)
- cdef setitem(self, int idx, rhs)
- cpdef update(self, list eqns)
+ cdef bint contains(self, int idx) noexcept
+ cdef NumberFieldElement_absolute get(self, int idx) noexcept
+ cdef setitem(self, int idx, rhs) noexcept
+ cpdef update(self, list eqns) noexcept
cdef class FvarsHandler:
cdef dict sext_to_idx, obj_cache
diff --git a/src/sage/algebras/fusion_rings/shm_managers.pyx b/src/sage/algebras/fusion_rings/shm_managers.pyx
index bbb364e91dd..dcfa274b5ea 100644
--- a/src/sage/algebras/fusion_rings/shm_managers.pyx
+++ b/src/sage/algebras/fusion_rings/shm_managers.pyx
@@ -144,7 +144,7 @@ cdef class KSHandler:
@cython.nonecheck(False)
@cython.wraparound(False)
@cython.boundscheck(False)
- cdef NumberFieldElement_absolute get(self, int idx):
+ cdef NumberFieldElement_absolute get(self, int idx) noexcept:
r"""
Retrieve the known square corresponding to the given index,
if it exists.
@@ -175,7 +175,7 @@ cdef class KSHandler:
self.obj_cache[idx] = cyc_coeff
return cyc_coeff
- cpdef update(self, list eqns):
+ cpdef update(self, list eqns) noexcept:
r"""
Update ```self``'s ``shared_memory``-backed dictionary of known
squares. Keys are variable indices and corresponding values
@@ -242,7 +242,7 @@ cdef class KSHandler:
@cython.nonecheck(False)
@cython.wraparound(False)
@cython.infer_types(False)
- cdef setitem(self, int idx, rhs):
+ cdef setitem(self, int idx, rhs) noexcept:
"""
Create an entry corresponding to the given index.
@@ -269,7 +269,7 @@ cdef class KSHandler:
nums[i] = num
denoms[i] = denom
- cdef bint contains(self, int idx):
+ cdef bint contains(self, int idx) noexcept:
r"""
Determine whether ``self`` contains entry corresponding to given
``idx``.
diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd
index d22fe4e9a40..ddd77e94be7 100644
--- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd
+++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pxd
@@ -13,5 +13,5 @@ from sage.algebras.letterplace.free_algebra_letterplace cimport FreeAlgebra_lett
cdef class FreeAlgebraElement_letterplace(AlgebraElement):
cdef MPolynomial_libsingular _poly
- cpdef _add_(self, other)
- cpdef _mul_(self, other)
+ cpdef _add_(self, other) noexcept
+ cpdef _mul_(self, other) noexcept
diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx
index 9029a8b07a5..8e48f0530d9 100644
--- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx
+++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx
@@ -441,7 +441,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
return True
return False
- cpdef _richcmp_(self, other, int op):
+ cpdef _richcmp_(self, other, int op) noexcept:
"""
Implement comparisons, using the Cython richcmp convention.
@@ -458,7 +458,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
################################
# Arithmetic
- cpdef _neg_(self):
+ cpdef _neg_(self) noexcept:
"""
TESTS::
@@ -474,7 +474,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
return FreeAlgebraElement_letterplace(self._parent, -self._poly,
check=False)
- cpdef _add_(self, other):
+ cpdef _add_(self, other) noexcept:
"""
Addition, under the side condition that either one summand
is zero, or both summands have the same degree.
@@ -508,7 +508,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
self._poly + right._poly,
check=False)
- cpdef _sub_(self, other):
+ cpdef _sub_(self, other) noexcept:
"""
Difference, under the side condition that either one summand
is zero or both have the same weighted degree.
@@ -548,7 +548,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
self._poly - right._poly,
check=False)
- cpdef _lmul_(self, Element right):
+ cpdef _lmul_(self, Element right) noexcept:
"""
Multiplication from the right with an element of the base ring.
@@ -563,7 +563,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
self._poly._lmul_(right),
check=False)
- cpdef _rmul_(self, Element left):
+ cpdef _rmul_(self, Element left) noexcept:
"""
Multiplication from the left with an element of the base ring.
@@ -578,7 +578,7 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
self._poly._rmul_(left),
check=False)
- cpdef _mul_(self, other):
+ cpdef _mul_(self, other) noexcept:
"""
Product of two free algebra elements in letterplace implementation.
diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pxd b/src/sage/algebras/letterplace/free_algebra_letterplace.pxd
index 47a7275aba0..a726262546b 100644
--- a/src/sage/algebras/letterplace/free_algebra_letterplace.pxd
+++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pxd
@@ -29,6 +29,6 @@ cdef class FreeAlgebra_letterplace(Algebra):
cdef int _ngens
cdef int _nb_slackvars
cdef object __monoid
- cdef str exponents_to_string(self, E)
- cdef str exponents_to_latex(self, E)
+ cdef str exponents_to_string(self, E) noexcept
+ cdef str exponents_to_latex(self, E) noexcept
cdef tuple _degrees
diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx
index 53f0dfdea6d..ddf3e5c2f09 100644
--- a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx
+++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx
@@ -137,7 +137,7 @@ freeAlgebra = singular_function("freeAlgebra")
#####################
# Auxiliary functions
-cdef MPolynomialRing_libsingular make_letterplace_ring(base_ring, blocks):
+cdef MPolynomialRing_libsingular make_letterplace_ring(base_ring, blocks) noexcept:
"""
Create a polynomial ring in block order.
@@ -563,7 +563,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
return self.__monoid
# Auxiliar methods
- cdef str exponents_to_string(self, E):
+ cdef str exponents_to_string(self, E) noexcept:
"""
This auxiliary method is used for the string representation of elements of this free algebra.
@@ -605,7 +605,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
return '*'.join(out)
# Auxiliar methods
- cdef str exponents_to_latex(self, E):
+ cdef str exponents_to_latex(self, E) noexcept:
r"""
This auxiliary method is used for the representation of elements of this free algebra as a latex string.
@@ -689,7 +689,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
###########################
# Coercion
- cpdef _coerce_map_from_(self, S):
+ cpdef _coerce_map_from_(self, S) noexcept:
"""
A ring ``R`` coerces into self, if
diff --git a/src/sage/algebras/lie_algebras/lie_algebra_element.pxd b/src/sage/algebras/lie_algebras/lie_algebra_element.pxd
index fdae38396b9..9005eae72fd 100644
--- a/src/sage/algebras/lie_algebras/lie_algebra_element.pxd
+++ b/src/sage/algebras/lie_algebras/lie_algebra_element.pxd
@@ -4,24 +4,24 @@ from sage.structure.sage_object cimport SageObject
from sage.modules.with_basis.indexed_element cimport IndexedFreeModuleElement
cdef class LieAlgebraElement(IndexedFreeModuleElement):
- cpdef lift(self)
+ cpdef lift(self) noexcept
cdef class LieAlgebraElementWrapper(ElementWrapper):
- cpdef _add_(self, right)
- cpdef _sub_(self, right)
+ cpdef _add_(self, right) noexcept
+ cpdef _sub_(self, right) noexcept
cdef class LieAlgebraMatrixWrapper(LieAlgebraElementWrapper):
pass
cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
cdef dict _monomial_coefficients
- cpdef dict monomial_coefficients(self, bint copy=*)
+ cpdef dict monomial_coefficients(self, bint copy=*) noexcept
cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
- cpdef bracket(self, right)
- cpdef _bracket_(self, right)
- cpdef to_vector(self, bint sparse=*)
- cpdef dict monomial_coefficients(self, bint copy=*)
+ cpdef bracket(self, right) noexcept
+ cpdef _bracket_(self, right) noexcept
+ cpdef to_vector(self, bint sparse=*) noexcept
+ cpdef dict monomial_coefficients(self, bint copy=*) noexcept
# cpdef lift(self)
cdef class UntwistedAffineLieAlgebraElement(Element):
@@ -30,23 +30,23 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
cdef _d_coeff
cdef long _hash
- cpdef _add_(self, other)
- cpdef _sub_(self, other)
- cpdef _neg_(self)
+ cpdef _add_(self, other) noexcept
+ cpdef _sub_(self, other) noexcept
+ cpdef _neg_(self) noexcept
- cpdef dict t_dict(self)
- cpdef c_coefficient(self)
- cpdef d_coefficient(self)
+ cpdef dict t_dict(self) noexcept
+ cpdef c_coefficient(self) noexcept
+ cpdef d_coefficient(self) noexcept
- cpdef bracket(self, y)
- cpdef _bracket_(self, y)
- cpdef canonical_derivation(self)
- cpdef monomial_coefficients(self, bint copy=*)
+ cpdef bracket(self, y) noexcept
+ cpdef _bracket_(self, y) noexcept
+ cpdef canonical_derivation(self) noexcept
+ cpdef monomial_coefficients(self, bint copy=*) noexcept
cdef class LieObject(SageObject):
cdef tuple _word
cdef public tuple _index_word
- cpdef tuple to_word(self)
+ cpdef tuple to_word(self) noexcept
cdef class LieGenerator(LieObject):
cdef public str _name
@@ -56,7 +56,7 @@ cdef class LieBracket(LieObject):
cdef public LieObject _right
cdef long _hash
- cpdef lift(self, dict UEA_gens_dict)
+ cpdef lift(self, dict UEA_gens_dict) noexcept
cdef class GradedLieBracket(LieBracket):
cdef public _grade
diff --git a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx
index ec8dafeec66..ed9680a0af5 100644
--- a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx
+++ b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx
@@ -124,7 +124,7 @@ cdef class LieAlgebraElement(IndexedFreeModuleElement):
return codomain.sum(base_map(c) * t._im_gens_(codomain, im_gens, names)
for t, c in self._monomial_coefficients.items())
- cpdef lift(self):
+ cpdef lift(self) noexcept:
"""
Lift ``self`` to the universal enveloping algebra.
@@ -275,7 +275,7 @@ cdef class LieAlgebraElementWrapper(ElementWrapper):
"""
return bool(self.value)
- cpdef _add_(self, right):
+ cpdef _add_(self, right) noexcept:
"""
Add ``self`` and ``rhs``.
@@ -288,7 +288,7 @@ cdef class LieAlgebraElementWrapper(ElementWrapper):
"""
return type(self)(self._parent, self.value + right.value)
- cpdef _sub_(self, right):
+ cpdef _sub_(self, right) noexcept:
"""
Subtract ``self`` and ``rhs``.
@@ -376,7 +376,7 @@ cdef class LieAlgebraElementWrapper(ElementWrapper):
"""
return self * (~x)
- cpdef _acted_upon_(self, scalar, bint self_on_left):
+ cpdef _acted_upon_(self, scalar, bint self_on_left) noexcept:
"""
Return the action of a scalar on ``self``.
@@ -572,7 +572,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
"""
return self._parent.module()(self.value.to_vector(sparse=sparse))
- cpdef dict monomial_coefficients(self, bint copy=True):
+ cpdef dict monomial_coefficients(self, bint copy=True) noexcept:
r"""
Return a dictionary whose keys are indices of basis elements
in the support of ``self`` and whose values are the
@@ -605,7 +605,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
return dict(self._monomial_coefficients)
return self._monomial_coefficients
- cpdef _add_(self, right):
+ cpdef _add_(self, right) noexcept:
"""
Add ``self`` and ``rhs``.
@@ -631,7 +631,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
ret._monomial_coefficients = mc
return ret
- cpdef _sub_(self, right):
+ cpdef _sub_(self, right) noexcept:
"""
Subtract ``self`` and ``rhs``.
@@ -657,7 +657,7 @@ cdef class LieSubalgebraElementWrapper(LieAlgebraElementWrapper):
ret._monomial_coefficients = mc
return ret
- cpdef _acted_upon_(self, scalar, bint self_on_left):
+ cpdef _acted_upon_(self, scalar, bint self_on_left) noexcept:
"""
Return the action of a scalar on ``self``.
@@ -757,7 +757,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
scalar_mult='·',
strip_one=True))
- cpdef bracket(self, right):
+ cpdef bracket(self, right) noexcept:
"""
Return the Lie bracket ``[self, right]``.
@@ -777,7 +777,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
# We need this method because the LieAlgebra.bracket method (from the
# category) calls this, where we are guaranteed to have the same parent.
- cpdef _bracket_(self, right):
+ cpdef _bracket_(self, right) noexcept:
"""
Return the Lie bracket ``[self, right]``.
@@ -832,7 +832,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
if v != zero:
yield (I[i], v)
- cpdef to_vector(self, bint sparse=False):
+ cpdef to_vector(self, bint sparse=False) noexcept:
"""
Return ``self`` as a vector.
@@ -865,7 +865,7 @@ cdef class StructureCoefficientsElement(LieAlgebraMatrixWrapper):
gens = UEA.gens()
return UEA.sum(c * gens[i] for i, c in self.value.items())
- cpdef dict monomial_coefficients(self, bint copy=True):
+ cpdef dict monomial_coefficients(self, bint copy=True) noexcept:
"""
Return the monomial coefficients of ``self`` as a dictionary.
@@ -1072,7 +1072,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
lambda t: "t" + unicode_superscript(t),
unicode_art('⋅'), unicode_art('⊗'))
- cpdef dict t_dict(self):
+ cpdef dict t_dict(self) noexcept:
r"""
Return the ``dict``, whose keys are powers of `t` and values are
elements of the classical Lie algebra, of ``self``.
@@ -1088,7 +1088,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
"""
return self._t_dict.copy()
- cpdef c_coefficient(self):
+ cpdef c_coefficient(self) noexcept:
r"""
Return the coefficient of `c` of ``self``.
@@ -1101,7 +1101,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
"""
return self._c_coeff
- cpdef d_coefficient(self):
+ cpdef d_coefficient(self) noexcept:
r"""
Return the coefficient of `d` of ``self``.
@@ -1114,7 +1114,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
"""
return self._d_coeff
- cpdef _richcmp_(self, other, int op):
+ cpdef _richcmp_(self, other, int op) noexcept:
"""
Return the rich comparison of ``self`` with ``other``.
@@ -1177,7 +1177,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
"""
return bool(self._t_dict) or bool(self._c_coeff) or bool(self._d_coeff)
- cpdef _add_(self, other):
+ cpdef _add_(self, other) noexcept:
"""
Add ``self`` and ``other``.
@@ -1193,7 +1193,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
self._c_coeff + rt._c_coeff,
self._d_coeff + rt._d_coeff)
- cpdef _sub_(self, other):
+ cpdef _sub_(self, other) noexcept:
"""
Subtract ``self`` and ``other``.
@@ -1217,7 +1217,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
self._c_coeff - rt._c_coeff,
self._d_coeff - rt._d_coeff)
- cpdef _neg_(self):
+ cpdef _neg_(self) noexcept:
"""
Negate ``self``.
@@ -1232,7 +1232,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
return type(self)(self._parent, negate(self._t_dict),
-self._c_coeff, -self._d_coeff)
- cpdef _acted_upon_(self, x, bint self_on_left):
+ cpdef _acted_upon_(self, x, bint self_on_left) noexcept:
"""
Return ``self`` acted upon by ``x``.
@@ -1250,7 +1250,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
x * self._c_coeff,
x * self._d_coeff)
- cpdef monomial_coefficients(self, bint copy=True):
+ cpdef monomial_coefficients(self, bint copy=True) noexcept:
"""
Return the monomial coefficients of ``self``.
@@ -1280,7 +1280,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
d['d'] = self._d_coeff
return d
- cpdef bracket(self, right):
+ cpdef bracket(self, right) noexcept:
"""
Return the Lie bracket ``[self, right]``.
@@ -1303,7 +1303,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
self, right = coercion_model.canonical_coercion(self, right)
return self._bracket_(right)
- cpdef _bracket_(self, y):
+ cpdef _bracket_(self, y) noexcept:
"""
Return the Lie bracket ``[self, y]``.
@@ -1371,7 +1371,7 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
return type(self)(self._parent, d, c,
self._parent.base_ring().zero())
- cpdef canonical_derivation(self):
+ cpdef canonical_derivation(self) noexcept:
r"""
Return the canonical derivation `d` applied to ``self``.
@@ -1511,7 +1511,7 @@ cdef class LieObject(SageObject):
"""
Abstract base class for :class:`LieGenerator` and :class:`LieBracket`.
"""
- cpdef tuple to_word(self):
+ cpdef tuple to_word(self) noexcept:
"""
Return the word ("flattening") of ``self``.
@@ -1645,7 +1645,7 @@ cdef class LieGenerator(LieObject):
"""
return im_gens[names.index(self._name)]
- cpdef tuple to_word(self):
+ cpdef tuple to_word(self) noexcept:
"""
Return the word ("flattening") of ``self``.
@@ -1831,7 +1831,7 @@ cdef class LieBracket(LieObject):
return codomain.bracket(self._left._im_gens_(codomain, im_gens, names),
self._right._im_gens_(codomain, im_gens, names))
- cpdef lift(self, dict UEA_gens_dict):
+ cpdef lift(self, dict UEA_gens_dict) noexcept:
"""
Lift ``self`` to the universal enveloping algebra.
@@ -1860,7 +1860,7 @@ cdef class LieBracket(LieObject):
return l*r - r*l
- cpdef tuple to_word(self):
+ cpdef tuple to_word(self) noexcept:
"""
Return the word ("flattening") of ``self``.
diff --git a/src/sage/algebras/octonion_algebra.pxd b/src/sage/algebras/octonion_algebra.pxd
index 78500729bdc..459e8ea3070 100644
--- a/src/sage/algebras/octonion_algebra.pxd
+++ b/src/sage/algebras/octonion_algebra.pxd
@@ -8,12 +8,12 @@ from sage.modules.free_module_element cimport FreeModuleElement
cdef class Octonion_generic(AlgebraElement):
cdef FreeModuleElement vec
- cpdef Octonion_generic conjugate(self)
- cpdef quadratic_form(self)
- cpdef norm(self)
- cpdef abs(self)
- cpdef real_part(self)
- cpdef Octonion_generic imag_part(self)
+ cpdef Octonion_generic conjugate(self) noexcept
+ cpdef quadratic_form(self) noexcept
+ cpdef norm(self) noexcept
+ cpdef abs(self) noexcept
+ cpdef real_part(self) noexcept
+ cpdef Octonion_generic imag_part(self) noexcept
cdef class Octonion(Octonion_generic):
pass
diff --git a/src/sage/algebras/octonion_algebra.pyx b/src/sage/algebras/octonion_algebra.pyx
index 18101c48f66..aef4f54aa9d 100644
--- a/src/sage/algebras/octonion_algebra.pyx
+++ b/src/sage/algebras/octonion_algebra.pyx
@@ -116,7 +116,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return (self.__class__, (self._parent, self.vec))
- cpdef _richcmp_(self, other, int op):
+ cpdef _richcmp_(self, other, int op) noexcept:
r"""
Compare ``self`` to ``other`` with type ``op``.
@@ -147,7 +147,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return hash(self.vec)
- cpdef _add_(self, other):
+ cpdef _add_(self, other) noexcept:
r"""
Return ``self`` plus ``other``.
@@ -161,7 +161,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return self.__class__(self._parent, self.vec + ( other).vec)
- cpdef _sub_(self, other):
+ cpdef _sub_(self, other) noexcept:
r"""
Return ``self`` minus ``other``.
@@ -191,7 +191,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return self.__class__(self._parent, -self.vec)
- cpdef _lmul_(self, Element other):
+ cpdef _lmul_(self, Element other) noexcept:
r"""
Return ``self * other`` for a scalar ``other``.
@@ -205,7 +205,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return self.__class__(self._parent, self.vec * other)
- cpdef _rmul_(self, Element other):
+ cpdef _rmul_(self, Element other) noexcept:
r"""
Return ``self * other`` for a scalar ``other``.
@@ -219,7 +219,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return self.__class__(self._parent, other * self.vec)
- cpdef _mul_(self, other):
+ cpdef _mul_(self, other) noexcept:
r"""
Return ``self`` multiplied by ``other``.
@@ -267,7 +267,7 @@ cdef class Octonion_generic(AlgebraElement):
ret[k] += cl * cr * coeff
return self.__class__(P, P._module(ret))
- cpdef _div_(self, other):
+ cpdef _div_(self, other) noexcept:
"""
Return ``self`` divided by ``other``.
@@ -356,7 +356,7 @@ cdef class Octonion_generic(AlgebraElement):
raise ZeroDivisionError
return self.quadratic_form().inverse_of_unit() * self.conjugate()
- cpdef Octonion_generic conjugate(self):
+ cpdef Octonion_generic conjugate(self) noexcept:
r"""
Return the conjugate of ``self``.
@@ -372,7 +372,7 @@ cdef class Octonion_generic(AlgebraElement):
v.set_unsafe(0, -v.get_unsafe(0))
return self.__class__(self._parent, v)
- cpdef quadratic_form(self):
+ cpdef quadratic_form(self) noexcept:
r"""
Return the quadratic form of ``self``.
@@ -395,7 +395,7 @@ cdef class Octonion_generic(AlgebraElement):
ret += -( table[i])[i][1] * self.vec.get_unsafe(i) ** 2
return ret
- cpdef norm(self):
+ cpdef norm(self) noexcept:
r"""
Return the norm of ``self``.
@@ -423,7 +423,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return sqrt(self.quadratic_form())
- cpdef abs(self):
+ cpdef abs(self) noexcept:
r"""
Return the absolute value of ``self``.
@@ -446,7 +446,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return self.norm()
- cpdef real_part(self):
+ cpdef real_part(self) noexcept:
r"""
Return the real part of ``self``.
@@ -466,7 +466,7 @@ cdef class Octonion_generic(AlgebraElement):
"""
return self.vec.get_unsafe(0)
- cpdef Octonion_generic imag_part(self):
+ cpdef Octonion_generic imag_part(self) noexcept:
r"""
Return the imginary part of ``self``.
@@ -542,7 +542,7 @@ cdef class Octonion(Octonion_generic):
This is an element of the octonion algebra with parameters
`a = b = c = -1`, which is a classical octonion number.
"""
- cpdef quadratic_form(self):
+ cpdef quadratic_form(self) noexcept:
r"""
Return the quadratic form of ``self``.
@@ -561,7 +561,7 @@ cdef class Octonion(Octonion_generic):
"""
return self.vec * self.vec
- cpdef norm(self):
+ cpdef norm(self) noexcept:
r"""
Return the norm of ``self``.
diff --git a/src/sage/algebras/quatalg/quaternion_algebra_element.pxd b/src/sage/algebras/quatalg/quaternion_algebra_element.pxd
index 243cae8e222..5a4f811443a 100644
--- a/src/sage/algebras/quatalg/quaternion_algebra_element.pxd
+++ b/src/sage/algebras/quatalg/quaternion_algebra_element.pxd
@@ -7,11 +7,11 @@ from sage.structure.element cimport AlgebraElement, RingElement, ModuleElement,
from sage.categories.morphism cimport Morphism
cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
- cpdef bint is_constant(self)
- cdef _do_print(self, x, y, z, w)
- cpdef conjugate(self)
- cpdef reduced_norm(self)
- cpdef reduced_trace(self)
+ cpdef bint is_constant(self) noexcept
+ cdef _do_print(self, x, y, z, w) noexcept
+ cpdef conjugate(self) noexcept
+ cpdef reduced_norm(self) noexcept
+ cpdef reduced_trace(self) noexcept
cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
cdef object x, y, z, w
@@ -21,8 +21,8 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstract):
cdef fmpz_poly_t x, y, z, w, a, b, modulus
cdef mpz_t d
- cdef inline canonicalize(self)
+ cdef inline canonicalize(self) noexcept
cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abstract):
cdef mpz_t x, y, z, w, a, b, d
- cdef inline canonicalize(self)
+ cdef inline canonicalize(self) noexcept
diff --git a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx
index 723c284989e..a1dd86a224c 100644
--- a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx
+++ b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx
@@ -53,7 +53,7 @@ from sage.libs.flint.ntl_interface cimport *
cdef mpz_t T1, T2, t3, t4, t5, t6, t7, t8, s1, s2, U1, U2
cdef fmpz_poly_t fT1, fT2, ft3, ft4, ft5, ft6, ft7, ft8, fs1, fs2, fU1, fU2
-cdef _clear_globals():
+cdef _clear_globals() noexcept:
"""
Clear all global variables allocated for optimization of
quaternion algebra arithmetic.
@@ -90,7 +90,7 @@ cdef _clear_globals():
fmpz_poly_clear(fU1)
fmpz_poly_clear(fU2)
-cdef _init_globals():
+cdef _init_globals() noexcept:
"""
Initialize all global variables allocated for optimization of
quaternion algebra arithmetic, and register a hook to eventually
@@ -137,7 +137,7 @@ cdef _init_globals():
# Initialize module-scope global C variables.
_init_globals()
-cdef to_quaternion(R, x):
+cdef to_quaternion(R, x) noexcept:
"""
Internal function used implicitly by quaternion algebra creation.
@@ -161,7 +161,7 @@ cdef to_quaternion(R, x):
else:
return R(x), R(0), R(0), R(0)
-cdef inline print_coeff(y, i, bint atomic):
+cdef inline print_coeff(y, i, bint atomic) noexcept:
"""
Internal function used implicitly by all quaternion algebra printing.
@@ -219,7 +219,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
h = ((h+34125L)*51125L) ^ hash(x)
return h
- cpdef bint is_constant(self):
+ cpdef bint is_constant(self) noexcept:
"""
Return True if this quaternion is constant, i.e., has no i, j, or k term.
@@ -335,7 +335,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return self[0] or self[1] or self[2] or self[3]
- cdef _do_print(self, x, y, z, w):
+ cdef _do_print(self, x, y, z, w) noexcept:
"""
Used internally by the print function.
@@ -384,7 +384,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return self._do_print(self[0], self[1], self[2], self[3])
- cpdef _richcmp_(self, right, int op):
+ cpdef _richcmp_(self, right, int op) noexcept:
"""
Comparing elements.
@@ -412,7 +412,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
return res
return rich_to_bool(op, 0)
- cpdef conjugate(self):
+ cpdef conjugate(self) noexcept:
"""
Return the conjugate of the quaternion: if `\\theta = x + yi + zj + wk`,
return `x - yi - zj - wk`; that is, return theta.reduced_trace() - theta.
@@ -436,7 +436,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return self.__class__(self._parent, (self[0], -self[1], -self[2], -self[3]), check=False)
- cpdef reduced_trace(self):
+ cpdef reduced_trace(self) noexcept:
"""
Return the reduced trace of self: if `\\theta = x + yi + zj +
wk`, then `\\theta` has reduced trace `2x`.
@@ -451,7 +451,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return 2*self[0]
- cpdef reduced_norm(self):
+ cpdef reduced_norm(self) noexcept:
"""
Return the reduced norm of self: if `\\theta = x + yi + zj +
wk`, then `\\theta` has reduced norm `x^2 - ay^2 - bz^2 +
@@ -508,7 +508,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return ~self.reduced_norm() * self.conjugate()
- cpdef _rmul_(self, Element left):
+ cpdef _rmul_(self, Element left) noexcept:
"""
Return left*self, where left is in the base ring.
@@ -523,7 +523,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return self.__class__(self._parent, (left*self[0], left*self[1], left*self[2], left*self[3]), check=False)
- cpdef _lmul_(self, Element right):
+ cpdef _lmul_(self, Element right) noexcept:
"""
Return self*right, where right is in the base ring.
@@ -538,7 +538,7 @@ cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
"""
return self.__class__(self._parent, (self[0]*right, self[1]*right, self[2]*right, self[3]*right), check=False)
- cpdef _div_(self, right):
+ cpdef _div_(self, right) noexcept:
"""
Return quotient of self by right.
@@ -769,7 +769,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
return (unpickle_QuaternionAlgebraElement_generic_v0,
(self._parent, (self.x, self.y, self.z, self.w)))
- cpdef _add_(self, _right):
+ cpdef _add_(self, _right) noexcept:
"""
Return the sum of self and _right.
@@ -785,7 +785,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
# TODO -- make this, etc. use __new__
return QuaternionAlgebraElement_generic(self._parent, (self.x + right.x, self.y + right.y, self.z + right.z, self.w + right.w), check=False)
- cpdef _sub_(self, _right):
+ cpdef _sub_(self, _right) noexcept:
"""
Return the difference of self and _right.
@@ -800,7 +800,7 @@ cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
cdef QuaternionAlgebraElement_generic right = _right
return QuaternionAlgebraElement_generic(self._parent, (self.x - right.x, self.y - right.y, self.z - right.z, self.w - right.w), check=False)
- cpdef _mul_(self, _right):
+ cpdef _mul_(self, _right) noexcept:
"""
Return the product of self and _right.
@@ -928,7 +928,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
return x
raise TypeError
- cpdef bint is_constant(self):
+ cpdef bint is_constant(self) noexcept:
"""
Return True if this quaternion is constant, i.e., has no i, j, or k term.
@@ -964,7 +964,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
"""
return bool(mpz_sgn(self.x) or mpz_sgn(self.y) or mpz_sgn(self.z) or mpz_sgn(self.w))
- cpdef _richcmp_(self, _right, int op):
+ cpdef _richcmp_(self, _right, int op) noexcept:
"""
Compare two quaternions.
@@ -1125,7 +1125,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
return (unpickle_QuaternionAlgebraElement_rational_field_v0,
(self._parent, (self[0], self[1], self[2], self[3])))
- cpdef _add_(self, _right):
+ cpdef _add_(self, _right) noexcept:
"""
EXAMPLES::
@@ -1181,7 +1181,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
mpz_set(result.b, self.b)
return result
- cpdef _sub_(self, _right):
+ cpdef _sub_(self, _right) noexcept:
"""
EXAMPLES::
@@ -1222,7 +1222,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
mpz_set(result.b, self.b)
return result
- cpdef _mul_(self, _right):
+ cpdef _mul_(self, _right) noexcept:
"""
EXAMPLES::
@@ -1335,7 +1335,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
return result
- cpdef reduced_norm(self):
+ cpdef reduced_norm(self) noexcept:
"""
Return the reduced norm of ``self``.
@@ -1376,7 +1376,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
return result
- cpdef conjugate(self):
+ cpdef conjugate(self) noexcept:
"""
Return the conjugate of this quaternion.
@@ -1407,7 +1407,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
return result
- cpdef reduced_trace(self):
+ cpdef reduced_trace(self) noexcept:
"""
Return the reduced trace of ``self``.
@@ -1431,7 +1431,7 @@ cdef class QuaternionAlgebraElement_rational_field(QuaternionAlgebraElement_abst
mpq_canonicalize(result.value)
return result
- cdef inline canonicalize(self):
+ cdef inline canonicalize(self) noexcept:
"""
Put the representation of this quaternion element into
smallest form. For `a = (1/d)(x + yi + zj + wk)` we
@@ -1785,7 +1785,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
return (unpickle_QuaternionAlgebraElement_number_field_v0,
(self._parent, (self[0], self[1], self[2], self[3])))
- cpdef _add_(self, _right):
+ cpdef _add_(self, _right) noexcept:
"""
Add self and _right:
@@ -1857,7 +1857,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
return result
- cpdef _sub_(self, _right):
+ cpdef _sub_(self, _right) noexcept:
"""
Subtract _right from self.
@@ -1906,7 +1906,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
return result
- cpdef _mul_(self, _right):
+ cpdef _mul_(self, _right) noexcept:
"""
Multiply self and _right.
@@ -2052,7 +2052,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra
return result
- cdef inline canonicalize(self):
+ cdef inline canonicalize(self) noexcept:
"""
Put the representation of this quaternion element into
smallest form. For a = `(1/d)(x + yi + zj + wk)` we
diff --git a/src/sage/arith/functions.pxd b/src/sage/arith/functions.pxd
index 9ddfc38b38b..58ad13a30b7 100644
--- a/src/sage/arith/functions.pxd
+++ b/src/sage/arith/functions.pxd
@@ -1,3 +1,3 @@
-cpdef LCM_list(v)
+cpdef LCM_list(v) noexcept
-cdef LCM_generic(itr, ret)
+cdef LCM_generic(itr, ret) noexcept
diff --git a/src/sage/arith/functions.pyx b/src/sage/arith/functions.pyx
index db49367b7f4..040a11ff0d6 100644
--- a/src/sage/arith/functions.pyx
+++ b/src/sage/arith/functions.pyx
@@ -124,7 +124,7 @@ def lcm(a, b=None):
raise TypeError(f"unable to find lcm of {a!r} and {b!r}")
-cpdef LCM_list(v):
+cpdef LCM_list(v) noexcept:
"""
Return the LCM of an iterable ``v``.
@@ -206,7 +206,7 @@ cpdef LCM_list(v):
return z
-cdef LCM_generic(itr, ret):
+cdef LCM_generic(itr, ret) noexcept:
"""
Return the least common multiple of the element ``ret`` and the
elements in the iterable ``itr``.
diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
index 3ea70cef571..ce6a70bc215 100644
--- a/src/sage/arith/long.pxd
+++ b/src/sage/arith/long.pxd
@@ -217,12 +217,12 @@ cdef inline bint integer_check_long(x, long* value, int* err) except -1:
return 0
-cdef inline long dig(const digit* D, int n):
+cdef inline long dig(const digit* D, int n) noexcept:
# Convenient helper function for integer_check_long_py()
return (D[n]) << (n * PyLong_SHIFT)
-cdef inline bint integer_check_long_py(x, long* value, int* err):
+cdef inline bint integer_check_long_py(x, long* value, int* err) noexcept:
"""
Return whether ``x`` is a python object of type ``int``.
@@ -381,7 +381,7 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
return 1
-cdef inline bint is_small_python_int(obj):
+cdef inline bint is_small_python_int(obj) noexcept:
"""
Test whether Python object is a small Python integer.
diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
index d18e83309e5..aa0174580a1 100644
--- a/src/sage/arith/misc.py
+++ b/src/sage/arith/misc.py
@@ -2688,6 +2688,11 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
Traceback (most recent call last):
...
TypeError: unable to factor 'xyz'
+
+ Test that :issue:`35219` is fixed::
+
+ sage: len(factor(2^2203-1,proof=false))
+ 1
"""
try:
m = n.factor
diff --git a/src/sage/arith/multi_modular.pxd b/src/sage/arith/multi_modular.pxd
index ca43eb3e23f..62534fce43c 100644
--- a/src/sage/arith/multi_modular.pxd
+++ b/src/sage/arith/multi_modular.pxd
@@ -13,11 +13,11 @@ cdef class MultiModularBasis_base():
cdef unsigned long _num_primes
cdef mod_int _new_random_prime(self, set known_primes) except 1
- cdef mod_int last_prime(self)
- cdef _realloc_to_new_count(self, new_count)
+ cdef mod_int last_prime(self) noexcept
+ cdef _realloc_to_new_count(self, new_count) noexcept
cdef int _extend_moduli_to_height_c(self, mpz_t height) except -1
- cdef void _refresh_products(self, int start)
- cdef void _refresh_prod(self)
+ cdef void _refresh_products(self, int start) noexcept
+ cdef void _refresh_prod(self) noexcept
cdef void _refresh_precomputations(self, int start) except *
cdef int min_moduli_count(self, mpz_t height) except -1
diff --git a/src/sage/arith/multi_modular.pyx b/src/sage/arith/multi_modular.pyx
index a656742bd50..44a6059c6f1 100644
--- a/src/sage/arith/multi_modular.pyx
+++ b/src/sage/arith/multi_modular.pyx
@@ -101,7 +101,7 @@ cdef class MultiModularBasis_base():
mpz_init(self.product)
mpz_init(self.half_product)
- cdef _realloc_to_new_count(self, new_count):
+ cdef _realloc_to_new_count(self, new_count) noexcept:
self.moduli = check_reallocarray(self.moduli, new_count, sizeof(mod_int))
self.partial_products = check_reallocarray(self.partial_products, new_count, sizeof(mpz_t))
self.C = check_reallocarray(self.C, new_count, sizeof(mod_int))
@@ -445,7 +445,7 @@ cdef class MultiModularBasis_base():
"""
self._extend_moduli_to_count(self.n + count)
- cdef void _refresh_products(self, int start):
+ cdef void _refresh_products(self, int start) noexcept:
r"""
Compute and store `\prod_j=1^{i-1} m_j` for i > start.
"""
@@ -460,7 +460,7 @@ cdef class MultiModularBasis_base():
mpz_clear(z)
self._refresh_prod()
- cdef void _refresh_prod(self):
+ cdef void _refresh_prod(self) noexcept:
# record the product and half product for balancing the lifts.
mpz_set(self.product, self.partial_products[self.n-1])
mpz_fdiv_q_ui(self.half_product, self.product, 2)
@@ -492,7 +492,7 @@ cdef class MultiModularBasis_base():
return count
- cdef mod_int last_prime(self):
+ cdef mod_int last_prime(self) noexcept:
return self.moduli[self.n-1]
cdef int mpz_reduce_tail(self, mpz_t z, mod_int* b, int offset, int len) except -1:
diff --git a/src/sage/arith/power.pxd b/src/sage/arith/power.pxd
index 7651245d2eb..33f043e9551 100644
--- a/src/sage/arith/power.pxd
+++ b/src/sage/arith/power.pxd
@@ -7,12 +7,12 @@ ctypedef fused ulong_or_object:
object
-cpdef generic_power(a, n)
-cdef generic_power_long(a, long n)
-cdef generic_power_pos(a, ulong_or_object n) # n > 0
+cpdef generic_power(a, n) noexcept
+cdef generic_power_long(a, long n) noexcept
+cdef generic_power_pos(a, ulong_or_object n) noexcept # n > 0
-cdef inline invert(a):
+cdef inline invert(a) noexcept:
"""
Return ``a^(-1)``.
"""
@@ -21,7 +21,7 @@ cdef inline invert(a):
return PyNumber_TrueDivide(type(a)(1), a)
-cdef inline one(a):
+cdef inline one(a) noexcept:
"""
Return ``a^0``.
"""
diff --git a/src/sage/arith/power.pyx b/src/sage/arith/power.pyx
index acd5f885e85..65090f23c23 100644
--- a/src/sage/arith/power.pyx
+++ b/src/sage/arith/power.pyx
@@ -20,7 +20,7 @@ from cysignals.signals cimport sig_check
from .long cimport integer_check_long
-cpdef generic_power(a, n):
+cpdef generic_power(a, n) noexcept:
"""
Return `a^n`.
@@ -88,7 +88,7 @@ cpdef generic_power(a, n):
return generic_power_pos(a, n)
-cdef generic_power_long(a, long n):
+cdef generic_power_long(a, long n) noexcept:
"""
As ``generic_power`` but where ``n`` is a C long.
"""
@@ -102,7 +102,7 @@ cdef generic_power_long(a, long n):
return generic_power_pos(a, u)
-cdef generic_power_pos(a, ulong_or_object n):
+cdef generic_power_pos(a, ulong_or_object n) noexcept:
"""
Return `a^n` where `n > 0`.
"""
diff --git a/src/sage/calculus/integration.pyx b/src/sage/calculus/integration.pyx
index 19b2dc2e4c8..621241436ae 100644
--- a/src/sage/calculus/integration.pyx
+++ b/src/sage/calculus/integration.pyx
@@ -43,10 +43,10 @@ cdef class PyFunctionWrapper:
cdef list lx
cdef class compiled_integrand:
- cdef int c_f(self, double t): # void *params):
+ cdef int c_f(self, double t) noexcept: # void *params):
return 0
-cdef double c_f(double t, void *params):
+cdef double c_f(double t, void *params) noexcept:
cdef double value
cdef PyFunctionWrapper wrapper
wrapper = params
@@ -401,7 +401,7 @@ def numerical_integral(func, a, b=None,
return result, abs_err
-cdef double c_monte_carlo_f(double *t, size_t dim, void *params):
+cdef double c_monte_carlo_f(double *t, size_t dim, void *params) noexcept:
cdef double value
cdef PyFunctionWrapper wrapper
wrapper = params
@@ -421,7 +421,7 @@ cdef double c_monte_carlo_f(double *t, size_t dim, void *params):
return value
-cdef double c_monte_carlo_ff(double *x, size_t dim, void *params):
+cdef double c_monte_carlo_ff(double *x, size_t dim, void *params) noexcept:
cdef double result
( params).call_c(x, &result)
return result
diff --git a/src/sage/calculus/interpolation.pxd b/src/sage/calculus/interpolation.pxd
index 9d60459a03b..2d729228149 100644
--- a/src/sage/calculus/interpolation.pxd
+++ b/src/sage/calculus/interpolation.pxd
@@ -8,5 +8,5 @@ cdef class Spline:
cdef int started
cdef object v
- cdef start_interp(self)
- cdef stop_interp(self)
+ cdef start_interp(self) noexcept
+ cdef stop_interp(self) noexcept
diff --git a/src/sage/calculus/interpolation.pyx b/src/sage/calculus/interpolation.pyx
index 83bc83d1797..59f9fcc8e7a 100644
--- a/src/sage/calculus/interpolation.pyx
+++ b/src/sage/calculus/interpolation.pyx
@@ -243,7 +243,7 @@ cdef class Spline:
"""
return str(self.v)
- cdef start_interp(self):
+ cdef start_interp(self) noexcept:
if self.started:
sig_free(self.x)
sig_free(self.y)
@@ -271,7 +271,7 @@ cdef class Spline:
gsl_spline_init (self.spline, self.x, self.y, n)
self.started = 1
- cdef stop_interp(self):
+ cdef stop_interp(self) noexcept:
if not self.started:
return
sig_free(self.x)
diff --git a/src/sage/calculus/ode.pxd b/src/sage/calculus/ode.pxd
index e517fe0c401..2de37b91764 100644
--- a/src/sage/calculus/ode.pxd
+++ b/src/sage/calculus/ode.pxd
@@ -1,4 +1,4 @@
cdef class ode_system:
- cdef int c_j(self,double , double *, double *,double *)
+ cdef int c_j(self,double , double *, double *,double *) noexcept
- cdef int c_f(self,double t, double* , double* )
+ cdef int c_f(self,double t, double* , double* ) noexcept
diff --git a/src/sage/calculus/ode.pyx b/src/sage/calculus/ode.pyx
index f1004b9b438..32ccfab5dfc 100644
--- a/src/sage/calculus/ode.pyx
+++ b/src/sage/calculus/ode.pyx
@@ -33,31 +33,31 @@ cdef class PyFunctionWrapper:
cdef object the_parameters
cdef int y_n
- cdef set_yn(self,x):
+ cdef set_yn(self,x) noexcept:
self.y_n = x
cdef class ode_system:
- cdef int c_j(self,double t, double *y, double *dfdy,double *dfdt): #void *params):
+ cdef int c_j(self,double t, double *y, double *dfdy,double *dfdt) noexcept: #void *params):
return 0
- cdef int c_f(self,double t, double* y, double* dydt): #void *params):
+ cdef int c_f(self,double t, double* y, double* dydt) noexcept: #void *params):
return 0
-cdef int c_jac_compiled(double t, double *y, double *dfdy,double *dfdt, void * params):
+cdef int c_jac_compiled(double t, double *y, double *dfdy,double *dfdt, void * params) noexcept:
cdef int status
cdef ode_system wrapper
wrapper = params
status = wrapper.c_j(t,y,dfdy,dfdt) #Could add parameters
return status
-cdef int c_f_compiled(double t, double *y, double *dydt, void *params):
+cdef int c_f_compiled(double t, double *y, double *dydt, void *params) noexcept:
cdef int status
cdef ode_system wrapper
wrapper = params
status = wrapper.c_f(t,y,dydt) #Could add parameters
return status
-cdef int c_jac(double t,double *y,double *dfdy,double *dfdt,void *params):
+cdef int c_jac(double t,double *y,double *dfdy,double *dfdt,void *params) noexcept:
cdef int i
cdef int j
cdef int y_n
@@ -84,7 +84,7 @@ cdef int c_jac(double t,double *y,double *dfdy,double *dfdt,void *params):
except Exception:
return -1
-cdef int c_f(double t,double* y, double* dydt,void *params):
+cdef int c_f(double t,double* y, double* dydt,void *params) noexcept:
cdef int i
cdef int y_n
cdef int param_n
diff --git a/src/sage/calculus/riemann.pyx b/src/sage/calculus/riemann.pyx
index a4f9545bffb..0b80a29da70 100644
--- a/src/sage/calculus/riemann.pyx
+++ b/src/sage/calculus/riemann.pyx
@@ -291,7 +291,7 @@ cdef class Riemann_Map:
"""
return "A Riemann or Ahlfors mapping of a figure to the unit circle."
- cdef _generate_theta_array(self):
+ cdef _generate_theta_array(self) noexcept:
"""
Generates the essential data for the Riemann map, primarily the
Szegő kernel and boundary correspondence.
@@ -515,7 +515,7 @@ cdef class Riemann_Map:
return np.column_stack(
[self.tk2, self.theta_array[boundary]]).tolist()
- cdef _generate_interior_mapper(self):
+ cdef _generate_interior_mapper(self) noexcept:
"""
Generates the data necessary to use the :meth:`riemann_map` function.
As much setup as possible is done here to minimize the computation
@@ -568,7 +568,7 @@ cdef class Riemann_Map:
cdef np.ndarray[double complex, ndim=1] pq = self.cps[:,list(range(N))+[0]].flatten()
self.pre_q_vector = pq
- cpdef riemann_map(self, COMPLEX_T pt):
+ cpdef riemann_map(self, COMPLEX_T pt) noexcept:
"""
Return the Riemann mapping of a point.
@@ -619,7 +619,7 @@ cdef class Riemann_Map:
self.pre_q_vector - pt1)
return -np.dot(self.p_vector, q_vector)
- cdef _generate_inverse_mapper(self):
+ cdef _generate_inverse_mapper(self) noexcept:
"""
Generates the data necessary to use the
:meth:`inverse_riemann_map` function. As much setup as possible is
@@ -656,7 +656,7 @@ cdef class Riemann_Map:
for i in range(N):
self.cosalpha[k, i] = cos(-theta_array[k, i])
- cpdef inverse_riemann_map(self, COMPLEX_T pt):
+ cpdef inverse_riemann_map(self, COMPLEX_T pt) noexcept:
"""
Return the inverse Riemann mapping of a point.
@@ -764,7 +764,7 @@ cdef class Riemann_Map:
pointsize=thickness)
return sum(plots)
- cpdef compute_on_grid(self, plot_range, int x_points):
+ cpdef compute_on_grid(self, plot_range, int x_points) noexcept:
"""
Compute the Riemann map on a grid of points.
@@ -1060,7 +1060,7 @@ cdef class Riemann_Map:
(ymin, ymax),options))
return g
-cdef comp_pt(clist, loop=True):
+cdef comp_pt(clist, loop=True) noexcept:
"""
Utility function to convert the list of complex numbers
``xderivs = get_derivatives(z_values, xstep, ystep)[0]`` to the plottable
@@ -1090,7 +1090,7 @@ cdef comp_pt(clist, loop=True):
return list2
cpdef get_derivatives(np.ndarray[COMPLEX_T, ndim=2] z_values, FLOAT_T xstep,
- FLOAT_T ystep):
+ FLOAT_T ystep) noexcept:
"""
Computes the r*e^(I*theta) form of derivatives from the grid of points. The
derivatives are computed using quick-and-dirty taylor expansion and
@@ -1146,7 +1146,7 @@ cpdef get_derivatives(np.ndarray[COMPLEX_T, ndim=2] z_values, FLOAT_T xstep,
cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
np.ndarray[FLOAT_T, ndim = 2] dr, np.ndarray[FLOAT_T, ndim = 2] dtheta,
- spokes, circles, rgbcolor, thickness, withcolor, min_mag):
+ spokes, circles, rgbcolor, thickness, withcolor, min_mag) noexcept:
"""
Converts a grid of complex numbers into a matrix containing rgb data
for the Riemann spiderweb plot.
@@ -1263,7 +1263,7 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
return rgb
-cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values):
+cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values) noexcept:
r"""
Convert from a (Numpy) array of complex numbers to its corresponding
matrix of RGB values. For internal use of :meth:`~Riemann_Map.plot_colored`
@@ -1368,7 +1368,7 @@ cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values):
sig_off()
return rgb
-cpdef analytic_boundary(FLOAT_T t, int n, FLOAT_T epsilon):
+cpdef analytic_boundary(FLOAT_T t, int n, FLOAT_T epsilon) noexcept:
"""
Provides an exact (for n = infinity) Riemann boundary
correspondence for the ellipse with axes 1 + epsilon and 1 - epsilon. The
@@ -1417,7 +1417,7 @@ cpdef analytic_boundary(FLOAT_T t, int n, FLOAT_T epsilon):
return result
-cpdef cauchy_kernel(t, args):
+cpdef cauchy_kernel(t, args) noexcept:
"""
Intermediate function for the integration in :meth:`~Riemann_Map.analytic_interior`.
@@ -1463,7 +1463,7 @@ cpdef cauchy_kernel(t, args):
return None
-cpdef analytic_interior(COMPLEX_T z, int n, FLOAT_T epsilon):
+cpdef analytic_interior(COMPLEX_T z, int n, FLOAT_T epsilon) noexcept:
"""
Provides a nearly exact computation of the Riemann Map of an interior
point of the ellipse with axes 1 + epsilon and 1 - epsilon. It is
diff --git a/src/sage/calculus/transforms/dft.py b/src/sage/calculus/transforms/dft.py
index b413bc0ea81..1b165fa6503 100644
--- a/src/sage/calculus/transforms/dft.py
+++ b/src/sage/calculus/transforms/dft.py
@@ -277,7 +277,7 @@ def plot(self):
S = self.list()
return line([[RR(I[i]), RR(S[i])] for i in range(len(I) - 1)])
- def dft(self, chi=lambda x: x):
+ def dft(self, chi=None):
r"""
A discrete Fourier transform "over `\QQ`" using exact
`N`-th roots of unity.
@@ -340,6 +340,8 @@ def dft(self, chi=lambda x: x):
implemented Group (permutation, matrix), call .characters()
and test if the index list is the set of conjugacy classes.
"""
+ if chi is None:
+ chi = lambda x: x
J = self.index_object() # index set of length N
N = len(J)
S = self.list()
diff --git a/src/sage/categories/action.pxd b/src/sage/categories/action.pxd
index 5883adebc97..a22a37cc22a 100644
--- a/src/sage/categories/action.pxd
+++ b/src/sage/categories/action.pxd
@@ -8,10 +8,10 @@ cdef class Action(Functor):
cdef readonly op
cdef readonly bint _is_left
cdef US
- cdef underlying_set(self)
+ cdef underlying_set(self) noexcept
- cdef _act_convert(self, g, x)
- cpdef _act_(self, g, x)
+ cdef _act_convert(self, g, x) noexcept
+ cpdef _act_(self, g, x) noexcept
cdef class InverseAction(Action):
diff --git a/src/sage/categories/action.pyx b/src/sage/categories/action.pyx
index 0d564e46c4d..b164e9213ce 100644
--- a/src/sage/categories/action.pyx
+++ b/src/sage/categories/action.pyx
@@ -66,7 +66,7 @@ from sage.categories import homset
from weakref import ref
-cdef inline category(x):
+cdef inline category(x) noexcept:
try:
return x.category()
except AttributeError:
@@ -178,7 +178,7 @@ cdef class Action(Functor):
else:
raise TypeError("actions should be called with 1 or 2 arguments")
- cdef _act_convert(self, g, x):
+ cdef _act_convert(self, g, x) noexcept:
"""
Let ``g`` act on ``x`` under this action, converting ``g``
and ``x`` to the correct parents first.
@@ -190,7 +190,7 @@ cdef class Action(Functor):
x = U(x)
return self._act_(g, x)
- cpdef _act_(self, g, x):
+ cpdef _act_(self, g, x) noexcept:
"""
Let ``g`` act on ``x`` under this action.
@@ -251,7 +251,7 @@ cdef class Action(Functor):
def actor(self):
return self.G
- cdef underlying_set(self):
+ cdef underlying_set(self) noexcept:
"""
The set on which the actor acts (it is not necessarily the codomain of
the action).
@@ -410,7 +410,7 @@ cdef class InverseAction(Action):
"""
return (type(self), (self._action,))
- cpdef _act_(self, g, x):
+ cpdef _act_(self, g, x) noexcept:
if self.S_precomposition is not None:
x = self.S_precomposition(x)
return self._action._act_(~g, x)
@@ -498,7 +498,7 @@ cdef class PrecomposedAction(Action):
"""
return (type(self), (self._action, self.G_precomposition, self.S_precomposition))
- cpdef _act_(self, g, x):
+ cpdef _act_(self, g, x) noexcept:
if self.G_precomposition is not None:
g = self.G_precomposition._call_(g)
if self.S_precomposition is not None:
@@ -569,7 +569,7 @@ cdef class ActionEndomorphism(Morphism):
self._action = action
self._g = g
- cdef dict _extra_slots(self):
+ cdef dict _extra_slots(self) noexcept:
"""
Helper for pickling and copying.
@@ -591,7 +591,7 @@ cdef class ActionEndomorphism(Morphism):
slots['_g'] = self._g
return slots
- cdef _update_slots(self, dict _slots):
+ cdef _update_slots(self, dict _slots) noexcept:
"""
Helper for pickling and copying.
@@ -612,7 +612,7 @@ cdef class ActionEndomorphism(Morphism):
self._g = _slots['_g']
Morphism._update_slots(self, _slots)
- cpdef Element _call_(self, x):
+ cpdef Element _call_(self, x) noexcept:
return self._action._act_(self._g, x)
def _repr_(self):
diff --git a/src/sage/categories/bimodules.py b/src/sage/categories/bimodules.py
index eccadf20a02..eec2f674aa7 100644
--- a/src/sage/categories/bimodules.py
+++ b/src/sage/categories/bimodules.py
@@ -37,22 +37,24 @@ class Bimodules(CategoryWithParameters):
def __init__(self, left_base, right_base, name=None):
"""
+ The ``name`` parameter is ignored.
+
EXAMPLES::
sage: C = Bimodules(QQ, ZZ)
sage: TestSuite(C).run()
"""
- if not ( left_base in Rings() or
- (isinstance(left_base, Category)
- and left_base.is_subcategory(Rings())) ):
+ if not (left_base in Rings() or
+ (isinstance(left_base, Category)
+ and left_base.is_subcategory(Rings()))):
raise ValueError("the left base must be a ring or a subcategory of Rings()")
- if not ( right_base in Rings() or
- (isinstance(right_base, Category)
- and right_base.is_subcategory(Rings())) ):
+ if not (right_base in Rings() or
+ (isinstance(right_base, Category)
+ and right_base.is_subcategory(Rings()))):
raise ValueError("the right base must be a ring or a subcategory of Rings()")
self._left_base_ring = left_base
self._right_base_ring = right_base
- Category.__init__(self, name)
+ Category.__init__(self)
def _make_named_class_key(self, name):
r"""
diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
index 29bce8ee415..fcf25b75fd4 100644
--- a/src/sage/categories/category.py
+++ b/src/sage/categories/category.py
@@ -118,6 +118,7 @@
_join_cache = WeakValueDictionary()
+
class Category(UniqueRepresentation, SageObject):
r"""
The base class for modeling mathematical categories, like for example:
@@ -448,7 +449,7 @@ class of ``C`` is a dynamic subclass ``Cs_with_category`` of
cls = cls.__base__
return super().__classcall__(cls, *args, **options)
- def __init__(self, s=None):
+ def __init__(self):
"""
Initialize this category.
@@ -468,12 +469,10 @@ def __init__(self, s=None):
.. NOTE::
- Specifying the name of this category by passing a string
- is deprecated. If the default name (built from the name of
- the class) is not adequate, please use
+ If the default name of the category (built from the name of
+ the class) is not adequate, please implement
:meth:`_repr_object_names` to customize it.
"""
- assert s is None
self.__class__ = dynamic_class("{}_with_category".format(self.__class__.__name__),
(self.__class__, self.subcategory_class, ),
cache=False, reduction=None,
@@ -491,49 +490,38 @@ def _label(self):
"""
t = str(self.__class__.__base__)
- t = t[t.rfind('.')+1:]
+ t = t[t.rfind('.') + 1:]
return t[:t.rfind("'")]
- # TODO: move this code into the method _repr_object_names once passing a string is not accepted anymore
- @lazy_attribute
- def __repr_object_names(self):
+ def _repr_object_names(self):
"""
- Determine the name of the objects of this category
- from its type, if it has not been explicitly given
- at initialisation.
+ Return the name of the objects of this category.
EXAMPLES::
- sage: Rings()._Category__repr_object_names
- 'rings'
- sage: PrincipalIdealDomains()._Category__repr_object_names
- 'principal ideal domains'
+ sage: FiniteGroups()._repr_object_names()
+ 'finite groups'
+ sage: AlgebrasWithBasis(QQ)._repr_object_names()
+ 'algebras with basis over Rational Field'
+
+ TESTS::
sage: Rings()
Category of rings
+ sage: Rings()._repr_object_names()
+ 'rings'
+ sage: PrincipalIdealDomains()._repr_object_names()
+ 'principal ideal domains'
"""
i = -1
s = self._label
- while i < len(s)-1:
+ while i < len(s) - 1:
for i in range(len(s)):
if s[i].isupper():
- s = s[:i] + " " + s[i].lower() + s[i+1:]
+ s = s[:i] + " " + s[i].lower() + s[i + 1:]
break
return s.lstrip()
- def _repr_object_names(self):
- """
- Return the name of the objects of this category.
-
- EXAMPLES::
-
- sage: FiniteGroups()._repr_object_names()
- 'finite groups'
- sage: AlgebrasWithBasis(QQ)._repr_object_names()
- 'algebras with basis over Rational Field'
- """
- return self.__repr_object_names
-
def _short_name(self):
"""
Return a CamelCase name for this category.
@@ -1256,7 +1244,7 @@ def structure(self):
recursively from the result of :meth:`additional_structure`
on the super categories of ``self``.
"""
- result = { D for C in self.super_categories() for D in C.structure() }
+ result = {D for C in self.super_categories() for D in C.structure()}
if self.additional_structure() is not None:
result.add(self)
return frozenset(result)
@@ -1319,8 +1307,7 @@ def is_full_subcategory(self, other):
False
"""
return self.is_subcategory(other) and \
- len(self.structure()) == \
- len(other.structure())
+ len(self.structure()) == len(other.structure())
@cached_method
def full_super_categories(self):
@@ -1446,27 +1433,26 @@ def _test_category(self, **options):
Traceback (most recent call last):
...
AssertionError: Category of my objects is not a subcategory of Objects()
-
"""
- from sage.categories.objects import Objects
+ from sage.categories.objects import Objects
from sage.categories.sets_cat import Sets
tester = self._tester(**options)
tester.assertTrue(isinstance(self.super_categories(), list),
- "%s.super_categories() should return a list" % self)
+ "%s.super_categories() should return a list" % self)
tester.assertTrue(self.is_subcategory(Objects()),
- "%s is not a subcategory of Objects()" % self)
+ "%s is not a subcategory of Objects()" % self)
tester.assertTrue(isinstance(self.parent_class, type))
tester.assertTrue(all(not isinstance(cat, JoinCategory) for cat in self._super_categories))
if not isinstance(self, JoinCategory):
- tester.assertTrue(all(self._cmp_key > cat._cmp_key for cat in self._super_categories))
- tester.assertTrue(self.is_subcategory( Category.join(self.super_categories()) )) # Not an obviously passing test with axioms
+ tester.assertTrue(all(self._cmp_key > cat._cmp_key for cat in self._super_categories))
+ tester.assertTrue(self.is_subcategory(Category.join(self.super_categories()))) # Not an obviously passing test with axioms
for category in self._all_super_categories_proper:
if self.is_full_subcategory(category):
tester.assertTrue(any(cat.is_subcategory(category)
- for cat in self.full_super_categories()),
- "Every full super category should be a super category"
- "of some immediate full super category")
+ for cat in self.full_super_categories()),
+ "Every full super category should be a super category"
+ "of some immediate full super category")
if self.is_subcategory(Sets()):
tester.assertTrue(isinstance(self.parent_class, type))
@@ -1588,7 +1574,7 @@ def _make_named_class(self, name, method_provider, cache=False, picklable=True):
doccls = cls
else:
# Otherwise, check XXXMethods
- assert inspect.isclass(method_provider_cls),\
+ assert inspect.isclass(method_provider_cls), \
"%s.%s should be a class" % (cls.__name__, method_provider)
mro = inspect.getmro(method_provider_cls)
if len(mro) > 2 or (len(mro) == 2 and mro[1] is not object):
@@ -1941,7 +1927,7 @@ def _meet_(self, other):
appropriate convention for AB.
"""
- if self is other: # useful? fast pathway
+ if self is other: # useful? fast pathway
return self
elif self.is_subcategory(other):
return other
@@ -2050,14 +2036,13 @@ def _with_axiom_as_tuple(self, axiom):
return (axiom_attribute(self),)
warn(("Expecting {}.{} to be a subclass of CategoryWithAxiom to"
" implement a category with axiom; got {}; ignoring").format(
- self.__class__.__base__.__name__, axiom, axiom_attribute))
+ self.__class__.__base__.__name__, axiom, axiom_attribute))
# self does not implement this axiom
- result = (self, ) + \
- tuple(cat
- for category in self._super_categories
- for cat in category._with_axiom_as_tuple(axiom))
- hook = getattr(self, axiom+"_extra_super_categories", None)
+ result = (self, ) + tuple(cat
+ for category in self._super_categories
+ for cat in category._with_axiom_as_tuple(axiom))
+ hook = getattr(self, axiom + "_extra_super_categories", None)
if hook is not None:
assert inspect.ismethod(hook)
result += tuple(hook())
@@ -2593,6 +2578,7 @@ def is_Category(x):
"""
return isinstance(x, Category)
+
@cached_function
def category_sample():
r"""
@@ -2606,7 +2592,8 @@ def category_sample():
sage: from sage.categories.category import category_sample
sage: sorted(category_sample(), key=str) # needs sage.groups
- [Category of G-sets for Symmetric group of order 8! as a permutation group,
+ [Category of Coxeter groups,
+ Category of G-sets for Symmetric group of order 8! as a permutation group,
Category of Hecke modules over Rational Field,
Category of Lie algebras over Rational Field,
Category of additive magmas, ...,
@@ -2900,6 +2887,7 @@ def _subcategory_hook_(self, C):
return False
return Unknown
+
#############################################################
# Join of several categories
#############################################################
@@ -2948,11 +2936,11 @@ def __init__(self, super_categories, **kwds):
INPUT:
- - super_categories -- Categories to join. This category will
+ - ``super_categories`` -- Categories to join. This category will
consist of objects and morphisms that lie in all of these
categories.
- - name -- An optional name for this category.
+ - ``name`` -- ignored
TESTS::
@@ -2960,17 +2948,13 @@ def __init__(self, super_categories, **kwds):
sage: C = JoinCategory((Groups(), CommutativeAdditiveMonoids())); C
Join of Category of groups and Category of commutative additive monoids
sage: TestSuite(C).run()
-
"""
assert len(super_categories) >= 2
assert all(not isinstance(category, JoinCategory) for category in super_categories)
# Use __super_categories to not overwrite the lazy attribute Category._super_categories
# Maybe this would not be needed if the flattening/sorting is does consistently?
self.__super_categories = list(super_categories)
- if 'name' in kwds:
- Category.__init__(self, kwds['name'])
- else:
- Category.__init__(self)
+ Category.__init__(self)
def _make_named_class_key(self, name):
r"""
diff --git a/src/sage/categories/category_cy_helper.pxd b/src/sage/categories/category_cy_helper.pxd
index f50ce4e8226..c7bf3759712 100644
--- a/src/sage/categories/category_cy_helper.pxd
+++ b/src/sage/categories/category_cy_helper.pxd
@@ -1,7 +1,7 @@
-cpdef tuple _sort_uniq(categories)
+cpdef tuple _sort_uniq(categories) noexcept
cdef class AxiomContainer(dict):
pass
-cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms)
+cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms) noexcept
from sage.misc.classcall_metaclass cimport ClasscallMetaclass
-cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory)
-cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms)
+cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory) noexcept
+cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms) noexcept
diff --git a/src/sage/categories/category_cy_helper.pyx b/src/sage/categories/category_cy_helper.pyx
index 1d0c5a2ad41..6ed38f4d00e 100644
--- a/src/sage/categories/category_cy_helper.pyx
+++ b/src/sage/categories/category_cy_helper.pyx
@@ -21,7 +21,7 @@ AUTHOR:
#######################################
# Sorting
-cpdef inline tuple category_sort_key(object category):
+cpdef inline tuple category_sort_key(object category) noexcept:
"""
Return ``category._cmp_key``.
@@ -38,7 +38,7 @@ cpdef inline tuple category_sort_key(object category):
"""
return category._cmp_key
-cpdef tuple _sort_uniq(categories):
+cpdef tuple _sort_uniq(categories) noexcept:
"""
Return the categories after sorting them and removing redundant categories.
@@ -72,7 +72,7 @@ cpdef tuple _sort_uniq(categories):
result.append(category)
return tuple(result)
-cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory):
+cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory) noexcept:
"""
Return the tuple of categories in ``categories``, while
flattening join categories.
@@ -108,7 +108,7 @@ cpdef tuple _flatten_categories(categories, ClasscallMetaclass JoinCategory):
#############################################
# Join
-cdef bint is_supercategory_of_done(new_cat, dict done):
+cdef bint is_supercategory_of_done(new_cat, dict done) noexcept:
# This is a helper function. It replaces the closure
# any(cat.is_subcategory(new_cat) for cat in done)
for cat in done:
@@ -116,7 +116,7 @@ cdef bint is_supercategory_of_done(new_cat, dict done):
return True
return False
-cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms):
+cpdef tuple join_as_tuple(tuple categories, tuple axioms, tuple ignore_axioms) noexcept:
"""
Helper for :meth:`~sage.categories.category.Category.join`.
@@ -267,7 +267,7 @@ cdef class AxiomContainer(dict):
return self
-cpdef inline get_axiom_index(AxiomContainer all_axioms, str axiom):
+cpdef inline get_axiom_index(AxiomContainer all_axioms, str axiom) noexcept:
"""
Helper function: Return the rank of an axiom.
@@ -286,7 +286,7 @@ cpdef inline get_axiom_index(AxiomContainer all_axioms, str axiom):
return (all_axioms)[axiom]
-cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms):
+cpdef tuple canonicalize_axioms(AxiomContainer all_axioms, axioms) noexcept:
r"""
Canonicalize a set of axioms.
diff --git a/src/sage/categories/category_types.py b/src/sage/categories/category_types.py
index c9e2fe79130..4ead4f23530 100644
--- a/src/sage/categories/category_types.py
+++ b/src/sage/categories/category_types.py
@@ -171,6 +171,8 @@ def __init__(self, base, name=None):
r"""
Initialize ``self``.
+ The ``name`` parameter is ignored.
+
EXAMPLES::
sage: S = Spec(ZZ)
@@ -183,7 +185,7 @@ def __init__(self, base, name=None):
sage: TestSuite(C).run()
"""
self.__base = base
- Category.__init__(self, name)
+ Category.__init__(self)
def _test_category_over_bases(self, **options):
"""
@@ -529,13 +531,15 @@ def __init__(self, ambient, name=None):
"""
Initialize ``self``.
+ The parameter ``name`` is ignored.
+
EXAMPLES::
sage: C = Ideals(IntegerRing())
sage: TestSuite(C).run()
"""
self.__ambient = ambient
- Category.__init__(self, name)
+ Category.__init__(self)
def ambient(self):
"""
diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
index 4775d4e5bf1..bb9dbbe2347 100644
--- a/src/sage/categories/category_with_axiom.py
+++ b/src/sage/categories/category_with_axiom.py
@@ -269,7 +269,7 @@ class from the base category class::
covers the following examples::
sage: FiniteCoxeterGroups()
- Category of finite coxeter groups
+ Category of finite Coxeter groups
sage: FiniteCoxeterGroups() is CoxeterGroups().Finite()
True
sage: FiniteCoxeterGroups._base_category_class_and_axiom_origin
diff --git a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
index 89667bfc237..d3908a8db03 100644
--- a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
+++ b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
@@ -130,7 +130,7 @@ def Irreducible(self):
sage: ComplexReflectionGroups().Irreducible()
Category of irreducible complex reflection groups
sage: CoxeterGroups().Irreducible()
- Category of irreducible coxeter groups
+ Category of irreducible Coxeter groups
TESTS::
diff --git a/src/sage/categories/coxeter_groups.py b/src/sage/categories/coxeter_groups.py
index b5e5da9ea1a..71285521a5e 100644
--- a/src/sage/categories/coxeter_groups.py
+++ b/src/sage/categories/coxeter_groups.py
@@ -41,7 +41,7 @@ class CoxeterGroups(Category_singleton):
EXAMPLES::
sage: C = CoxeterGroups(); C
- Category of coxeter groups
+ Category of Coxeter groups
sage: C.super_categories()
[Category of generalized coxeter groups]
@@ -128,6 +128,17 @@ def additional_structure(self):
Finite = LazyImport('sage.categories.finite_coxeter_groups', 'FiniteCoxeterGroups')
Algebras = LazyImport('sage.categories.coxeter_group_algebras', 'CoxeterGroupAlgebras')
+ def _repr_object_names(self):
+ """
+ Return the name of the objects of this category.
+
+ EXAMPLES::
+
+ sage: CoxeterGroups().Finite()
+ Category of finite Coxeter groups
+ """
+ return "Coxeter groups"
+
class ParentMethods:
@abstract_method
def coxeter_matrix(self):
diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
index b0ea05d0563..8ae3270491c 100644
--- a/src/sage/categories/enumerated_sets.py
+++ b/src/sage/categories/enumerated_sets.py
@@ -313,8 +313,7 @@ def iterator_range(self, start=None, stop=None, step=None):
if stop is None:
if start is None:
if step is None:
- for x in self:
- yield x
+ yield from self
return
start = 0
elif start < 0:
@@ -793,8 +792,7 @@ def _iterator_from_list(self):
sage: [next(it), next(it), next(it)]
[1, 2, 3]
"""
- for x in self.tuple():
- yield x
+ yield from self.tuple()
def _iterator_from_next(self):
"""
diff --git a/src/sage/categories/examples/semigroups_cython.pyx b/src/sage/categories/examples/semigroups_cython.pyx
index b456c2868f8..2b7b76c00e3 100644
--- a/src/sage/categories/examples/semigroups_cython.pyx
+++ b/src/sage/categories/examples/semigroups_cython.pyx
@@ -85,7 +85,7 @@ cdef class LeftZeroSemigroupElement(Element):
"""
return LeftZeroSemigroupElement, (self._parent, self._value)
- cpdef _richcmp_(self, other, int op):
+ cpdef _richcmp_(self, other, int op) noexcept:
"""
EXAMPLES::
@@ -100,7 +100,7 @@ cdef class LeftZeroSemigroupElement(Element):
right = (other)._value
return PyObject_RichCompare(left, right, op)
- cpdef _mul_(self, other):
+ cpdef _mul_(self, other) noexcept:
"""
EXAMPLES::
diff --git a/src/sage/categories/finite_complex_reflection_groups.py b/src/sage/categories/finite_complex_reflection_groups.py
index 3ee374b739c..80ff28a90f2 100644
--- a/src/sage/categories/finite_complex_reflection_groups.py
+++ b/src/sage/categories/finite_complex_reflection_groups.py
@@ -135,7 +135,7 @@ def WellGenerated(self):
desired output (well generated does not appear)::
sage: CoxeterGroups().Finite()
- Category of finite coxeter groups
+ Category of finite Coxeter groups
"""
return self._with_axiom('WellGenerated')
diff --git a/src/sage/categories/finite_coxeter_groups.py b/src/sage/categories/finite_coxeter_groups.py
index 3459135c9c0..4d422a7541f 100644
--- a/src/sage/categories/finite_coxeter_groups.py
+++ b/src/sage/categories/finite_coxeter_groups.py
@@ -25,10 +25,10 @@ class FiniteCoxeterGroups(CategoryWithAxiom):
EXAMPLES::
sage: CoxeterGroups.Finite()
- Category of finite coxeter groups
+ Category of finite Coxeter groups
sage: FiniteCoxeterGroups().super_categories()
[Category of finite generalized coxeter groups,
- Category of coxeter groups]
+ Category of Coxeter groups]
sage: G = CoxeterGroups().Finite().example()
sage: G.cayley_graph(side = "right").plot()
@@ -55,7 +55,7 @@ def extra_super_categories(self):
sage: CoxeterGroups().Finite().super_categories()
[Category of finite generalized coxeter groups,
- Category of coxeter groups]
+ Category of Coxeter groups]
"""
from sage.categories.complex_reflection_groups import ComplexReflectionGroups
return [ComplexReflectionGroups().Finite().WellGenerated()]
@@ -214,7 +214,7 @@ def bruhat_poset(self, facade=False):
handle large / infinite Coxeter groups.
"""
from sage.combinat.posets.posets import Poset
- covers = tuple([u, v] for v in self for u in v.bruhat_lower_covers() )
+ covers = tuple([u, v] for v in self for u in v.bruhat_lower_covers())
return Poset((self, covers), cover_relations=True, facade=facade)
def shard_poset(self, side='right'):
@@ -590,7 +590,7 @@ def m_cambrian_lattice(self, c, m=1, on_roots=False):
inv_woc = self.inversion_sequence(sorting_word)
S = self.simple_reflections()
T = self.reflections_from_w0()
- Twords = {t : t.reduced_word() for t in T}
+ Twords = {t: t.reduced_word() for t in T}
elements = set()
covers = []
@@ -799,11 +799,12 @@ def coxeter_poset(self):
sage: P.rank()
3
- sage: W = CoxeterGroup(['H', 3], implementation="permutation") # optional - gap3
- sage: P = W.coxeter_poset() # optional - gap3
- sage: P # optional - gap3
+ sage: # optional - gap3
+ sage: W = CoxeterGroup(['H', 3], implementation="permutation")
+ sage: P = W.coxeter_poset()
+ sage: P
Finite meet-semilattice containing 363 elements
- sage: P.rank() # optional - gap3
+ sage: P.rank()
3
"""
I = self.index_set()
@@ -871,11 +872,12 @@ def coxeter_complex(self):
sage: C.homology()
{0: 0, 1: 0, 2: Z}
- sage: W = CoxeterGroup(['H', 3], implementation="permutation") # optional - gap3
- sage: C = W.coxeter_complex() # optional - gap3
- sage: C # optional - gap3
+ sage: # optional - gap3
+ sage: W = CoxeterGroup(['H', 3], implementation="permutation")
+ sage: C = W.coxeter_complex()
+ sage: C
Simplicial complex with 62 vertices and 120 facets
- sage: C.homology() # optional - gap3
+ sage: C.homology()
{0: 0, 1: 0, 2: Z}
"""
I = self.index_set()
@@ -898,7 +900,7 @@ def coxeter_complex(self):
verts = set()
for F in facets.values():
verts.update(F)
- labels = {x: i for i,x in enumerate(verts)}
+ labels = {x: i for i, x in enumerate(verts)}
result = [[labels[v] for v in F] for F in facets.values()]
from sage.topology.simplicial_complex import SimplicialComplex
return SimplicialComplex(result)
@@ -938,12 +940,13 @@ def bruhat_upper_covers(self):
are those covers of `ws_i` that have a descent at `i`.
"""
- i = self.first_descent(positive=True,side='right')
+ i = self.first_descent(positive=True, side='right')
if i is not None:
- wsi = self.apply_simple_reflection(i,side='right')
- return [u.apply_simple_reflection(i,side='right') for u in wsi.bruhat_upper_covers() if u.has_descent(i,side='right')] + [wsi]
- else:
- return []
+ wsi = self.apply_simple_reflection(i, side='right')
+ return [u.apply_simple_reflection(i, side='right')
+ for u in wsi.bruhat_upper_covers()
+ if u.has_descent(i, side='right')] + [wsi]
+ return []
def coxeter_knuth_neighbor(self, w):
r"""
@@ -984,7 +987,7 @@ def coxeter_knuth_neighbor(self, w):
if not C[0] == 'A':
raise NotImplementedError("this has only been implemented in finite type A so far")
d = []
- for i in range(2,len(w)):
+ for i in range(2, len(w)):
v = [j for j in w]
if w[i-2] == w[i]:
if w[i] == w[i-1] - 1:
@@ -1046,7 +1049,7 @@ def coxeter_knuth_graph(self):
R = [tuple(v) for v in self.reduced_words()]
G = Graph()
G.add_vertices(R)
- G.add_edges([v,vp] for v in R for vp in self.coxeter_knuth_neighbor(v))
+ G.add_edges([v, vp] for v in R for vp in self.coxeter_knuth_neighbor(v))
return G
def is_coxeter_element(self):
diff --git a/src/sage/categories/finite_enumerated_sets.py b/src/sage/categories/finite_enumerated_sets.py
index 8a3c0e42ca5..4ca87850b7a 100644
--- a/src/sage/categories/finite_enumerated_sets.py
+++ b/src/sage/categories/finite_enumerated_sets.py
@@ -446,8 +446,7 @@ def iterator_range(self, start=None, stop=None, step=None):
for j in range(stop):
yield next(it)
return
- for x in self:
- yield x
+ yield from self
return
if L is None:
L = self.tuple()
diff --git a/src/sage/categories/finite_weyl_groups.py b/src/sage/categories/finite_weyl_groups.py
index 4420827c833..4210e2f9feb 100644
--- a/src/sage/categories/finite_weyl_groups.py
+++ b/src/sage/categories/finite_weyl_groups.py
@@ -20,7 +20,7 @@ class FiniteWeylGroups(CategoryWithAxiom):
sage: C
Category of finite weyl groups
sage: C.super_categories()
- [Category of finite coxeter groups, Category of weyl groups]
+ [Category of finite Coxeter groups, Category of weyl groups]
sage: C.example()
The symmetric group on {0, ..., 3}
diff --git a/src/sage/categories/map.pxd b/src/sage/categories/map.pxd
index 0467b872353..98c74d862e4 100644
--- a/src/sage/categories/map.pxd
+++ b/src/sage/categories/map.pxd
@@ -8,12 +8,12 @@ cdef class Map(Element):
# a rough measure of the cost of using this morphism in the coercion system.
# 10 by default, 100 if a DefaultCoercionMorphism, 10000 if inexact.
- cdef _update_slots(self, dict)
- cdef dict _extra_slots(self)
+ cdef _update_slots(self, dict) noexcept
+ cdef dict _extra_slots(self) noexcept
# these methods require x is an element of domain, and returns an element with parent codomain
- cpdef Element _call_(self, x)
- cpdef Element _call_with_args(self, x, args=*, kwds=*)
+ cpdef Element _call_(self, x) noexcept
+ cpdef Element _call_with_args(self, x, args=*, kwds=*) noexcept
cdef public domain # will be either a weakref or a constant map
cdef public codomain # will be a constant map
@@ -23,7 +23,7 @@ cdef class Map(Element):
cdef public _repr_type_str
cdef public bint _is_coercion
- cpdef _pow_int(self, n)
+ cpdef _pow_int(self, n) noexcept
cdef class Section(Map):
diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx
index 71c3ef3f1d2..fadd066d7f4 100644
--- a/src/sage/categories/map.pyx
+++ b/src/sage/categories/map.pyx
@@ -389,7 +389,7 @@ cdef class Map(Element):
self.domain = ConstantFunction(D)
self._parent = homset.Hom(D, C, self._category_for)
- cdef _update_slots(self, dict slots):
+ cdef _update_slots(self, dict slots) noexcept:
"""
Set various attributes of this map to implement unpickling.
@@ -451,7 +451,7 @@ cdef class Map(Element):
"""
self._update_slots(_slots)
- cdef dict _extra_slots(self):
+ cdef dict _extra_slots(self) noexcept:
"""
Return a dict with attributes to pickle and copy this map.
"""
@@ -816,7 +816,7 @@ cdef class Map(Element):
return self._call_(x)
return self._call_with_args(x, args, kwds)
- cpdef Element _call_(self, x):
+ cpdef Element _call_(self, x) noexcept:
"""
Call method with a single argument, not implemented in the base class.
@@ -831,7 +831,7 @@ cdef class Map(Element):
"""
raise NotImplementedError(type(self))
- cpdef Element _call_with_args(self, x, args=(), kwds={}):
+ cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept:
"""
Call method with multiple arguments, not implemented in the base class.
@@ -1222,7 +1222,7 @@ cdef class Map(Element):
"""
raise NotImplementedError(type(self))
- cpdef _pow_int(self, n):
+ cpdef _pow_int(self, n) noexcept:
"""
TESTS::
@@ -1368,7 +1368,7 @@ cdef class Section(Map):
Map.__init__(self, Hom(map.codomain(), map.domain(), SetsWithPartialMaps()))
self._inverse = map # TODO: Use this attribute somewhere!
- cdef dict _extra_slots(self):
+ cdef dict _extra_slots(self) noexcept:
"""
Helper for pickling and copying.
@@ -1387,7 +1387,7 @@ cdef class Section(Map):
slots['_inverse'] = self._inverse
return slots
- cdef _update_slots(self, dict _slots):
+ cdef _update_slots(self, dict _slots) noexcept:
"""
Helper for pickling and copying.
@@ -1576,7 +1576,7 @@ cdef class FormalCompositeMap(Map):
"""
return FormalCompositeMap(self.parent(), [f.__copy__() for f in self.__list])
- cdef _update_slots(self, dict _slots):
+ cdef _update_slots(self, dict _slots) noexcept:
"""
Used in pickling and copying.
@@ -1595,7 +1595,7 @@ cdef class FormalCompositeMap(Map):
self.__list = _slots['__list']
Map._update_slots(self, _slots)
- cdef dict _extra_slots(self):
+ cdef dict _extra_slots(self) noexcept:
"""
Used in pickling and copying.
@@ -1708,7 +1708,7 @@ cdef class FormalCompositeMap(Map):
"""
return self.__list[i]
- cpdef Element _call_(self, x):
+ cpdef Element _call_(self, x) noexcept:
"""
Call with a single argument
@@ -1726,7 +1726,7 @@ cdef class FormalCompositeMap(Map):
x = f._call_(x)
return x
- cpdef Element _call_with_args(self, x, args=(), kwds={}):
+ cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept:
"""
Additional arguments are only passed to the last applied map.
diff --git a/src/sage/categories/morphism.pxd b/src/sage/categories/morphism.pxd
index 2222a9c679a..e5befc8207e 100644
--- a/src/sage/categories/morphism.pxd
+++ b/src/sage/categories/morphism.pxd
@@ -7,4 +7,4 @@ cdef class Morphism(Map):
cdef class SetMorphism(Morphism):
cdef object _function
- cpdef bint _eq_c_impl(left, Element right)
+ cpdef bint _eq_c_impl(left, Element right) noexcept
diff --git a/src/sage/categories/morphism.pyx b/src/sage/categories/morphism.pyx
index 571f90a7330..32fcd565e34 100644
--- a/src/sage/categories/morphism.pyx
+++ b/src/sage/categories/morphism.pyx
@@ -344,7 +344,7 @@ cdef class Morphism(Map):
definition = repr(self)
return hash((domain, codomain, definition))
- cpdef _richcmp_(self, other, int op):
+ cpdef _richcmp_(self, other, int op) noexcept:
"""
Generic comparison function for morphisms.
@@ -453,7 +453,7 @@ cdef class FormalCoercionMorphism(Morphism):
def _repr_type(self):
return "Coercion"
- cpdef Element _call_(self, x):
+ cpdef Element _call_(self, x) noexcept:
return self._codomain.coerce(x)
cdef class CallMorphism(Morphism):
@@ -461,7 +461,7 @@ cdef class CallMorphism(Morphism):
def _repr_type(self):
return "Call"
- cpdef Element _call_(self, x):
+ cpdef Element _call_(self, x) noexcept:
return self._codomain(x)
cdef class IdentityMorphism(Morphism):
@@ -475,10 +475,10 @@ cdef class IdentityMorphism(Morphism):
def _repr_type(self):
return "Identity"
- cpdef Element _call_(self, x):
+ cpdef Element _call_(self, x) noexcept:
return x
- cpdef Element _call_with_args(self, x, args=(), kwds={}):
+ cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept:
if not args and not kwds:
return x
cdef Parent C = self._codomain
@@ -499,7 +499,7 @@ cdef class IdentityMorphism(Morphism):
else:
return left
- cpdef _pow_int(self, n):
+ cpdef _pow_int(self, n) noexcept:
return self
def __invert__(self):
@@ -586,7 +586,7 @@ cdef class SetMorphism(Morphism):
Morphism.__init__(self, parent)
self._function = function
- cpdef Element _call_(self, x):
+ cpdef Element _call_(self, x) noexcept:
"""
INPUT:
@@ -607,7 +607,7 @@ cdef class SetMorphism(Morphism):
"""
return self._function(x)
- cpdef Element _call_with_args(self, x, args=(), kwds={}):
+ cpdef Element _call_with_args(self, x, args=(), kwds={}) noexcept:
"""
Extra arguments are passed to the defining function.
@@ -629,7 +629,7 @@ cdef class SetMorphism(Morphism):
except Exception:
raise TypeError("Underlying map %s does not accept additional arguments" % type(self._function))
- cdef dict _extra_slots(self):
+ cdef dict _extra_slots(self) noexcept:
"""
INPUT:
@@ -651,7 +651,7 @@ cdef class SetMorphism(Morphism):
slots['_function'] = self._function
return slots
- cdef _update_slots(self, dict _slots):
+ cdef _update_slots(self, dict _slots) noexcept:
"""
INPUT:
@@ -680,7 +680,7 @@ cdef class SetMorphism(Morphism):
self._function = _slots['_function']
Map._update_slots(self, _slots)
- cpdef bint _eq_c_impl(self, Element other):
+ cpdef bint _eq_c_impl(self, Element other) noexcept:
"""
Equality test
diff --git a/src/sage/categories/posets.py b/src/sage/categories/posets.py
index 5cad3c70f73..98d1be6049d 100644
--- a/src/sage/categories/posets.py
+++ b/src/sage/categories/posets.py
@@ -150,8 +150,7 @@ def __iter__(self):
from sage.combinat.posets.posets import FinitePosets_n
n = 0
while True:
- for P in FinitePosets_n(n):
- yield P
+ yield from FinitePosets_n(n)
n += 1
Finite = LazyImport('sage.categories.finite_posets', 'FinitePosets')
diff --git a/src/sage/categories/weyl_groups.py b/src/sage/categories/weyl_groups.py
index 1322ecd8499..88879d2b478 100644
--- a/src/sage/categories/weyl_groups.py
+++ b/src/sage/categories/weyl_groups.py
@@ -26,7 +26,7 @@ class WeylGroups(Category_singleton):
sage: WeylGroups()
Category of weyl groups
sage: WeylGroups().super_categories()
- [Category of coxeter groups]
+ [Category of Coxeter groups]
Here are some examples::
@@ -53,7 +53,7 @@ def super_categories(self):
EXAMPLES::
sage: WeylGroups().super_categories()
- [Category of coxeter groups]
+ [Category of Coxeter groups]
"""
return [CoxeterGroups()]
diff --git a/src/sage/coding/ag_code_decoders.pyx b/src/sage/coding/ag_code_decoders.pyx
index ccd6c8c6912..162c7210fc5 100644
--- a/src/sage/coding/ag_code_decoders.pyx
+++ b/src/sage/coding/ag_code_decoders.pyx
@@ -1318,7 +1318,7 @@ class DifferentialAGCodeUniqueDecoder(Decoder):
return self._encode(self._decode(received_vector, **kwargs))
-cdef inline int pos_mod(int a, int b):
+cdef inline int pos_mod(int a, int b) noexcept:
"""
Return ``a % b`` such that the result is positive.
@@ -1384,7 +1384,7 @@ cdef class Decoder_K():
message_index = self.message_index
return vector(sum([message[i]*code_basis[i] for i in range(len(message_index))]))
- cdef inline int _degree(self, Polynomial f):
+ cdef inline int _degree(self, Polynomial f) noexcept:
"""
Return the degree of polynomial ``f``
@@ -1395,7 +1395,7 @@ cdef class Decoder_K():
else:
return f.degree()
- cdef void _exponents(self, int s, int *sk, int *si):
+ cdef void _exponents(self, int s, int *sk, int *si) noexcept:
"""
Compute the exponents of the monomial with weighted degree ``s``.
@@ -1414,7 +1414,7 @@ cdef class Decoder_K():
@cython.wraparound(False)
@cython.boundscheck(False)
- cdef void _substitution(self, FreeModuleElement vec, w, int k, Py_ssize_t i):
+ cdef void _substitution(self, FreeModuleElement vec, w, int k, Py_ssize_t i) noexcept:
r"""
Substitute ``z`` with ``(z + w*phi_s)``.
@@ -1740,7 +1740,7 @@ cdef class Decoder_K():
@cython.wraparound(False)
@cython.boundscheck(False)
- cdef inline int _next(self, int s):
+ cdef inline int _next(self, int s) noexcept:
"""
Return the next value after ``s`` in dRbar(dWbar).
"""
@@ -1757,7 +1757,7 @@ cdef class Decoder_K():
@cython.wraparound(False)
@cython.boundscheck(False)
- cdef inline void _get_eta_basis(self, list basis, list vecs, int s0, mon_func):
+ cdef inline void _get_eta_basis(self, list basis, list vecs, int s0, mon_func) noexcept:
"""
Compute a basis of J and h-functions via FGLM algorithm.
diff --git a/src/sage/coding/binary_code.pxd b/src/sage/coding/binary_code.pxd
index 4ae828dcd2b..38be220c731 100644
--- a/src/sage/coding/binary_code.pxd
+++ b/src/sage/coding/binary_code.pxd
@@ -1,4 +1,4 @@
-cdef int *hamming_weights()
+cdef int *hamming_weights() noexcept
ctypedef unsigned int codeword
@@ -18,20 +18,20 @@ cdef class BinaryCode:
cdef int radix
cdef int nwords
- cdef int is_one(self, int, int)
- cdef int is_automorphism(self, int *, int *)
- cpdef int put_in_std_form(self)
- cdef void _apply_permutation_to_basis(self, object labeling)
- cdef void _update_words_from_basis(self)
+ cdef int is_one(self, int, int) noexcept
+ cdef int is_automorphism(self, int *, int *) noexcept
+ cpdef int put_in_std_form(self) noexcept
+ cdef void _apply_permutation_to_basis(self, object labeling) noexcept
+ cdef void _update_words_from_basis(self) noexcept
-cdef WordPermutation *create_word_perm(object)
-cdef WordPermutation *create_array_word_perm(int *, int, int)
-cdef WordPermutation *create_id_word_perm(int)
-cdef WordPermutation *create_comp_word_perm(WordPermutation *, WordPermutation *)
-cdef WordPermutation *create_inv_word_perm(WordPermutation *)
-cdef int dealloc_word_perm(WordPermutation *)
-cdef codeword permute_word_by_wp(WordPermutation *, codeword)
-cdef codeword *expand_to_ortho_basis(BinaryCode, int)
+cdef WordPermutation *create_word_perm(object) noexcept
+cdef WordPermutation *create_array_word_perm(int *, int, int) noexcept
+cdef WordPermutation *create_id_word_perm(int) noexcept
+cdef WordPermutation *create_comp_word_perm(WordPermutation *, WordPermutation *) noexcept
+cdef WordPermutation *create_inv_word_perm(WordPermutation *) noexcept
+cdef int dealloc_word_perm(WordPermutation *) noexcept
+cdef codeword permute_word_by_wp(WordPermutation *, codeword) noexcept
+cdef codeword *expand_to_ortho_basis(BinaryCode, int) noexcept
cdef class OrbitPartition:
cdef int nwords
@@ -45,11 +45,11 @@ cdef class OrbitPartition:
cdef int *col_min_cell_rep
cdef int *col_size
- cdef int wd_find(self, int)
- cdef void wd_union(self, int, int)
- cdef int col_find(self, int)
- cdef void col_union(self, int, int)
- cdef int merge_perm(self, int *, int *)
+ cdef int wd_find(self, int) noexcept
+ cdef void wd_union(self, int, int) noexcept
+ cdef int col_find(self, int) noexcept
+ cdef void col_union(self, int, int) noexcept
+ cdef int merge_perm(self, int *, int *) noexcept
cdef class PartitionStack:
cdef int *wd_ents
@@ -69,24 +69,24 @@ cdef class PartitionStack:
cdef int *wd_counts # These are just for scratch space...
cdef int *wd_output #
- cdef int is_discrete(self, int)
- cdef int num_cells(self, int)
- cdef int sat_225(self, int)
- cdef void new_min_cell_reps(self, int, unsigned int *, int)
- cdef void fixed_vertices(self, int, unsigned int *, unsigned int *, int)
- cdef int new_first_smallest_nontrivial(self, int, unsigned int *, int)
- cdef void col_percolate(self, int, int)
- cdef void wd_percolate(self, int, int)
- cdef int split_vertex(self, int, int)
- cdef int col_degree(self, BinaryCode, int, int, int)
- cdef int wd_degree(self, BinaryCode, int, int, int, int *)
- cdef int sort_cols(self, int, int)
- cdef int sort_wds(self, int, int)
- cdef int refine(self, int, int *, int, BinaryCode, int *)
- cdef void clear(self, int)
- cpdef int cmp(self, PartitionStack, BinaryCode)
- cdef int find_basis(self, int *)
- cdef void get_permutation(self, PartitionStack, int *, int *)
+ cdef int is_discrete(self, int) noexcept
+ cdef int num_cells(self, int) noexcept
+ cdef int sat_225(self, int) noexcept
+ cdef void new_min_cell_reps(self, int, unsigned int *, int) noexcept
+ cdef void fixed_vertices(self, int, unsigned int *, unsigned int *, int) noexcept
+ cdef int new_first_smallest_nontrivial(self, int, unsigned int *, int) noexcept
+ cdef void col_percolate(self, int, int) noexcept
+ cdef void wd_percolate(self, int, int) noexcept
+ cdef int split_vertex(self, int, int) noexcept
+ cdef int col_degree(self, BinaryCode, int, int, int) noexcept
+ cdef int wd_degree(self, BinaryCode, int, int, int, int *) noexcept
+ cdef int sort_cols(self, int, int) noexcept
+ cdef int sort_wds(self, int, int) noexcept
+ cdef int refine(self, int, int *, int, BinaryCode, int *) noexcept
+ cdef void clear(self, int) noexcept
+ cpdef int cmp(self, PartitionStack, BinaryCode) noexcept
+ cdef int find_basis(self, int *) noexcept
+ cdef void get_permutation(self, PartitionStack, int *, int *) noexcept
cdef class BinaryCodeClassifier:
cdef int *ham_wts
@@ -113,6 +113,6 @@ cdef class BinaryCodeClassifier:
cdef int Phi_size
- cdef void record_automorphism(self, int *, int)
- cdef void aut_gp_and_can_label(self, BinaryCode, int)
+ cdef void record_automorphism(self, int *, int) noexcept
+ cdef void aut_gp_and_can_label(self, BinaryCode, int) noexcept
diff --git a/src/sage/coding/binary_code.pyx b/src/sage/coding/binary_code.pyx
index fba66d7c690..6779708bfda 100644
--- a/src/sage/coding/binary_code.pyx
+++ b/src/sage/coding/binary_code.pyx
@@ -57,7 +57,7 @@ WORD_SIZE = sizeof(codeword) << 3
cdef enum:
chunk_size = 8
-cdef inline int min(int a, int b):
+cdef inline int min(int a, int b) noexcept:
if a > b:
return b
else:
@@ -67,7 +67,7 @@ cdef inline int min(int a, int b):
## functions come without an underscore, and the def'd equivalents, which are
## essentially only for doctesting and debugging, have underscores.
-cdef int *hamming_weights():
+cdef int *hamming_weights() noexcept:
cdef int *ham_wts
cdef int i
ham_wts = sig_malloc( 65536 * sizeof(int) )
@@ -279,7 +279,7 @@ def test_word_perms(t_limit=5.0):
dealloc_word_perm(i)
sig_free(arr)
-cdef WordPermutation *create_word_perm(object list_perm):
+cdef WordPermutation *create_word_perm(object list_perm) noexcept:
r"""
Create a word permutation from a Python list permutation L, i.e. such that
`i \mapsto L[i]`.
@@ -330,7 +330,7 @@ cdef WordPermutation *create_word_perm(object list_perm):
image ^= images_i[1 << j]
return word_perm
-cdef WordPermutation *create_array_word_perm(int *array, int start, int degree):
+cdef WordPermutation *create_array_word_perm(int *array, int start, int degree) noexcept:
"""
Create a word permutation of a given degree from a C array, starting at start.
"""
@@ -379,7 +379,7 @@ cdef WordPermutation *create_array_word_perm(int *array, int start, int degree):
image ^= images_i[1 << j]
return word_perm
-cdef WordPermutation *create_id_word_perm(int degree):
+cdef WordPermutation *create_id_word_perm(int degree) noexcept:
"""
Create the identity word permutation of degree degree.
"""
@@ -427,7 +427,7 @@ cdef WordPermutation *create_id_word_perm(int degree):
image ^= images_i[1 << j]
return word_perm
-cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation *h):
+cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation *h) noexcept:
r"""
Create the composition of word permutations `g \circ h`.
"""
@@ -478,7 +478,7 @@ cdef WordPermutation *create_comp_word_perm(WordPermutation *g, WordPermutation
image ^= images_i[1 << j]
return word_perm
-cdef WordPermutation *create_inv_word_perm(WordPermutation *g):
+cdef WordPermutation *create_inv_word_perm(WordPermutation *g) noexcept:
r"""
Create the inverse `g^{-1}` of the word permutation of `g`.
"""
@@ -496,7 +496,7 @@ cdef WordPermutation *create_inv_word_perm(WordPermutation *g):
sig_free(array)
return w
-cdef int dealloc_word_perm(WordPermutation *wp):
+cdef int dealloc_word_perm(WordPermutation *wp) noexcept:
"""
Free the memory used by a word permutation.
"""
@@ -506,7 +506,7 @@ cdef int dealloc_word_perm(WordPermutation *wp):
sig_free(wp.images)
sig_free(wp)
-cdef codeword permute_word_by_wp(WordPermutation *wp, codeword word):
+cdef codeword permute_word_by_wp(WordPermutation *wp, codeword word) noexcept:
"""
Return the codeword obtained by applying the permutation wp to word.
"""
@@ -574,7 +574,7 @@ def test_expand_to_ortho_basis(B=None):
print(''.join(reversed(Integer(output[i]).binary().zfill(C.ncols))))
sig_free(output)
-cdef codeword *expand_to_ortho_basis(BinaryCode B, int n):
+cdef codeword *expand_to_ortho_basis(BinaryCode B, int n) noexcept:
r"""
INPUT:
@@ -1073,7 +1073,7 @@ cdef class BinaryCode:
"""
return self.is_one(word, col) != 0
- cdef int is_one(self, int word, int column):
+ cdef int is_one(self, int word, int column) noexcept:
return (self.words[word] & ( 1 << column)) >> column
def _is_automorphism(self, col_gamma, word_gamma):
@@ -1121,7 +1121,7 @@ cdef class BinaryCode:
sig_free(_word_gamma)
return result
- cdef int is_automorphism(self, int *col_gamma, int *word_gamma):
+ cdef int is_automorphism(self, int *col_gamma, int *word_gamma) noexcept:
cdef int i, j, self_nwords = self.nwords, self_ncols = self.ncols
i = 1
while i < self_nwords:
@@ -1180,7 +1180,7 @@ cdef class BinaryCode:
self._apply_permutation_to_basis(labeling)
self._update_words_from_basis()
- cdef void _apply_permutation_to_basis(self, object labeling):
+ cdef void _apply_permutation_to_basis(self, object labeling) noexcept:
cdef WordPermutation *wp
cdef int i
wp = create_word_perm(labeling)
@@ -1188,7 +1188,7 @@ cdef class BinaryCode:
self.basis[i] = permute_word_by_wp(wp, self.basis[i])
dealloc_word_perm(wp)
- cdef void _update_words_from_basis(self):
+ cdef void _update_words_from_basis(self) noexcept:
cdef codeword word
cdef int j, parity, combination
word = 0
@@ -1206,7 +1206,7 @@ cdef class BinaryCode:
combination ^= (1 << j)
word ^= self.basis[j]
- cpdef int put_in_std_form(self):
+ cpdef int put_in_std_form(self) noexcept:
"""
Put the code in binary form, which is defined by an identity matrix on
the left, augmented by a matrix of data.
@@ -1386,7 +1386,7 @@ cdef class OrbitPartition:
"""
return self.wd_find(word)
- cdef int wd_find(self, int word):
+ cdef int wd_find(self, int word) noexcept:
if self.wd_parent[word] == word:
return word
else:
@@ -1421,7 +1421,7 @@ cdef class OrbitPartition:
"""
self.wd_union(x, y)
- cdef void wd_union(self, int x, int y):
+ cdef void wd_union(self, int x, int y) noexcept:
cdef int x_root, y_root
x_root = self.wd_find(x)
y_root = self.wd_find(y)
@@ -1460,7 +1460,7 @@ cdef class OrbitPartition:
"""
return self.col_find(col)
- cdef int col_find(self, int col):
+ cdef int col_find(self, int col) noexcept:
if self.col_parent[col] == col:
return col
else:
@@ -1495,7 +1495,7 @@ cdef class OrbitPartition:
"""
self.col_union(x, y)
- cdef void col_union(self, int x, int y):
+ cdef void col_union(self, int x, int y) noexcept:
cdef int x_root, y_root
x_root = self.col_find(x)
y_root = self.col_find(y)
@@ -1558,7 +1558,7 @@ cdef class OrbitPartition:
sig_free(_wd_gamma)
return result
- cdef int merge_perm(self, int *col_gamma, int *wd_gamma):
+ cdef int merge_perm(self, int *col_gamma, int *wd_gamma) noexcept:
cdef int i, gamma_i_root
cdef int j, gamma_j_root, return_value = 0
cdef int *self_wd_parent = self.wd_parent
@@ -1906,7 +1906,7 @@ cdef class PartitionStack:
"""
return self.is_discrete(k)
- cdef int is_discrete(self, int k):
+ cdef int is_discrete(self, int k) noexcept:
cdef int i, self_ncols = self.ncols, self_nwords = self.nwords
cdef int *self_col_lvls = self.col_lvls
cdef int *self_wd_lvls = self.wd_lvls
@@ -1942,7 +1942,7 @@ cdef class PartitionStack:
"""
return self.num_cells(k)
- cdef int num_cells(self, int k):
+ cdef int num_cells(self, int k) noexcept:
cdef int i, j = 0
cdef int *self_wd_lvls = self.wd_lvls
cdef int *self_col_lvls = self.col_lvls
@@ -1982,7 +1982,7 @@ cdef class PartitionStack:
"""
return self.sat_225(k)
- cdef int sat_225(self, int k):
+ cdef int sat_225(self, int k) noexcept:
cdef int i, n = self.nwords + self.ncols, in_cell = 0
cdef int nontrivial_cells = 0, total_cells = self.num_cells(k)
cdef int *self_wd_lvls = self.wd_lvls
@@ -2049,7 +2049,7 @@ cdef class PartitionStack:
# reps += (1 << i)
# return reps
#
- cdef void new_min_cell_reps(self, int k, unsigned int *Omega, int start):
+ cdef void new_min_cell_reps(self, int k, unsigned int *Omega, int start) noexcept:
cdef int i, j
cdef int *self_col_lvls = self.col_lvls
cdef int *self_wd_lvls = self.wd_lvls
@@ -2109,7 +2109,7 @@ cdef class PartitionStack:
# fixed += (1 << i)
# return fixed & mcrs
#
- cdef void fixed_vertices(self, int k, unsigned int *Phi, unsigned int *Omega, int start):
+ cdef void fixed_vertices(self, int k, unsigned int *Phi, unsigned int *Omega, int start) noexcept:
cdef int i, j, length, ell, fixed = 0
cdef int radix = self.radix, nwords = self.nwords, ncols = self.ncols
cdef int *self_col_lvls = self.col_lvls
@@ -2184,7 +2184,7 @@ cdef class PartitionStack:
# cell = (~0 << location) ^ (~0 << j+1) # <------- self.radix ----->
# return cell # [0]*(radix-j-1) + [1]*(j-location+1) + [0]*location
#
- cdef int new_first_smallest_nontrivial(self, int k, unsigned int *W, int start):
+ cdef int new_first_smallest_nontrivial(self, int k, unsigned int *W, int start) noexcept:
cdef int ell
cdef int i = 0, j = 0, location = 0, min = self.ncols, nwords = self.nwords
cdef int min_is_col = 1, radix = self.radix
@@ -2296,7 +2296,7 @@ cdef class PartitionStack:
"""
self.col_percolate(start, end)
- cdef void col_percolate(self, int start, int end):
+ cdef void col_percolate(self, int start, int end) noexcept:
cdef int i, temp
cdef int *self_col_ents = self.col_ents
for i from end >= i > start:
@@ -2331,7 +2331,7 @@ cdef class PartitionStack:
"""
self.wd_percolate(start, end)
- cdef void wd_percolate(self, int start, int end):
+ cdef void wd_percolate(self, int start, int end) noexcept:
cdef int i, temp
cdef int *self_wd_ents = self.wd_ents
for i from end >= i > start:
@@ -2430,7 +2430,7 @@ cdef class PartitionStack:
"""
return self.split_vertex(v, k)
- cdef int split_vertex(self, int v, int k):
+ cdef int split_vertex(self, int v, int k) noexcept:
cdef int i = 0, j, flag = self.flag
cdef int *ents
cdef int *lvls
@@ -2496,7 +2496,7 @@ cdef class PartitionStack:
"""
return self.col_degree(C, col, wd_ptr, k)
- cdef int col_degree(self, BinaryCode CG, int col, int wd_ptr, int k):
+ cdef int col_degree(self, BinaryCode CG, int col, int wd_ptr, int k) noexcept:
cdef int i = 0
cdef int *self_wd_lvls = self.wd_lvls
cdef int *self_wd_ents = self.wd_ents
@@ -2540,7 +2540,7 @@ cdef class PartitionStack:
sig_free(ham_wts)
return result
- cdef int wd_degree(self, BinaryCode CG, int wd, int col_ptr, int k, int *ham_wts):
+ cdef int wd_degree(self, BinaryCode CG, int wd, int col_ptr, int k, int *ham_wts) noexcept:
cdef int *self_col_lvls = self.col_lvls
cdef int *self_col_ents = self.col_ents
@@ -2580,7 +2580,7 @@ cdef class PartitionStack:
self.col_degs[i] = degrees[i]
return self.sort_cols(start, k)
- cdef int sort_cols(self, int start, int k):
+ cdef int sort_cols(self, int start, int k) noexcept:
cdef int i, j, max, max_location, self_ncols = self.ncols
cdef int self_nwords = self.nwords, ii
cdef int *self_col_counts = self.col_counts
@@ -2650,7 +2650,7 @@ cdef class PartitionStack:
self.wd_degs[i] = degrees[i]
return self.sort_wds(start, k)
- cdef int sort_wds(self, int start, int k):
+ cdef int sort_wds(self, int start, int k) noexcept:
cdef int i, j, max, max_location, self_nwords = self.nwords
cdef int ii, self_ncols = self.ncols
cdef int *self_wd_counts = self.wd_counts
@@ -2755,7 +2755,7 @@ cdef class PartitionStack:
sig_free(ham_wts)
return result
- cdef int refine(self, int k, int *alpha, int alpha_length, BinaryCode CG, int *ham_wts):
+ cdef int refine(self, int k, int *alpha, int alpha_length, BinaryCode CG, int *ham_wts) noexcept:
cdef int q, r, s, t, flag = self.flag, self_ncols = self.ncols
cdef int t_w, self_nwords = self.nwords, invariant = 0, i, j, m = 0
cdef int *self_wd_degs = self.wd_degs
@@ -2858,7 +2858,7 @@ cdef class PartitionStack:
"""
self.clear(k)
- cdef void clear(self, int k):
+ cdef void clear(self, int k) noexcept:
cdef int i, j = 0, nwords = self.nwords, ncols = self.ncols
cdef int *wd_lvls = self.wd_lvls
cdef int *col_lvls = self.col_lvls
@@ -2876,7 +2876,7 @@ cdef class PartitionStack:
self.col_percolate(j, i)
j = i + 1
- cpdef int cmp(self, PartitionStack other, BinaryCode CG):
+ cpdef int cmp(self, PartitionStack other, BinaryCode CG) noexcept:
"""
EXAMPLES::
@@ -2996,7 +2996,7 @@ cdef class PartitionStack:
self.find_basis(ham_wts)
sig_free(ham_wts)
- cdef int find_basis(self, int *ham_wts):
+ cdef int find_basis(self, int *ham_wts) noexcept:
cdef int i = 0, j, k, nwords = self.nwords, weight, basis_elts = 0, nrows = self.nrows
cdef int *self_wd_ents = self.wd_ents
if self.basis_locations is NULL:
@@ -3072,7 +3072,7 @@ cdef class PartitionStack:
sig_free(col_g)
return word_l, col_l
- cdef void get_permutation(self, PartitionStack other, int *word_gamma, int *col_gamma):
+ cdef void get_permutation(self, PartitionStack other, int *word_gamma, int *col_gamma) noexcept:
cdef int i
cdef int *self_wd_ents = self.wd_ents
cdef int *other_wd_ents = other.wd_ents
@@ -3159,7 +3159,7 @@ cdef class BinaryCodeClassifier:
sig_free(self.labeling)
sig_free(self.base)
- cdef void record_automorphism(self, int *gamma, int ncols):
+ cdef void record_automorphism(self, int *gamma, int ncols) noexcept:
cdef int i, j
if self.aut_gp_index + ncols > self.aut_gens_size:
self.aut_gens_size *= 2
@@ -3337,7 +3337,7 @@ cdef class BinaryCodeClassifier:
aut_gp_size = self.aut_gp_size
return py_aut_gp_gens, py_labeling, aut_gp_size, base
- cdef void aut_gp_and_can_label(self, BinaryCode C, int verbosity):
+ cdef void aut_gp_and_can_label(self, BinaryCode C, int verbosity) noexcept:
# declare variables:
cdef int i, j, ii, jj, iii, jjj, iiii # local variables
diff --git a/src/sage/coding/codecan/codecan.pxd b/src/sage/coding/codecan/codecan.pxd
index dd72f6bb798..b76608d68e3 100644
--- a/src/sage/coding/codecan/codecan.pxd
+++ b/src/sage/coding/codecan/codecan.pxd
@@ -14,23 +14,23 @@ cdef class InnerGroup:
cdef SemimonomialTransformation transporter
cdef bint compute_transporter
- cdef inline int get_rep(self, int pos)
- cdef inline int join_rows(self, int rep1, int rep2)
+ cdef inline int get_rep(self, int pos) noexcept
+ cdef inline int join_rows(self, int rep1, int rep2) noexcept
- cdef InnerGroup _new_c(self)
- cdef void copy_from(self, InnerGroup other)
- cdef bint has_semilinear_action(self)
- cdef minimize_by_row_mult(self, FreeModuleElement v)
+ cdef InnerGroup _new_c(self) noexcept
+ cdef void copy_from(self, InnerGroup other) noexcept
+ cdef bint has_semilinear_action(self) noexcept
+ cdef minimize_by_row_mult(self, FreeModuleElement v) noexcept
cdef minimize_matrix_col(self, object m, int pos, list fixed_minimized_cols,
- bint *group_changed)
- cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos)
- cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow)
+ bint *group_changed) noexcept
+ cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos) noexcept
+ cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow) noexcept
- cdef SemimonomialTransformation get_transporter(self)
+ cdef SemimonomialTransformation get_transporter(self) noexcept
- cdef bint has_semilinear_action(self)
- cpdef int get_frob_pow(self)
- cpdef column_blocks(self, mat)
+ cdef bint has_semilinear_action(self) noexcept
+ cpdef int get_frob_pow(self) noexcept
+ cpdef column_blocks(self, mat) noexcept
cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
cdef int _k, _q
@@ -53,10 +53,10 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
cdef list _autom_group_generators
# specialized refine methods, called in refine
- cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition)
- cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition)
- cdef bint _hyp_refine(self, bint *changed_partition)
+ cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept
+ cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept
+ cdef bint _hyp_refine(self, bint *changed_partition) noexcept
# some additional methods
- cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type)
- cdef _init_point_hyperplane_incidence(self)
+ cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type) noexcept
+ cdef _init_point_hyperplane_incidence(self) noexcept
diff --git a/src/sage/coding/codecan/codecan.pyx b/src/sage/coding/codecan/codecan.pyx
index b0709155b57..4276fffda68 100644
--- a/src/sage/coding/codecan/codecan.pyx
+++ b/src/sage/coding/codecan/codecan.pyx
@@ -190,20 +190,20 @@ cdef class InnerGroup:
"""
OP_dealloc(self.row_partition)
- cdef int get_rep(self, int pos):
+ cdef int get_rep(self, int pos) noexcept:
"""
Get the index of the cell of ``self.row_partition`` containing ``pos``.
"""
return OP_find(self.row_partition, pos)
- cdef bint has_semilinear_action(self):
+ cdef bint has_semilinear_action(self) noexcept:
"""
Returns ``True`` iff the field automorphism group component of ``self``
is non-trivial.
"""
return (self.frob_pow > 0)
- cdef int join_rows(self, int rep1, int rep2):
+ cdef int join_rows(self, int rep1, int rep2) noexcept:
"""
Join the cells with unique representatives
``rep1`` and ``rep2`` of ``self.row_partition``.
@@ -212,7 +212,7 @@ cdef class InnerGroup:
OP_join(self.row_partition, rep1, rep2)
return self.get_rep(rep1)
- cdef void copy_from(self, InnerGroup other):
+ cdef void copy_from(self, InnerGroup other) noexcept:
"""
Copy the group ``other`` to ``self``.
"""
@@ -221,7 +221,7 @@ cdef class InnerGroup:
self.permutational_only = other.permutational_only
OP_copy_from_to(other.row_partition, self.row_partition)
- cdef minimize_by_row_mult(self, FreeModuleElement w):
+ cdef minimize_by_row_mult(self, FreeModuleElement w) noexcept:
r"""
We suppose `v \in \GF{q}^k` and the entries `v_i = 0` for all
``i >= self.rank``.
@@ -249,7 +249,7 @@ cdef class InnerGroup:
return d, v
cdef minimize_matrix_col(self, object m, int pos, list fixed_minimized_cols,
- bint *group_changed):
+ bint *group_changed) noexcept:
r"""
Minimize the column at position ``pos`` of the matrix ``m`` by the
action of ``self``. ``m`` should have no zero column. ``self`` is set to
@@ -330,7 +330,7 @@ cdef class InnerGroup:
self.rank += 1
return m
- cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos):
+ cdef void gaussian_elimination(self, object m, int pos, int pivot, list nz_pos) noexcept:
r"""
Minimize the column at position ``pos`` of the matrix ``m`` by the
action of ``self``. We know that there is some nonzero entry of this
@@ -347,7 +347,7 @@ cdef class InnerGroup:
if pivot != self.rank:
m.swap_rows(self.rank, pivot)
- cdef InnerGroup _new_c(self):
+ cdef InnerGroup _new_c(self) noexcept:
r"""
Make a new copy of ``self``.
"""
@@ -358,7 +358,7 @@ cdef class InnerGroup:
res.permutational_only = self.permutational_only
return res
- cdef SemimonomialTransformation get_transporter(self):
+ cdef SemimonomialTransformation get_transporter(self) noexcept:
r"""
Return the group element we have applied. Should only be called if
we passed an element in
@@ -380,7 +380,7 @@ cdef class InnerGroup:
"with rank = %s, frobenius power = %s and partition =%s" % (self.rank,
self.frob_pow, OP_string(self.row_partition))
- cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow):
+ cdef void minimize_by_frobenius(self, object v, int *applied_frob, int *stab_pow) noexcept:
r"""
Minimize the vector ``v \in \GF{q}^k`` by the
action of the field automorphism component of ``self``.
@@ -417,7 +417,7 @@ cdef class InnerGroup:
stab_pow[0] = 0
break # for
- cpdef int get_frob_pow(self):
+ cpdef int get_frob_pow(self) noexcept:
r"""
Return the power of the Frobenius automorphism which generates
the corresponding component of ``self``.
@@ -431,7 +431,7 @@ cdef class InnerGroup:
"""
return self.frob_pow
- cpdef column_blocks(self, mat):
+ cpdef column_blocks(self, mat) noexcept:
r"""
Let ``mat`` be a matrix which is stabilized by ``self`` having no zero
columns. We know that for each column of ``mat`` there is a uniquely
@@ -646,7 +646,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
self._autom_group_generators.append(transp_inv * x * self._transporter)
self._inner_group_stabilizer_order *= Integer(F.degree() / remaining_inner_group.get_frob_pow())
- cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type):
+ cdef _compute_group_element(self, SemimonomialTransformation trans, str algorithm_type) noexcept:
"""
Apply ``trans`` to ``self._root_matrix`` and minimize this matrix
column by column under the inner minimization. The action is
@@ -738,7 +738,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
"""
return self._inner_group_stabilizer_order
- cdef _init_point_hyperplane_incidence(self):
+ cdef _init_point_hyperplane_incidence(self) noexcept:
r"""
Compute a set of codewords `W` of `C` (generated by self) which is compatible
with the group action, i.e. if we start with some other code `(g,\pi)C`
@@ -811,7 +811,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
self._hyp_refine_vals = _BestValStore(self._hyp_part.degree)
- cdef bint _minimization_allowed_on_col(self, int pos):
+ cdef bint _minimization_allowed_on_col(self, int pos) noexcept:
r"""
Decide if we are allowed to perform the inner minimization on position
``pos`` which is supposed to be a singleton. For linear codes over finite
@@ -819,7 +819,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
"""
return True
- cdef bint _inner_min_(self, int pos, bint *inner_group_changed):
+ cdef bint _inner_min_(self, int pos, bint *inner_group_changed) noexcept:
r"""
Minimize the node by the action of the inner group on the ``pos``-th position.
Sets ``inner_group_changed`` to ``True`` if and only if the inner group
@@ -850,7 +850,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
return True
cdef bint _refine(self, bint *part_changed,
- bint inner_group_changed, bint first_step):
+ bint inner_group_changed, bint first_step) noexcept:
"""
Refine the partition ``self.part``. Set ``part_changed`` to ``True``
if and only if ``self.part`` was refined.
@@ -900,7 +900,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
return True
- cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition):
+ cdef bint _inner_min_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept:
"""
Refine the partition ``self.part`` by computing the orbit (respectively
the hash of a canonical form) of each column vector under the inner group.
@@ -953,7 +953,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
return self._one_refinement(best_vals, 0, self._n, inner_stab_changed,
changed_partition, "supp_refine")
- cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition):
+ cdef bint _point_refine(self, bint *inner_stab_changed, bint *changed_partition) noexcept:
"""
Refine the partition ``self.part`` by counting
(colored) neighbours in the point-hyperplane graph.
@@ -999,7 +999,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
self._part.depth -= 1
return ret_val
- cdef bint _hyp_refine(self, bint *changed_partition):
+ cdef bint _hyp_refine(self, bint *changed_partition) noexcept:
"""
Refine the partition of the hyperplanes by counting
(colored) neighbours in the point-hyperplane graph.
@@ -1045,7 +1045,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
self._hyp_part.depth -= 1
return ret_val[0]
- cdef tuple _store_state_(self):
+ cdef tuple _store_state_(self) noexcept:
r"""
Store the current state of the node to a tuple, such that it can be
restored by :meth:`_restore_state_`.
@@ -1054,7 +1054,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
self._nr_of_point_refine_calls, self._nr_of_hyp_refine_calls,
self._hyp_part.depth)
- cdef void _restore_state_(self, tuple act_state):
+ cdef void _restore_state_(self, tuple act_state) noexcept:
r"""
The inverse of :meth:`_store_state_`.
"""
@@ -1064,13 +1064,13 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
self._nr_of_hyp_refine_calls = act_state[3]
self._hyp_part.depth = act_state[4]
- cdef void _store_best_(self):
+ cdef void _store_best_(self) noexcept:
"""
Store this node as the actual best candidate for the canonical form.
"""
self._best_candidate = copy(self._matrix)
- cdef void _latex_act_node(self, str comment="", int printlvl=0):
+ cdef void _latex_act_node(self, str comment="", int printlvl=0) noexcept:
"""
Print the actual status as latex (tikz) commands to
``self._latex_debug_string``. Only needed if one wants to visualize
diff --git a/src/sage/coding/guruswami_sudan/interpolation.py b/src/sage/coding/guruswami_sudan/interpolation.py
index 8625bae5b49..eea537a115a 100644
--- a/src/sage/coding/guruswami_sudan/interpolation.py
+++ b/src/sage/coding/guruswami_sudan/interpolation.py
@@ -46,8 +46,7 @@ def _flatten_once(lstlst):
[1, 2, 3, 4, 5, 6]
"""
for lst in lstlst:
- for e in lst:
- yield e
+ yield from lst
#*************************************************************
# Linear algebraic Interpolation algorithm, helper functions
diff --git a/src/sage/combinat/abstract_tree.py b/src/sage/combinat/abstract_tree.py
index 1dd26c41222..ee797d990fa 100644
--- a/src/sage/combinat/abstract_tree.py
+++ b/src/sage/combinat/abstract_tree.py
@@ -779,8 +779,7 @@ def paths_at_depth(self, depth, path=[]):
yield tuple(path)
else:
for i in range(len(self)):
- for p in self[i].paths_at_depth(depth - 1, path + [i]):
- yield p
+ yield from self[i].paths_at_depth(depth - 1, path + [i])
def node_number_at_depth(self, depth):
r"""
diff --git a/src/sage/combinat/alternating_sign_matrix.py b/src/sage/combinat/alternating_sign_matrix.py
index ee34e183a70..e4eec5eedaf 100644
--- a/src/sage/combinat/alternating_sign_matrix.py
+++ b/src/sage/combinat/alternating_sign_matrix.py
@@ -1908,8 +1908,7 @@ def __iter__(self):
[[1, 2, 3], [2, 3], [2]],
[[1, 2, 3], [2, 3], [3]]]
"""
- for z in self._iterator_rec(self.n):
- yield z
+ yield from self._iterator_rec(self.n)
def _next_column_iterator(previous_column, height, i=None):
diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
index 514acb43636..58fa26437fa 100644
--- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
+++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
@@ -3878,8 +3878,7 @@ def b_matrix_class_iter(self, depth=infinity, up_to_equivalence=True):
]
"""
Q = self.quiver()
- for M in Q.mutation_class_iter(depth=depth, up_to_equivalence=up_to_equivalence, data_type='matrix'):
- yield M
+ yield from Q.mutation_class_iter(depth=depth, up_to_equivalence=up_to_equivalence, data_type='matrix')
def b_matrix_class(self, depth=infinity, up_to_equivalence=True):
r"""
diff --git a/src/sage/combinat/colored_permutations.py b/src/sage/combinat/colored_permutations.py
index d97624a218d..ff9a67e3083 100644
--- a/src/sage/combinat/colored_permutations.py
+++ b/src/sage/combinat/colored_permutations.py
@@ -1557,7 +1557,7 @@ def _coerce_map_from_(self, C):
[1 if v == 0 else -1
for v in x._colors],
x._perm)
- return super(SignedPermutations, self)._coerce_map_from_(C)
+ return super()._coerce_map_from_(C)
def long_element(self, index_set=None):
"""
@@ -1587,7 +1587,7 @@ def long_element(self, index_set=None):
True
"""
if index_set is not None:
- return super(SignedPermutations, self).long_element()
+ return super().long_element()
return self.element_class(self, [-ZZ.one()] * self._n, self._P.one())
def conjugacy_class_representative(self, nu):
diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py
index 4b763bb5af8..4c182f7c0da 100644
--- a/src/sage/combinat/combinat.py
+++ b/src/sage/combinat/combinat.py
@@ -1938,8 +1938,7 @@ def __iterator_from_list(self) -> Iterator:
sage: list(C) # indirect doctest
[1, 2, 3]
"""
- for x in self.list():
- yield x
+ yield from self.list()
def __iter__(self):
"""
@@ -2574,8 +2573,7 @@ def __iter__(self) -> Iterator:
raise NotImplementedError
i = 0
while True:
- for c in finite(i):
- yield c
+ yield from finite(i)
i += 1
diff --git a/src/sage/combinat/combinat_cython.pxd b/src/sage/combinat/combinat_cython.pxd
index 40cae00a781..dfafe45f589 100644
--- a/src/sage/combinat/combinat_cython.pxd
+++ b/src/sage/combinat/combinat_cython.pxd
@@ -1,5 +1,5 @@
from sage.libs.gmp.all cimport mpz_t
-cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k)
+cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k) noexcept
-cdef list convert(Py_ssize_t* f, Py_ssize_t n)
+cdef list convert(Py_ssize_t* f, Py_ssize_t n) noexcept
diff --git a/src/sage/combinat/combinat_cython.pyx b/src/sage/combinat/combinat_cython.pyx
index c0905491ac2..68a7de2498e 100644
--- a/src/sage/combinat/combinat_cython.pyx
+++ b/src/sage/combinat/combinat_cython.pyx
@@ -28,7 +28,7 @@ set_partition_iterator_blocks = LazyImport('sage.combinat.set_partition_iterator
linear_extension_iterator = LazyImport('sage.combinat.posets.linear_extension_iterator', 'linear_extension_iterator', deprecation=35741)
-cdef void mpz_addmul_alt(mpz_t s, mpz_t t, mpz_t u, unsigned long parity):
+cdef void mpz_addmul_alt(mpz_t s, mpz_t t, mpz_t u, unsigned long parity) noexcept:
"""
Set s = s + t*u * (-1)^parity
"""
@@ -38,7 +38,7 @@ cdef void mpz_addmul_alt(mpz_t s, mpz_t t, mpz_t u, unsigned long parity):
mpz_addmul(s, t, u)
-cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k):
+cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k) noexcept:
"""
Set s = S(n,k) where S(n,k) denotes a Stirling number of the
second kind.
@@ -134,6 +134,7 @@ cdef mpz_stirling_s2(mpz_t s, unsigned long n, unsigned long k):
mpz_clear(t)
mpz_clear(u)
+
def _stirling_number2(n, k):
"""
Python wrapper of mpz_stirling_s2.
@@ -148,8 +149,9 @@ def _stirling_number2(n, k):
mpz_stirling_s2(s.value, n, k)
return s
+
#####################################################################
-## Lyndon word iterator
+# Lyndon word iterator
def lyndon_word_iterator(Py_ssize_t n, Py_ssize_t k):
r"""
@@ -204,7 +206,8 @@ def lyndon_word_iterator(Py_ssize_t n, Py_ssize_t k):
while a[i] == n - 1:
i -= 1
-## Perfect matchings iterator
+
+# Perfect matchings iterator
def perfect_matchings_iterator(Py_ssize_t n):
r"""
@@ -276,7 +279,8 @@ def perfect_matchings_iterator(Py_ssize_t n):
sig_free(e)
sig_free(f)
-cdef list convert(Py_ssize_t* f, Py_ssize_t n):
+
+cdef list convert(Py_ssize_t* f, Py_ssize_t n) noexcept:
"""
Convert a list ``f`` representing a fixed-point free involution
to a set partition.
@@ -288,8 +292,9 @@ cdef list convert(Py_ssize_t* f, Py_ssize_t n):
ret.append((i, f[i]))
return ret
+
#####################################################################
-## Set partition composition
+# Set partition composition
def set_partition_composition(tuple sp1, tuple sp2):
r"""
diff --git a/src/sage/combinat/crystals/letters.pxd b/src/sage/combinat/crystals/letters.pxd
index 4b9598127cd..e473a02dc24 100644
--- a/src/sage/combinat/crystals/letters.pxd
+++ b/src/sage/combinat/crystals/letters.pxd
@@ -5,74 +5,74 @@ cdef class Letter(Element):
cdef class EmptyLetter(Element):
cdef readonly str value
- cpdef e(self, int i)
- cpdef f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef e(self, int i) noexcept
+ cpdef f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class Crystal_of_letters_type_A_element(Letter):
- cpdef Letter e(self, int i)
- cpdef Letter f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Letter e(self, int i) noexcept
+ cpdef Letter f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class Crystal_of_letters_type_B_element(Letter):
- cpdef Letter e(self, int i)
- cpdef Letter f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Letter e(self, int i) noexcept
+ cpdef Letter f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class Crystal_of_letters_type_C_element(Letter):
- cpdef Letter e(self, int i)
- cpdef Letter f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Letter e(self, int i) noexcept
+ cpdef Letter f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class Crystal_of_letters_type_D_element(Letter):
- cpdef Letter e(self, int i)
- cpdef Letter f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Letter e(self, int i) noexcept
+ cpdef Letter f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class Crystal_of_letters_type_G_element(Letter):
- cpdef Letter e(self, int i)
- cpdef Letter f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Letter e(self, int i) noexcept
+ cpdef Letter f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class LetterTuple(Element):
cdef readonly tuple value
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class Crystal_of_letters_type_E6_element(LetterTuple):
- cpdef LetterTuple e(self, int i)
- cpdef LetterTuple f(self, int i)
+ cpdef LetterTuple e(self, int i) noexcept
+ cpdef LetterTuple f(self, int i) noexcept
cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple):
- cpdef LetterTuple lift(self)
- cpdef LetterTuple retract(self, LetterTuple p)
- cpdef LetterTuple e(self, int i)
- cpdef LetterTuple f(self, int i)
+ cpdef LetterTuple lift(self) noexcept
+ cpdef LetterTuple retract(self, LetterTuple p) noexcept
+ cpdef LetterTuple e(self, int i) noexcept
+ cpdef LetterTuple f(self, int i) noexcept
cdef class Crystal_of_letters_type_E7_element(LetterTuple):
- cpdef LetterTuple e(self, int i)
- cpdef LetterTuple f(self, int i)
+ cpdef LetterTuple e(self, int i) noexcept
+ cpdef LetterTuple f(self, int i) noexcept
cdef class BKKLetter(Letter):
- cpdef Letter e(self, int i)
- cpdef Letter f(self, int i)
+ cpdef Letter e(self, int i) noexcept
+ cpdef Letter f(self, int i) noexcept
cdef class QueerLetter_element(Letter):
- cpdef Letter e(self, int i)
- cpdef Letter f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Letter e(self, int i) noexcept
+ cpdef Letter f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class LetterWrapped(Element):
cdef readonly Element value
- cpdef tuple _to_tuple(self)
- cpdef LetterWrapped e(self, int i)
- cpdef LetterWrapped f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef tuple _to_tuple(self) noexcept
+ cpdef LetterWrapped e(self, int i) noexcept
+ cpdef LetterWrapped f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
diff --git a/src/sage/combinat/crystals/letters.pyx b/src/sage/combinat/crystals/letters.pyx
index d204a979563..cf8d25587d8 100644
--- a/src/sage/combinat/crystals/letters.pyx
+++ b/src/sage/combinat/crystals/letters.pyx
@@ -464,7 +464,7 @@ cdef class Letter(Element):
"""
return self.value
- cpdef _richcmp_(left, right, int op):
+ cpdef _richcmp_(left, right, int op) noexcept:
"""
Return ``True`` if ``left`` compares with ``right`` based on ``op``.
@@ -585,7 +585,7 @@ cdef class EmptyLetter(Element):
"""
return hash(self.value)
- cpdef _richcmp_(left, right, int op):
+ cpdef _richcmp_(left, right, int op) noexcept:
"""
Return ``True`` if ``left`` compares with ``right`` based on ``op``.
@@ -625,7 +625,7 @@ cdef class EmptyLetter(Element):
"""
return self._parent.weight_lattice_realization().zero()
- cpdef e(self, int i):
+ cpdef e(self, int i) noexcept:
"""
Return `e_i` of ``self`` which is ``None``.
@@ -636,7 +636,7 @@ cdef class EmptyLetter(Element):
"""
return None
- cpdef f(self, int i):
+ cpdef f(self, int i) noexcept:
"""
Return `f_i` of ``self`` which is ``None``.
@@ -647,7 +647,7 @@ cdef class EmptyLetter(Element):
"""
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -659,7 +659,7 @@ cdef class EmptyLetter(Element):
"""
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -711,7 +711,7 @@ cdef class Crystal_of_letters_type_A_element(Letter):
"""
return self._parent.weight_lattice_realization().monomial(self.value-1)
- cpdef Letter e(self, int i):
+ cpdef Letter e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -726,7 +726,7 @@ cdef class Crystal_of_letters_type_A_element(Letter):
else:
return None
- cpdef Letter f(self, int i):
+ cpdef Letter f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -741,7 +741,7 @@ cdef class Crystal_of_letters_type_A_element(Letter):
else:
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -755,7 +755,7 @@ cdef class Crystal_of_letters_type_A_element(Letter):
return 1
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -804,7 +804,7 @@ cdef class Crystal_of_letters_type_B_element(Letter):
else:
return self._parent.weight_lattice_realization()(0)
- cpdef Letter e(self, int i):
+ cpdef Letter e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -833,7 +833,7 @@ cdef class Crystal_of_letters_type_B_element(Letter):
else:
return None
- cpdef Letter f(self, int i):
+ cpdef Letter f(self, int i) noexcept:
r"""
Return the actions of `f_i` on ``self``.
@@ -862,7 +862,7 @@ cdef class Crystal_of_letters_type_B_element(Letter):
else:
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -883,7 +883,7 @@ cdef class Crystal_of_letters_type_B_element(Letter):
return 1
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -942,7 +942,7 @@ cdef class Crystal_of_letters_type_C_element(Letter):
else:
return self._parent.weight_lattice_realization()(0)
- cpdef Letter e(self, int i):
+ cpdef Letter e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -965,7 +965,7 @@ cdef class Crystal_of_letters_type_C_element(Letter):
else:
return None
- cpdef Letter f(self, int i):
+ cpdef Letter f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -983,7 +983,7 @@ cdef class Crystal_of_letters_type_C_element(Letter):
else:
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -997,7 +997,7 @@ cdef class Crystal_of_letters_type_C_element(Letter):
return 1
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -1049,7 +1049,7 @@ cdef class Crystal_of_letters_type_D_element(Letter):
else:
return self._parent.weight_lattice_realization()(0)
- cpdef Letter e(self, int i):
+ cpdef Letter e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -1082,7 +1082,7 @@ cdef class Crystal_of_letters_type_D_element(Letter):
else:
return None
- cpdef Letter f(self, int i):
+ cpdef Letter f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -1113,7 +1113,7 @@ cdef class Crystal_of_letters_type_D_element(Letter):
else:
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -1130,7 +1130,7 @@ cdef class Crystal_of_letters_type_D_element(Letter):
return 1
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -1188,7 +1188,7 @@ cdef class Crystal_of_letters_type_G_element(Letter):
else:
raise RuntimeError("G2 crystal of letters element %d not valid" % self.value)
- cpdef Letter e(self, int i):
+ cpdef Letter e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -1222,7 +1222,7 @@ cdef class Crystal_of_letters_type_G_element(Letter):
else:
return None
- cpdef Letter f(self, int i):
+ cpdef Letter f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -1256,7 +1256,7 @@ cdef class Crystal_of_letters_type_G_element(Letter):
else:
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -1276,7 +1276,7 @@ cdef class Crystal_of_letters_type_G_element(Letter):
return 1
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -1358,7 +1358,7 @@ cdef class LetterTuple(Element):
"""
return hash(self.value)
- cpdef _richcmp_(left, right, int op):
+ cpdef _richcmp_(left, right, int op) noexcept:
"""
Check comparison between ``left`` and ``right`` based on ``op``
@@ -1438,7 +1438,7 @@ cdef class LetterTuple(Element):
ret+= repr(v)
return ret + "\\right)"
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -1454,7 +1454,7 @@ cdef class LetterTuple(Element):
return 1
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -1555,7 +1555,7 @@ cdef class Crystal_of_letters_type_E6_element(LetterTuple):
R = self._parent.weight_lattice_realization().fundamental_weights()
return sum(Integer(i).sign() * R[abs(i)] for i in self.value)
- cpdef LetterTuple e(self, int i):
+ cpdef LetterTuple e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -1643,7 +1643,7 @@ cdef class Crystal_of_letters_type_E6_element(LetterTuple):
else:
return None
- cpdef LetterTuple f(self, int i):
+ cpdef LetterTuple f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -1774,7 +1774,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple):
return l[self._parent.list().index(self)]
return repr(self.value)
- cpdef LetterTuple lift(self):
+ cpdef LetterTuple lift(self) noexcept:
"""
Lift an element of ``self`` to the crystal of letters
``crystals.Letters(['E',6])`` by taking its inverse weight.
@@ -1791,7 +1791,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple):
# tuple from a list
return self._parent._ambient(tuple([-i for i in self.value]))
- cpdef LetterTuple retract(self, LetterTuple p):
+ cpdef LetterTuple retract(self, LetterTuple p) noexcept:
"""
Retract element ``p``, which is an element in
``crystals.Letters(['E',6])`` to an element in
@@ -1814,7 +1814,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple):
# tuple from a list
return self._parent._element_constructor_(tuple([-i for i in p.value]))
- cpdef LetterTuple e(self, int i):
+ cpdef LetterTuple e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -1826,7 +1826,7 @@ cdef class Crystal_of_letters_type_E6_element_dual(LetterTuple):
"""
return self.retract(self.lift().f(i))
- cpdef LetterTuple f(self, int i):
+ cpdef LetterTuple f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -1956,7 +1956,7 @@ cdef class Crystal_of_letters_type_E7_element(LetterTuple):
R = self._parent.weight_lattice_realization().fundamental_weights()
return sum(Integer(i).sign() * R[abs(i)] for i in self.value)
- cpdef LetterTuple e(self, int i):
+ cpdef LetterTuple e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -2138,7 +2138,7 @@ cdef class Crystal_of_letters_type_E7_element(LetterTuple):
else:
return None
- cpdef LetterTuple f(self, int i):
+ cpdef LetterTuple f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -2395,7 +2395,7 @@ cdef class BKKLetter(Letter):
ret = "\\underline{{{}}}".format(ret)
return ret
- cpdef Letter e(self, int i):
+ cpdef Letter e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -2435,7 +2435,7 @@ cdef class BKKLetter(Letter):
return self._parent._element_constructor_(-1)
return None
- cpdef Letter f(self, int i):
+ cpdef Letter f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -2715,7 +2715,7 @@ cdef class QueerLetter_element(Letter):
"""
return self._parent.weight_lattice_realization().monomial(self.value-1)
- cpdef Letter e(self, int i):
+ cpdef Letter e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -2731,7 +2731,7 @@ cdef class QueerLetter_element(Letter):
return self._parent._element_constructor_(self.value-1)
return None
- cpdef Letter f(self, int i):
+ cpdef Letter f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -2747,7 +2747,7 @@ cdef class QueerLetter_element(Letter):
return self._parent._element_constructor_(self.value+1)
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -2761,7 +2761,7 @@ cdef class QueerLetter_element(Letter):
return 1
return 0
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -2823,7 +2823,7 @@ cdef class LetterWrapped(Element):
"""
return hash(self.value)
- cpdef _richcmp_(left, right, int op):
+ cpdef _richcmp_(left, right, int op) noexcept:
"""
Check comparison between ``left`` and ``right`` based on ``op``
@@ -2854,7 +2854,7 @@ cdef class LetterWrapped(Element):
return self.value == x.value or x._parent.lt_elements(x, self)
return False
- cpdef tuple _to_tuple(self):
+ cpdef tuple _to_tuple(self) noexcept:
r"""
Return a tuple encoding the `\varepsilon_i` and `\varphi_i`
values of ``elt``.
@@ -2923,7 +2923,7 @@ cdef class LetterWrapped(Element):
ret+= repr(v)
return ret + "\\right)"
- cpdef LetterWrapped e(self, int i):
+ cpdef LetterWrapped e(self, int i) noexcept:
r"""
Return `e_i` of ``self``.
@@ -2939,7 +2939,7 @@ cdef class LetterWrapped(Element):
return None
return type(self)(self._parent, ret)
- cpdef LetterWrapped f(self, int i):
+ cpdef LetterWrapped f(self, int i) noexcept:
r"""
Return `f_i` of ``self``.
@@ -2955,7 +2955,7 @@ cdef class LetterWrapped(Element):
return None
return type(self)(self._parent, ret)
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -2969,7 +2969,7 @@ cdef class LetterWrapped(Element):
"""
return self.value.epsilon(i)
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
diff --git a/src/sage/combinat/crystals/pbw_datum.pxd b/src/sage/combinat/crystals/pbw_datum.pxd
index 9c3aab083df..ecfbf60b842 100644
--- a/src/sage/combinat/crystals/pbw_datum.pxd
+++ b/src/sage/combinat/crystals/pbw_datum.pxd
@@ -1,3 +1,3 @@
-cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum)
-cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum)
-cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type)
+cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum) noexcept
+cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum) noexcept
+cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type) noexcept
diff --git a/src/sage/combinat/crystals/pbw_datum.pyx b/src/sage/combinat/crystals/pbw_datum.pyx
index 2adcb09d902..a81732cdc73 100644
--- a/src/sage/combinat/crystals/pbw_datum.pyx
+++ b/src/sage/combinat/crystals/pbw_datum.pyx
@@ -282,7 +282,7 @@ class PBWData(): # UniqueRepresentation?
# enhanced_braid_chain is an ugly data structure.
@cython.boundscheck(False)
@cython.wraparound(False)
-cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum):
+cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig_datum) noexcept:
"""
Return the Lusztig datum obtained by applying tropical Plücker
relations along ``enhanced_braid_chain`` starting with
@@ -330,7 +330,7 @@ cpdef tuple compute_new_lusztig_datum(list enhanced_braid_chain, initial_lusztig
# The tropical Plücker relations
@cython.boundscheck(False)
@cython.wraparound(False)
-cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum):
+cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum) noexcept:
r"""
Apply the tropical Plücker relation of type ``a`` to ``lusztig_datum``.
@@ -403,7 +403,7 @@ cpdef tuple tropical_plucker_relation(tuple a, lusztig_datum):
# TODO: Move to PBW_data?
@cython.boundscheck(False)
@cython.wraparound(False)
-cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type):
+cpdef list enhance_braid_move_chain(braid_move_chain, cartan_type) noexcept:
r"""
Return a list of tuples that records the data of the long words in
``braid_move_chain`` plus the data of the intervals where the braid moves
diff --git a/src/sage/combinat/crystals/spins.pxd b/src/sage/combinat/crystals/spins.pxd
index a486aaa2518..a98f1702508 100644
--- a/src/sage/combinat/crystals/spins.pxd
+++ b/src/sage/combinat/crystals/spins.pxd
@@ -5,16 +5,16 @@ cdef class Spin(Element):
cdef int _n
cdef long _hash
- cdef Spin _new_c(self, bint* value)
+ cdef Spin _new_c(self, bint* value) noexcept
cdef class Spin_crystal_type_B_element(Spin):
- cpdef Spin e(self, int i)
- cpdef Spin f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Spin e(self, int i) noexcept
+ cpdef Spin f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
cdef class Spin_crystal_type_D_element(Spin):
- cpdef Spin e(self, int i)
- cpdef Spin f(self, int i)
- cpdef int epsilon(self, int i)
- cpdef int phi(self, int i)
+ cpdef Spin e(self, int i) noexcept
+ cpdef Spin f(self, int i) noexcept
+ cpdef int epsilon(self, int i) noexcept
+ cpdef int phi(self, int i) noexcept
diff --git a/src/sage/combinat/crystals/spins.pyx b/src/sage/combinat/crystals/spins.pyx
index 7548b7b695e..97e8157afd5 100644
--- a/src/sage/combinat/crystals/spins.pyx
+++ b/src/sage/combinat/crystals/spins.pyx
@@ -297,7 +297,7 @@ cdef class Spin(Element):
self._value[i] = (val[i] != 1)
Element.__init__(self, parent)
- cdef Spin _new_c(self, bint* value):
+ cdef Spin _new_c(self, bint* value) noexcept:
r"""
Fast creation of a spin element.
"""
@@ -349,7 +349,7 @@ cdef class Spin(Element):
tup = tuple([-1 if self._value[i] else 1 for i in range(self._n)])
return (self._parent, (tup,))
- cpdef _richcmp_(left, right, int op):
+ cpdef _richcmp_(left, right, int op) noexcept:
"""
Return ``True`` if ``left`` compares with ``right`` based on ``op``.
@@ -534,7 +534,7 @@ cdef class Spin_crystal_type_B_element(Spin):
r"""
Type B spin representation crystal element
"""
- cpdef Spin e(self, int i):
+ cpdef Spin e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -567,7 +567,7 @@ cdef class Spin_crystal_type_B_element(Spin):
return self._new_c(ret)
return None
- cpdef Spin f(self, int i):
+ cpdef Spin f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -600,7 +600,7 @@ cdef class Spin_crystal_type_B_element(Spin):
return self._new_c(ret)
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -617,7 +617,7 @@ cdef class Spin_crystal_type_B_element(Spin):
return self._value[i-1]
return self._value[i-1] and not self._value[i]
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
@@ -638,7 +638,7 @@ cdef class Spin_crystal_type_D_element(Spin):
r"""
Type D spin representation crystal element
"""
- cpdef Spin e(self, int i):
+ cpdef Spin e(self, int i) noexcept:
r"""
Return the action of `e_i` on ``self``.
@@ -679,7 +679,7 @@ cdef class Spin_crystal_type_D_element(Spin):
return self._new_c(ret)
return None
- cpdef Spin f(self, int i):
+ cpdef Spin f(self, int i) noexcept:
r"""
Return the action of `f_i` on ``self``.
@@ -720,7 +720,7 @@ cdef class Spin_crystal_type_D_element(Spin):
return self._new_c(ret)
return None
- cpdef int epsilon(self, int i):
+ cpdef int epsilon(self, int i) noexcept:
r"""
Return `\varepsilon_i` of ``self``.
@@ -737,7 +737,7 @@ cdef class Spin_crystal_type_D_element(Spin):
return self._value[i-1] and self._value[i-2]
return self._value[i-1] and not self._value[i]
- cpdef int phi(self, int i):
+ cpdef int phi(self, int i) noexcept:
r"""
Return `\varphi_i` of ``self``.
diff --git a/src/sage/combinat/crystals/tensor_product_element.pxd b/src/sage/combinat/crystals/tensor_product_element.pxd
index aae31eb7a03..c1af4e1cb20 100644
--- a/src/sage/combinat/crystals/tensor_product_element.pxd
+++ b/src/sage/combinat/crystals/tensor_product_element.pxd
@@ -1,14 +1,14 @@
from sage.structure.list_clone cimport ClonableArray
cdef class ImmutableListWithParent(ClonableArray):
- cpdef _set_index(self, k, value)
+ cpdef _set_index(self, k, value) noexcept
cdef class TensorProductOfCrystalsElement(ImmutableListWithParent):
pass
cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement):
- cpdef position_of_last_unmatched_minus(self, i)
- cpdef position_of_first_unmatched_plus(self, i)
+ cpdef position_of_last_unmatched_minus(self, i) noexcept
+ cpdef position_of_first_unmatched_plus(self, i) noexcept
cdef class CrystalOfTableauxElement(TensorProductOfRegularCrystalsElement):
pass
@@ -31,4 +31,4 @@ cdef class TensorProductOfQueerSuperCrystalsElement(TensorProductOfRegularCrysta
cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrystalsElement):
cdef list _row_lengths
-cdef Py_ssize_t count_leading(list row, letter)
+cdef Py_ssize_t count_leading(list row, letter) noexcept
diff --git a/src/sage/combinat/crystals/tensor_product_element.pyx b/src/sage/combinat/crystals/tensor_product_element.pyx
index bafdb5e175a..abc5a743a4e 100644
--- a/src/sage/combinat/crystals/tensor_product_element.pyx
+++ b/src/sage/combinat/crystals/tensor_product_element.pyx
@@ -73,7 +73,7 @@ cdef class ImmutableListWithParent(ClonableArray):
self._is_immutable = True
self._hash = 0
- cpdef _set_index(self, k, value):
+ cpdef _set_index(self, k, value) noexcept:
r"""
Return a sibling of ``self`` obtained by setting the
`k^{th}` entry of self to value.
@@ -573,7 +573,7 @@ cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement)
height = height - minus + plus
return height
- cpdef position_of_last_unmatched_minus(self, i):
+ cpdef position_of_last_unmatched_minus(self, i) noexcept:
"""
Return the position of the last unmatched `-` or ``None`` if
there is no unmatched `-`.
@@ -599,7 +599,7 @@ cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement)
height = height - minus + plus
return unmatched_minus
- cpdef position_of_first_unmatched_plus(self, i):
+ cpdef position_of_first_unmatched_plus(self, i) noexcept:
"""
Return the position of the first unmatched `+` or ``None`` if
there is no unmatched `+`.
@@ -1858,7 +1858,7 @@ cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrysta
ret -= L(1).weight() # From the 1 on the bottom row
return ret
-cdef Py_ssize_t count_leading(list row, letter):
+cdef Py_ssize_t count_leading(list row, letter) noexcept:
cdef Py_ssize_t i
for i in range(len(row)-1,-1,-1):
if row[i] != letter:
diff --git a/src/sage/combinat/debruijn_sequence.pyx b/src/sage/combinat/debruijn_sequence.pyx
index d98a3e66c87..18fe9212504 100644
--- a/src/sage/combinat/debruijn_sequence.pyx
+++ b/src/sage/combinat/debruijn_sequence.pyx
@@ -57,15 +57,16 @@ AUTHOR:
"""
-#*******************************************************************************
+# ******************************************************************************
# Copyright (C) 2011 Eviatar Bach
#
# Distributed under the terms of the GNU General Public License (GPL)
-# http://www.gnu.org/licenses/
-#*******************************************************************************
+# https://www.gnu.org/licenses/
+# ******************************************************************************
from sage.data_structures.bitset_base cimport *
+
def debruijn_sequence(int k, int n):
"""
The generating function for De Bruijn sequences. This avoids the object
@@ -93,7 +94,8 @@ def debruijn_sequence(int k, int n):
gen(1, 1, k, n)
return sequence
-cdef gen(int t, int p, k, n):
+
+cdef gen(int t, int p, k, n) noexcept:
"""
The internal generation function. This should not be accessed by the
user.
@@ -183,6 +185,7 @@ def is_debruijn_sequence(seq, k, n):
return answer
+
from sage.categories.finite_sets import FiniteSets
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.parent import Parent
@@ -190,6 +193,7 @@ from sage.structure.parent import Parent
from sage.rings.integer cimport Integer
from sage.rings.integer_ring import ZZ
+
class DeBruijnSequences(UniqueRepresentation, Parent):
"""
Represents the De Bruijn sequences of given parameters `k` and `n`.
@@ -256,35 +260,32 @@ class DeBruijnSequences(UniqueRepresentation, Parent):
"""
Constructor.
- Checks the consistency of the given arguments.
+ This checks the consistency of the given arguments.
TESTS:
- Setting ``n`` orr ``k`` to anything under 1 will return a ValueError:
-
- ::
+ Setting ``n`` or ``k`` to anything under 1 will return
+ a :class:`ValueError`::
sage: DeBruijnSequences(3, 0).an_element()
Traceback (most recent call last):
...
- ValueError: k and n cannot be under 1.
+ ValueError: k and n cannot be under 1
Setting ``n`` or ``k`` to any type except an integer will return a
- TypeError:
-
- ::
+ :class:`TypeError`::
sage: DeBruijnSequences(2.5, 3).an_element()
Traceback (most recent call last):
...
- TypeError: k and n must be integers.
+ TypeError: k and n must be integers
"""
Parent.__init__(self, category=FiniteSets())
if n < 1 or k < 1:
- raise ValueError('k and n cannot be under 1.')
+ raise ValueError('k and n cannot be under 1')
if (not isinstance(n, (Integer, int)) or
- not isinstance(k, (Integer,int))):
- raise TypeError('k and n must be integers.')
+ not isinstance(k, (Integer, int))):
+ raise TypeError('k and n must be integers')
self.k = k
self.n = n
diff --git a/src/sage/combinat/degree_sequences.pyx b/src/sage/combinat/degree_sequences.pyx
index 0ccc2377f2c..2052677a4a4 100644
--- a/src/sage/combinat/degree_sequences.pyx
+++ b/src/sage/combinat/degree_sequences.pyx
@@ -57,9 +57,9 @@ An integer sequence need not necessarily be a degree sequence. Indeed, in a
degree sequence of length `n` no integer can be larger than `n-1` -- the degree
of a vertex is at most `n-1` -- and the sum of them is at most `n(n-1)`.
-Degree sequences are completely characterized by a result from Erdos and Gallai:
+Degree sequences are completely characterized by a result from Erdős and Gallai:
-**Erdos and Gallai:** *The sequence of integers* `d_1 \geq \cdots \geq d_n`
+**Erdős and Gallai:** *The sequence of integers* `d_1 \geq \cdots \geq d_n`
*is a degree sequence if and only if* `\sum_i d_i` is even and `\forall i`
.. MATH::
@@ -281,6 +281,7 @@ from cysignals.signals cimport sig_on, sig_off
cdef unsigned char * seq
cdef list sequences
+
class DegreeSequences:
def __init__(self, n):
@@ -307,16 +308,16 @@ class DegreeSequences:
sage: DegreeSequences(-1)
Traceback (most recent call last):
...
- ValueError: The input parameter must be >= 0.
+ ValueError: the input parameter must be >= 0
"""
if n < 0:
- raise ValueError("The input parameter must be >= 0.")
+ raise ValueError("the input parameter must be >= 0")
self._n = n
def __contains__(self, seq):
"""
- Checks whether a given integer sequence is the degree sequence
- of a graph on `n` elements
+ Check whether a given integer sequence is the degree sequence
+ of a graph on `n` elements.
EXAMPLES::
@@ -342,7 +343,7 @@ class DegreeSequences:
[[0]]
"""
cdef int n = self._n
- if len(seq)!=n:
+ if len(seq) != n:
return False
# Is the sum even ?
@@ -352,13 +353,13 @@ class DegreeSequences:
# Partial represents the left side of Erdos and Gallai's inequality,
# i.e. the sum of the i first integers.
cdef int partial = 0
- cdef int i,d,dd, right
+ cdef int i, d, dd, right
# Temporary variable to ensure that the sequence is indeed
# non-increasing
- cdef int prev = n-1
+ cdef int prev = n - 1
- for i,d in enumerate(seq):
+ for i, d in enumerate(seq):
# Non-increasing ?
if d > prev:
@@ -370,9 +371,9 @@ class DegreeSequences:
partial += d
# Evaluating the right hand side
- right = i*(i+1)
- for dd in seq[i+1:]:
- right += min(dd,i+1)
+ right = i * (i + 1)
+ for dd in seq[i + 1:]:
+ right += min(dd, i + 1)
# Comparing the two
if partial > right:
@@ -404,7 +405,7 @@ class DegreeSequences:
sage: all(seq in DS for seq in DS)
True
"""
- return iter( init(self._n) )
+ yield from init(self._n)
def __dealloc__():
"""
@@ -412,7 +413,8 @@ class DegreeSequences:
"""
sig_free(seq)
-cdef init(int n):
+
+cdef init(int n) noexcept:
"""
Initializes the memory and starts the enumeration algorithm.
"""
@@ -432,11 +434,11 @@ cdef init(int n):
N = n
sequences = []
- enum(1,0)
+ enum(1, 0)
sig_free(seq)
return sequences
-cdef inline add_seq():
+cdef inline add_seq() noexcept:
"""
This function is called whenever a sequence is found.
@@ -457,7 +459,7 @@ cdef inline add_seq():
sequences.append(s)
-cdef void enum(int k, int M):
+cdef void enum(int k, int M) noexcept:
r"""
Main function; for an explanation of the algorithm please refer to the
:mod:`sage.combinat.degree_sequences` documentation.
@@ -467,7 +469,7 @@ cdef void enum(int k, int M):
- ``k`` -- depth of the partial degree sequence
- ``M`` -- value of a maximum element in the partial degree sequence
"""
- cdef int i,j
+ cdef int i, j
global seq
cdef int taken = 0
cdef int current_box
@@ -491,21 +493,21 @@ cdef void enum(int k, int M):
if M == 0:
seq[0] += 1
- enum(k+1, M)
+ enum(k + 1, M)
seq[0] -= 1
# We need not automatically increase the degree at each step. In this case,
# we have no other choice but to link the new vertex of degree M to vertices
# of degree M-1, which will become vertices of degree M too.
- elif seq[M-1] >= M:
+ elif seq[M - 1] >= M:
- seq[M] += M+1
- seq[M-1] -= M
+ seq[M] += M + 1
+ seq[M - 1] -= M
- enum(k+1, M)
+ enum(k + 1, M)
- seq[M] -= M+1
- seq[M-1] += M
+ seq[M] -= M + 1
+ seq[M - 1] += M
###############################################
# Creating vertices of Vertices of degree > M #
@@ -542,13 +544,13 @@ cdef void enum(int k, int M):
seq[current_box] -= i
seq[current_box+1] += i
- for max(0,((M+1)-taken-i)) <= j <= n_previous_box:
+ for max(0, ((M+1)-taken-i)) <= j <= n_previous_box:
seq[current_box-1] -= j
seq[current_box] += j
new_vertex = taken + i + j
seq[new_vertex] += 1
- enum(k+1,new_vertex)
+ enum(k+1, new_vertex)
seq[new_vertex] -= 1
seq[current_box-1] += j
@@ -566,7 +568,7 @@ cdef void enum(int k, int M):
# Now current_box = 0. All the vertices of nonzero degree are taken, we just
# want to know how many vertices of degree 0 will be neighbors of the new
# vertex.
- for max(0,((M+1)-taken)) <= i <= seq[0]:
+ for max(0, ((M+1)-taken)) <= i <= seq[0]:
seq[1] += i
seq[0] -= i
diff --git a/src/sage/combinat/designs/design_catalog.py b/src/sage/combinat/designs/design_catalog.py
index 26b899cb93d..8bf7f14fd0b 100644
--- a/src/sage/combinat/designs/design_catalog.py
+++ b/src/sage/combinat/designs/design_catalog.py
@@ -118,4 +118,4 @@
'OAMainFunctions', as_='orthogonal_arrays')
lazy_import('sage.combinat.designs.gen_quadrangles_with_spread',
- ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid'))
\ No newline at end of file
+ ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid'))
diff --git a/src/sage/combinat/designs/designs_pyx.pxd b/src/sage/combinat/designs/designs_pyx.pxd
index 345a41f2945..8ff6bee5bd4 100644
--- a/src/sage/combinat/designs/designs_pyx.pxd
+++ b/src/sage/combinat/designs/designs_pyx.pxd
@@ -17,4 +17,4 @@ cdef struct cache_entry:
cdef cache_entry * _OA_cache
cdef int _OA_cache_size
-cpdef _OA_cache_get(int k, int n)
+cpdef _OA_cache_get(int k, int n) noexcept
diff --git a/src/sage/combinat/designs/designs_pyx.pyx b/src/sage/combinat/designs/designs_pyx.pyx
index 4b6638634f6..027cc00fbb0 100644
--- a/src/sage/combinat/designs/designs_pyx.pyx
+++ b/src/sage/combinat/designs/designs_pyx.pyx
@@ -15,6 +15,7 @@ from cysignals.memory cimport sig_malloc, sig_calloc, sig_realloc, sig_free
from sage.misc.unknown import Unknown
+
def is_covering_array(array, strength=None, levels=None, verbose=False, parameters=False):
r"""
Check if the input is a covering array with given strength.
@@ -349,6 +350,7 @@ def is_orthogonal_array(OA, int k, int n, int t=2, verbose=False, terminology="O
bitset_free(seen)
return True
+
def is_group_divisible_design(groups,blocks,v,G=None,K=None,lambd=1,verbose=False):
r"""
Checks that input is a Group Divisible Design on `\{0,...,v-1\}`
@@ -588,6 +590,7 @@ def is_pairwise_balanced_design(blocks,v,K=None,lambd=1,verbose=False):
lambd=lambd,
verbose=verbose)
+
def is_projective_plane(blocks, verbose=False):
r"""
Test whether the blocks form a projective plane on `\{0,...,v-1\}`
@@ -661,6 +664,7 @@ def is_projective_plane(blocks, verbose=False):
lambd=1,
verbose=verbose)
+
def is_difference_matrix(M,G,k,lmbda=1,verbose=False):
r"""
Test if `M` is a `(G,k,\lambda)`-difference matrix.
@@ -725,6 +729,7 @@ def is_difference_matrix(M,G,k,lmbda=1,verbose=False):
"""
return is_quasi_difference_matrix(M,G,k,lmbda=lmbda,mu=lmbda,u=0,verbose=verbose)
+
def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False):
r"""
Test if the matrix is a `(G,k;\lambda,\mu;u)`-quasi-difference matrix
@@ -938,6 +943,7 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False):
sig_free(M_c)
return True
+
# Cached information for OA constructions (see .pxd file for more info)
_OA_cache = sig_malloc(2*sizeof(cache_entry))
@@ -948,7 +954,7 @@ _OA_cache[0].max_true = -1
_OA_cache[1].max_true = -1
_OA_cache_size = 2
-cpdef _OA_cache_set(int k,int n,truth_value):
+cpdef _OA_cache_set(int k,int n,truth_value) noexcept:
r"""
Sets a value in the OA cache of existence results
@@ -983,7 +989,7 @@ cpdef _OA_cache_set(int k,int n,truth_value):
else:
_OA_cache[n].min_false = k if k<_OA_cache[n].min_false else _OA_cache[n].min_false
-cpdef _OA_cache_get(int k,int n):
+cpdef _OA_cache_get(int k,int n) noexcept:
r"""
Gets a value from the OA cache of existence results
@@ -1002,7 +1008,7 @@ cpdef _OA_cache_get(int k,int n):
return None
-cpdef _OA_cache_construction_available(int k,int n):
+cpdef _OA_cache_construction_available(int k,int n) noexcept:
r"""
Tests if a construction is implemented using the cache's information
diff --git a/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx b/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx
index 26da661f3cd..72baf1a5d28 100644
--- a/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx
+++ b/src/sage/combinat/designs/gen_quadrangles_with_spread.pyx
@@ -123,6 +123,7 @@ def generalised_quadrangle_with_spread(const int s, const int t,
raise RuntimeError(
f"Sage can't build a GQ of order ({s}, {t}) with a spread")
+
def is_GQ_with_spread(GQ, S, s=None, t=None):
r"""
Check if GQ is a generalised quadrangle of order `(s,t)` and
@@ -233,6 +234,7 @@ def dual_GQ_ovoid(GQ, O):
D = IncidenceStructure(newBlocks)
return (D, S)
+
def generalised_quadrangle_hermitian_with_ovoid(const int q):
r"""
Construct the generalised quadrangle `H(3,q^2)` with an ovoid.
diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx
index 066eecb9197..6b6bd11dfb1 100644
--- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx
+++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx
@@ -51,6 +51,7 @@ from .orthogonal_arrays import orthogonal_array
from sage.rings.integer cimport smallInteger
from sage.arith.misc import prime_powers
+
@cached_function
def find_recursive_construction(k, n):
r"""
@@ -114,7 +115,8 @@ def find_recursive_construction(k, n):
return res
return False
-cpdef find_product_decomposition(int k,int n):
+
+cpdef find_product_decomposition(int k,int n) noexcept:
r"""
Find `n_1n_2=n` to obtain an `OA(k,n)` by the product construction.
@@ -155,7 +157,7 @@ cpdef find_product_decomposition(int k,int n):
return wilson_construction, (None,k,n1,n2,(),False)
return False
-cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n):
+cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n) noexcept:
r"""
Find `rm+u=n` to obtain an `OA(k,n)` by Wilson's construction with one truncated column.
@@ -206,7 +208,7 @@ cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n):
return False
-cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n):
+cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n) noexcept:
r"""
Find `rm+r_1+r_2=n` to obtain an `OA(k,n)` by Wilson's construction with two truncated columns.
@@ -268,7 +270,7 @@ cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n):
return wilson_construction, (None,k,r,m,(r1,r2),False)
return False
-cpdef find_construction_3_3(int k,int n):
+cpdef find_construction_3_3(int k,int n) noexcept:
r"""
Find a decomposition for construction 3.3 from [AC07]_
@@ -307,7 +309,7 @@ cpdef find_construction_3_3(int k,int n):
from .orthogonal_arrays_build_recursive import construction_3_3
return construction_3_3, (k,nn,mm,i)
-cpdef find_construction_3_4(int k,int n):
+cpdef find_construction_3_4(int k,int n) noexcept:
r"""
Find a decomposition for construction 3.4 from [AC07]_
@@ -350,7 +352,7 @@ cpdef find_construction_3_4(int k,int n):
from .orthogonal_arrays_build_recursive import construction_3_4
return construction_3_4, (k,nn,mm,r,s)
-cpdef find_construction_3_5(int k,int n):
+cpdef find_construction_3_5(int k,int n) noexcept:
r"""
Find a decomposition for construction 3.5 from [AC07]_
@@ -400,7 +402,7 @@ cpdef find_construction_3_5(int k,int n):
from .orthogonal_arrays_build_recursive import construction_3_5
return construction_3_5, (k,nn,mm,r,s,t)
-cpdef find_construction_3_6(int k,int n):
+cpdef find_construction_3_6(int k,int n) noexcept:
r"""
Find a decomposition for construction 3.6 from [AC07]_
@@ -441,7 +443,7 @@ cpdef find_construction_3_6(int k,int n):
from .orthogonal_arrays_build_recursive import construction_3_6
return construction_3_6, (k,nn,mm,i)
-cpdef find_q_x(int k,int n):
+cpdef find_q_x(int k,int n) noexcept:
r"""
Find integers `q,x` such that the `q-x` construction yields an `OA(k,n)`.
@@ -494,7 +496,7 @@ cpdef find_q_x(int k,int n):
return construction_q_x, (k,q,x)
return False
-cpdef find_thwart_lemma_3_5(int k,int N):
+cpdef find_thwart_lemma_3_5(int k,int N) noexcept:
r"""
Find the values on which Lemma 3.5 from [Thwarts]_ applies.
@@ -615,7 +617,7 @@ cpdef find_thwart_lemma_3_5(int k,int N):
return False
-cpdef find_thwart_lemma_4_1(int k,int n):
+cpdef find_thwart_lemma_4_1(int k,int n) noexcept:
r"""
Find a decomposition for Lemma 4.1 from [Thwarts]_.
@@ -664,7 +666,7 @@ cpdef find_thwart_lemma_4_1(int k,int n):
return False
-cpdef find_three_factor_product(int k,int n):
+cpdef find_three_factor_product(int k,int n) noexcept:
r"""
Find `n_1n_2n_3=n` to obtain an `OA(k,n)` by the three-factor product from [DukesLing14]_
@@ -709,7 +711,7 @@ cpdef find_three_factor_product(int k,int n):
return False
-cpdef find_brouwer_separable_design(int k,int n):
+cpdef find_brouwer_separable_design(int k,int n) noexcept:
r"""
Find `t(q^2+q+1)+x=n` to obtain an `OA(k,n)` by Brouwer's separable design construction.
@@ -880,7 +882,8 @@ def int_as_sum(int value, list S, int k_max):
return None
-cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n):
+
+cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n) noexcept:
r"""
Find `rm+x_1+...+x_c=n` such that the Brouwer-van Rees constructions yields a `OA(k,n)`.
diff --git a/src/sage/combinat/designs/subhypergraph_search.pyx b/src/sage/combinat/designs/subhypergraph_search.pyx
index ace387a4bf2..267ff3b2fe0 100644
--- a/src/sage/combinat/designs/subhypergraph_search.pyx
+++ b/src/sage/combinat/designs/subhypergraph_search.pyx
@@ -129,13 +129,13 @@ ctypedef struct hypergraph:
uint64_t * set_space
int * names
-cdef inline int bs_get(uint64_t * bitset, int index):
+cdef inline int bs_get(uint64_t * bitset, int index) noexcept:
r"""
Return a bit of a bitset
"""
return (bitset[index/64]>>(index%64))&1
-cdef inline void bs_set(uint64_t * bitset, int index, int bit):
+cdef inline void bs_set(uint64_t * bitset, int index, int bit) noexcept:
r"""
Set a bit of a bitset.
@@ -145,7 +145,7 @@ cdef inline void bs_set(uint64_t * bitset, int index, int bit):
bitset[index/64] &= ~(( 1)< bit)<=c` sets of size `k` containing `S` in h1. This
@@ -295,7 +295,7 @@ cdef int is_subhypergraph_admissible(hypergraph h1,hypergraph * h2_trace,int n,h
return 1
-cdef int cmp_128_bits(void * a, void * b) nogil:
+cdef int cmp_128_bits(void * a, void * b) noexcept nogil:
r"""
Lexicographic order on 128-bits words
"""
@@ -308,7 +308,7 @@ cdef int cmp_128_bits(void * a, void * b) nogil:
else:
return -1
-cdef int is_induced_admissible64(hypergraph h1,hypergraph * h2_induced,int n,hypergraph tmp1):
+cdef int is_induced_admissible64(hypergraph h1,hypergraph * h2_induced,int n,hypergraph tmp1) noexcept:
r"""
Test if the hypergraph induced in h1 by 0,...,n-1 is equal to the hypergraph
induced in h2 by 0,...,n-1.
diff --git a/src/sage/combinat/enumeration_mod_permgroup.pxd b/src/sage/combinat/enumeration_mod_permgroup.pxd
index 2f457429ccf..6d73f402321 100644
--- a/src/sage/combinat/enumeration_mod_permgroup.pxd
+++ b/src/sage/combinat/enumeration_mod_permgroup.pxd
@@ -1,9 +1,9 @@
from sage.structure.list_clone cimport ClonableIntArray
-cpdef list all_children(ClonableIntArray v, int max_part)
-cpdef int lex_cmp_partial(ClonableIntArray t1, ClonableIntArray t2, int step)
-cpdef int lex_cmp(ClonableIntArray t1, ClonableIntArray t2)
+cpdef list all_children(ClonableIntArray v, int max_part) noexcept
+cpdef int lex_cmp_partial(ClonableIntArray t1, ClonableIntArray t2, int step) noexcept
+cpdef int lex_cmp(ClonableIntArray t1, ClonableIntArray t2) noexcept
cpdef bint is_canonical(list sgs, ClonableIntArray v) except -1
-cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v)
-cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part)
-cpdef set orbit(list sgs, ClonableIntArray v)
+cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v) noexcept
+cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part) noexcept
+cpdef set orbit(list sgs, ClonableIntArray v) noexcept
diff --git a/src/sage/combinat/enumeration_mod_permgroup.pyx b/src/sage/combinat/enumeration_mod_permgroup.pyx
index 3e0b891165f..0da6b2d2638 100644
--- a/src/sage/combinat/enumeration_mod_permgroup.pyx
+++ b/src/sage/combinat/enumeration_mod_permgroup.pyx
@@ -12,7 +12,7 @@ Tools for enumeration modulo the action of a permutation group
from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement
-cpdef list all_children(ClonableIntArray v, int max_part):
+cpdef list all_children(ClonableIntArray v, int max_part) noexcept:
r"""
Returns all the children of an integer vector (:class:`~sage.structure.list_clone.ClonableIntArray`)
``v`` in the tree of enumeration by lexicographic order. The children of
@@ -56,7 +56,7 @@ cpdef list all_children(ClonableIntArray v, int max_part):
all_children.append(child)
return all_children
-cpdef int lex_cmp_partial(ClonableIntArray v1, ClonableIntArray v2, int step):
+cpdef int lex_cmp_partial(ClonableIntArray v1, ClonableIntArray v2, int step) noexcept:
r"""
Partial comparison of the two lists according the lexicographic
order. It compares the ``step``-th first entries.
@@ -85,7 +85,7 @@ cpdef int lex_cmp_partial(ClonableIntArray v1, ClonableIntArray v2, int step):
return -1
return 0
-cpdef int lex_cmp(ClonableIntArray v1, ClonableIntArray v2):
+cpdef int lex_cmp(ClonableIntArray v1, ClonableIntArray v2) noexcept:
"""
Lexicographic comparison of :class:`~sage.structure.list_clone.ClonableIntArray`.
@@ -183,7 +183,7 @@ cpdef bint is_canonical(list sgs, ClonableIntArray v) except -1:
return True
-cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v):
+cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIntArray v) noexcept:
r"""
Returns the maximal vector for the lexicographic order living in
the orbit of `v` under the action of the permutation group whose
@@ -229,7 +229,7 @@ cpdef ClonableIntArray canonical_representative_of_orbit_of(list sgs, ClonableIn
representative = max(to_analyse)
return representative
-cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part):
+cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part) noexcept:
r"""
Returns the canonical children of the integer vector ``v``. This
function computes all children of the integer vector ``v`` via the
@@ -250,7 +250,7 @@ cpdef list canonical_children(list sgs, ClonableIntArray v, int max_part):
cdef ClonableIntArray child
return [child for child in all_children(v, max_part) if is_canonical(sgs, child)]
-cpdef set orbit(list sgs, ClonableIntArray v):
+cpdef set orbit(list sgs, ClonableIntArray v) noexcept:
r"""
Returns the orbit of the integer vector ``v`` under the action of the
permutation group whose strong generating system is ``sgs``.
diff --git a/src/sage/combinat/expnums.pyx b/src/sage/combinat/expnums.pyx
index bff30b763d7..216850b43f1 100644
--- a/src/sage/combinat/expnums.pyx
+++ b/src/sage/combinat/expnums.pyx
@@ -117,6 +117,7 @@ def expnums(int n, int aa):
# return bell[1];
# end);
+
def expnums2(n, aa):
r"""
A vanilla python (but compiled via Cython) implementation of
diff --git a/src/sage/combinat/fast_vector_partitions.pyx b/src/sage/combinat/fast_vector_partitions.pyx
index 2a1e093104b..5142eb79108 100644
--- a/src/sage/combinat/fast_vector_partitions.pyx
+++ b/src/sage/combinat/fast_vector_partitions.pyx
@@ -30,7 +30,7 @@ AUTHORS:
#
# To understand the code below, consult the ALGORITHM.
-cdef list vector_halve(list v):
+cdef list vector_halve(list v) noexcept:
r"""
Return the vector halfway (lexicographically) between ``v`` and zero.
@@ -126,19 +126,20 @@ def recursive_within_from_to(list m, list s, list e, bint useS, bint useE):
if len(m) == 1:
# We use this style of Cython code for now in order to get this to convert
# to an optimized pure C for loop. See Cython github issue #532.
- #for x in range(start, end - 1, -1):
+ # for x in range(start, end - 1, -1):
for x from start >= x >= end by 1:
yield [x] # we know the answer for singletons
else:
# We use this style of Cython code for now in order to get this to convert
# to an optimized pure C for loop. See Cython github issue #532.
- #for x in range(start, end - 1, -1):
+ # for x in range(start, end - 1, -1):
for x from start >= x >= end by 1:
useSS = useS and x == s[0]
useEE = useE and x == e[0]
for o in recursive_within_from_to(m[1:], s[1:], e[1:], useSS, useEE):
yield [x] + o
+
def within_from_to(list m, list s, list e):
r"""
Iterate over a lexicographically ordered list of lists ``v`` satisfying
@@ -229,7 +230,8 @@ def within_from_to(list m, list s, list e):
return
yield from recursive_within_from_to(m, ss, e, True, True)
-cdef inline list vector_sub(list a, list b):
+
+cdef inline list vector_sub(list a, list b) noexcept:
"""
Return ``a - b`` considered as vectors.
@@ -241,6 +243,7 @@ cdef inline list vector_sub(list a, list b):
ret.append(( a[i]) - ( b[i]))
return ret
+
def recursive_vector_partitions(list v, list vL):
r"""
Iterate over a lexicographically ordered list of lists, each list
diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
index acd0adb2718..8bfddfaf76a 100644
--- a/src/sage/combinat/finite_state_machine.py
+++ b/src/sage/combinat/finite_state_machine.py
@@ -949,7 +949,7 @@
from sage.structure.sage_object import SageObject
-def full_group_by(l, key=lambda x: x):
+def full_group_by(l, key=None):
"""
Group iterable ``l`` by values of ``key``.
@@ -1003,6 +1003,8 @@ def full_group_by(l, key=lambda x: x):
Here, the result ``r`` has been sorted in order to guarantee a
consistent order for the doctest suite.
"""
+ if key is None:
+ key = lambda x: x
elements = defaultdict(list)
original_keys = {}
for item in l:
@@ -5406,8 +5408,7 @@ def _iter_transitions_all_(self):
[('1', '2'), ('2', '2')]
"""
for state in self.iter_states():
- for t in state.transitions:
- yield t
+ yield from state.transitions
def initial_states(self):
"""
@@ -6461,8 +6462,7 @@ def _iter_process_simple_(self, iterator):
"here." %
(len(branch.outputs),))
- for o in branch.outputs[0]:
- yield o
+ yield from branch.outputs[0]
branch.outputs[0] = []
# Reset output so that in the next round
# (of "for current in iterator") only new
diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py
index 2dce68651a2..14711e8713e 100644
--- a/src/sage/combinat/free_module.py
+++ b/src/sage/combinat/free_module.py
@@ -328,7 +328,7 @@ def __classcall_private__(cls, base_ring, basis_keys=None, category=None,
latex_names = tuple(latex_names)
keywords['latex_names'] = latex_names
- return super(CombinatorialFreeModule, cls).__classcall__(cls,
+ return super().__classcall__(cls,
base_ring, basis_keys, category=category, prefix=prefix, names=names,
**keywords)
@@ -1674,7 +1674,7 @@ def _coerce_map_from_(self, R):
[vector_map[i](M.monomial(x[i]))
for i, M in enumerate(modules)]), codomain=self)
- return super(CombinatorialFreeModule_Tensor, self)._coerce_map_from_(R)
+ return super()._coerce_map_from_(R)
class CartesianProductWithFlattening():
diff --git a/src/sage/combinat/integer_matrices.py b/src/sage/combinat/integer_matrices.py
index 8d737c64349..238d0ef4091 100644
--- a/src/sage/combinat/integer_matrices.py
+++ b/src/sage/combinat/integer_matrices.py
@@ -77,7 +77,7 @@ def __classcall__(cls, row_sums, column_sums):
from sage.combinat.composition import Composition
row_sums = Composition(row_sums)
column_sums = Composition(column_sums)
- return super(IntegerMatrices, cls).__classcall__(cls, row_sums, column_sums)
+ return super().__classcall__(cls, row_sums, column_sums)
def __init__(self, row_sums, column_sums):
r"""
diff --git a/src/sage/combinat/integer_vector_weighted.py b/src/sage/combinat/integer_vector_weighted.py
index bd2198f29da..c7700671c61 100644
--- a/src/sage/combinat/integer_vector_weighted.py
+++ b/src/sage/combinat/integer_vector_weighted.py
@@ -101,7 +101,7 @@ def __classcall_private__(cls, n=None, weight=None):
if n is None:
return WeightedIntegerVectors_all(weight)
- return super(WeightedIntegerVectors, cls).__classcall__(cls, n, weight)
+ return super().__classcall__(cls, n, weight)
def __init__(self, n, weight):
"""
diff --git a/src/sage/combinat/k_tableau.py b/src/sage/combinat/k_tableau.py
index 530f621ca31..0e4bbc41758 100644
--- a/src/sage/combinat/k_tableau.py
+++ b/src/sage/combinat/k_tableau.py
@@ -4104,8 +4104,7 @@ def __iter__(self):
yield self([[None]*(row) for row in self._inner_shape])
else:
for unT in StrongTableaux.standard_unmarked_iterator( self.k, size, self._outer_shape, self._inner_shape ):
- for T in StrongTableaux.marked_given_unmarked_and_weight_iterator( unT, self.k, self._weight ):
- yield T
+ yield from StrongTableaux.marked_given_unmarked_and_weight_iterator( unT, self.k, self._weight )
@classmethod
def standard_unmarked_iterator( cls, k, size, outer_shape=None, inner_shape=[] ):
@@ -4410,8 +4409,7 @@ def standard_marked_iterator( cls, k, size, outer_shape=None, inner_shape=[] ):
[[]]
"""
for T in cls.standard_unmarked_iterator( k, size, outer_shape, inner_shape ):
- for TT in cls.marked_given_unmarked_and_weight_iterator( T, k, [1]*(size) ):
- yield TT
+ yield from cls.marked_given_unmarked_and_weight_iterator( T, k, [1]*(size) )
@classmethod
def cells_head_dictionary( cls, T ):
diff --git a/src/sage/combinat/lr_tableau.py b/src/sage/combinat/lr_tableau.py
index c19effc2173..a94f576a134 100644
--- a/src/sage/combinat/lr_tableau.py
+++ b/src/sage/combinat/lr_tableau.py
@@ -174,7 +174,7 @@ def __classcall_private__(cls, shape, weight):
weight = tuple(Partition(a) for a in weight)
if shape.size() != sum(a.size() for a in weight):
raise ValueError("the sizes of shapes and sequence of weights do not match")
- return super(LittlewoodRichardsonTableaux, cls).__classcall__(cls, shape, weight)
+ return super().__classcall__(cls, shape, weight)
def __init__(self, shape, weight):
r"""
@@ -193,7 +193,7 @@ def __init__(self, shape, weight):
self._shape = shape
self._weight = weight
self._heights = [a.length() for a in self._weight]
- super(LittlewoodRichardsonTableaux, self).__init__(category=FiniteEnumeratedSets())
+ super().__init__(category=FiniteEnumeratedSets())
def _repr_(self):
"""
diff --git a/src/sage/combinat/matrices/dancing_links.pyx b/src/sage/combinat/matrices/dancing_links.pyx
index df6cb7915f8..f0ecfeacd17 100644
--- a/src/sage/combinat/matrices/dancing_links.pyx
+++ b/src/sage/combinat/matrices/dancing_links.pyx
@@ -67,7 +67,7 @@ There is also a method ``reinitialize`` to reinitialize the algorithm::
sage: x.get_solution()
[0, 1]
"""
-#*****************************************************************************
+# ****************************************************************************
# Copyright (C) 2008 Carlo Hamalainen
# Copyright (C) 2015-2018 Sébastien Labbé
#
@@ -75,8 +75,8 @@ There is also a method ``reinitialize`` to reinitialize the algorithm::
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
-# http://www.gnu.org/licenses/
-#*****************************************************************************
+# https://www.gnu.org/licenses/
+# ****************************************************************************
from cpython.object cimport PyObject_RichCompare
from libcpp.vector cimport vector
diff --git a/src/sage/combinat/partitions.pyx b/src/sage/combinat/partitions.pyx
index c26ccdb3ddb..c461797067c 100644
--- a/src/sage/combinat/partitions.pyx
+++ b/src/sage/combinat/partitions.pyx
@@ -8,7 +8,7 @@ AUTHOR:
that does all the actual heavy lifting.
"""
-#*****************************************************************************
+# ****************************************************************************
# Copyright (C) 2007 William Stein
# Copyright (C) 2007 Jonathan Bober
#
@@ -16,8 +16,9 @@ AUTHOR:
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
-# http://www.gnu.org/licenses/
-#*****************************************************************************
+# https://www.gnu.org/licenses/
+# ****************************************************************************
+
def ZS1_iterator(int n):
"""
@@ -82,9 +83,10 @@ def ZS1_iterator(int n):
if t > 1:
h += 1
x[h] = t
- #yield [x[i] for i in range(m+1)]
+ # yield [x[i] for i in range(m+1)]
yield x[:m+1]
- #free(x)
+ # free(x)
+
def ZS1_iterator_nk(int n, int k):
"""
@@ -176,4 +178,4 @@ def ZS1_iterator_nk(int n, int k):
h += 1
x[m] = t
yield x[:m+1]
- #free(x)
+ # free(x)
diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py
index 8b3d1899ba0..eb3e451b0ff 100644
--- a/src/sage/combinat/permutation.py
+++ b/src/sage/combinat/permutation.py
@@ -7268,7 +7268,7 @@ def algebra(self, base_ring, category=None):
Symmetric group algebra of order 4 over Rational Field
sage: A.category() # optional - sage.combinat sage.modules
- Join of Category of coxeter group algebras over Rational Field
+ Join of Category of Coxeter group algebras over Rational Field
and Category of finite group algebras over Rational Field
and Category of finite dimensional cellular algebras
with basis over Rational Field
diff --git a/src/sage/combinat/permutation_cython.pxd b/src/sage/combinat/permutation_cython.pxd
index 9f19d942604..9744b2f549e 100644
--- a/src/sage/combinat/permutation_cython.pxd
+++ b/src/sage/combinat/permutation_cython.pxd
@@ -1,11 +1,11 @@
from cpython.array cimport array
-cdef void reset_swap(int n, int *c, int *o)
-cdef int next_swap(int n, int *c, int *o)
-cpdef bint next_perm(array l)
-cpdef map_to_list(array l, tuple values, int n)
-cpdef list left_action_same_n(list l, list r)
-cpdef list right_action_same_n(list l, list r)
-cpdef list left_action_product(list l, list r)
-cpdef list right_action_product(list l, list r)
+cdef void reset_swap(int n, int *c, int *o) noexcept
+cdef int next_swap(int n, int *c, int *o) noexcept
+cpdef bint next_perm(array l) noexcept
+cpdef map_to_list(array l, tuple values, int n) noexcept
+cpdef list left_action_same_n(list l, list r) noexcept
+cpdef list right_action_same_n(list l, list r) noexcept
+cpdef list left_action_product(list l, list r) noexcept
+cpdef list right_action_product(list l, list r) noexcept
diff --git a/src/sage/combinat/permutation_cython.pyx b/src/sage/combinat/permutation_cython.pyx
index 1a0b02ac734..17010476cd9 100644
--- a/src/sage/combinat/permutation_cython.pyx
+++ b/src/sage/combinat/permutation_cython.pyx
@@ -54,7 +54,7 @@ from cysignals.memory cimport check_allocarray, sig_free
#
##########################################################
-cdef void reset_swap(int n, int *c, int *o):
+cdef void reset_swap(int n, int *c, int *o) noexcept:
"""
Reset the plain_swapper to the initial state.
"""
@@ -63,7 +63,7 @@ cdef void reset_swap(int n, int *c, int *o):
c[i] = -1
o[i] = 1
-cdef int next_swap(int n, int *c, int *o):
+cdef int next_swap(int n, int *c, int *o) noexcept:
"""
Here's the translation of Algorithm P. We've modified
it to
@@ -174,7 +174,7 @@ def permutation_iterator_transposition_list(int n):
@cython.wraparound(False)
@cython.boundscheck(False)
-cpdef bint next_perm(array l):
+cpdef bint next_perm(array l) noexcept:
"""
Obtain the next permutation under lex order of ``l``
by mutating ``l``.
@@ -255,7 +255,7 @@ cpdef bint next_perm(array l):
@cython.boundscheck(False)
-cpdef map_to_list(array l, tuple values, int n):
+cpdef map_to_list(array l, tuple values, int n) noexcept:
"""
Build a list by mapping the array ``l`` using ``values``.
@@ -291,7 +291,7 @@ cpdef map_to_list(array l, tuple values, int n):
#####################################################################
## Multiplication functions for permutations
-cpdef list left_action_same_n(list S, list lp):
+cpdef list left_action_same_n(list S, list lp) noexcept:
r"""
Return the permutation obtained by composing a permutation
``S`` with a permutation ``lp`` in such an order that ``lp``
@@ -318,7 +318,7 @@ cpdef list left_action_same_n(list S, list lp):
ret.append(S[i-1])
return ret
-cpdef list right_action_same_n(list S, list rp):
+cpdef list right_action_same_n(list S, list rp) noexcept:
"""
Return the permutation obtained by composing a permutation
``S`` with a permutation ``rp`` in such an order that ``S`` is
@@ -345,7 +345,7 @@ cpdef list right_action_same_n(list S, list rp):
ret.append(rp[i-1])
return ret
-cpdef list left_action_product(list S, list lp):
+cpdef list left_action_product(list S, list lp) noexcept:
r"""
Return the permutation obtained by composing a permutation
``S`` with a permutation ``lp`` in such an order that ``lp`` is
@@ -379,7 +379,7 @@ cpdef list left_action_product(list S, list lp):
lp.append(i)
return left_action_same_n(S, lp)
-cpdef list right_action_product(list S, list rp):
+cpdef list right_action_product(list S, list rp) noexcept:
"""
Return the permutation obtained by composing a permutation
``S`` with a permutation ``rp`` in such an order that ``S`` is
diff --git a/src/sage/combinat/plane_partition.py b/src/sage/combinat/plane_partition.py
index 14d284b77c6..d18177aac00 100644
--- a/src/sage/combinat/plane_partition.py
+++ b/src/sage/combinat/plane_partition.py
@@ -1748,7 +1748,7 @@ def __init__(self, n):
sage: TestSuite(PP).run()
"""
- super(PlanePartitions_n, self).__init__(category=FiniteEnumeratedSets())
+ super().__init__(category=FiniteEnumeratedSets())
self._n = n
def _repr_(self) -> str:
diff --git a/src/sage/combinat/posets/hasse_cython_flint.pyx b/src/sage/combinat/posets/hasse_cython_flint.pyx
index fcbe29faaf6..fb01d5967f2 100644
--- a/src/sage/combinat/posets/hasse_cython_flint.pyx
+++ b/src/sage/combinat/posets/hasse_cython_flint.pyx
@@ -22,7 +22,7 @@ from sage.matrix.matrix_space import MatrixSpace
from sage.rings.integer_ring import ZZ
-cpdef Matrix_integer_dense moebius_matrix_fast(list positions):
+cpdef Matrix_integer_dense moebius_matrix_fast(list positions) noexcept:
"""
Compute the Möbius matrix of a poset by a specific triangular inversion.
@@ -61,7 +61,7 @@ cpdef Matrix_integer_dense moebius_matrix_fast(list positions):
for i in range(n):
pos_lens[i] = len(positions[i])
pos_array[i] = sig_malloc(pos_lens[i]*sizeof(int))
- for jind,j in enumerate(positions[i]):
+ for jind, j in enumerate(positions[i]):
pos_array[i][jind] = j
for i in range(n - 1, -1, -1):
@@ -81,7 +81,7 @@ cpdef Matrix_integer_dense moebius_matrix_fast(list positions):
return A
-cpdef Matrix_integer_dense coxeter_matrix_fast(list positions):
+cpdef Matrix_integer_dense coxeter_matrix_fast(list positions) noexcept:
"""
Compute the Coxeter matrix of a poset by a specific algorithm.
@@ -120,7 +120,7 @@ cpdef Matrix_integer_dense coxeter_matrix_fast(list positions):
for i in range(n):
pos_lens[i] = len(positions[i])
pos_array[i] = sig_malloc(pos_lens[i]*sizeof(int))
- for jind,j in enumerate(positions[i]):
+ for jind, j in enumerate(positions[i]):
pos_array[i][jind] = j
for i in range(n - 1, -1, -1):
diff --git a/src/sage/combinat/posets/linear_extension_iterator.pyx b/src/sage/combinat/posets/linear_extension_iterator.pyx
index 5eb101b32e2..142287d88c2 100644
--- a/src/sage/combinat/posets/linear_extension_iterator.pyx
+++ b/src/sage/combinat/posets/linear_extension_iterator.pyx
@@ -5,6 +5,8 @@ Fast linear extension iterator
cimport cython
from copy import copy
+
+
def _linear_extension_prepare(D):
r"""
The preprocessing routine in Figure 7 of "Generating Linear
@@ -27,9 +29,8 @@ def _linear_extension_prepare(D):
sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] })._hasse_diagram
sage: _linear_extension_prepare(D)
([0, 1, 2, 3, 4], [1, 3], [2, 4])
-
"""
- dag_copy = copy(D) # this copy is destroyed during preparation
+ dag_copy = copy(D) # this copy is destroyed during preparation
le = []
a = []
b = []
@@ -57,9 +58,10 @@ def _linear_extension_prepare(D):
return (le, a, b)
+
@cython.wraparound(False)
@cython.boundscheck(False)
-cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py_ssize_t i):
+cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py_ssize_t i) noexcept:
"""
This implements the ``Switch`` procedure described on page 7
of "Generating Linear Extensions Fast" by Pruesse and Ruskey.
@@ -81,9 +83,10 @@ cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py
_b[i] = a
_a[i] = b
+
@cython.wraparound(False)
@cython.boundscheck(False)
-cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i):
+cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i) noexcept:
"""
Return ``True`` if and only if ``_a[i]`` is incomparable with the
element to its right in ``_le`` and the element to the right is
@@ -109,9 +112,10 @@ cdef bint _linear_extension_right_a(_D, list _le, list _a, list _b, Py_ssize_t i
y = _le[yindex]
return y != _b[i] and _D.are_incomparable(x, y)
+
@cython.wraparound(False)
@cython.boundscheck(False)
-cdef bint _linear_extension_right_b(_D, list _le, list _a, list _b, Py_ssize_t i):
+cdef bint _linear_extension_right_b(_D, list _le, list _a, list _b, Py_ssize_t i) noexcept:
"""
Return True if and only if ``_b[i]`` is incomparable with the
elements to its right in ``_le``.
@@ -136,6 +140,7 @@ cdef bint _linear_extension_right_b(_D, list _le, list _a, list _b, Py_ssize_t i
y = _le[yindex]
return _D.are_incomparable(x, y)
+
@cython.wraparound(False)
@cython.boundscheck(False)
def _linear_extension_gen(_D, list _le, list _a, list _b, list _is_plus, Py_ssize_t i):
@@ -276,7 +281,7 @@ def linear_extension_iterator(D):
"""
_le, _a, _b = _linear_extension_prepare(D)
_max_pair = len(_a) - 1
- _is_plus = [True] # this is modified by _linear_extension_switch
+ _is_plus = [True] # this is modified by _linear_extension_switch
yield _le[:]
for e in _linear_extension_gen(D, _le, _a, _b, _is_plus, _max_pair):
diff --git a/src/sage/combinat/recognizable_series.py b/src/sage/combinat/recognizable_series.py
index 698dd959619..173e061276b 100644
--- a/src/sage/combinat/recognizable_series.py
+++ b/src/sage/combinat/recognizable_series.py
@@ -455,7 +455,7 @@ def __init__(self, parent, mu, left, right):
sage: S.mu[0] is M0, S.mu[1] is M1, S.left is L, S.right is R
(True, True, True, True)
"""
- super(RecognizableSeries, self).__init__(parent=parent)
+ super().__init__(parent=parent)
from copy import copy
from sage.matrix.constructor import Matrix
@@ -1660,7 +1660,7 @@ def __classcall__(cls, *args, **kwds):
sage: Rec1 is Rec2 is Rec3
True
"""
- return super(RecognizableSeriesSpace, cls).__classcall__(
+ return super().__classcall__(
cls, *cls.__normalize__(*args, **kwds))
@classmethod
@@ -1782,7 +1782,7 @@ def __init__(self, coefficient_ring, indices, category, minimize_results):
"""
self._indices_ = indices
self._minimize_results_ = minimize_results
- super(RecognizableSeriesSpace, self).__init__(
+ super().__init__(
category=category, base=coefficient_ring)
def __reduce__(self):
diff --git a/src/sage/combinat/regular_sequence.py b/src/sage/combinat/regular_sequence.py
index a10ceb7cf17..c585e51e194 100644
--- a/src/sage/combinat/regular_sequence.py
+++ b/src/sage/combinat/regular_sequence.py
@@ -1510,7 +1510,7 @@ def some_elements(self):
"""
return iter(element.regenerated()
for element
- in super(RegularSequenceRing, self).some_elements(
+ in super().some_elements(
allow_degenerated_sequence=True))
def _element_constructor_(self, *args, **kwds):
@@ -1537,7 +1537,7 @@ def _element_constructor_(self, *args, **kwds):
2-regular sequence 1, 3, 6, 9, 12, 18, 18, 27, 24, 36, ...
"""
allow_degenerated_sequence = kwds.pop('allow_degenerated_sequence', False)
- element = super(RegularSequenceRing, self)._element_constructor_(*args, **kwds)
+ element = super()._element_constructor_(*args, **kwds)
if not allow_degenerated_sequence:
element._error_if_degenerated_()
return element
diff --git a/src/sage/combinat/ribbon_shaped_tableau.py b/src/sage/combinat/ribbon_shaped_tableau.py
index a5bfc841e7b..4115a6a13aa 100644
--- a/src/sage/combinat/ribbon_shaped_tableau.py
+++ b/src/sage/combinat/ribbon_shaped_tableau.py
@@ -191,7 +191,7 @@ class based on input.
# return RibbonShapedTableaux_shape(Partition(shape))
# Otherwise arg0 takes the place of the category in pickling
- return super(RibbonShapedTableaux, cls).__classcall__(cls, **kwds)
+ return super().__classcall__(cls, **kwds)
def __init__(self, category=None):
"""
@@ -262,7 +262,7 @@ class based on input.
return StandardRibbonShapedTableaux_shape(Partition(shape))
# Otherwise arg0 takes the place of the category in pickling
- return super(StandardRibbonShapedTableaux, cls).__classcall__(cls, **kwds)
+ return super().__classcall__(cls, **kwds)
def __init__(self, category=None):
"""
diff --git a/src/sage/combinat/rigged_configurations/kleber_tree.py b/src/sage/combinat/rigged_configurations/kleber_tree.py
index 2403ad7ab05..b4a57e365f6 100644
--- a/src/sage/combinat/rigged_configurations/kleber_tree.py
+++ b/src/sage/combinat/rigged_configurations/kleber_tree.py
@@ -609,7 +609,7 @@ def __classcall_private__(cls, cartan_type, B, classical=None):
classical = cartan_type.classical()
else:
classical = CartanType(classical)
- return super(KleberTree, cls).__classcall__(cls, cartan_type, B, classical)
+ return super().__classcall__(cls, cartan_type, B, classical)
def __init__(self, cartan_type, B, classical_ct):
r"""
@@ -811,8 +811,7 @@ def _children_iter(self, node):
# tradeoff occurs between the methods. However, this may grow as
# the _children_iter_vector is further optimized.
if node != self.root and prod(val+1 for val in node.up_root.coefficients()) < 1000:
- for x in self._children_iter_vector(node):
- yield x
+ yield from self._children_iter_vector(node)
return
n = self._classical_ct.rank()
@@ -985,8 +984,7 @@ def _depth_first_iter(self, cur):
yield cur
for child in cur.children:
- for x in self._depth_first_iter(child):
- yield x
+ yield from self._depth_first_iter(child)
__iter__ = breadth_first_iter
@@ -1160,7 +1158,7 @@ def __classcall_private__(cls, cartan_type, B):
return KleberTreeTypeA2Even(cartan_type, B)
if cartan_type.classical().is_simply_laced():
raise ValueError("use KleberTree for simply-laced types")
- return super(VirtualKleberTree, cls).__classcall__(cls, cartan_type, B)
+ return super().__classcall__(cls, cartan_type, B)
def __init__(self, cartan_type, B):
"""
@@ -1354,7 +1352,7 @@ def __classcall_private__(cls, cartan_type, B):
cartan_type = CartanType(cartan_type)
# Standardize B input into a tuple of tuples
B = tuple(map(tuple, B))
- return super(KleberTreeTypeA2Even, cls).__classcall__(cls, cartan_type, B)
+ return super().__classcall__(cls, cartan_type, B)
def __init__(self, cartan_type, B):
"""
diff --git a/src/sage/combinat/rigged_configurations/kr_tableaux.py b/src/sage/combinat/rigged_configurations/kr_tableaux.py
index 3addee9e2e5..8bdc1d275b9 100644
--- a/src/sage/combinat/rigged_configurations/kr_tableaux.py
+++ b/src/sage/combinat/rigged_configurations/kr_tableaux.py
@@ -554,7 +554,7 @@ def tensor(self, *crystals, **options):
elif isinstance(B, KirillovReshetikhinTableaux):
dims.append([B._r, B._s])
return TensorProductOfKirillovReshetikhinTableaux(ct, dims)
- return super(KirillovReshetikhinTableaux, self).tensor(*crystals, **options)
+ return super().tensor(*crystals, **options)
@lazy_attribute
def _tableau_height(self):
diff --git a/src/sage/combinat/rigged_configurations/rc_crystal.py b/src/sage/combinat/rigged_configurations/rc_crystal.py
index 647d3c6eb0d..13bc6a86cfa 100644
--- a/src/sage/combinat/rigged_configurations/rc_crystal.py
+++ b/src/sage/combinat/rigged_configurations/rc_crystal.py
@@ -153,7 +153,7 @@ def __classcall_private__(cls, cartan_type, wt=None, WLR=None):
if isinstance(cartan_type, CartanTypeFolded):
return CrystalOfNonSimplyLacedRC(cartan_type, wt, WLR)
- return super(CrystalOfRiggedConfigurations, cls).__classcall__(cls, wt, WLR=WLR)
+ return super().__classcall__(cls, wt, WLR=WLR)
def __init__(self, wt, WLR):
r"""
diff --git a/src/sage/combinat/rigged_configurations/rc_infinity.py b/src/sage/combinat/rigged_configurations/rc_infinity.py
index e592f9b3656..d633f50abca 100644
--- a/src/sage/combinat/rigged_configurations/rc_infinity.py
+++ b/src/sage/combinat/rigged_configurations/rc_infinity.py
@@ -147,7 +147,7 @@ def __classcall_private__(cls, cartan_type):
return InfinityCrystalOfNonSimplyLacedRC(cartan_type)
cartan_type = CartanType(cartan_type)
- return super(InfinityCrystalOfRiggedConfigurations, cls).__classcall__(cls, cartan_type)
+ return super().__classcall__(cls, cartan_type)
def __init__(self, cartan_type):
r"""
@@ -241,7 +241,7 @@ def _coerce_map_from_(self, P):
and self.cartan_type().is_simply_laced()):
from sage.combinat.rigged_configurations.bij_infinity import FromTableauIsomorphism
return FromTableauIsomorphism(Hom(P, self))
- return super(InfinityCrystalOfRiggedConfigurations, self)._coerce_map_from_(P)
+ return super()._coerce_map_from_(P)
def _calc_vacancy_number(self, partitions, a, i, **options):
r"""
@@ -358,7 +358,7 @@ def _coerce_map_from_(self, P):
if isinstance(P, InfinityCrystalOfTableaux):
from sage.combinat.rigged_configurations.bij_infinity import FromTableauIsomorphism
return FromTableauIsomorphism(Hom(P, self))
- return super(InfinityCrystalOfNonSimplyLacedRC, self)._coerce_map_from_(P)
+ return super()._coerce_map_from_(P)
def _calc_vacancy_number(self, partitions, a, i):
r"""
diff --git a/src/sage/combinat/rigged_configurations/rigged_configurations.py b/src/sage/combinat/rigged_configurations/rigged_configurations.py
index b822a668612..2d558322721 100644
--- a/src/sage/combinat/rigged_configurations/rigged_configurations.py
+++ b/src/sage/combinat/rigged_configurations/rigged_configurations.py
@@ -358,7 +358,7 @@ def __classcall_private__(cls, cartan_type, B):
if not cartan_type.classical().is_simply_laced():
return RCNonSimplyLaced(cartan_type, B)
- return super(RiggedConfigurations, cls).__classcall__(cls, cartan_type, B)
+ return super().__classcall__(cls, cartan_type, B)
def __init__(self, cartan_type, B):
r"""
@@ -476,7 +476,7 @@ def _repr_option(self, key):
"""
if key == 'element_ascii_art':
return self.options.element_ascii_art
- return super(RiggedConfigurations, self)._repr_option(key)
+ return super()._repr_option(key)
def __iter__(self):
"""
@@ -1062,7 +1062,7 @@ def tensor(self, *crystals, **options):
for B in crystals:
dims += B.dims
return RiggedConfigurations(ct, dims)
- return super(RiggedConfigurations, self).tensor(*crystals, **options)
+ return super().tensor(*crystals, **options)
Element = KRRCSimplyLacedElement
@@ -1093,7 +1093,7 @@ def __classcall_private__(cls, cartan_type, B):
# Standardize B input into a tuple of tuples
B = tuple(map(tuple, B))
- return super(RCNonSimplyLaced, cls).__classcall__(cls, cartan_type, B)
+ return super().__classcall__(cls, cartan_type, B)
def __init__(self, cartan_type, dims):
"""
diff --git a/src/sage/combinat/rigged_configurations/rigged_partition.pxd b/src/sage/combinat/rigged_configurations/rigged_partition.pxd
index e99258f33b2..9b333b4fdc6 100644
--- a/src/sage/combinat/rigged_configurations/rigged_partition.pxd
+++ b/src/sage/combinat/rigged_configurations/rigged_partition.pxd
@@ -6,9 +6,9 @@ cdef class RiggedPartition(SageObject):
cdef public list rigging
cdef long _hash
- cpdef get_num_cells_to_column(self, int end_column, t=*)
- cpdef insert_cell(self, int max_width)
- cpdef remove_cell(self, row, int num_cells=*)
+ cpdef get_num_cells_to_column(self, int end_column, t=*) noexcept
+ cpdef insert_cell(self, int max_width) noexcept
+ cpdef remove_cell(self, row, int num_cells=*) noexcept
cdef class RiggedPartitionTypeB(RiggedPartition):
pass
diff --git a/src/sage/combinat/rigged_configurations/rigged_partition.pyx b/src/sage/combinat/rigged_configurations/rigged_partition.pyx
index 694b3dd5977..5b30b15608f 100644
--- a/src/sage/combinat/rigged_configurations/rigged_partition.pyx
+++ b/src/sage/combinat/rigged_configurations/rigged_partition.pyx
@@ -354,7 +354,7 @@ cdef class RiggedPartition(SageObject):
# Should we move these functions to the CP -> RC bijections?
- cpdef get_num_cells_to_column(self, int end_column, t=1):
+ cpdef get_num_cells_to_column(self, int end_column, t=1) noexcept:
r"""
Get the number of cells in all columns before the ``end_column``.
@@ -394,7 +394,7 @@ cdef class RiggedPartition(SageObject):
return sum_cells
- cpdef insert_cell(self, int max_width):
+ cpdef insert_cell(self, int max_width) noexcept:
r"""
Insert a cell given at a singular value as long as its less than the
specified width.
@@ -446,7 +446,7 @@ cdef class RiggedPartition(SageObject):
self.rigging[max_pos] = None # State that we've changed this row
return self._list[max_pos] - 1
- cpdef remove_cell(self, row, int num_cells=1):
+ cpdef remove_cell(self, row, int num_cells=1) noexcept:
r"""
Removes a cell at the specified ``row``.
diff --git a/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py b/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py
index 3314986004f..a2ccd72e902 100644
--- a/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py
+++ b/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py
@@ -133,8 +133,7 @@ def __iter__(self):
if self._cache is None:
self._cache = tuple([x.to_tensor_product_of_kirillov_reshetikhin_tableaux()
for x in self.tp_krt.rigged_configurations().module_generators])
- for x in self._cache:
- yield x
+ yield from self._cache
def __repr__(self):
"""
@@ -296,7 +295,7 @@ def __classcall_private__(cls, cartan_type, B):
# Standardize B input into a tuple of tuples
B = tuple(tuple(dim) for dim in B)
- return super(TensorProductOfKirillovReshetikhinTableaux, cls).__classcall__(cls, cartan_type, B)
+ return super().__classcall__(cls, cartan_type, B)
def __init__(self, cartan_type, B):
r"""
@@ -493,7 +492,7 @@ def tensor(self, *crystals, **options):
elif isinstance(B, KirillovReshetikhinTableaux):
dims.append([B._r, B._s])
return TensorProductOfKirillovReshetikhinTableaux(ct, dims)
- return super(TensorProductOfKirillovReshetikhinTableaux, self).tensor(*crystals, **options)
+ return super().tensor(*crystals, **options)
TensorProductOfKirillovReshetikhinTableaux.Element = TensorProductOfKirillovReshetikhinTableauxElement
diff --git a/src/sage/combinat/root_system/braid_orbit.pyx b/src/sage/combinat/root_system/braid_orbit.pyx
index d95bc388f83..c7983eeb43a 100644
--- a/src/sage/combinat/root_system/braid_orbit.pyx
+++ b/src/sage/combinat/root_system/braid_orbit.pyx
@@ -1,4 +1,4 @@
-#cython: wraparound=False, boundscheck=False
+# cython: wraparound=False, boundscheck=False
"""
Braid Orbit
@@ -7,7 +7,7 @@ Cython function to compute the orbit of the braid moves on a reduced word.
from cysignals.signals cimport sig_check
-cpdef set BraidOrbit(list word, list rels):
+cpdef set BraidOrbit(list word, list rels) noexcept:
r"""
Return the orbit of ``word`` by all replacements given by ``rels``.
@@ -48,11 +48,11 @@ cpdef set BraidOrbit(list word, list rels):
cdef list rel
l = len(word)
- cdef set words = set( [tuple(word)] )
- cdef list test_words = [ tuple(word) ]
+ cdef set words = {tuple(word)}
+ cdef list test_words = [tuple(word)]
- rels = rels + [ [b,a] for a,b in rels ]
- rels = [ [tuple(a), tuple(b), len(a)] for a,b in rels ]
+ rels = rels + [[b, a] for a, b in rels]
+ rels = [[tuple(a), tuple(b), len(a)] for a, b in rels]
loop_ind = 0
list_len = 1
@@ -74,7 +74,7 @@ cpdef set BraidOrbit(list word, list rels):
return words
-cpdef bint is_fully_commutative(list word, list rels):
+cpdef bint is_fully_commutative(list word, list rels) noexcept:
r"""
Check if the braid orbit of ``word`` is using a braid relation.
@@ -101,8 +101,8 @@ cpdef bint is_fully_commutative(list word, list rels):
cdef list rel
l = len(word)
- cdef set words = set( [tuple(word)] )
- cdef list test_words = [ tuple(word) ]
+ cdef set words = {tuple(word)}
+ cdef list test_words = [tuple(word)]
rels = rels + [[b, a] for a, b in rels]
rels = [[tuple(a), tuple(b), len(a)] for a, b in rels]
@@ -129,7 +129,7 @@ cpdef bint is_fully_commutative(list word, list rels):
return True
-cdef inline bint pattern_match(tuple L, int i, tuple X, int l):
+cdef inline bint pattern_match(tuple L, int i, tuple X, int l) noexcept:
r"""
Return ``True`` if ``L[i:i+l] == X``.
diff --git a/src/sage/combinat/root_system/reflection_group_c.pyx b/src/sage/combinat/root_system/reflection_group_c.pyx
index 247e9a62c02..e2f5eff21b1 100644
--- a/src/sage/combinat/root_system/reflection_group_c.pyx
+++ b/src/sage/combinat/root_system/reflection_group_c.pyx
@@ -1,4 +1,4 @@
-#cython: wraparound=False, boundscheck=False
+# cython: wraparound=False, boundscheck=False
r"""
This contains a few time-critical auxiliary cython functions for
finite complex or real reflection groups.
@@ -31,7 +31,7 @@ cdef class Iterator():
cdef list noncom
cdef list order
- cdef list noncom_letters(self):
+ cdef list noncom_letters(self) noexcept:
"""
Return a list ``L`` of lists such that ...
@@ -51,7 +51,7 @@ cdef class Iterator():
for i in range(n):
si = S[i]
noncom_i = []
- for j in range(i+1,n):
+ for j in range(i+1, n):
sj = S[j]
if si._mul_(sj) == sj._mul_(si):
pass
@@ -87,29 +87,29 @@ cdef class Iterator():
raise ValueError('the algorithm (="%s") must be either "depth", "breadth", or "parabolic"')
self.algorithm = algorithm
-# self.noncom = self.noncom_letters()
+ # self.noncom = self.noncom_letters()
- cdef list succ(self, PermutationGroupElement u, int first):
+ cdef list succ(self, PermutationGroupElement u, int first) noexcept:
cdef PermutationGroupElement si
cdef int i
cdef list successors = []
cdef tuple S = self.S
cdef int N = self.N
-# cdef list nc = self.noncom[first]
+ # cdef list nc = self.noncom[first]
for i in range(first):
si = (S[i])
if self.test(u, si, i):
- successors.append((_new_mul_(si,u), i))
- for i in range(first+1,self.n):
-# for i in nc:
+ successors.append((_new_mul_(si, u), i))
+ for i in range(first+1, self.n):
+ # for i in nc:
if u.perm[i] < N:
si = (S[i])
if self.test(u, si, i):
- successors.append((_new_mul_(si,u), i))
+ successors.append((_new_mul_(si, u), i))
return successors
- cdef list succ_words(self, PermutationGroupElement u, list word, int first):
+ cdef list succ_words(self, PermutationGroupElement u, list word, int first) noexcept:
cdef PermutationGroupElement u1, si
cdef int i
cdef list successors = []
@@ -120,7 +120,7 @@ cdef class Iterator():
for i in range(first):
si = (S[i])
if self.test(u, si, i):
- u1 = (_new_mul_(si,u))
+ u1 = (_new_mul_(si, u))
# try to use word+[i] and the reversed
word_new = [i] + word
u1._reduced_word = word_new
@@ -129,13 +129,13 @@ cdef class Iterator():
if u.perm[i] < N:
si = (S[i])
if self.test(u, si, i):
- u1 = (_new_mul_(si,u))
+ u1 = (_new_mul_(si, u))
word_new = [i] + word
u1._reduced_word = word_new
successors.append((u1, word_new, i))
return successors
- cdef inline bint test(self, PermutationGroupElement u, PermutationGroupElement si, int i):
+ cdef inline bint test(self, PermutationGroupElement u, PermutationGroupElement si, int i) noexcept:
cdef int j
cdef int N = self.N
cdef int* siperm = si.perm
@@ -375,6 +375,7 @@ cdef class Iterator():
for v in coset_reps:
yield _new_mul_(w, v)
+
def iterator_tracking_words(W):
r"""
Return an iterator through the elements of ``self`` together
@@ -417,7 +418,7 @@ def iterator_tracking_words(W):
cdef list index_list = list(range(len(S)))
cdef list level_set_cur = [(W.one(), [])]
- cdef set level_set_old = set([ W.one() ])
+ cdef set level_set_old = {W.one()}
cdef list word
cdef PermutationGroupElement x, y
@@ -432,10 +433,11 @@ def iterator_tracking_words(W):
level_set_new.append((y, word+[i]))
level_set_cur = level_set_new
-cdef inline bint has_left_descent(PermutationGroupElement w, int i, int N):
+
+cdef inline bint has_left_descent(PermutationGroupElement w, int i, int N) noexcept:
return w.perm[i] >= N
-cdef int first_descent(PermutationGroupElement w, int n, int N, bint left):
+cdef int first_descent(PermutationGroupElement w, int n, int N, bint left) noexcept:
cdef int i
if not left:
w = ~w
@@ -445,7 +447,7 @@ cdef int first_descent(PermutationGroupElement w, int n, int N, bint left):
return -1
cdef int first_descent_in_parabolic(PermutationGroupElement w, list parabolic,
- int N, bint left):
+ int N, bint left) noexcept:
cdef int i
if not left:
w = ~w
@@ -457,7 +459,7 @@ cdef int first_descent_in_parabolic(PermutationGroupElement w, list parabolic,
cpdef PermutationGroupElement reduce_in_coset(PermutationGroupElement w, tuple S,
- list parabolic, int N, bint right):
+ list parabolic, int N, bint right) noexcept:
r"""
Return the minimal length coset representative of ``w`` of the parabolic
subgroup indexed by ``parabolic`` (with indices `\{0, \ldots, n\}`).
@@ -501,7 +503,7 @@ cpdef PermutationGroupElement reduce_in_coset(PermutationGroupElement w, tuple S
w = _new_mul_(w, si)
cdef list reduced_coset_representatives(W, list parabolic_big, list parabolic_small,
- bint right):
+ bint right) noexcept:
cdef tuple S = tuple(W.simple_reflections())
cdef int N = W.number_of_reflections()
cdef set totest = set([W.one()])
@@ -515,10 +517,10 @@ cdef list reduced_coset_representatives(W, list parabolic_big, list parabolic_sm
S, parabolic_small, N, right)
for i in parabolic_big])
res.update(totest)
- totest = new.difference(res)#[ w for w in new if w not in res ]
+ totest = new.difference(res) # [w for w in new if w not in res]
return list(res)
-cdef parabolic_recursive(PermutationGroupElement x, list v, f):
+cdef parabolic_recursive(PermutationGroupElement x, list v, f) noexcept:
if not v:
f(x)
else:
@@ -558,7 +560,8 @@ def parabolic_iteration_application(W, f):
parabolic_recursive(W.one(), coset_reps, f)
-cpdef list reduced_word_c(W, PermutationGroupElement w):
+
+cpdef list reduced_word_c(W, PermutationGroupElement w) noexcept:
r"""
Computes a reduced word for the element ``w`` in the
reflection group ``W`` in the positions ``range(n)``.
@@ -584,7 +587,7 @@ cpdef list reduced_word_c(W, PermutationGroupElement w):
word.append(fdes)
return word
-cdef PermutationGroupElement _new_mul_(PermutationGroupElement left, PermutationGroupElement right):
+cdef PermutationGroupElement _new_mul_(PermutationGroupElement left, PermutationGroupElement right) noexcept:
"""
Multiply two :class:`PermutationGroupElement` directly without the
coercion framework.
diff --git a/src/sage/combinat/root_system/reflection_group_element.pxd b/src/sage/combinat/root_system/reflection_group_element.pxd
index 04e98fc3fb2..194688e25b6 100644
--- a/src/sage/combinat/root_system/reflection_group_element.pxd
+++ b/src/sage/combinat/root_system/reflection_group_element.pxd
@@ -1,11 +1,11 @@
from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement
cdef class ComplexReflectionGroupElement(PermutationGroupElement):
- cpdef action(self, vec, on_space=*)
- cpdef action_on_root_indices(self, i)
+ cpdef action(self, vec, on_space=*) noexcept
+ cpdef action_on_root_indices(self, i) noexcept
cdef class RealReflectionGroupElement(ComplexReflectionGroupElement):
- cpdef bint has_left_descent(self, i)
- cpdef bint has_descent(self, i, side=*, positive=*)
- cpdef action(self, vec, side=*, on_space=*)
- cpdef action_on_root_indices(self, i, side=*)
+ cpdef bint has_left_descent(self, i) noexcept
+ cpdef bint has_descent(self, i, side=*, positive=*) noexcept
+ cpdef action(self, vec, side=*, on_space=*) noexcept
+ cpdef action_on_root_indices(self, i, side=*) noexcept
diff --git a/src/sage/combinat/root_system/reflection_group_element.pyx b/src/sage/combinat/root_system/reflection_group_element.pyx
index 8f5a61ff0a2..6cc6c6e25a2 100644
--- a/src/sage/combinat/root_system/reflection_group_element.pyx
+++ b/src/sage/combinat/root_system/reflection_group_element.pyx
@@ -115,7 +115,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
gens = [W.simple_reflection(j) for j in W._index_set]
return _gap_factorization(self, gens)
- #@cached_in_parent_method
+ # @cached_in_parent_method
def reduced_word_in_reflections(self):
r"""
Return a word in the reflections to obtain ``self``.
@@ -180,7 +180,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
"""
return ZZ(len(self.reduced_word()))
- #@cached_in_parent_method
+ # @cached_in_parent_method
def to_matrix(self, on_space="primal"):
r"""
Return ``self`` as a matrix acting on the underlying vector
@@ -347,7 +347,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
mat.set_immutable()
return mat
- cpdef action(self, vec, on_space="primal"):
+ cpdef action(self, vec, on_space="primal") noexcept:
r"""
Return the image of ``vec`` under the action of ``self``.
@@ -372,7 +372,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
mat = self.matrix(on_space=on_space)
return vec * mat
- cpdef _act_on_(self, vec, bint self_on_left):
+ cpdef _act_on_(self, vec, bint self_on_left) noexcept:
r"""
Defines the action of ``self`` as a linear transformation
on the vector space, in the basis given by the simple
@@ -396,7 +396,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
return (~self).action(vec)
return self.action(vec)
- cpdef action_on_root_indices(self, i):
+ cpdef action_on_root_indices(self, i) noexcept:
"""
Return the right action on the set of roots.
@@ -481,7 +481,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
W = self._parent
return PermutationGroupElement(self, W)
- #@cached_in_parent_method
+ # @cached_in_parent_method
def fix_space(self):
r"""
Return the fix space of ``self``.
@@ -531,7 +531,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
I = identity_matrix(QQ, self._parent.rank())
return (self.to_matrix() - I).right_kernel()
- #@cached_in_parent_method
+ # @cached_in_parent_method
def reflection_eigenvalues(self, is_class_representative=False):
r"""
Return the reflection eigenvalues of ``self``.
@@ -578,7 +578,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
"""
return self._parent.reflection_eigenvalues(self, is_class_representative=is_class_representative)
- #@cached_in_parent_method
+ # @cached_in_parent_method
def galois_conjugates(self):
r"""
Return all Galois conjugates of ``self``.
@@ -683,8 +683,8 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
"""
rk = self._parent.rank()
M = self.to_matrix().list()
- m = lcm([x.conductor() if hasattr(x,"conductor") else 1 for x in M])
- cdef list M_gals = [x.galois_conjugates(m) if hasattr(x,"galois_conjugates") else [x] for x in M]
+ m = lcm([x.conductor() if hasattr(x, "conductor") else 1 for x in M])
+ cdef list M_gals = [x.galois_conjugates(m) if hasattr(x, "galois_conjugates") else [x] for x in M]
cdef list conjugates = []
cdef int i
for i in range(len(M_gals[0])):
@@ -763,7 +763,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement):
"""
return ZZ(len(self._reduced_word))
- cpdef bint has_left_descent(self, i):
+ cpdef bint has_left_descent(self, i) noexcept:
r"""
Return whether ``i`` is a left descent of ``self``.
@@ -784,7 +784,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement):
# we also check == because 0-based indexing
return self.perm[W._index_set_inverse[i]] >= W.number_of_reflections()
- cpdef bint has_descent(self, i, side="left", positive=False):
+ cpdef bint has_descent(self, i, side="left", positive=False) noexcept:
r"""
Return whether ``i`` is a descent (or ascent) of ``self``.
@@ -808,10 +808,10 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement):
False
"""
if not isinstance(positive, bool):
- raise TypeError("%s is not a boolean"%(bool))
+ raise TypeError("%s is not a boolean" % (bool))
if i not in self._parent.index_set():
- raise ValueError("the given index %s is not in the index set"%i)
+ raise ValueError("the given index %s is not in the index set" % i)
negative = not positive
@@ -957,7 +957,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement):
matrix = to_matrix
- cpdef action(self, vec, side="right", on_space="primal"):
+ cpdef action(self, vec, side="right", on_space="primal") noexcept:
r"""
Return the image of ``vec`` under the action of ``self``.
@@ -1020,7 +1020,7 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement):
else:
raise ValueError('on_space must be "primal" or "dual"')
- cpdef _act_on_(self, vec, bint self_on_left):
+ cpdef _act_on_(self, vec, bint self_on_left) noexcept:
r"""
Give the action of ``self`` as a linear transformation on
the vector space, in the basis given by the simple roots.
@@ -1049,11 +1049,10 @@ cdef class RealReflectionGroupElement(ComplexReflectionGroupElement):
(1, 1) -> (0, -1)
"""
if self_on_left:
- return self.action(vec,side="left")
- else:
- return self.action(vec,side="right")
+ return self.action(vec, side="left")
+ return self.action(vec, side="right")
- cpdef action_on_root_indices(self, i, side="right"):
+ cpdef action_on_root_indices(self, i, side="right") noexcept:
"""
Return the action on the set of roots.
@@ -1177,11 +1176,12 @@ def _gap_factorization(w, gens):
"""
from sage.interfaces.gap3 import gap3
- gap3.execute('W := GroupWithGenerators(%s)'%str(gens))
+ gap3.execute('W := GroupWithGenerators(%s)' % str(gens))
gap3.execute(_gap_factorization_code)
- fac = gap3('MinimalWord(W,%s)'%str(w)).sage()
+ fac = gap3('MinimalWord(W,%s)' % str(w)).sage()
return [i-1 for i in fac]
+
_gap_factorization_code = r"""
# MinimalWord(G,w)
# given a permutation group G find some expression of minimal length in the
@@ -1232,6 +1232,7 @@ MinimalWord:=function(G,w)
od;
end;"""
+
def _gap_return(S, coerce_obj='self'):
r"""
Return the string ``S`` after a few modifications are done.
@@ -1245,6 +1246,6 @@ def _gap_return(S, coerce_obj='self'):
sage: _gap_return("[ (), (1,4)(2,3)(5,6), (1,6,2)(3,5,4) ]") # optional - gap3
"[self('()',check=False),self('(1,4)(2,3)(5,6)',check=False),self('(1,6,2)(3,5,4)',check=False)]"
"""
- S = S.replace(' ','').replace('\n','')
- S = S.replace(',(','\',check=False),%s(\'('%coerce_obj).replace('[','[%s(\''%coerce_obj).replace(']','\',check=False)]')
+ S = S.replace(' ', '').replace('\n', '')
+ S = S.replace(',(', '\',check=False),%s(\'(' % coerce_obj).replace('[', '[%s(\'' % coerce_obj).replace(']', '\',check=False)]')
return S
diff --git a/src/sage/combinat/root_system/type_A.py b/src/sage/combinat/root_system/type_A.py
index 96bcec25f39..48d1474c1f4 100644
--- a/src/sage/combinat/root_system/type_A.py
+++ b/src/sage/combinat/root_system/type_A.py
@@ -277,7 +277,7 @@ def dynkin_diagram(self):
g.add_edge(i, i+1)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -297,6 +297,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$1$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n > 1:
@@ -306,7 +308,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
return ret + "".join(node((i-1)*node_dist, 0, label(i))
for i in self.index_set())
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the Dynkin diagram.
@@ -332,6 +334,8 @@ def ascii_art(self, label=lambda i: i, node=None):
n = self.n
if n == 0:
return ""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
ret = "---".join(node(label(i)) for i in range(1,n+1)) + "\n"
diff --git a/src/sage/combinat/root_system/type_A_affine.py b/src/sage/combinat/root_system/type_A_affine.py
index f10d15c7f0e..57ed18afd01 100644
--- a/src/sage/combinat/root_system/type_A_affine.py
+++ b/src/sage/combinat/root_system/type_A_affine.py
@@ -111,7 +111,7 @@ def dynkin_diagram(self):
g.add_edge(0, n)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -128,6 +128,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (3.0 cm, 1.2 cm) circle (.25cm) node[anchor=south east]{$0$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
@@ -148,7 +150,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
ret += node(mid, 1.2, label(0), 'anchor=south east')
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.
@@ -178,6 +180,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O<=>O
2 3
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
diff --git a/src/sage/combinat/root_system/type_A_infinity.py b/src/sage/combinat/root_system/type_A_infinity.py
index c3a2c603266..9e0f4711ccd 100644
--- a/src/sage/combinat/root_system/type_A_infinity.py
+++ b/src/sage/combinat/root_system/type_A_infinity.py
@@ -86,7 +86,7 @@ def _latex_(self):
"""
return 'A_{{{}}}'.format(self.n._latex_())
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.
@@ -100,6 +100,8 @@ def ascii_art(self, label=lambda i: i, node=None):
0 1 2 3 4 5 6
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
diff --git a/src/sage/combinat/root_system/type_B.py b/src/sage/combinat/root_system/type_B.py
index 67794141adc..8e9cb6e75a5 100644
--- a/src/sage/combinat/root_system/type_B.py
+++ b/src/sage/combinat/root_system/type_B.py
@@ -245,7 +245,7 @@ def dynkin_diagram(self):
g.set_edge_label(n-1, n, 2)
return g
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the Dynkin diagram.
@@ -261,6 +261,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O---O=>=O
3 4 5 6 7
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
@@ -271,7 +273,7 @@ def ascii_art(self, label=lambda i: i, node=None):
ret += "".join("{!s:4}".format(label(i)) for i in range(1, n + 1))
return ret
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -307,6 +309,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
- :meth:`sage.combinat.root_system.type_C.CartanType._latex_dynkin_diagram`
- :meth:`sage.combinat.root_system.type_BC_affine.CartanType._latex_dynkin_diagram`
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
diff --git a/src/sage/combinat/root_system/type_BC_affine.py b/src/sage/combinat/root_system/type_BC_affine.py
index bbc261902fb..740dfa2e5f3 100644
--- a/src/sage/combinat/root_system/type_BC_affine.py
+++ b/src/sage/combinat/root_system/type_BC_affine.py
@@ -138,7 +138,7 @@ def _latex_(self):
else:
return "BC_{%s}^{(2)}" % self.n
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -180,6 +180,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
@@ -206,7 +208,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += "}\n" + node(0, 0, label(0))
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return a ascii art representation of the extended Dynkin diagram.
@@ -227,6 +229,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O=<=O
2 3
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
diff --git a/src/sage/combinat/root_system/type_B_affine.py b/src/sage/combinat/root_system/type_B_affine.py
index 6cfe46255ae..047144f02d6 100644
--- a/src/sage/combinat/root_system/type_B_affine.py
+++ b/src/sage/combinat/root_system/type_B_affine.py
@@ -96,7 +96,7 @@ def dynkin_diagram(self):
g.add_edge(0,2)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -130,6 +130,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
@@ -155,7 +157,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += node(i*node_dist, 0, label(i+1))
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.
@@ -184,6 +186,8 @@ def ascii_art(self, label=lambda i: i, node=None):
"""
n = self.n
from .cartan_type import CartanType
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
if n == 1:
diff --git a/src/sage/combinat/root_system/type_C.py b/src/sage/combinat/root_system/type_C.py
index 57669883bea..8c7ebce3359 100644
--- a/src/sage/combinat/root_system/type_C.py
+++ b/src/sage/combinat/root_system/type_C.py
@@ -232,7 +232,7 @@ def dynkin_diagram(self):
"""
return self.dual().dynkin_diagram().dual()
- def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -268,9 +268,11 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=
- :meth:`sage.combinat.root_system.type_C.CartanType._latex_dynkin_diagram`
- :meth:`sage.combinat.root_system.type_BC_affine.CartanType._latex_dynkin_diagram`
"""
+ if label is None:
+ label = lambda i: i
return self.dual()._latex_dynkin_diagram(label=label, node=node, node_dist=node_dist, dual=not dual)
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return a ascii art representation of the extended Dynkin diagram.
@@ -289,6 +291,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O---O=<=O
3 4 5 6 7
"""
+ if label is None:
+ label = lambda i: i
return self.dual().ascii_art(label=label, node=node).replace("=>=", "=<=")
def _default_folded_cartan_type(self):
diff --git a/src/sage/combinat/root_system/type_C_affine.py b/src/sage/combinat/root_system/type_C_affine.py
index 72843b4d0a9..adaf5c77562 100644
--- a/src/sage/combinat/root_system/type_C_affine.py
+++ b/src/sage/combinat/root_system/type_C_affine.py
@@ -76,7 +76,7 @@ def dynkin_diagram(self):
g.add_edge(0,1,2)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -117,6 +117,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 1:
@@ -134,7 +136,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += "}\n" + node(0, 0, label(0))
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return a ascii art representation of the extended Dynkin diagram.
@@ -156,6 +158,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O<=>O
0 1
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
diff --git a/src/sage/combinat/root_system/type_D.py b/src/sage/combinat/root_system/type_D.py
index 28d4cd29cb2..5f1469e48a8 100644
--- a/src/sage/combinat/root_system/type_D.py
+++ b/src/sage/combinat/root_system/type_D.py
@@ -272,7 +272,7 @@ def dynkin_diagram(self):
g.add_edge(n-2, n)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -288,6 +288,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (4 cm, -0.7 cm) circle (.25cm) node[right=3pt]{$3$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n == 2:
@@ -305,7 +307,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
ret += node(rt_most, -0.7, label(self.n-1), 'right=3pt')
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return a ascii art representation of the extended Dynkin diagram.
@@ -336,6 +338,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O---O---O
3 4 5 6 7
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
diff --git a/src/sage/combinat/root_system/type_D_affine.py b/src/sage/combinat/root_system/type_D_affine.py
index 3ea86f32438..f77204e4a01 100644
--- a/src/sage/combinat/root_system/type_D_affine.py
+++ b/src/sage/combinat/root_system/type_D_affine.py
@@ -111,7 +111,7 @@ def dynkin_diagram(self):
g.add_edge(0,2)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -130,6 +130,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (4 cm, -0.7 cm) circle (.25cm) node[right=3pt]{$3$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
n = self.n
@@ -152,7 +154,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += node(rt_most, -0.7, label(n-1), "right=3pt")
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.
@@ -182,6 +184,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O
5 3 4
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
n = self.n
diff --git a/src/sage/combinat/root_system/type_E.py b/src/sage/combinat/root_system/type_E.py
index 478c628a5e9..5771d6d948f 100644
--- a/src/sage/combinat/root_system/type_E.py
+++ b/src/sage/combinat/root_system/type_E.py
@@ -573,7 +573,7 @@ def dynkin_diagram(self):
g.add_edge(i, i+1)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -591,6 +591,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (4 cm, 2 cm) circle (.25cm) node[right=3pt]{$2$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
ret = "\\draw (0 cm,0) -- (%s cm,0);\n" % ((self.n-2)*node_dist)
@@ -601,7 +603,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
ret += node(2*node_dist, node_dist, label(2), 'right=3pt')
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return a ascii art representation of the extended Dynkin diagram.
@@ -626,6 +628,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O---O---O---O---O
2 4 5 6 7 8 9
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
labels = [label(i) for i in [1,3,4,5,6] + list(range(7, self.n+1))] # We exclude 2 because of the special case
diff --git a/src/sage/combinat/root_system/type_E_affine.py b/src/sage/combinat/root_system/type_E_affine.py
index ac64cbfbdde..3268d0603e5 100644
--- a/src/sage/combinat/root_system/type_E_affine.py
+++ b/src/sage/combinat/root_system/type_E_affine.py
@@ -132,7 +132,7 @@ def dynkin_diagram(self):
raise ValueError("Invalid Cartan Type for Type E affine")
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -152,6 +152,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
"""
n = self.n
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
@@ -181,7 +183,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
ret += node(2*node_dist, node_dist, label(2), "right=3pt")
return ret
- def ascii_art(self, label=lambda x: x, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.
@@ -210,6 +212,8 @@ def ascii_art(self, label=lambda x: x, node=None):
-2 0 1 2 3 4 5 -3
"""
n = self.n
+ if label is None:
+ label = lambda x: x
if node is None:
node = self._ascii_art_node
if n == 6:
diff --git a/src/sage/combinat/root_system/type_F.py b/src/sage/combinat/root_system/type_F.py
index ac33d97fbee..524dd1f7c35 100644
--- a/src/sage/combinat/root_system/type_F.py
+++ b/src/sage/combinat/root_system/type_F.py
@@ -290,7 +290,7 @@ def dynkin_diagram(self):
g.set_edge_label(2,3,2)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -308,6 +308,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
ret = "\\draw (0 cm,0) -- (%s cm,0);\n" % node_dist
@@ -322,7 +324,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += node(i*node_dist, 0, label(i+1))
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the extended Dynkin diagram.
@@ -335,6 +337,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O=>=O---O
-1 0 1 2
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
ret = "{}---{}=>={}---{}\n".format(node(label(1)), node(label(2)),
diff --git a/src/sage/combinat/root_system/type_F_affine.py b/src/sage/combinat/root_system/type_F_affine.py
index 403c5b6e8ad..3d2dc8350ee 100644
--- a/src/sage/combinat/root_system/type_F_affine.py
+++ b/src/sage/combinat/root_system/type_F_affine.py
@@ -72,7 +72,7 @@ def dynkin_diagram(self):
g.add_edge(0, 1)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -95,6 +95,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
ret = "\\draw (0 cm,0) -- (%s cm,0);\n" % node_dist
@@ -103,7 +105,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += "}\n" + node(0, 0, label(0))
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Returns a ascii art representation of the extended Dynkin diagram
@@ -113,6 +115,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O=>=O---O
2 3 4 5 6
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
ret = "{}---{}---{}=>={}---{}\n".format(node(label(0)), node(label(1)),
diff --git a/src/sage/combinat/root_system/type_G.py b/src/sage/combinat/root_system/type_G.py
index 15da57bc11c..21dae3effa7 100644
--- a/src/sage/combinat/root_system/type_G.py
+++ b/src/sage/combinat/root_system/type_G.py
@@ -200,7 +200,7 @@ def dynkin_diagram(self):
g.set_edge_label(2,1,3)
return g
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -215,6 +215,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
\draw[fill=white] (2 cm, 0 cm) circle (.25cm) node[below=4pt]{$2$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
ret = "\\draw (0,0) -- (%s cm,0);\n" % node_dist
@@ -228,7 +230,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2, dual=
ret += node(node_dist, 0, label(2))
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the Dynkin diagram.
@@ -239,6 +241,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O=<=O
3 4
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
ret = " 3\n{}=<={}\n".format(node(label(1)), node(label(2)))
diff --git a/src/sage/combinat/root_system/type_G_affine.py b/src/sage/combinat/root_system/type_G_affine.py
index 2cb1487dfd8..582f7d9ed03 100644
--- a/src/sage/combinat/root_system/type_G_affine.py
+++ b/src/sage/combinat/root_system/type_G_affine.py
@@ -70,7 +70,7 @@ def dynkin_diagram(self):
g.add_edge(0, 2)
return g
- def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=False):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2, dual=False):
r"""
Return a latex representation of the Dynkin diagram.
@@ -89,6 +89,8 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=
\draw[fill=white] (4 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$};
"""
+ if label is None:
+ label = lambda x: x
if node is None:
node = self._latex_draw_node
ret = "\\draw (%s cm,0) -- (%s cm,0);\n" % (node_dist, node_dist*2.0)
@@ -98,7 +100,7 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2, dual=
ret += node(2*node_dist, 0, label(0))
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Returns an ascii art representation of the Dynkin diagram
@@ -109,6 +111,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O=<=O---O
3 4 2
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
ret = " 3\n{}=<={}---{}".format(node(label(1)), node(label(2)), node(label(0)))
diff --git a/src/sage/combinat/root_system/type_dual.py b/src/sage/combinat/root_system/type_dual.py
index c2ea5d978d3..22c4fb809d4 100644
--- a/src/sage/combinat/root_system/type_dual.py
+++ b/src/sage/combinat/root_system/type_dual.py
@@ -209,7 +209,7 @@ def __reduce__(self):
"""
return (attrcall("dual"), (self._type,))
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
EXAMPLES::
@@ -229,11 +229,13 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
}
\draw[fill=white] (0 cm, 0 cm) circle (.25cm) node[below=4pt]{$0$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
return self._type._latex_dynkin_diagram(label, node, node_dist, dual=True)
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of this Cartan type
@@ -261,6 +263,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O=>=O---O---O=>=O
0 1 2 3 4
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
res = self._type.ascii_art(label, node)
diff --git a/src/sage/combinat/root_system/type_marked.py b/src/sage/combinat/root_system/type_marked.py
index 5d80ca1052a..a9ca7d15a35 100644
--- a/src/sage/combinat/root_system/type_marked.py
+++ b/src/sage/combinat/root_system/type_marked.py
@@ -278,7 +278,7 @@ def _latex_draw_mark(self, x, y, color='black', thickness='thin'):
ret += "\\draw[shift={{({}, {})}}, {}, {}] (0.25cm, -0.25cm) -- (-0.25cm, 0.25cm);\n".format(x, y, color, thickness)
return ret
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -296,11 +296,13 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$};
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
return self._type._latex_dynkin_diagram(label, node, node_dist)
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of this Cartan type.
@@ -320,6 +322,8 @@ def ascii_art(self, label=lambda i: i, node=None):
X---O---X=>=O---O
0 1 2 3 4
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
return self._type.ascii_art(label, node)
diff --git a/src/sage/combinat/root_system/type_reducible.py b/src/sage/combinat/root_system/type_reducible.py
index 0f84b3f3b90..46cdccd2ab4 100644
--- a/src/sage/combinat/root_system/type_reducible.py
+++ b/src/sage/combinat/root_system/type_reducible.py
@@ -308,7 +308,7 @@ def dynkin_diagram(self):
g.add_edge(relabelling[i,e1], relabelling[i,e2], label=l)
return g
- def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -332,6 +332,8 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2):
\draw[fill=white] (2 cm, 0 cm) circle (.25cm) node[below=4pt]{$4$};
}
"""
+ if label is None:
+ label = lambda x: x
types = self.component_types()
relabelling = self._index_relabelling
ret = "{\n"
@@ -341,7 +343,7 @@ def _latex_dynkin_diagram(self, label=lambda x: x, node=None, node_dist=2):
ret += "}"
return ret
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of this reducible Cartan type.
@@ -367,6 +369,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O=<=O
11 12 13
"""
+ if label is None:
+ label = lambda i: i
types = self.component_types()
relabelling = self._index_relabelling
return "\n".join(types[i].ascii_art(lambda x: label(relabelling[i,x]), node)
diff --git a/src/sage/combinat/root_system/type_relabel.py b/src/sage/combinat/root_system/type_relabel.py
index 142ddeffa45..350e290b32a 100644
--- a/src/sage/combinat/root_system/type_relabel.py
+++ b/src/sage/combinat/root_system/type_relabel.py
@@ -55,7 +55,7 @@ def __classcall__(cls, type, relabelling):
return type
relabelling = FiniteFamily(relabelling) # Hack to emulate a frozendict which would be hashable!!!!
- return super(CartanType, cls).__classcall__(cls, type, relabelling)
+ return super().__classcall__(cls, type, relabelling)
def __init__(self, type, relabelling):
"""
@@ -271,7 +271,7 @@ def _latex_(self):
ret += " \\text{ relabelled by } " + latex(self._relabelling)
return ret
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -285,9 +285,11 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[fill=white] (6 cm, 0 cm) circle (.25cm) node[below=4pt]{$2$};
"""
+ if label is None:
+ label = lambda i: i
return self._type._latex_dynkin_diagram(lambda i: label(self._relabelling[i]), node, node_dist)
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of this Cartan type.
@@ -307,6 +309,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O=>=O---O
4 3 2 1 0
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._ascii_art_node
return self._type.ascii_art(lambda i: label(self._relabelling[i]), node)
diff --git a/src/sage/combinat/root_system/type_super_A.py b/src/sage/combinat/root_system/type_super_A.py
index dedc56b9011..c2717a572ff 100644
--- a/src/sage/combinat/root_system/type_super_A.py
+++ b/src/sage/combinat/root_system/type_super_A.py
@@ -737,7 +737,7 @@ def _latex_draw_node(self, x, y, label, position="below=4pt"):
x+.17, y-.17, x-.17, y+.17)
return ret
- def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
+ def _latex_dynkin_diagram(self, label=None, node=None, node_dist=2):
r"""
Return a latex representation of the Dynkin diagram.
@@ -775,6 +775,8 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
\draw[-,thick] (0.17 cm, 0.17 cm) -- (-0.17 cm, -0.17 cm);
\draw[-,thick] (0.17 cm, -0.17 cm) -- (-0.17 cm, 0.17 cm);
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = self._latex_draw_node
if self.n + self.m > 1:
@@ -784,7 +786,7 @@ def _latex_dynkin_diagram(self, label=lambda i: i, node=None, node_dist=2):
return ret + "".join(node((self.m+i)*node_dist, 0, label(i))
for i in self.index_set())
- def ascii_art(self, label=lambda i: i, node=None):
+ def ascii_art(self, label=None, node=None):
"""
Return an ascii art representation of the Dynkin diagram.
@@ -812,6 +814,8 @@ def ascii_art(self, label=lambda i: i, node=None):
O---O---O---O---O---X
-5 -4 -3 -2 -1 0
"""
+ if label is None:
+ label = lambda i: i
if node is None:
node = lambda i: 'O'
ret = "---".join(node(label(i)) for i in range(1,self.m+1))
diff --git a/src/sage/combinat/set_partition_iterator.pyx b/src/sage/combinat/set_partition_iterator.pyx
index fff6a71fefe..47667561a71 100644
--- a/src/sage/combinat/set_partition_iterator.pyx
+++ b/src/sage/combinat/set_partition_iterator.pyx
@@ -7,7 +7,7 @@ cimport cython
@cython.wraparound(False)
@cython.boundscheck(False)
-cdef list from_word(list w, list base_set):
+cdef list from_word(list w, list base_set) noexcept:
cdef list sp = []
cdef Py_ssize_t i
cdef Py_ssize_t b
@@ -20,6 +20,7 @@ cdef list from_word(list w, list base_set):
sp[b].append(x)
return sp
+
@cython.wraparound(False)
@cython.boundscheck(False)
def set_partition_iterator(base_set):
@@ -74,6 +75,7 @@ def set_partition_iterator(base_set):
# H3: increase a_{n-1}
a[last] += 1
+
@cython.wraparound(False)
@cython.boundscheck(False)
def _set_partition_block_gen(Py_ssize_t n, Py_ssize_t k, list a):
@@ -108,6 +110,7 @@ def _set_partition_block_gen(Py_ssize_t n, Py_ssize_t k, list a):
yield P
a[n-1] = n-1
+
@cython.wraparound(False)
@cython.boundscheck(False)
def set_partition_iterator_blocks(base_set, Py_ssize_t k):
diff --git a/src/sage/combinat/species/cycle_species.py b/src/sage/combinat/species/cycle_species.py
index 335223143ed..ed442e75ba9 100644
--- a/src/sage/combinat/species/cycle_species.py
+++ b/src/sage/combinat/species/cycle_species.py
@@ -113,7 +113,7 @@ def __classcall__(cls, *args, **kwds):
sage: C = species.CycleSpecies(); C
Cyclic permutation species
"""
- return super(CycleSpecies, cls).__classcall__(cls, *args, **kwds)
+ return super().__classcall__(cls, *args, **kwds)
def __init__(self, min=None, max=None, weight=None):
"""
diff --git a/src/sage/combinat/species/linear_order_species.py b/src/sage/combinat/species/linear_order_species.py
index a62fde28fb5..6203442ec8f 100644
--- a/src/sage/combinat/species/linear_order_species.py
+++ b/src/sage/combinat/species/linear_order_species.py
@@ -77,7 +77,7 @@ def __classcall__(cls, *args, **kwds):
sage: L = species.LinearOrderSpecies(); L
Linear order species
"""
- return super(LinearOrderSpecies, cls).__classcall__(cls, *args, **kwds)
+ return super().__classcall__(cls, *args, **kwds)
def __init__(self, min=None, max=None, weight=None):
"""
diff --git a/src/sage/combinat/species/partition_species.py b/src/sage/combinat/species/partition_species.py
index 3ed00b45ca4..f9044db7c73 100644
--- a/src/sage/combinat/species/partition_species.py
+++ b/src/sage/combinat/species/partition_species.py
@@ -142,7 +142,7 @@ def __classcall__(cls, *args, **kwds):
sage: P = species.PartitionSpecies(); P
Partition species
"""
- return super(PartitionSpecies, cls).__classcall__(cls, *args, **kwds)
+ return super().__classcall__(cls, *args, **kwds)
def __init__(self, min=None, max=None, weight=None):
"""
diff --git a/src/sage/combinat/species/permutation_species.py b/src/sage/combinat/species/permutation_species.py
index 4549e0354ff..64534c9e8bb 100644
--- a/src/sage/combinat/species/permutation_species.py
+++ b/src/sage/combinat/species/permutation_species.py
@@ -115,7 +115,7 @@ def __classcall__(cls, *args, **kwds):
sage: P = species.PermutationSpecies(); P
Permutation species
"""
- return super(PermutationSpecies, cls).__classcall__(cls, *args, **kwds)
+ return super().__classcall__(cls, *args, **kwds)
def __init__(self, min=None, max=None, weight=None):
"""
diff --git a/src/sage/combinat/species/set_species.py b/src/sage/combinat/species/set_species.py
index c4942dc653d..daa7d7e5835 100644
--- a/src/sage/combinat/species/set_species.py
+++ b/src/sage/combinat/species/set_species.py
@@ -91,7 +91,7 @@ def __classcall__(cls, *args, **kwds):
sage: E = species.SetSpecies(); E
Set species
"""
- return super(SetSpecies, cls).__classcall__(cls, *args, **kwds)
+ return super().__classcall__(cls, *args, **kwds)
def __init__(self, min=None, max=None, weight=None):
"""
diff --git a/src/sage/combinat/species/subset_species.py b/src/sage/combinat/species/subset_species.py
index 2bd89885533..81156e5183d 100644
--- a/src/sage/combinat/species/subset_species.py
+++ b/src/sage/combinat/species/subset_species.py
@@ -134,7 +134,7 @@ def __classcall__(cls, *args, **kwds):
sage: S = species.SubsetSpecies(); S
Subset species
"""
- return super(SubsetSpecies, cls).__classcall__(cls, *args, **kwds)
+ return super().__classcall__(cls, *args, **kwds)
def __init__(self, min=None, max=None, weight=None):
"""
diff --git a/src/sage/combinat/subword_complex_c.pyx b/src/sage/combinat/subword_complex_c.pyx
index 66da5184356..ec85790c133 100644
--- a/src/sage/combinat/subword_complex_c.pyx
+++ b/src/sage/combinat/subword_complex_c.pyx
@@ -1,7 +1,7 @@
# sage.doctest: needs sage.modules
cpdef int _flip_c(W, set positions, list extended_root_conf_indices,
- int i, side="both"):
+ int i, side="both") noexcept:
r"""
Flip a facet.
@@ -57,10 +57,10 @@ cpdef int _flip_c(W, set positions, list extended_root_conf_indices,
if j != i:
t = R[min(r, r_minus)]
for k in range(min(i, j) + 1, max(i, j) + 1):
- extended_root_conf_indices[k] = t.action_on_root_indices(extended_root_conf_indices[k],side="left")
+ extended_root_conf_indices[k] = t.action_on_root_indices(extended_root_conf_indices[k], side="left")
return j
-cpdef list _construct_facets_c(tuple Q, w, int n=-1, int pos=0, int l=-1):
+cpdef list _construct_facets_c(tuple Q, w, int n=-1, int pos=0, int l=-1) noexcept:
r"""
Return the list of facets of the subword complex associated to the
word `Q` and the element `w` in a Coxeter group `W`.
diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py
index 2103cb810a7..f7e58a15c20 100644
--- a/src/sage/combinat/tableau.py
+++ b/src/sage/combinat/tableau.py
@@ -9440,8 +9440,7 @@ def __iter__(self):
for (r, c) in growth_choice:
new_tab[r][c] = growth_num
list_of_partial_inc_tabs.append(Tableau(new_tab))
- for inctab in list_of_inc_tabs:
- yield inctab
+ yield from list_of_inc_tabs
class IncreasingTableaux_size_weight(IncreasingTableaux):
diff --git a/src/sage/combinat/words/abstract_word.py b/src/sage/combinat/words/abstract_word.py
index 77174089f78..610dba1437a 100644
--- a/src/sage/combinat/words/abstract_word.py
+++ b/src/sage/combinat/words/abstract_word.py
@@ -900,8 +900,7 @@ def _iterated_right_palindromic_closure_iterator(self, f=None):
w = (w*par([letter])).palindromic_closure(f=f)
length_after = w.length()
d = length_after - length_before
- for a in w[-d:]:
- yield a
+ yield from w[-d:]
def _iterated_right_palindromic_closure_recursive_iterator(self, f=None):
r"""
@@ -991,8 +990,7 @@ def _iterated_right_palindromic_closure_recursive_iterator(self, f=None):
else:
to_append = ipcw[lengths[pos]:]
ipcw += to_append
- for a in to_append:
- yield a
+ yield from to_append
def iterated_right_palindromic_closure(self, f=None, algorithm='recursive'):
r"""
diff --git a/src/sage/combinat/words/word_char.pyx b/src/sage/combinat/words/word_char.pyx
index 433aae3f4db..f2b7b47edb2 100644
--- a/src/sage/combinat/words/word_char.pyx
+++ b/src/sage/combinat/words/word_char.pyx
@@ -1,15 +1,15 @@
r"""
Fast word datatype using an array of unsigned char
"""
-#*****************************************************************************
+# ****************************************************************************
# Copyright (C) 2014 Vincent Delecroix <20100.delecroix@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
-# http://www.gnu.org/licenses/
-#*****************************************************************************
+# https://www.gnu.org/licenses/
+# ****************************************************************************
from cysignals.memory cimport check_allocarray, sig_free
from cysignals.signals cimport sig_on, sig_off
@@ -98,9 +98,9 @@ cdef class WordDatatype_char(WordDatatype):
if data:
self._set_data(data)
- @cython.boundscheck(False) # assume that indexing will not cause any IndexErrors
+ @cython.boundscheck(False) # assume that indexing will not cause any IndexErrors
@cython.wraparound(False) # not check not correctly handle negative indices
- cdef _set_data(self, data):
+ cdef _set_data(self, data) noexcept:
r"""
set the attribute ._data and ._length from the sequence data
(usually data is a word, a tuple or a list)
@@ -196,7 +196,7 @@ cdef class WordDatatype_char(WordDatatype):
[1, 3, 2]
"""
cdef bitset_t seen
- bitset_init(seen, 256) # allocation + initialization to 0
+ bitset_init(seen, 256) # allocation + initialization to 0
cdef size_t i
cdef list res = []
@@ -209,7 +209,7 @@ cdef class WordDatatype_char(WordDatatype):
bitset_free(seen)
return res
- cdef _new_c(self, unsigned char * data, size_t length, WordDatatype_char master):
+ cdef _new_c(self, unsigned char * data, size_t length, WordDatatype_char master) noexcept:
r"""
TO DISCUSS: in Integer (sage.rings.integer) this method is actually an
external function. But we might want to have several possible inheritance.
@@ -217,7 +217,7 @@ cdef class WordDatatype_char(WordDatatype):
cdef type t = type(self)
cdef WordDatatype_char other = t.__new__(t)
other._data = data
- other._master = master # can be None
+ other._master = master # can be None
other._is_slice = 0 if master is None else 1
other._length = length
other._parent = self._parent
@@ -367,9 +367,9 @@ cdef class WordDatatype_char(WordDatatype):
if isinstance(key, slice):
# here the key is a slice
PySlice_GetIndicesEx(key,
- self._length,
- &start, &stop, &step,
- &slicelength)
+ self._length,
+ &start, &stop, &step,
+ &slicelength)
if slicelength == 0:
return self._new_c(NULL, 0, None)
if step == 1:
@@ -425,7 +425,7 @@ cdef class WordDatatype_char(WordDatatype):
"""
return reversed_word_iterator(self)
- cdef _concatenate(self, WordDatatype_char other):
+ cdef _concatenate(self, WordDatatype_char other) noexcept:
cdef unsigned char * data
data = check_allocarray(self._length + other._length, sizeof(unsigned char))
diff --git a/src/sage/combinat/words/word_datatypes.pyx b/src/sage/combinat/words/word_datatypes.pyx
index 57c8079aad6..daf21a97469 100644
--- a/src/sage/combinat/words/word_datatypes.pyx
+++ b/src/sage/combinat/words/word_datatypes.pyx
@@ -1,7 +1,7 @@
r"""
Datatypes for finite words
"""
-#*****************************************************************************
+# ****************************************************************************
# Copyright (C) 2009 Franco Saliola
# Vincent Delecroix <20100.delecroix@gmail.com>
#
@@ -9,8 +9,8 @@ Datatypes for finite words
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
-# http://www.gnu.org/licenses/
-#*****************************************************************************
+# https://www.gnu.org/licenses/
+# ****************************************************************************
from cpython.object cimport Py_EQ, Py_NE
from itertools import islice
@@ -20,10 +20,10 @@ cdef class WordDatatype():
r"""
The generic WordDatatype class.
- Any word datatype must contain two attributes (at least)::
+ Any word datatype must contain two attributes (at least):
- - _parent
- - _hash
+ - ``_parent``
+ - ``_hash``
They are automatically defined here and it's not necessary (and forbidden)
to define them anywhere else.
@@ -419,7 +419,7 @@ cdef class WordDatatype_str(WordDatatype):
else:
return a in self._data
- cpdef _has_factor_naive(self, w):
+ cpdef _has_factor_naive(self, w) noexcept:
r"""
A naive test for testing whether the word contains ``w`` as a factor.
@@ -449,7 +449,7 @@ cdef class WordDatatype_str(WordDatatype):
return w in self._data
raise ValueError
- cpdef find(self, sub, start=0, end=None):
+ cpdef find(self, sub, start=0, end=None) noexcept:
r"""
Returns the index of the first occurrence of sub in self,
such that sub is contained within self[start:end].
diff --git a/src/sage/combinat/words/word_generators.py b/src/sage/combinat/words/word_generators.py
index 06141373c85..d7093ae997c 100644
--- a/src/sage/combinat/words/word_generators.py
+++ b/src/sage/combinat/words/word_generators.py
@@ -1651,8 +1651,7 @@ def _s_adic_iterator(self, sequence, letters):
if not precedent_letter == m(a)[0]:
raise ValueError("the hypothesis of the algorithm used is not satisfied; the image of the %s-th letter (=%s) under the %s-th morphism (=%s) should start with the %s-th letter (=%s)" % (i+1,a,i+1,m,i,precedent_letter))
w = p(m(a)[1:])
- for b in w:
- yield b
+ yield from w
p = p * m
precedent_letter = a
diff --git a/src/sage/combinat/words/words.py b/src/sage/combinat/words/words.py
index 900ab9c8508..63d6f1f0d05 100644
--- a/src/sage/combinat/words/words.py
+++ b/src/sage/combinat/words/words.py
@@ -960,8 +960,7 @@ def __iter__(self):
word: 444
"""
for l in itertools.count():
- for w in self.iterate_by_length(l):
- yield w
+ yield from self.iterate_by_length(l)
def __contains__(self, x):
"""
diff --git a/src/sage/cpython/_py2_random.py b/src/sage/cpython/_py2_random.py
index 1cd9532fee4..3ba96ccbbd1 100644
--- a/src/sage/cpython/_py2_random.py
+++ b/src/sage/cpython/_py2_random.py
@@ -92,19 +92,19 @@ def seed(self, a=None):
import time
a = int(time.time() * 256) # use fractional seconds
- super(Random, self).seed(a)
+ super().seed(a)
self.gauss_next = None
def getstate(self):
"""Return internal state; can be passed to setstate() later."""
- return self.VERSION, super(Random, self).getstate(), self.gauss_next
+ return self.VERSION, super().getstate(), self.gauss_next
def setstate(self, state):
"""Restore internal state from object returned by getstate()."""
version = state[0]
if version == 3:
version, internalstate, self.gauss_next = state
- super(Random, self).setstate(internalstate)
+ super().setstate(internalstate)
elif version == 2:
version, internalstate, self.gauss_next = state
# In version 2, the state was saved as signed ints, which causes
@@ -115,7 +115,7 @@ def setstate(self, state):
internalstate = tuple( int(x) % (2**32) for x in internalstate )
except ValueError as e:
raise TypeError(e)
- super(Random, self).setstate(internalstate)
+ super().setstate(internalstate)
else:
raise ValueError("state with version %s passed to "
"Random.setstate() of version %s" %
@@ -131,7 +131,7 @@ def jumpahead(self, n):
# we use hashing to create a large n for the shuffle.
s = repr(n) + repr(self.getstate())
n = int(_hashlib.new('sha512', s).hexdigest(), 16)
- super(Random, self).jumpahead(n)
+ super().jumpahead(n)
## ---- Methods below this point do not need to be overridden when
## ---- subclassing for the purpose of using a different core generator.
diff --git a/src/sage/cpython/getattr.pxd b/src/sage/cpython/getattr.pxd
index e0987cfa4c5..299509a00dc 100644
--- a/src/sage/cpython/getattr.pxd
+++ b/src/sage/cpython/getattr.pxd
@@ -5,4 +5,4 @@ cdef class AttributeErrorMessage:
cdef public cls
cdef public name
-cpdef getattr_from_other_class(self, cls, name)
+cpdef getattr_from_other_class(self, cls, name) noexcept
diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
index 1f49e5230c3..3a06167ea99 100644
--- a/src/sage/cpython/getattr.pyx
+++ b/src/sage/cpython/getattr.pyx
@@ -111,7 +111,7 @@ cdef class AttributeErrorMessage:
cdef AttributeErrorMessage dummy_error_message = AttributeErrorMessage()
-cpdef raw_getattr(obj, name):
+cpdef raw_getattr(obj, name) noexcept:
"""
Like ``getattr(obj, name)`` but without invoking the binding
behavior of descriptors under normal attribute access.
@@ -227,7 +227,7 @@ cpdef raw_getattr(obj, name):
raise AttributeError(dummy_error_message)
-cpdef getattr_from_other_class(self, cls, name):
+cpdef getattr_from_other_class(self, cls, name) noexcept:
"""
Emulate ``getattr(self, name)``, as if ``self`` was an instance of
``cls``.
diff --git a/src/sage/cpython/string.pxd b/src/sage/cpython/string.pxd
index 1fde0aec0de..dbf1c91c08b 100644
--- a/src/sage/cpython/string.pxd
+++ b/src/sage/cpython/string.pxd
@@ -13,7 +13,7 @@ cdef extern from "string_impl.h":
bytes _str_to_bytes(s, encoding, errors)
-cdef inline str char_to_str(const char* c, encoding=None, errors=None):
+cdef inline str char_to_str(const char* c, encoding=None, errors=None) noexcept:
r"""
Convert a C string to a Python ``str``.
"""
@@ -23,7 +23,7 @@ cdef inline str char_to_str(const char* c, encoding=None, errors=None):
return _cstr_to_str(c, encoding, errors)
-cpdef inline str bytes_to_str(b, encoding=None, errors=None):
+cpdef inline str bytes_to_str(b, encoding=None, errors=None) noexcept:
r"""
Convert ``bytes`` to ``str``.
@@ -49,7 +49,7 @@ cpdef inline str bytes_to_str(b, encoding=None, errors=None):
return _cstr_to_str(b, encoding, errors)
-cpdef inline bytes str_to_bytes(s, encoding=None, errors=None):
+cpdef inline bytes str_to_bytes(s, encoding=None, errors=None) noexcept:
r"""
Convert ``str`` or ``unicode`` to ``bytes``.
diff --git a/src/sage/cpython/type.pxd b/src/sage/cpython/type.pxd
index adb13dce6aa..f3f80c7a6c6 100644
--- a/src/sage/cpython/type.pxd
+++ b/src/sage/cpython/type.pxd
@@ -1 +1 @@
-cpdef bint can_assign_class(obj)
+cpdef bint can_assign_class(obj) noexcept
diff --git a/src/sage/cpython/type.pyx b/src/sage/cpython/type.pyx
index 8106c99f6ab..f9dcabc5df4 100644
--- a/src/sage/cpython/type.pyx
+++ b/src/sage/cpython/type.pyx
@@ -12,7 +12,7 @@ except ImportError:
pass
-cpdef bint can_assign_class(obj):
+cpdef bint can_assign_class(obj) noexcept:
"""
Can we assign ``obj.__class__``?
diff --git a/src/sage/cpython/wrapperdescr.pxd b/src/sage/cpython/wrapperdescr.pxd
index b6775860710..2260c062f1f 100644
--- a/src/sage/cpython/wrapperdescr.pxd
+++ b/src/sage/cpython/wrapperdescr.pxd
@@ -24,7 +24,7 @@ cdef extern from *:
PyDescr_NewWrapper(PyTypeObject* cls, wrapperbase* wrapper, void* wrapped)
-cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds)
+cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds) noexcept
cdef inline wrapperbase* get_slotdef(wrapper_descriptor slotwrapper) except NULL:
diff --git a/src/sage/cpython/wrapperdescr.pyx b/src/sage/cpython/wrapperdescr.pyx
index 66c79ca38e2..108ca690b8d 100644
--- a/src/sage/cpython/wrapperdescr.pyx
+++ b/src/sage/cpython/wrapperdescr.pyx
@@ -87,7 +87,7 @@ def wrapperdescr_call(slotwrapper, self, *args, **kwds):
return wrapperdescr_fastcall(slotwrapper, self, args, kwds)
-cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds):
+cdef wrapperdescr_fastcall(wrapper_descriptor slotwrapper, self, args, kwds) noexcept:
# Cython implementation of wrapperdescr_call
cdef wrapperbase* slotdef = slotwrapper.d_base
diff --git a/src/sage/crypto/boolean_function.pxd b/src/sage/crypto/boolean_function.pxd
index 8a97eb875aa..d9fd1017fcd 100644
--- a/src/sage/crypto/boolean_function.pxd
+++ b/src/sage/crypto/boolean_function.pxd
@@ -1,4 +1,4 @@
-cdef inline unsigned int hamming_weight(unsigned int x):
+cdef inline unsigned int hamming_weight(unsigned int x) noexcept:
# valid for 32bits
x -= (x>>1) & 0x55555555UL # 0-2 in 2 bits
x = ((x>>2) & 0x33333333UL) + (x & 0x33333333UL) # 0-4 in 4 bits
@@ -6,4 +6,4 @@ cdef inline unsigned int hamming_weight(unsigned int x):
x *= 0x01010101UL
return x>>24
-cdef walsh_hadamard(long *f, int ldn)
+cdef walsh_hadamard(long *f, int ldn) noexcept
diff --git a/src/sage/crypto/boolean_function.pyx b/src/sage/crypto/boolean_function.pyx
index fa99fab5ea3..6190129278f 100644
--- a/src/sage/crypto/boolean_function.pyx
+++ b/src/sage/crypto/boolean_function.pyx
@@ -51,7 +51,7 @@ except ImportError:
# walsh_hadamard transform, reed_muller transform, and a lot
# more, see 'Matters computational' available on www.jjj.de.
-cdef walsh_hadamard(long *f, int ldn):
+cdef walsh_hadamard(long *f, int ldn) noexcept:
r"""
The Walsh Hadamard transform is an orthogonal transform equivalent
to a multidimensional discrete Fourier transform of size 2x2x...x2.
@@ -84,7 +84,7 @@ cdef walsh_hadamard(long *f, int ldn):
t1 += 1
t2 += 1
-cdef long yellow_code(unsigned long a):
+cdef long yellow_code(unsigned long a) noexcept:
"""
The yellow-code is just a Reed Muller transform applied to a
word.
@@ -109,7 +109,7 @@ cdef long yellow_code(unsigned long a):
m ^= (m<`. It is a
symmetric key cipher so
@@ -27,22 +29,21 @@ class of
| + VigenereCryptosystem
+ PublicKeyCryptosystem
"""
-
-#*****************************************************************************
+# ****************************************************************************
# Copyright (C) 2007 David Kohel
#
# Distributed under the terms of the GNU General Public License (GPL)
#
-# http://www.gnu.org/licenses/
-#*****************************************************************************
-
-import sage.structure.parent_old as parent_old
+# https://www.gnu.org/licenses/
+# ****************************************************************************
from sage.sets.set import Set_generic
-class Cryptosystem(parent_old.Parent, Set_generic):
+
+class Cryptosystem(Set_generic):
r"""
A base cryptosystem class. This is meant to be extended by other
specialized child classes that implement specific cryptosystems.
+
A cryptosystem is a pair of maps
.. MATH::
@@ -143,7 +144,9 @@ def __init__(self, plaintext_space, ciphertext_space, key_space,
def __eq__(self, right):
r"""
- Comparing ``self`` with ``right``. Two ``Cryptosystem`` objects
+ Comparing ``self`` with ``right``.
+
+ Two ``Cryptosystem`` objects
are the same if they satisfy all of these conditions:
- share the same type
@@ -323,7 +326,9 @@ def key_space(self):
def block_length(self):
r"""
- Return the block length of this cryptosystem. For some cryptosystems
+ Return the block length of this cryptosystem.
+
+ For some cryptosystems
this is not relevant, in which case the block length defaults to 1.
EXAMPLES:
@@ -348,6 +353,7 @@ def period(self):
raise TypeError("Argument has no associated period.")
return self._period
+
class SymmetricKeyCryptosystem(Cryptosystem):
r"""
The base class for symmetric key, or secret key, cryptosystems.
@@ -373,6 +379,7 @@ def alphabet_size(self):
"""
return self._cipher_domain.ngens()
+
class PublicKeyCryptosystem(Cryptosystem):
r"""
The base class for asymmetric or public-key cryptosystems.
diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx
index e66cb52186c..a08eacb4740 100644
--- a/src/sage/crypto/sbox.pyx
+++ b/src/sage/crypto/sbox.pyx
@@ -25,7 +25,7 @@ from sage.rings.integer cimport Integer
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
-cdef Py_ssize_t _nterms(Py_ssize_t nvars, Py_ssize_t deg):
+cdef Py_ssize_t _nterms(Py_ssize_t nvars, Py_ssize_t deg) noexcept:
"""
Return the number of monomials possible up to a given
degree.
@@ -268,7 +268,7 @@ cdef class SBox(SageObject):
"""
return not self.__eq__(other)
- cpdef list to_bits(self, x, n=None):
+ cpdef list to_bits(self, x, n=None) noexcept:
"""
Return bitstring of length ``n`` for integer ``x``. The
returned bitstring is guaranteed to have length ``n``.
@@ -333,7 +333,7 @@ cdef class SBox(SageObject):
return ZZ(self._rpad(x, n), 2)
- cdef list _rpad(self, list x, Py_ssize_t n=-1):
+ cdef list _rpad(self, list x, Py_ssize_t n=-1) noexcept:
"""
Right pads ``x`` such that ``len(x) == n``.
@@ -1920,7 +1920,7 @@ cdef class SBox(SageObject):
return self == self.inverse()
-cdef Py_ssize_t feistel_substitute(Py_ssize_t x, Py_ssize_t input_size, list sboxes):
+cdef Py_ssize_t feistel_substitute(Py_ssize_t x, Py_ssize_t input_size, list sboxes) noexcept:
"""
Compute a Feistel output using the given sboxes.
@@ -1947,7 +1947,7 @@ cdef Py_ssize_t feistel_substitute(Py_ssize_t x, Py_ssize_t input_size, list sbo
return (xl << input_size) | xr
-cdef Py_ssize_t misty_substitute(Py_ssize_t x, Py_ssize_t input_size, list sboxes):
+cdef Py_ssize_t misty_substitute(Py_ssize_t x, Py_ssize_t input_size, list sboxes) noexcept:
"""
Compute a Misty output using the given sboxes.
@@ -1974,10 +1974,10 @@ cdef Py_ssize_t misty_substitute(Py_ssize_t x, Py_ssize_t input_size, list sboxe
return (xl << input_size) | xr
-ctypedef Py_ssize_t (*_SBOX_CONSTR) (Py_ssize_t, Py_ssize_t, list)
+ctypedef Py_ssize_t (*_SBOX_CONSTR) (Py_ssize_t, Py_ssize_t, list) noexcept
-cdef sbox_construction(_SBOX_CONSTR construction, list args):
+cdef sbox_construction(_SBOX_CONSTR construction, list args) noexcept:
"""
Construct an Sbox from the given input sboxes that has a twice
as big input size.
diff --git a/src/sage/data_structures/binary_matrix.pxd b/src/sage/data_structures/binary_matrix.pxd
index b2e4f2fa03f..848489e7697 100644
--- a/src/sage/data_structures/binary_matrix.pxd
+++ b/src/sage/data_structures/binary_matrix.pxd
@@ -61,7 +61,7 @@ cdef inline int binary_matrix_realloc(binary_matrix_t m, mp_bitcnt_t n_rows, mp_
m.n_cols = n_cols
m.n_rows = n_rows
-cdef inline void binary_matrix_free(binary_matrix_t m):
+cdef inline void binary_matrix_free(binary_matrix_t m) noexcept:
r"""
Free the memory allocated by the matrix
"""
@@ -71,7 +71,7 @@ cdef inline void binary_matrix_free(binary_matrix_t m):
bitset_free(m.rows[i])
sig_free(m.rows)
-cdef inline void binary_matrix_copy(binary_matrix_t dst, binary_matrix_t src):
+cdef inline void binary_matrix_copy(binary_matrix_t dst, binary_matrix_t src) noexcept:
"""
Copy the binary matrix src over to the binary matrix dst, overwriting dst.
@@ -81,7 +81,7 @@ cdef inline void binary_matrix_copy(binary_matrix_t dst, binary_matrix_t src):
for i in range(dst.n_rows):
bitset_copy(dst.rows[i], src.rows[i])
-cdef inline void binary_matrix_fill(binary_matrix_t m, bint bit):
+cdef inline void binary_matrix_fill(binary_matrix_t m, bint bit) noexcept:
r"""
Fill the whole matrix with a bit
"""
@@ -94,7 +94,7 @@ cdef inline void binary_matrix_fill(binary_matrix_t m, bint bit):
for i in range(m.n_rows):
bitset_clear(m.rows[i])
-cdef inline void binary_matrix_complement(binary_matrix_t m):
+cdef inline void binary_matrix_complement(binary_matrix_t m) noexcept:
r"""
Complement all of the matrix' bits.
"""
@@ -102,31 +102,31 @@ cdef inline void binary_matrix_complement(binary_matrix_t m):
for i in range(m.n_rows):
bitset_complement(m.rows[i], m.rows[i])
-cdef inline void binary_matrix_set1(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col):
+cdef inline void binary_matrix_set1(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col) noexcept:
r"""
Set an entry to 1
"""
bitset_add(m.rows[row], col)
-cdef inline void binary_matrix_set0(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col):
+cdef inline void binary_matrix_set0(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col) noexcept:
r"""
Set an entry to 0
"""
bitset_discard(m.rows[row], col)
-cdef inline void binary_matrix_set(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col, bint value):
+cdef inline void binary_matrix_set(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col, bint value) noexcept:
r"""
Set an entry
"""
bitset_set_to(m.rows[row],col,value)
-cdef inline bint binary_matrix_get(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col):
+cdef inline bint binary_matrix_get(binary_matrix_t m, mp_bitcnt_t row, mp_bitcnt_t col) noexcept:
r"""
Return the value of a given entry
"""
return bitset_in(m.rows[row], col)
-cdef inline binary_matrix_print(binary_matrix_t m):
+cdef inline binary_matrix_print(binary_matrix_t m) noexcept:
r"""
Print the binary matrix
"""
diff --git a/src/sage/data_structures/binary_search.pxd b/src/sage/data_structures/binary_search.pxd
index 640857720ae..5eee088e8b8 100644
--- a/src/sage/data_structures/binary_search.pxd
+++ b/src/sage/data_structures/binary_search.pxd
@@ -1,2 +1,2 @@
-cdef Py_ssize_t binary_search(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x, Py_ssize_t* ins)
-cdef Py_ssize_t binary_search0(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x)
\ No newline at end of file
+cdef Py_ssize_t binary_search(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x, Py_ssize_t* ins) noexcept
+cdef Py_ssize_t binary_search0(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x) noexcept
\ No newline at end of file
diff --git a/src/sage/data_structures/binary_search.pyx b/src/sage/data_structures/binary_search.pyx
index a53061c3efb..173affa5687 100644
--- a/src/sage/data_structures/binary_search.pyx
+++ b/src/sage/data_structures/binary_search.pyx
@@ -1,6 +1,6 @@
# We can probably get away with only having the mpz_binary_searches in here.
# I'm too scared to get rid of it at 2am though.
-cdef Py_ssize_t binary_search(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x, Py_ssize_t* ins):
+cdef Py_ssize_t binary_search(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x, Py_ssize_t* ins) noexcept:
"""
Find the position of the integer x in the array v, which has length n.
@@ -38,7 +38,7 @@ cdef Py_ssize_t binary_search(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x, Py_ssiz
return -1
-cdef Py_ssize_t binary_search0(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x):
+cdef Py_ssize_t binary_search0(Py_ssize_t* v, Py_ssize_t n, Py_ssize_t x) noexcept:
"""
Find the position of the int x in the array v, which has length n.
diff --git a/src/sage/data_structures/bitset.pxd b/src/sage/data_structures/bitset.pxd
index 08394ffcf5f..d8122c05165 100644
--- a/src/sage/data_structures/bitset.pxd
+++ b/src/sage/data_structures/bitset.pxd
@@ -12,29 +12,29 @@ from .bitset_base cimport bitset_t
# Python layer over bitset_t
cdef class FrozenBitset:
cdef bitset_t _bitset
- cdef FrozenBitset _new(self,long int capacity)
- cpdef FrozenBitset _larger_capacity_(self, long size)
- cpdef long capacity(self)
- cpdef bint isempty(self)
+ cdef FrozenBitset _new(self,long int capacity) noexcept
+ cpdef FrozenBitset _larger_capacity_(self, long size) noexcept
+ cpdef long capacity(self) noexcept
+ cpdef bint isempty(self) noexcept
cpdef bint issubset(self, FrozenBitset other) except -1
cpdef bint issuperset(self, FrozenBitset other) except -1
cpdef bint isdisjoint(self, FrozenBitset other) except -1
- cpdef _union(self, FrozenBitset other)
- cpdef intersection(self, FrozenBitset other)
- cpdef difference(self, FrozenBitset other)
- cpdef symmetric_difference(self, FrozenBitset other)
- cpdef complement(self)
- cpdef __copy__(self)
+ cpdef _union(self, FrozenBitset other) noexcept
+ cpdef intersection(self, FrozenBitset other) noexcept
+ cpdef difference(self, FrozenBitset other) noexcept
+ cpdef symmetric_difference(self, FrozenBitset other) noexcept
+ cpdef complement(self) noexcept
+ cpdef __copy__(self) noexcept
cdef class Bitset(FrozenBitset):
- cpdef __copy__(self)
- cpdef update(self, FrozenBitset other)
- cpdef intersection_update(self, FrozenBitset other)
- cpdef difference_update(self, FrozenBitset other)
- cpdef symmetric_difference_update(self, FrozenBitset other)
- cpdef add(self, unsigned long n)
- cpdef remove(self, unsigned long n)
- cpdef discard(self, unsigned long n)
- cpdef pop(self)
- cpdef clear(self)
+ cpdef __copy__(self) noexcept
+ cpdef update(self, FrozenBitset other) noexcept
+ cpdef intersection_update(self, FrozenBitset other) noexcept
+ cpdef difference_update(self, FrozenBitset other) noexcept
+ cpdef symmetric_difference_update(self, FrozenBitset other) noexcept
+ cpdef add(self, unsigned long n) noexcept
+ cpdef remove(self, unsigned long n) noexcept
+ cpdef discard(self, unsigned long n) noexcept
+ cpdef pop(self) noexcept
+ cpdef clear(self) noexcept
diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
index d9906b5edd2..0e3f6e3d640 100644
--- a/src/sage/data_structures/bitset.pyx
+++ b/src/sage/data_structures/bitset.pyx
@@ -404,7 +404,7 @@ cdef class FrozenBitset:
for n in iter:
bitset_add(self._bitset, n)
- cdef FrozenBitset _new(self, long int capacity):
+ cdef FrozenBitset _new(self, long int capacity) noexcept:
r"""
Return an object of the same type as ``self``, initialized with a
bitset of capacity ``capacity``.
@@ -471,7 +471,7 @@ cdef class FrozenBitset:
"""
return reversed(bitset_list(self._bitset))
- cpdef FrozenBitset _larger_capacity_(self, long capacity):
+ cpdef FrozenBitset _larger_capacity_(self, long capacity) noexcept:
"""
Return a copy of ``self`` where the bitset has the maximum of the
current capacity and the capacity passed. If no resizing is needed,
@@ -518,7 +518,7 @@ cdef class FrozenBitset:
bitset_realloc(temp._bitset, capacity)
return temp
- cpdef long capacity(self):
+ cpdef long capacity(self) noexcept:
"""
Return the size of the underlying bitset.
@@ -556,7 +556,7 @@ cdef class FrozenBitset:
else:
return hash
- cpdef bint isempty(self):
+ cpdef bint isempty(self) noexcept:
"""
Test if the bitset is empty.
@@ -872,7 +872,7 @@ cdef class FrozenBitset:
"""
return str(self)
- cpdef _union(self, FrozenBitset other):
+ cpdef _union(self, FrozenBitset other) noexcept:
"""
Return the union of ``self`` and ``other``.
@@ -971,7 +971,7 @@ cdef class FrozenBitset:
"""
return self._union(other)
- cpdef intersection(self, FrozenBitset other):
+ cpdef intersection(self, FrozenBitset other) noexcept:
"""
Return the intersection of ``self`` and ``other``.
@@ -1041,7 +1041,7 @@ cdef class FrozenBitset:
"""
return self.intersection(other)
- cpdef difference(self, FrozenBitset other):
+ cpdef difference(self, FrozenBitset other) noexcept:
"""
Return the difference of ``self`` and ``other``.
@@ -1110,7 +1110,7 @@ cdef class FrozenBitset:
"""
return self.difference(other)
- cpdef symmetric_difference(self, FrozenBitset other):
+ cpdef symmetric_difference(self, FrozenBitset other) noexcept:
"""
Return the symmetric difference of ``self`` and ``other``.
@@ -1183,7 +1183,7 @@ cdef class FrozenBitset:
"""
return self.symmetric_difference(other)
- cpdef complement(self):
+ cpdef complement(self) noexcept:
"""
Return the complement of self.
@@ -1229,7 +1229,7 @@ cdef class FrozenBitset:
"""
return self.complement()
- cpdef __copy__(self):
+ cpdef __copy__(self) noexcept:
"""
Return ``self`` (since ``self`` is immutable).
@@ -1287,7 +1287,7 @@ cdef class Bitset(FrozenBitset):
True
"""
- cpdef __copy__(self):
+ cpdef __copy__(self) noexcept:
"""
Return a copy of ``self``.
@@ -1427,7 +1427,7 @@ cdef class Bitset(FrozenBitset):
elif op == Py_GE:
return bitset_issuperset(left._bitset, right._bitset)
- cdef FrozenBitset _new(self, long int capacity):
+ cdef FrozenBitset _new(self, long int capacity) noexcept:
"""
Return an object of the same type as ``self``, initialized with a
bitset of capacity ``capacity``.
@@ -1436,7 +1436,7 @@ cdef class Bitset(FrozenBitset):
b = Bitset.__new__(Bitset, None, capacity)
return b
- cpdef update(self, FrozenBitset other):
+ cpdef update(self, FrozenBitset other) noexcept:
"""
Update the bitset to include items in ``other``.
@@ -1508,7 +1508,7 @@ cdef class Bitset(FrozenBitset):
self.update(other)
return self
- cpdef intersection_update(self, FrozenBitset other):
+ cpdef intersection_update(self, FrozenBitset other) noexcept:
"""
Update the bitset to the intersection of ``self`` and ``other``.
@@ -1577,7 +1577,7 @@ cdef class Bitset(FrozenBitset):
self.intersection_update(other)
return self
- cpdef difference_update(self, FrozenBitset other):
+ cpdef difference_update(self, FrozenBitset other) noexcept:
"""
Update the bitset to the difference of ``self`` and ``other``.
@@ -1674,7 +1674,7 @@ cdef class Bitset(FrozenBitset):
self.difference_update(other)
return self
- cpdef symmetric_difference_update(self, FrozenBitset other):
+ cpdef symmetric_difference_update(self, FrozenBitset other) noexcept:
"""
Update the bitset to the symmetric difference of ``self`` and
``other``.
@@ -1767,7 +1767,7 @@ cdef class Bitset(FrozenBitset):
self.symmetric_difference_update(other)
return self
- cpdef add(self, unsigned long n):
+ cpdef add(self, unsigned long n) noexcept:
"""
Update the bitset by adding ``n``.
@@ -1796,7 +1796,7 @@ cdef class Bitset(FrozenBitset):
bitset_realloc(self._bitset, n + 1)
bitset_add(self._bitset, n)
- cpdef remove(self, unsigned long n):
+ cpdef remove(self, unsigned long n) noexcept:
"""
Update the bitset by removing ``n``. Raises ``KeyError`` if ``n`` is
not contained in the bitset.
@@ -1836,7 +1836,7 @@ cdef class Bitset(FrozenBitset):
else:
bitset_remove(self._bitset, n)
- cpdef discard(self, unsigned long n):
+ cpdef discard(self, unsigned long n) noexcept:
"""
Update the bitset by removing ``n``.
@@ -1869,7 +1869,7 @@ cdef class Bitset(FrozenBitset):
if n < self._bitset.size:
bitset_discard(self._bitset, n)
- cpdef pop(self):
+ cpdef pop(self) noexcept:
"""
Remove and return an arbitrary element from the set. Raises
``KeyError`` if the set is empty.
@@ -1897,7 +1897,7 @@ cdef class Bitset(FrozenBitset):
"""
return bitset_pop(self._bitset)
- cpdef clear(self):
+ cpdef clear(self) noexcept:
"""
Removes all elements from the bitset.
diff --git a/src/sage/data_structures/bitset_base.pxd b/src/sage/data_structures/bitset_base.pxd
index 6c1d69364c9..60082345ccc 100644
--- a/src/sage/data_structures/bitset_base.pxd
+++ b/src/sage/data_structures/bitset_base.pxd
@@ -132,26 +132,26 @@ cdef extern from "bitset_intrinsics.h":
# NOTE: In all functions in this section, the index n is interpreted
# modulo GMP_LIMB_BITS, the number of bits in a limb.
#
-cdef inline mp_limb_t limb_one_set_bit(mp_bitcnt_t n):
+cdef inline mp_limb_t limb_one_set_bit(mp_bitcnt_t n) noexcept:
"""
Return a limb with only bit n set.
"""
return (1) << (n % GMP_LIMB_BITS)
-cdef inline mp_limb_t limb_one_zero_bit(mp_bitcnt_t n):
+cdef inline mp_limb_t limb_one_zero_bit(mp_bitcnt_t n) noexcept:
"""
Return a limb with all bits set, except for bit n.
"""
return ~((1) << (n % GMP_LIMB_BITS))
-cdef inline mp_limb_t limb_lower_bits_down(mp_bitcnt_t n):
+cdef inline mp_limb_t limb_lower_bits_down(mp_bitcnt_t n) noexcept:
"""
Return a limb with the lower n bits set, where n is interpreted
in [0 .. GMP_LIMB_BITS-1].
"""
return ((1) << (n % GMP_LIMB_BITS)) - 1
-cdef inline mp_limb_t limb_lower_bits_up(mp_bitcnt_t n):
+cdef inline mp_limb_t limb_lower_bits_up(mp_bitcnt_t n) noexcept:
"""
Return a limb with the lower n bits set, where n is interpreted
in [1 .. GMP_LIMB_BITS].
@@ -184,7 +184,7 @@ cdef inline bint bitset_init(fused_bitset_t bits, mp_bitcnt_t size) except -1:
bits.non_zero_chunks_are_initialized = False
bits.non_zero_chunks = check_allocarray((bits.limbs*LIMB_SIZE) // ALIGNMENT, sizeof(mp_bitcnt_t))
-cdef inline bint bitset_check_alignment(fused_bitset_t bits):
+cdef inline bint bitset_check_alignment(fused_bitset_t bits) noexcept:
"""
Return whether the bitset is aligned correctly.
"""
@@ -215,7 +215,7 @@ cdef inline int bitset_realloc(bitset_t bits, mp_bitcnt_t size) except -1:
# Zero removed bits
bitset_fix(bits)
-cdef inline void bitset_free(fused_bitset_t bits):
+cdef inline void bitset_free(fused_bitset_t bits) noexcept:
"""
Deallocate the memory in bits.
"""
@@ -225,7 +225,7 @@ cdef inline void bitset_free(fused_bitset_t bits):
sig_free(bits.mem)
sig_free(bits.non_zero_chunks)
-cdef inline void bitset_clear(fused_bitset_t bits):
+cdef inline void bitset_clear(fused_bitset_t bits) noexcept:
"""
Remove all elements from the set.
"""
@@ -233,7 +233,7 @@ cdef inline void bitset_clear(fused_bitset_t bits):
if fused_bitset_t is sparse_bitset_t:
bits.non_zero_chunks_are_initialized = False
-cdef inline void bitset_zero(fused_bitset_t bits):
+cdef inline void bitset_zero(fused_bitset_t bits) noexcept:
"""
Remove all elements from the set.
@@ -243,7 +243,7 @@ cdef inline void bitset_zero(fused_bitset_t bits):
if fused_bitset_t is sparse_bitset_t:
bits.non_zero_chunks_are_initialized = False
-cdef inline void bitset_copy(fused_bitset_t dst, fused_bitset_t src):
+cdef inline void bitset_copy(fused_bitset_t dst, fused_bitset_t src) noexcept:
"""
Copy the bitset src over to the bitset dst, overwriting dst.
@@ -253,7 +253,7 @@ cdef inline void bitset_copy(fused_bitset_t dst, fused_bitset_t src):
if fused_bitset_t is sparse_bitset_t:
dst.non_zero_chunks_are_initialized = False
-cdef inline void bitset_copy_flex(fused_bitset_t dst, fused_bitset_t src):
+cdef inline void bitset_copy_flex(fused_bitset_t dst, fused_bitset_t src) noexcept:
"""
Copy the bitset src over to the bitset dst, overwriting dst.
@@ -266,13 +266,13 @@ cdef inline void bitset_copy_flex(fused_bitset_t dst, fused_bitset_t src):
if fused_bitset_t is sparse_bitset_t:
dst.non_zero_chunks_are_initialized = False
-cdef inline void bitset_fix(fused_bitset_t bits):
+cdef inline void bitset_fix(fused_bitset_t bits) noexcept:
"""
Clear upper bits in upper limb which should be zero.
"""
bits.bits[bits.limbs - 1] &= limb_lower_bits_up(bits.size)
-cdef inline void sparse_bitset_set_non_zero(sparse_bitset_t bits) nogil:
+cdef inline void sparse_bitset_set_non_zero(sparse_bitset_t bits) noexcept nogil:
"""
Set the non zero chunks of ``bits``.
"""
@@ -283,7 +283,7 @@ cdef inline void sparse_bitset_set_non_zero(sparse_bitset_t bits) nogil:
# Bitset Comparison
#############################################################################
-cdef inline bint mpn_equal_bits(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n):
+cdef inline bint mpn_equal_bits(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n) noexcept:
"""
Return ``True`` iff the first n bits of *b1 and *b2 agree.
"""
@@ -298,7 +298,7 @@ cdef inline bint mpn_equal_bits(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n):
cdef mp_limb_t b2h = b2[nlimbs]
return (b1h ^ b2h) & mask == 0
-cdef inline bint mpn_equal_bits_shifted(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n, mp_bitcnt_t offset):
+cdef inline bint mpn_equal_bits_shifted(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t n, mp_bitcnt_t offset) noexcept:
"""
Return ``True`` iff the first n bits of *b1 and the bits ranging from
offset to offset+n of *b2 agree.
@@ -329,14 +329,14 @@ cdef inline bint mpn_equal_bits_shifted(mp_srcptr b1, mp_srcptr b2, mp_bitcnt_t
tmp_limb |= (b2[preinc(i2)] << neg_bit_offset)
return (b1h ^ tmp_limb) & mask == 0
-cdef inline bint bitset_isempty(fused_bitset_t bits) nogil:
+cdef inline bint bitset_isempty(fused_bitset_t bits) noexcept nogil:
"""
Test whether bits is empty. Return True (i.e., 1) if the set is
empty, False (i.e., 0) otherwise.
"""
return _bitset_isempty(bits.bits, bits.limbs)
-cdef inline bint bitset_is_zero(fused_bitset_t bits):
+cdef inline bint bitset_is_zero(fused_bitset_t bits) noexcept:
"""
Test whether bits is empty (i.e., zero). Return True (1) if
the set is empty, False (0) otherwise.
@@ -345,7 +345,7 @@ cdef inline bint bitset_is_zero(fused_bitset_t bits):
"""
return bitset_isempty(bits)
-cdef inline bint bitset_eq(fused_bitset_t a, fused_bitset_t b):
+cdef inline bint bitset_eq(fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Compare bitset a and b. Return True (i.e., 1) if the sets are
equal, and False (i.e., 0) otherwise.
@@ -354,7 +354,7 @@ cdef inline bint bitset_eq(fused_bitset_t a, fused_bitset_t b):
"""
return _bitset_cmp(a.bits, b.bits, b.limbs, EQUAL)
-cdef inline int bitset_cmp(fused_bitset_t a, fused_bitset_t b):
+cdef inline int bitset_cmp(fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Compare bitsets a and b. Return 0 if the two sets are
identical, and consistently return -1 or 1 for two sets that are
@@ -364,7 +364,7 @@ cdef inline int bitset_cmp(fused_bitset_t a, fused_bitset_t b):
"""
return mpn_cmp(a.bits, b.bits, b.limbs)
-cdef inline int bitset_lex_cmp(fused_bitset_t a, fused_bitset_t b):
+cdef inline int bitset_lex_cmp(fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Compare bitsets ``a`` and ``b`` using lexicographical ordering.
@@ -393,7 +393,7 @@ cdef inline int bitset_lex_cmp(fused_bitset_t a, fused_bitset_t b):
else:
return -1
-cdef inline bint bitset_issubset(fused_bitset_t a, fused_bitset_t b) nogil:
+cdef inline bint bitset_issubset(fused_bitset_t a, fused_bitset_t b) noexcept nogil:
"""
Test whether a is a subset of b (i.e., every element in a is also
in b).
@@ -405,7 +405,7 @@ cdef inline bint bitset_issubset(fused_bitset_t a, fused_bitset_t b) nogil:
else:
return _bitset_cmp(a.bits, b.bits, a.limbs, SUBSET)
-cdef inline bint bitset_issuperset(fused_bitset_t a, fused_bitset_t b) nogil:
+cdef inline bint bitset_issuperset(fused_bitset_t a, fused_bitset_t b) noexcept nogil:
"""
Test whether a is a superset of b (i.e., every element in b is also
in a).
@@ -414,7 +414,7 @@ cdef inline bint bitset_issuperset(fused_bitset_t a, fused_bitset_t b) nogil:
"""
return bitset_issubset(b, a)
-cdef inline bint bitset_are_disjoint(fused_bitset_t a, fused_bitset_t b):
+cdef inline bint bitset_are_disjoint(fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Tests whether ``a`` and ``b`` have an empty intersection.
@@ -430,14 +430,14 @@ cdef inline bint bitset_are_disjoint(fused_bitset_t a, fused_bitset_t b):
# Bitset Bit Manipulation
#############################################################################
-cdef inline bint bitset_in(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline bint bitset_in(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Check if n is in bits. Return True (i.e., 1) if n is in the
set, False (i.e., 0) otherwise.
"""
return (bits.bits[n >> index_shift] >> (n % GMP_LIMB_BITS)) & 1
-cdef inline bint bitset_check(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline bint bitset_check(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Check if n is in bits. Return True (i.e., 1) if n is in the
set, False (i.e., 0) otherwise.
@@ -446,7 +446,7 @@ cdef inline bint bitset_check(fused_bitset_t bits, mp_bitcnt_t n):
"""
return bitset_in(bits, n)
-cdef inline bint bitset_not_in(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline bint bitset_not_in(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Check if n is not in bits. Return True (i.e., 1) if n is not in the
set, False (i.e., 0) otherwise.
@@ -463,7 +463,7 @@ cdef inline bint bitset_remove(fused_bitset_t bits, mp_bitcnt_t n) except -1:
if fused_bitset_t is sparse_bitset_t:
bits.non_zero_chunks_are_initialized = False
-cdef inline void bitset_discard(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline void bitset_discard(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Remove n from bits.
"""
@@ -471,7 +471,7 @@ cdef inline void bitset_discard(fused_bitset_t bits, mp_bitcnt_t n):
if fused_bitset_t is sparse_bitset_t:
bits.non_zero_chunks_are_initialized = False
-cdef inline void bitset_unset(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline void bitset_unset(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Remove n from bits.
@@ -479,7 +479,7 @@ cdef inline void bitset_unset(fused_bitset_t bits, mp_bitcnt_t n):
"""
bitset_discard(bits, n)
-cdef inline void bitset_add(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline void bitset_add(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Add n to bits.
"""
@@ -487,7 +487,7 @@ cdef inline void bitset_add(fused_bitset_t bits, mp_bitcnt_t n):
if fused_bitset_t is sparse_bitset_t:
bits.non_zero_chunks_are_initialized = False
-cdef inline void bitset_set(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline void bitset_set(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Add n to bits.
@@ -495,14 +495,14 @@ cdef inline void bitset_set(fused_bitset_t bits, mp_bitcnt_t n):
"""
bitset_add(bits, n)
-cdef inline void bitset_set_to(bitset_t bits, mp_bitcnt_t n, bint b):
+cdef inline void bitset_set_to(bitset_t bits, mp_bitcnt_t n, bint b) noexcept:
"""
If b is True, add n to bits. If b is False, remove n from bits.
"""
bitset_unset(bits, n)
bits.bits[n >> index_shift] |= (b) << (n % GMP_LIMB_BITS)
-cdef inline void bitset_flip(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline void bitset_flip(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
If n is in bits, remove n from bits. If n is not in bits, add n
to bits.
@@ -511,7 +511,7 @@ cdef inline void bitset_flip(fused_bitset_t bits, mp_bitcnt_t n):
if fused_bitset_t is sparse_bitset_t:
bits.non_zero_chunks_are_initialized = False
-cdef inline void bitset_set_first_n(fused_bitset_t bits, mp_bitcnt_t n):
+cdef inline void bitset_set_first_n(fused_bitset_t bits, mp_bitcnt_t n) noexcept:
"""
Set exactly the first n bits.
"""
@@ -530,7 +530,7 @@ cdef inline void bitset_set_first_n(fused_bitset_t bits, mp_bitcnt_t n):
# Bitset Searching
#############################################################################
-cdef inline long bitset_first(fused_bitset_t a):
+cdef inline long bitset_first(fused_bitset_t a) noexcept:
"""
Calculate the index of the first element in the set. If the set
is empty, returns -1.
@@ -541,7 +541,7 @@ cdef inline long bitset_first(fused_bitset_t a):
return (i << index_shift) | _bitset_first_in_limb_nonzero(a.bits[i])
return -1
-cdef inline long bitset_first_in_complement(fused_bitset_t a):
+cdef inline long bitset_first_in_complement(fused_bitset_t a) noexcept:
"""
Calculate the index of the first element not in the set. If the set
is full, returns -1.
@@ -567,7 +567,7 @@ cdef inline long bitset_pop(fused_bitset_t a) except -1:
bitset_discard(a, i)
return i
-cdef inline long bitset_first_diff(fused_bitset_t a, fused_bitset_t b):
+cdef inline long bitset_first_diff(fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Calculate the index of the first difference between a and b. If a
and b are equal, then return -1.
@@ -580,7 +580,7 @@ cdef inline long bitset_first_diff(fused_bitset_t a, fused_bitset_t b):
return (i << index_shift) | _bitset_first_in_limb_nonzero(a.bits[i] ^ b.bits[i])
return -1
-cdef inline long bitset_next(fused_bitset_t a, mp_bitcnt_t n):
+cdef inline long bitset_next(fused_bitset_t a, mp_bitcnt_t n) noexcept:
"""
Calculate the index of the next element in the set, starting at
(and including) n. Return -1 if there are no elements from n
@@ -598,7 +598,7 @@ cdef inline long bitset_next(fused_bitset_t a, mp_bitcnt_t n):
return (i << index_shift) | _bitset_first_in_limb_nonzero(a.bits[i])
return -1
-cdef inline long bitset_next_diff(fused_bitset_t a, fused_bitset_t b, mp_bitcnt_t n):
+cdef inline long bitset_next_diff(fused_bitset_t a, fused_bitset_t b, mp_bitcnt_t n) noexcept:
"""
Calculate the index of the next element that differs between a and
b, starting at (and including) n. Return -1 if there are no
@@ -618,13 +618,13 @@ cdef inline long bitset_next_diff(fused_bitset_t a, fused_bitset_t b, mp_bitcnt_
return (i << index_shift) | _bitset_first_in_limb(a.bits[i] ^ b.bits[i])
return -1
-cdef inline long bitset_len(fused_bitset_t bits) nogil:
+cdef inline long bitset_len(fused_bitset_t bits) noexcept nogil:
"""
Calculate the number of items in the set (i.e., the number of nonzero bits).
"""
return _bitset_len(bits.bits, bits.limbs)
-cdef inline long bitset_hash(fused_bitset_t bits):
+cdef inline long bitset_hash(fused_bitset_t bits) noexcept:
"""
Calculate a (very naive) hash function.
@@ -641,7 +641,7 @@ cdef inline long bitset_hash(fused_bitset_t bits):
# Bitset Arithmetic
#############################################################################
-cdef inline void bitset_complement(fused_bitset_t r, fused_bitset_t a):
+cdef inline void bitset_complement(fused_bitset_t r, fused_bitset_t a) noexcept:
"""
Set r to be the complement of a, overwriting r.
@@ -652,7 +652,7 @@ cdef inline void bitset_complement(fused_bitset_t r, fused_bitset_t a):
if fused_bitset_t is sparse_bitset_t:
r.non_zero_chunks_are_initialized = False
-cdef inline void bitset_not(fused_bitset_t r, fused_bitset_t a):
+cdef inline void bitset_not(fused_bitset_t r, fused_bitset_t a) noexcept:
"""
Set r to be the complement of a, overwriting r.
@@ -664,7 +664,7 @@ cdef inline void bitset_not(fused_bitset_t r, fused_bitset_t a):
if fused_bitset_t is sparse_bitset_t:
r.non_zero_chunks_are_initialized = False
-cdef inline void bitset_intersection(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil:
+cdef inline void bitset_intersection(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil:
"""
Set r to the intersection of a and b, overwriting r.
@@ -674,7 +674,7 @@ cdef inline void bitset_intersection(fused_bitset_t r, fused_bitset_t a, fused_b
if fused_bitset_t is sparse_bitset_t:
r.non_zero_chunks_are_initialized = False
-cdef inline void sparse_bitset_intersection(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil:
+cdef inline void sparse_bitset_intersection(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil:
"""
Set r to the intersection of a and b, overwriting r.
@@ -685,7 +685,7 @@ cdef inline void sparse_bitset_intersection(sparse_bitset_t r, fused_bitset_t a,
r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, AND)
r.non_zero_chunks_are_initialized = True
-cdef inline void bitset_and(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b):
+cdef inline void bitset_and(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Set r to the intersection of a and b, overwriting r.
@@ -695,7 +695,7 @@ cdef inline void bitset_and(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b
"""
bitset_intersection(r, a, b)
-cdef inline void bitset_union(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil:
+cdef inline void bitset_union(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil:
"""
Set r to the union of a and b, overwriting r.
@@ -706,7 +706,7 @@ cdef inline void bitset_union(fused_bitset_t r, fused_bitset_t a, fused_bitset_t
if fused_bitset_t is sparse_bitset_t:
r.non_zero_chunks_are_initialized = False
-cdef inline void sparse_bitset_union(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) nogil:
+cdef inline void sparse_bitset_union(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept nogil:
"""
Set r to the union of a and b, overwriting r.
@@ -718,7 +718,7 @@ cdef inline void sparse_bitset_union(sparse_bitset_t r, fused_bitset_t a, fused_
r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, OR)
r.non_zero_chunks_are_initialized = True
-cdef inline void bitset_or(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b):
+cdef inline void bitset_or(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Set r to the union of a and b, overwriting r.
@@ -729,7 +729,7 @@ cdef inline void bitset_or(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b)
"""
bitset_union(r, a, b)
-cdef inline void bitset_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b):
+cdef inline void bitset_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Set r to the difference of a and b (i.e., things in a that are not
in b), overwriting r.
@@ -741,7 +741,7 @@ cdef inline void bitset_difference(fused_bitset_t r, fused_bitset_t a, fused_bit
if fused_bitset_t is sparse_bitset_t:
r.non_zero_chunks_are_initialized = False
-cdef inline void sparse_bitset_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b):
+cdef inline void sparse_bitset_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Set r to the difference of a and b (i.e., things in a that are not
in b), overwriting r.
@@ -754,7 +754,7 @@ cdef inline void sparse_bitset_difference(sparse_bitset_t r, fused_bitset_t a, f
r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, ANDNOT)
r.non_zero_chunks_are_initialized = True
-cdef inline void bitset_symmetric_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b):
+cdef inline void bitset_symmetric_difference(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Set r to the symmetric difference of a and b, overwriting r.
@@ -765,7 +765,7 @@ cdef inline void bitset_symmetric_difference(fused_bitset_t r, fused_bitset_t a,
if fused_bitset_t is sparse_bitset_t:
r.non_zero_chunks_are_initialized = False
-cdef inline void sparse_bitset_symmetric_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b):
+cdef inline void sparse_bitset_symmetric_difference(sparse_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Set r to the symmetric difference of a and b, overwriting r.
@@ -777,7 +777,7 @@ cdef inline void sparse_bitset_symmetric_difference(sparse_bitset_t r, fused_bit
r.n_non_zero_chunks = _sparse_bitset_operation(r.bits, r.non_zero_chunks, a.bits, b.bits, b.limbs, XOR)
r.non_zero_chunks_are_initialized = True
-cdef inline void bitset_xor(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b):
+cdef inline void bitset_xor(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b) noexcept:
"""
Set r to the symmetric difference of a and b, overwriting r.
@@ -788,7 +788,7 @@ cdef inline void bitset_xor(fused_bitset_t r, fused_bitset_t a, fused_bitset_t b
"""
bitset_symmetric_difference(r, a, b)
-cdef inline void bitset_rshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n):
+cdef inline void bitset_rshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n) noexcept:
"""
Shift the bitset ``a`` right by ``n`` bits and store the result in
``r``.
@@ -831,7 +831,7 @@ cdef inline void bitset_rshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n
if fused_bitset_t is sparse_bitset_t:
r.non_zero_chunks_are_initialized = False
-cdef inline void bitset_lshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n):
+cdef inline void bitset_lshift(fused_bitset_t r, fused_bitset_t a, mp_bitcnt_t n) noexcept:
"""
Shift the bitset ``a`` left by ``n`` bits and store the result in
``r``.
@@ -898,25 +898,25 @@ cdef inline int bitset_map(fused_bitset_t r, fused_bitset_t a, m) except -1:
# Hamming Weights
#############################################################################
-cdef inline long bitset_hamming_weight(fused_bitset_t a):
+cdef inline long bitset_hamming_weight(fused_bitset_t a) noexcept:
return bitset_len(a)
#############################################################################
# Bitset Conversion
#############################################################################
-cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=*, char one=*)
+cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=*, char one=*) noexcept
cdef int bitset_from_char(bitset_t bits, char* s, char zero=*, char one=*) except -1
cdef int bitset_from_str(bitset_t bits, object s, char zero=*, char one=*) except -1
-cdef bitset_string(fused_bitset_t bits)
+cdef bitset_string(fused_bitset_t bits) noexcept
-cdef bitset_bytes(fused_bitset_t bits)
+cdef bitset_bytes(fused_bitset_t bits) noexcept
-cdef list bitset_list(fused_bitset_t bits)
+cdef list bitset_list(fused_bitset_t bits) noexcept
-cdef bitset_pickle(bitset_t bs)
+cdef bitset_pickle(bitset_t bs) noexcept
-cdef bitset_unpickle(bitset_t bs, tuple input)
+cdef bitset_unpickle(bitset_t bs, tuple input) noexcept
diff --git a/src/sage/data_structures/bitset_base.pyx b/src/sage/data_structures/bitset_base.pyx
index 6a527a8ebfe..616e3b1ab04 100644
--- a/src/sage/data_structures/bitset_base.pyx
+++ b/src/sage/data_structures/bitset_base.pyx
@@ -11,7 +11,7 @@ Few functions from ``bitset_base.pxd`` that are not inlined.
# http://www.gnu.org/licenses/
#*****************************************************************************
-cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=c'0', char one=c'1'):
+cdef char* bitset_chars(char* s, fused_bitset_t bits, char zero=c'0', char one=c'1') noexcept:
"""
Return a string representation of the bitset in s, using zero for
the character representing the items not in the bitset and one for
@@ -47,13 +47,13 @@ cdef int bitset_from_str(bitset_t bits, object s, char zero=c'0', char one=c'1')
cdef bytes b = str_to_bytes(s)
return bitset_from_char(bits, b, zero, one)
-cdef bitset_string(fused_bitset_t bits):
+cdef bitset_string(fused_bitset_t bits) noexcept:
"""
Return a python string representing the bitset.
"""
return bytes_to_str(bitset_bytes(bits))
-cdef bitset_bytes(fused_bitset_t bits):
+cdef bitset_bytes(fused_bitset_t bits) noexcept:
"""
Return a python bytes string representing the bitset.
@@ -66,7 +66,7 @@ cdef bitset_bytes(fused_bitset_t bits):
sig_free(s)
return py_s
-cdef list bitset_list(fused_bitset_t bits):
+cdef list bitset_list(fused_bitset_t bits) noexcept:
"""
Return a list of elements in the bitset.
"""
@@ -77,7 +77,7 @@ cdef list bitset_list(fused_bitset_t bits):
elt = bitset_next(bits, elt + 1)
return elts
-cdef bitset_pickle(bitset_t bs):
+cdef bitset_pickle(bitset_t bs) noexcept:
"""
Convert ``bs`` to a reasonably compact Python structure.
@@ -91,7 +91,7 @@ cdef bitset_pickle(bitset_t bs):
data.append(bs.bits[i])
return (version, bs.size, bs.limbs, sizeof(unsigned long), tuple(data))
-cdef bitset_unpickle(bitset_t bs, tuple input):
+cdef bitset_unpickle(bitset_t bs, tuple input) noexcept:
"""
Convert the data into a bitset.
diff --git a/src/sage/data_structures/blas_dict.pxd b/src/sage/data_structures/blas_dict.pxd
index 7464c0daba8..3def4f5a950 100644
--- a/src/sage/data_structures/blas_dict.pxd
+++ b/src/sage/data_structures/blas_dict.pxd
@@ -1,11 +1,11 @@
cpdef int iaxpy(a, dict X, dict Y, bint remove_zeros=*, bint factor_on_left=*) except -1
-cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=*)
-cpdef dict negate(dict D)
-cpdef dict scal(a, dict D, bint factor_on_left=*)
-cpdef dict add(dict D, dict D2)
-cpdef dict sum(dict_iter)
-cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=*)
-cpdef dict sum_of_monomials(monomials, scalar)
-cpdef dict sum_of_terms(index_coeff_pairs)
-cdef dict remove_zeros(dict D)
-cpdef dict convert_remove_zeroes(dict D, R)
+cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=*) noexcept
+cpdef dict negate(dict D) noexcept
+cpdef dict scal(a, dict D, bint factor_on_left=*) noexcept
+cpdef dict add(dict D, dict D2) noexcept
+cpdef dict sum(dict_iter) noexcept
+cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=*) noexcept
+cpdef dict sum_of_monomials(monomials, scalar) noexcept
+cpdef dict sum_of_terms(index_coeff_pairs) noexcept
+cdef dict remove_zeros(dict D) noexcept
+cpdef dict convert_remove_zeroes(dict D, R) noexcept
diff --git a/src/sage/data_structures/blas_dict.pyx b/src/sage/data_structures/blas_dict.pyx
index c13cab2aab9..c624aa6a2d5 100644
--- a/src/sage/data_structures/blas_dict.pyx
+++ b/src/sage/data_structures/blas_dict.pyx
@@ -143,7 +143,7 @@ cpdef int iaxpy(a, dict X, dict Y, bint remove_zeros=True, bint factor_on_left=T
del Y[key]
return 0
-cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=True):
+cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=True) noexcept:
"""
Return `a X + Y`.
@@ -203,7 +203,7 @@ cpdef dict axpy(a, dict X, dict Y, bint factor_on_left=True):
iaxpy(a, X, Y, True, factor_on_left)
return Y
-cpdef dict negate(dict D):
+cpdef dict negate(dict D) noexcept:
r"""
Return a dictionary representing the vector `-X`.
@@ -220,7 +220,7 @@ cpdef dict negate(dict D):
"""
return { key: -value for key, value in D.iteritems() }
-cpdef dict scal(a, dict D, bint factor_on_left=True):
+cpdef dict scal(a, dict D, bint factor_on_left=True) noexcept:
r"""
Return a dictionary representing the vector `a*X`.
@@ -242,7 +242,7 @@ cpdef dict scal(a, dict D, bint factor_on_left=True):
# So for now we just delegate to axpy.
return axpy(a, D, {}, factor_on_left=factor_on_left)
-cpdef dict add(dict D, dict D2):
+cpdef dict add(dict D, dict D2) noexcept:
r"""
Return the pointwise addition of dictionaries ``D`` and ``D2``.
@@ -269,7 +269,7 @@ cpdef dict add(dict D, dict D2):
D, D2 = D2, D
return axpy(1, D2, D)
-cpdef dict sum(dict_iter):
+cpdef dict sum(dict_iter) noexcept:
r"""
Return the pointwise addition of dictionaries with coefficients.
@@ -310,7 +310,7 @@ cpdef dict sum(dict_iter):
return remove_zeros(result)
-cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True):
+cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True) noexcept:
r"""
Return the pointwise addition of dictionaries with coefficients.
@@ -355,7 +355,7 @@ cpdef dict linear_combination(dict_factor_iter, bint factor_on_left=True):
return remove_zeros(result)
-cpdef dict sum_of_monomials(monomials, scalar):
+cpdef dict sum_of_monomials(monomials, scalar) noexcept:
r"""
Return the pointwise addition of ``monomials``.
@@ -383,7 +383,7 @@ cpdef dict sum_of_monomials(monomials, scalar):
result[m] = scalar
return remove_zeros(result)
-cpdef dict sum_of_terms(index_coeff_pairs):
+cpdef dict sum_of_terms(index_coeff_pairs) noexcept:
r"""
Return the linear combination of a monomial scaled by a coefficient.
@@ -411,7 +411,7 @@ cpdef dict sum_of_terms(index_coeff_pairs):
result[index] = coeff
return remove_zeros(result)
-cdef dict remove_zeros(dict D):
+cdef dict remove_zeros(dict D) noexcept:
"""
Remove all keys whose value is zero from ``D``.
"""
@@ -422,7 +422,7 @@ cdef dict remove_zeros(dict D):
del D[index]
return D
-cpdef dict convert_remove_zeroes(dict D, R):
+cpdef dict convert_remove_zeroes(dict D, R) noexcept:
"""
Remove all keys whose value is zero from ``D``
after coercing into the ring ``R``.
diff --git a/src/sage/data_structures/bounded_integer_sequences.pxd b/src/sage/data_structures/bounded_integer_sequences.pxd
index b4466741034..44267b4fb46 100644
--- a/src/sage/data_structures/bounded_integer_sequences.pxd
+++ b/src/sage/data_structures/bounded_integer_sequences.pxd
@@ -34,28 +34,28 @@ ctypedef struct biseq_s:
ctypedef biseq_s biseq_t[1]
cdef bint biseq_init(biseq_t R, mp_size_t l, mp_bitcnt_t itemsize) except -1
-cdef void biseq_dealloc(biseq_t S)
+cdef void biseq_dealloc(biseq_t S) noexcept
cdef bint biseq_init_copy(biseq_t R, biseq_t S) except -1
-cdef tuple biseq_pickle(biseq_t S)
+cdef tuple biseq_pickle(biseq_t S) noexcept
cdef bint biseq_unpickle(biseq_t R, tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) except -1
cdef bint biseq_init_list(biseq_t R, list data, size_t bound) except -1
-cdef Py_hash_t biseq_hash(biseq_t S)
-cdef bint biseq_richcmp(biseq_t S1, biseq_t S2, int op)
+cdef Py_hash_t biseq_hash(biseq_t S) noexcept
+cdef bint biseq_richcmp(biseq_t S1, biseq_t S2, int op) noexcept
cdef bint biseq_init_concat(biseq_t R, biseq_t S1, biseq_t S2) except -1
cdef bint biseq_startswith(biseq_t S1, biseq_t S2) except -1
cdef mp_size_t biseq_contains(biseq_t S1, biseq_t S2, mp_size_t start) except -2
cdef mp_size_t biseq_startswith_tail(biseq_t S1, biseq_t S2, mp_size_t start) except -2
cdef mp_size_t biseq_index(biseq_t S, size_t item, mp_size_t start) except -2
-cdef size_t biseq_getitem(biseq_t S, mp_size_t index)
-cdef biseq_getitem_py(biseq_t S, mp_size_t index)
-cdef void biseq_inititem(biseq_t S, mp_size_t index, size_t item)
-cdef void biseq_clearitem(biseq_t S, mp_size_t index)
+cdef size_t biseq_getitem(biseq_t S, mp_size_t index) noexcept
+cdef biseq_getitem_py(biseq_t S, mp_size_t index) noexcept
+cdef void biseq_inititem(biseq_t S, mp_size_t index, size_t item) noexcept
+cdef void biseq_clearitem(biseq_t S, mp_size_t index) noexcept
cdef bint biseq_init_slice(biseq_t R, biseq_t S, mp_size_t start, mp_size_t stop, mp_size_t step) except -1
cdef class BoundedIntegerSequence:
cdef biseq_t data
- cpdef bint startswith(self, BoundedIntegerSequence other)
- cpdef list list(self)
- cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other)
+ cpdef bint startswith(self, BoundedIntegerSequence other) noexcept
+ cpdef list list(self) noexcept
+ cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other) noexcept
-cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length)
+cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) noexcept
diff --git a/src/sage/data_structures/bounded_integer_sequences.pyx b/src/sage/data_structures/bounded_integer_sequences.pyx
index 907f9b4298a..7e6513ec1b0 100644
--- a/src/sage/data_structures/bounded_integer_sequences.pyx
+++ b/src/sage/data_structures/bounded_integer_sequences.pyx
@@ -142,7 +142,7 @@ cdef bint biseq_init(biseq_t R, mp_size_t l, mp_bitcnt_t itemsize) except -1:
R.itembitsize = itemsize
R.mask_item = limb_lower_bits_up(itemsize)
-cdef inline void biseq_dealloc(biseq_t S):
+cdef inline void biseq_dealloc(biseq_t S) noexcept:
"""
Deallocate the memory used by ``S``.
"""
@@ -161,7 +161,7 @@ cdef bint biseq_init_copy(biseq_t R, biseq_t S) except -1:
# Pickling
#
-cdef tuple biseq_pickle(biseq_t S):
+cdef tuple biseq_pickle(biseq_t S) noexcept:
return (bitset_pickle(S.data), S.itembitsize, S.length)
cdef bint biseq_unpickle(biseq_t R, tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) except -1:
@@ -199,10 +199,10 @@ cdef bint biseq_init_list(biseq_t R, list data, size_t bound) except -1:
biseq_inititem(R, index, item_c)
index += 1
-cdef inline Py_hash_t biseq_hash(biseq_t S):
+cdef inline Py_hash_t biseq_hash(biseq_t S) noexcept:
return S.itembitsize*(1073807360)+bitset_hash(S.data)
-cdef inline bint biseq_richcmp(biseq_t S1, biseq_t S2, int op):
+cdef inline bint biseq_richcmp(biseq_t S1, biseq_t S2, int op) noexcept:
if S1.itembitsize != S2.itembitsize:
return richcmp_not_equal(S1.itembitsize, S2.itembitsize, op)
if S1.length != S2.length:
@@ -271,7 +271,7 @@ cdef mp_size_t biseq_index(biseq_t S, size_t item, mp_size_t start) except -2:
return -1
-cdef inline size_t biseq_getitem(biseq_t S, mp_size_t index):
+cdef inline size_t biseq_getitem(biseq_t S, mp_size_t index) noexcept:
"""
Get item ``S[index]``, without checking margins.
@@ -288,7 +288,7 @@ cdef inline size_t biseq_getitem(biseq_t S, mp_size_t index):
out |= (S.data.bits[limb_index+1]) << (GMP_LIMB_BITS - bit_index)
return out & S.mask_item
-cdef biseq_getitem_py(biseq_t S, mp_size_t index):
+cdef biseq_getitem_py(biseq_t S, mp_size_t index) noexcept:
"""
Get item ``S[index]`` as a Python ``int``, without
checking margins.
@@ -297,7 +297,7 @@ cdef biseq_getitem_py(biseq_t S, mp_size_t index):
cdef size_t out = biseq_getitem(S, index)
return PyLong_FromSize_t(out)
-cdef inline void biseq_inititem(biseq_t S, mp_size_t index, size_t item):
+cdef inline void biseq_inititem(biseq_t S, mp_size_t index, size_t item) noexcept:
"""
Set ``S[index] = item``, without checking margins.
@@ -314,7 +314,7 @@ cdef inline void biseq_inititem(biseq_t S, mp_size_t index, size_t item):
# Our item is stored using 2 limbs, add the part from the upper limb
S.data.bits[limb_index+1] |= (item >> (GMP_LIMB_BITS - bit_index))
-cdef inline void biseq_clearitem(biseq_t S, mp_size_t index):
+cdef inline void biseq_clearitem(biseq_t S, mp_size_t index) noexcept:
"""
Set ``S[index] = 0``, without checking margins.
@@ -1041,7 +1041,7 @@ cdef class BoundedIntegerSequence:
return False
return biseq_contains(self.data, right.data, 0) >= 0
- cpdef list list(self):
+ cpdef list list(self) noexcept:
"""
Converts this bounded integer sequence to a list
@@ -1067,7 +1067,7 @@ cdef class BoundedIntegerSequence:
cdef mp_size_t i
return [biseq_getitem_py(self.data, i) for i in range(self.data.length)]
- cpdef bint startswith(self, BoundedIntegerSequence other):
+ cpdef bint startswith(self, BoundedIntegerSequence other) noexcept:
"""
Tells whether ``self`` starts with a given bounded integer sequence
@@ -1236,7 +1236,7 @@ cdef class BoundedIntegerSequence:
biseq_init_concat(out.data, myself.data, right.data)
return out
- cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other):
+ cpdef BoundedIntegerSequence maximal_overlap(self, BoundedIntegerSequence other) noexcept:
"""
Return ``self``'s maximal trailing sub-sequence that ``other`` starts with.
@@ -1355,7 +1355,7 @@ cdef class BoundedIntegerSequence:
return 0
return h
-cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length):
+cpdef BoundedIntegerSequence NewBISEQ(tuple bitset_data, mp_bitcnt_t itembitsize, mp_size_t length) noexcept:
"""
Helper function for unpickling of :class:`BoundedIntegerSequence`.
diff --git a/src/sage/data_structures/mutable_poset.py b/src/sage/data_structures/mutable_poset.py
index 44d086fa920..97bfcf1cd52 100644
--- a/src/sage/data_structures/mutable_poset.py
+++ b/src/sage/data_structures/mutable_poset.py
@@ -947,9 +947,8 @@ def _iter_depth_first_visit_(self, marked,
if key is not None:
S = sorted(S, key=key)
for shell in S:
- for e in shell._iter_depth_first_visit_(marked, reverse,
- key, condition):
- yield e
+ yield from shell._iter_depth_first_visit_(marked, reverse,
+ key, condition)
def iter_depth_first(self, reverse=False, key=None, condition=None):
r"""
@@ -1072,9 +1071,8 @@ def _iter_topological_visit_(self, marked,
if key is not None and len(S) > 1:
S = sorted(S, key=key)
for shell in S:
- for e in shell._iter_topological_visit_(marked, reverse,
- key, condition):
- yield e
+ yield from shell._iter_topological_visit_(marked, reverse,
+ key, condition)
yield self
def iter_topological(self, reverse=False, key=None, condition=None):
@@ -1768,8 +1766,7 @@ def shells(self, include_special=False):
"""
if include_special:
yield self.null
- for e in self._shells_.values():
- yield e
+ yield from self._shells_.values()
if include_special:
yield self.oo
diff --git a/src/sage/databases/stein_watkins.py b/src/sage/databases/stein_watkins.py
index 167fa3a195b..6abf39426dd 100644
--- a/src/sage/databases/stein_watkins.py
+++ b/src/sage/databases/stein_watkins.py
@@ -158,8 +158,7 @@ def __len__(self):
def __iter__(self):
try:
- for E in self.curves:
- yield E
+ yield from self.curves
except AttributeError:
return
diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py
index b5521868dd5..6c3b0b225ac 100644
--- a/src/sage/doctest/forker.py
+++ b/src/sage/doctest/forker.py
@@ -503,7 +503,7 @@ def getvalue(self):
TestResults = namedtuple('TestResults', 'failed attempted')
-class SageDocTestRunner(doctest.DocTestRunner, object):
+class SageDocTestRunner(doctest.DocTestRunner):
def __init__(self, *args, **kwds):
"""
A customized version of DocTestRunner that tracks dependencies
diff --git a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py
index e672314a9c0..6938068bbc6 100644
--- a/src/sage/dynamics/arithmetic_dynamics/affine_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/affine_ds.py
@@ -162,8 +162,9 @@ class DynamicalSystem_affine(SchemeMorphism_polynomial_affine_space,
If you pass in quotient ring elements, they are reduced::
+ sage: # needs sage.libs.singular
sage: A. = AffineSpace(QQ, 3)
- sage: X = A.subscheme([x-y])
+ sage: X = A.subscheme([x - y])
sage: u,v,w = X.coordinate_ring().gens()
sage: DynamicalSystem_affine([u, v, u+v], domain=X)
Dynamical System of Closed subscheme of Affine Space of dimension 3
@@ -174,9 +175,10 @@ class DynamicalSystem_affine(SchemeMorphism_polynomial_affine_space,
::
+ sage: # needs sage.libs.singular
sage: R. = PolynomialRing(QQ)
sage: A. = AffineSpace(R, 3)
- sage: X = A.subscheme(x^2-y^2)
+ sage: X = A.subscheme(x^2 - y^2)
sage: H = End(X)
sage: f = H([x^2/(t*y), t*y^2, x*z])
sage: DynamicalSystem_affine(f)
@@ -188,8 +190,8 @@ class DynamicalSystem_affine(SchemeMorphism_polynomial_affine_space,
::
- sage: x = var('x')
- sage: DynamicalSystem_affine(x^2+1)
+ sage: x = var('x') # needs sage.symbolic
+ sage: DynamicalSystem_affine(x^2 + 1) # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: symbolic ring cannot be the base ring
@@ -397,10 +399,11 @@ def homogenize(self, n):
::
+ sage: # needs sage.rings.number_field
sage: R. = PolynomialRing(QQbar)
sage: A. = AffineSpace(R, 2)
- sage: f = DynamicalSystem_affine([QQbar(sqrt(2))*x*y, a*x^2])
- sage: f.homogenize(2)
+ sage: f = DynamicalSystem_affine([QQbar(sqrt(2))*x*y, a*x^2]) # needs sage.symbolic
+ sage: f.homogenize(2) # needs sage.symbolic
Dynamical System of Projective Space of dimension 2 over Univariate
Polynomial Ring in a over Algebraic Field
Defn: Defined on coordinates by sending (x0 : x1 : x2) to
@@ -453,7 +456,7 @@ def dynatomic_polynomial(self, period):
sage: A. = AffineSpace(ZZ, 1)
sage: f = DynamicalSystem_affine([(x^2+1)/x])
- sage: f.dynatomic_polynomial(4)
+ sage: f.dynatomic_polynomial(4) # needs sage.libs.pari
2*x^12 + 18*x^10 + 57*x^8 + 79*x^6 + 48*x^4 + 12*x^2 + 1
::
@@ -507,8 +510,8 @@ def dynatomic_polynomial(self, period):
::
sage: A. = AffineSpace(CC,1)
- sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))])
- sage: F.dynatomic_polynomial([1,1])
+ sage: F = DynamicalSystem_affine([1/2*x^2 + CC(sqrt(3))]) # needs sage.symbolic
+ sage: F.dynatomic_polynomial([1,1]) # needs sage.symbolic
(0.125000000000000*x^4 + 0.366025403784439*x^2 + 1.50000000000000)/(0.500000000000000*x^2 - x + 1.73205080756888)
TESTS::
@@ -770,7 +773,7 @@ def multiplier(self, P, n, check=True):
sage: P. = AffineSpace(CC, 1)
sage: f = DynamicalSystem_affine([x^2 + 1/2])
- sage: f.multiplier(P([0.5 + 0.5*I]), 1)
+ sage: f.multiplier(P([0.5 + 0.5*I]), 1) # needs sage.symbolic
[1.00000000000000 + 1.00000000000000*I]
::
@@ -784,7 +787,7 @@ def multiplier(self, P, n, check=True):
::
sage: P. = AffineSpace(QQ, 2)
- sage: X = P.subscheme([x^2-y^2])
+ sage: X = P.subscheme([x^2 - y^2])
sage: f = DynamicalSystem_affine([x^2, y^2], domain=X)
sage: f.multiplier(X([1, 1]), 1)
[2 0]
@@ -823,7 +826,7 @@ def conjugate(self, M):
EXAMPLES::
sage: A. = AffineSpace(QQ, 1)
- sage: f = DynamicalSystem_affine([t^2+1])
+ sage: f = DynamicalSystem_affine([t^2 + 1])
sage: f.conjugate(matrix([[1,2], [0,1]]))
Dynamical System of Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (t) to
@@ -832,18 +835,20 @@ def conjugate(self, M):
::
sage: A. = AffineSpace(ZZ,2)
- sage: f = DynamicalSystem_affine([x^3+y^3,y^2])
+ sage: f = DynamicalSystem_affine([x^3 + y^3, y^2])
sage: f.conjugate(matrix([[1,2,3], [0,1,2], [0,0,1]]))
Dynamical System of Affine Space of dimension 2 over Integer Ring
Defn: Defined on coordinates by sending (x, y) to
- (x^3 + 6*x^2*y + 12*x*y^2 + 9*y^3 + 9*x^2 + 36*x*y + 40*y^2 + 27*x + 58*y + 28, y^2 + 4*y + 2)
+ (x^3 + 6*x^2*y + 12*x*y^2 + 9*y^3
+ + 9*x^2 + 36*x*y + 40*y^2 + 27*x + 58*y + 28, y^2 + 4*y + 2)
::
+ sage: # needs sage.rings.number_field
sage: R. = PolynomialRing(QQ)
- sage: K. = NumberField(x^2+1)
+ sage: K. = NumberField(x^2 + 1)
sage: A. = AffineSpace(ZZ,1)
- sage: f = DynamicalSystem_affine([x^3+2*x^2+3])
+ sage: f = DynamicalSystem_affine([x^3 + 2*x^2 + 3])
sage: f.conjugate(matrix([[i,i], [0,-i]]))
Dynamical System of Affine Space of dimension 1 over Integer Ring
Defn: Defined on coordinates by sending (x) to
@@ -860,6 +865,7 @@ def degree(self):
EXAMPLES::
+ sage: # needs sage.rings.number_field
sage: R. = QuadraticField(7)
sage: A. = AffineSpace(R, 3)
sage: f = DynamicalSystem_affine([x^2 + y^5 + c, x^11, z^19])
@@ -911,9 +917,10 @@ def weil_restriction(self):
EXAMPLES::
+ sage: # needs sage.rings.number_field
sage: K. = QuadraticField(5)
sage: A. = AffineSpace(K, 2)
- sage: f = DynamicalSystem_affine([x^2-y^2, y^2])
+ sage: f = DynamicalSystem_affine([x^2 - y^2, y^2])
sage: f.weil_restriction()
Dynamical System of Affine Space of dimension 4 over Rational Field
Defn: Defined on coordinates by sending (z0, z1, z2, z3) to
@@ -921,6 +928,7 @@ def weil_restriction(self):
::
+ sage: # needs sage.rings.number_field
sage: K. = QuadraticField(5)
sage: PS. = AffineSpace(K, 2)
sage: f = DynamicalSystem_affine([x, y])
@@ -940,13 +948,14 @@ def reduce_base_field(self):
The base field of the map could be strictly larger than
the field where all of the coefficients are defined. This function
reduces the base field to the minimal possible. This can be done when
- the base ring is a number field, QQbar, a finite field, or algebraic
+ the base ring is a number field, ``QQbar``, a finite field, or algebraic
closure of a finite field.
OUTPUT: A dynamical system
EXAMPLES::
+ sage: # needs sage.rings.finite_rings
sage: K. = GF(5^2)
sage: A. = AffineSpace(K, 2)
sage: f = DynamicalSystem_affine([x^2 + 3*y^2, 3*y^2])
@@ -957,15 +966,20 @@ def reduce_base_field(self):
::
+ sage: # needs sage.rings.number_field sage.symbolic
sage: A. = AffineSpace(QQbar, 2)
- sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2, QQbar(sqrt(-1))*y^2])
+ sage: f = DynamicalSystem_affine([x^2 + QQbar(sqrt(3))*y^2,
+ ....: QQbar(sqrt(-1))*y^2])
sage: f.reduce_base_field()
- Dynamical System of Affine Space of dimension 2 over Number Field in a with defining polynomial y^4 - y^2 + 1 with a = -0.866025403784439? + 0.50000000000000000?*I
+ Dynamical System of Affine Space of dimension 2 over Number Field in a
+ with defining polynomial y^4 - y^2 + 1
+ with a = -0.866025403784439? + 0.50000000000000000?*I
Defn: Defined on coordinates by sending (x, y) to
(x^2 + (a^3 - 2*a)*y^2, (a^3)*y^2)
::
+ sage: # needs sage.rings.number_field
sage: K. = CyclotomicField(5)
sage: A. = AffineSpace(K, 2)
sage: f = DynamicalSystem_affine([(3*x^2 + y) / (5*x), (y^2+1) / (x+y)])
@@ -1001,6 +1015,7 @@ def orbit_structure(self, P):
::
+ sage: # needs sage.rings.finite_rings
sage: A. = AffineSpace(GF(49, 't'), 3)
sage: f = DynamicalSystem_affine([x^2 - z, x - y + z, y^2 - x^2])
sage: f.orbit_structure(A(1, 1, 2))
@@ -1028,23 +1043,24 @@ def cyclegraph(self):
EXAMPLES::
sage: P. = AffineSpace(GF(5), 2)
- sage: f = DynamicalSystem_affine([x^2-y, x*y+1])
- sage: f.cyclegraph()
+ sage: f = DynamicalSystem_affine([x^2 - y, x*y + 1])
+ sage: f.cyclegraph() # needs sage.graphs
Looped digraph on 25 vertices
::
+ sage: # needs sage.rings.finite_rings
sage: P. = AffineSpace(GF(3^3, 't'), 1)
- sage: f = DynamicalSystem_affine([x^2-1])
- sage: f.cyclegraph()
+ sage: f = DynamicalSystem_affine([x^2 - 1])
+ sage: f.cyclegraph() # needs sage.graphs
Looped digraph on 27 vertices
::
sage: P. = AffineSpace(GF(7), 2)
- sage: X = P.subscheme(x-y)
+ sage: X = P.subscheme(x - y)
sage: f = DynamicalSystem_affine([x^2, y^2], domain=X)
- sage: f.cyclegraph()
+ sage: f.cyclegraph() # needs sage.graphs
Looped digraph on 7 vertices
"""
V = []
diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py
index 203eb70b563..5559a48ecce 100644
--- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py
@@ -1,3 +1,4 @@
+# sage.doctest: needs sage.rings.padics
r"""
Dynamical systems on Berkovich space over `\CC_p`.
@@ -22,23 +23,26 @@
# http://www.gnu.org/licenses/
#*****************************************************************************
-from sage.structure.element import Element
+from sage.categories.number_fields import NumberFields
+from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine
from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem
-from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
+from sage.dynamics.arithmetic_dynamics.projective_ds import DynamicalSystem_projective
+from sage.matrix.constructor import Matrix
from sage.misc.classcall_metaclass import typecall
+from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
+from sage.misc.lazy_import import lazy_import
+from sage.rings.infinity import Infinity
+from sage.rings.integer_ring import ZZ
+from sage.rings.rational_field import QQ
+from sage.schemes.affine.affine_space import is_AffineSpace
from sage.schemes.berkovich.berkovich_space import (Berkovich_Cp_Affine,
Berkovich_Cp_Projective, is_Berkovich_Cp,
Berkovich_Element_Cp_Affine)
from sage.schemes.projective.projective_space import is_ProjectiveSpace
-from sage.schemes.affine.affine_space import is_AffineSpace
-from sage.rings.padics.padic_base_generic import pAdicBaseGeneric
-from sage.dynamics.arithmetic_dynamics.projective_ds import DynamicalSystem_projective
-from sage.dynamics.arithmetic_dynamics.affine_ds import DynamicalSystem_affine
-from sage.categories.number_fields import NumberFields
-from sage.rings.integer_ring import ZZ
-from sage.rings.rational_field import QQ
-from sage.rings.infinity import Infinity
-from sage.matrix.constructor import Matrix
+from sage.structure.element import Element
+
+lazy_import('sage.rings.padics.padic_base_generic', 'pAdicBaseGeneric')
+
class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMetaclass):
r"""
@@ -71,15 +75,18 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet
sage: P. = ProjectiveSpace(Qp(3), 1)
sage: f = DynamicalSystem_projective([2*x^2 + 4*y^2, 3*x^2 + 9*y^2])
sage: DynamicalSystem_Berkovich(f)
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
Defn: Defined on coordinates by sending (x : y) to
- ((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2 : (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2)
+ ((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2
+ : (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2)
Or directly from polynomials::
sage: P. = ProjectiveSpace(Qp(3),1)
sage: DynamicalSystem_Berkovich([x^2 + y^2, y^2])
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
Defn: Defined on coordinates by sending (x : y) to
(x^2 + y^2 : y^2)
@@ -87,7 +94,8 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet
sage: R. = Qp(3)[]
sage: DynamicalSystem_Berkovich([x^2, y^2])
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
Defn: Defined on coordinates by sending (x : y) to
(x^2 : y^2)
@@ -112,6 +120,7 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet
We can create dynamical systems which act on Berkovich spaces backed by number fields::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: A. = NumberField(z^2 + 1)
sage: ideal = A.prime_above(2)
@@ -126,6 +135,7 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet
We can use the optional parameter ``ideal`` to create the
same dynamical system more efficiently::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: A. = NumberField(z^2 + 1)
sage: prime_ideal = A.prime_above(2)
@@ -196,7 +206,7 @@ class DynamicalSystem_Berkovich(Element, metaclass=InheritComparisonClasscallMet
sage: B = Berkovich_Cp_Projective(P, 3)
sage: H = DynamicalSystem_Berkovich([x*y^2, x^3 + 20*y^3], B)
sage: Q4 = B(1/9, 1.5)
- sage: H(Q4)
+ sage: H(Q4) # needs sage.rings.number_field
Type III point centered at (81/14581 : 1) of radius 0.00205761316872428
Alternatively, if checking for poles in the disk has been done already,
@@ -358,9 +368,9 @@ def as_scheme_dynamical_system(self):
sage: P. = ProjectiveSpace(Qp(3), 1)
sage: f = DynamicalSystem_Berkovich([x^2 + y^2, x*y])
sage: f.as_scheme_dynamical_system()
- Dynamical System of Projective Space of dimension 1 over 3-adic Field with capped relative precision 20
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 + y^2 : x*y)
+ Dynamical System of Projective Space of dimension 1 over
+ 3-adic Field with capped relative precision 20
+ Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : x*y)
"""
return self._system
@@ -399,7 +409,7 @@ def defining_polynomials(self):
sage: g = DynamicalSystem_Berkovich(f)
sage: g.defining_polynomials()
((2 + O(3^20))*x^2 + (1 + 3 + O(3^20))*y^2,
- (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2)
+ (3 + O(3^21))*x^2 + (3^2 + O(3^22))*y^2)
"""
return self._system._polys
@@ -418,6 +428,7 @@ def base_ring(self):
::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: A. = NumberField(z^3 + 20)
sage: P. = ProjectiveSpace(A, 1)
@@ -488,18 +499,16 @@ class DynamicalSystem_Berkovich_projective(DynamicalSystem_Berkovich):
sage: H = End(P1)
sage: DynamicalSystem_Berkovich(H([y, x]))
Dynamical system of Projective Berkovich line over Cp(3) of precision 20
- induced by the map
- Defn: Defined on coordinates by sending (x : y) to
- (y : x)
+ induced by the map
+ Defn: Defined on coordinates by sending (x : y) to (y : x)
Or from polynomials::
sage: P. = ProjectiveSpace(Qp(3), 1)
sage: DynamicalSystem_Berkovich([x^2+y^2, y^2])
Dynamical system of Projective Berkovich line over Cp(3) of precision 20
- induced by the map
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 + y^2 : y^2)
+ induced by the map
+ Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2)
"""
@staticmethod
def __classcall_private__(cls, dynamical_system, domain=None):
@@ -512,9 +521,8 @@ def __classcall_private__(cls, dynamical_system, domain=None):
sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_projective
sage: DynamicalSystem_Berkovich_projective([y, x])
Dynamical system of Projective Berkovich line over Cp(3) of precision 20
- induced by the map
- Defn: Defined on coordinates by sending (x : y) to
- (y : x)
+ induced by the map
+ Defn: Defined on coordinates by sending (x : y) to (y : x)
"""
if not isinstance(dynamical_system, DynamicalSystem):
if not isinstance(dynamical_system, DynamicalSystem_projective):
@@ -549,7 +557,8 @@ def __init__(self, dynamical_system, domain=None):
sage: P. = ProjectiveSpace(Qp(3), 1)
sage: DynamicalSystem_Berkovich([x^2 + x*y + 2*y^2, 2*x*y])
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
Defn: Defined on coordinates by sending (x : y) to
(x^2 + x*y + (2 + O(3^20))*y^2 : (2 + O(3^20))*x*y)
"""
@@ -570,12 +579,13 @@ def scale_by(self, t):
sage: P. = ProjectiveSpace(Qp(3), 1)
sage: f = DynamicalSystem_Berkovich([x^2, y^2])
sage: f.scale_by(x); f
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
- Defn: Defined on coordinates by sending (x : y) to
- (x^3 : x*y^2)
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
+ Defn: Defined on coordinates by sending (x : y) to (x^3 : x*y^2)
::
+ sage: # needs sage.rings.number_field
sage: Q. = QQ[]
sage: A. = NumberField(z^3 + 20)
sage: ideal = A.prime_above(3)
@@ -601,15 +611,15 @@ def normalize_coordinates(self):
sage: P. = ProjectiveSpace(Qp(3), 1)
sage: f = DynamicalSystem_Berkovich([2*x^2, 2*y^2])
sage: f.normalize_coordinates(); f
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
Normalize_coordinates may sometimes fail over p-adic fields::
sage: g = DynamicalSystem_Berkovich([2*x^2, x*y])
- sage: g.normalize_coordinates() #not tested
+ sage: g.normalize_coordinates() # not tested
Traceback (most recent call last):
...
TypeError: unable to coerce since the denominator is not 1
@@ -621,9 +631,9 @@ def normalize_coordinates(self):
sage: B = Berkovich_Cp_Projective(P, 3)
sage: g = DynamicalSystem_Berkovich([2*x^2, x*y], B)
sage: g.normalize_coordinates(); g
- Dynamical system of Projective Berkovich line over Cp(3), with base Rational Field induced by the map
- Defn: Defined on coordinates by sending (x : y) to
- (2*x : y)
+ Dynamical system of Projective Berkovich line over Cp(3), with base Rational Field
+ induced by the map
+ Defn: Defined on coordinates by sending (x : y) to (2*x : y)
"""
self._system.normalize_coordinates()
@@ -655,12 +665,14 @@ def conjugate(self, M, adjugate=False, new_ideal=None):
sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2])
sage: g = DynamicalSystem_Berkovich(f)
sage: g.conjugate(Matrix([[1, 1], [0, 1]]))
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
Defn: Defined on coordinates by sending (x : y) to
(x^2 + (2 + O(3^20))*x*y : (2 + O(3^20))*y^2)
::
+ sage: # needs sage.rings.number_field
sage: P. = ProjectiveSpace(QQ, 1)
sage: f = DynamicalSystem_Berkovich([x^2 + y^2, y^2], ideal=5)
sage: R. = QQ[]
@@ -676,6 +688,7 @@ def conjugate(self, M, adjugate=False, new_ideal=None):
the base ring of ``M`` and of this dynamical system are not the
same::
+ sage: # needs sage.rings.number_field
sage: ideal = A.ideal(5).factor()[1][0]; ideal
Fractional ideal (2*a + 1)
sage: g = f.conjugate(conj, new_ideal=ideal)
@@ -719,6 +732,7 @@ def resultant(self, normalize=False):
::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: A. = NumberField(z^3 + 20)
sage: P. = ProjectiveSpace(A, 1)
@@ -748,7 +762,8 @@ def dehomogenize(self, n):
sage: f = DynamicalSystem_projective([x^2 + y^2, x*y + y^2])
sage: g = DynamicalSystem_Berkovich(f)
sage: g.dehomogenize(1)
- Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map
+ Dynamical system of Affine Berkovich line over Cp(3) of precision 20
+ induced by the map
Defn: Defined on coordinates by sending (x) to
((x^2 + 1 + O(3^20))/(x + 1 + O(3^20)))
"""
@@ -766,8 +781,8 @@ def __call__(self, x, type_3_pole_check=True):
- ``x`` -- a point of projective Berkovich space over ``Cp``.
- - type_3_pole_check -- (default ``True``) A bool. WARNING:
- changing the value of type_3_pole_check can lead to mathematically
+ - ``type_3_pole_check`` -- (default ``True``) A bool. WARNING:
+ changing the value of ``type_3_pole_check`` can lead to mathematically
incorrect answers. Only set to ``False`` if there are NO
poles of the dynamical system in the disk corresponding
to the type III point ``x``. See Examples.
@@ -969,8 +984,7 @@ class DynamicalSystem_Berkovich_affine(DynamicalSystem_Berkovich):
sage: f = DynamicalSystem_affine([(x^2 + 1)/x])
sage: DynamicalSystem_Berkovich(f)
Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map
- Defn: Defined on coordinates by sending (x) to
- ((x^2 + 1 + O(5^20))/x)
+ Defn: Defined on coordinates by sending (x) to ((x^2 + 1 + O(5^20))/x)
Dynamical system can be created from a morphism::
@@ -978,8 +992,7 @@ class DynamicalSystem_Berkovich_affine(DynamicalSystem_Berkovich):
sage: phi = H([x + 3])
sage: DynamicalSystem_Berkovich(phi)
Dynamical system of Affine Berkovich line over Cp(5) of precision 20 induced by the map
- Defn: Defined on coordinates by sending (x) to
- (x + 3 + O(5^20))
+ Defn: Defined on coordinates by sending (x) to (x + 3 + O(5^20))
"""
@staticmethod
def __classcall_private__(cls, dynamical_system, domain=None):
@@ -991,9 +1004,9 @@ def __classcall_private__(cls, dynamical_system, domain=None):
sage: A. = AffineSpace(Qp(3), 1)
sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine
sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^2))
- Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map
- Defn: Defined on coordinates by sending (x) to
- (x^2)
+ Dynamical system of Affine Berkovich line over Cp(3) of precision 20
+ induced by the map
+ Defn: Defined on coordinates by sending (x) to (x^2)
"""
if not isinstance(dynamical_system, DynamicalSystem):
if not isinstance(dynamical_system, DynamicalSystem_affine):
@@ -1025,9 +1038,9 @@ def __init__(self, dynamical_system, domain):
sage: A. = AffineSpace(Qp(3), 1)
sage: from sage.dynamics.arithmetic_dynamics.berkovich_ds import DynamicalSystem_Berkovich_affine
sage: DynamicalSystem_Berkovich_affine(DynamicalSystem_affine(x^3))
- Dynamical system of Affine Berkovich line over Cp(3) of precision 20 induced by the map
- Defn: Defined on coordinates by sending (x) to
- (x^3)
+ Dynamical system of Affine Berkovich line over Cp(3) of precision 20
+ induced by the map
+ Defn: Defined on coordinates by sending (x) to (x^3)
"""
DynamicalSystem_Berkovich.__init__(self, dynamical_system, domain)
@@ -1052,9 +1065,9 @@ def homogenize(self, n):
sage: f = DynamicalSystem_affine(1/x)
sage: f = DynamicalSystem_Berkovich(f)
sage: f.homogenize(1)
- Dynamical system of Projective Berkovich line over Cp(3) of precision 20 induced by the map
- Defn: Defined on coordinates by sending (x0 : x1) to
- (x1 : x0)
+ Dynamical system of Projective Berkovich line over Cp(3) of precision 20
+ induced by the map
+ Defn: Defined on coordinates by sending (x0 : x1) to (x1 : x0)
"""
new_system = self._system.homogenize(n)
ideal = self.domain().ideal()
diff --git a/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py b/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py
index 5b324ddbd9a..ebb8702a7db 100644
--- a/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py
+++ b/src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py
@@ -51,13 +51,12 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: P. = ProjectiveSpace(QQ, 1)
sage: DynamicalSemigroup(([x, y], [x^2, y^2]))
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
::
@@ -65,23 +64,22 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: f = DynamicalSystem([x, y], P)
sage: g = DynamicalSystem([x^2, y^2], P)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
::
sage: A. = AffineSpace(QQ, 1)
sage: f = DynamicalSystem_affine(x, A)
sage: DynamicalSemigroup(f)
- Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 1 dynamical system:
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (x)
+ Dynamical semigroup over Affine Space of dimension 1 over Rational Field
+ defined by 1 dynamical system:
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x) to (x)
::
@@ -89,13 +87,12 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: f = DynamicalSystem(x, A)
sage: g = DynamicalSystem(x^2, A)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (x)
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (x^2)
+ Dynamical semigroup over Affine Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x) to (x)
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x) to (x^2)
::
@@ -104,32 +101,32 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: f = DynamicalSystem_projective([x, y], X)
sage: g = DynamicalSystem_projective([x^2, y^2], X)
sage: DynamicalSemigroup_projective([f, g])
- Dynamical semigroup over Closed subscheme of Projective Space of dimension 1 over Rational Field defined by:
- x - y defined by 2 dynamical systems:
- Dynamical System of Closed subscheme of Projective Space of dimension 1 over Rational Field defined by:
- x - y
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Closed subscheme of Projective Space of dimension 1 over Rational Field defined by:
- x - y
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
-
- If a dynamical semigroup is built from dynamical systems with different base rings, all systems will be coerced
- to the largest base ring::
+ Dynamical semigroup over Closed subscheme of Projective Space of dimension 1
+ over Rational Field defined by: x - y
+ defined by 2 dynamical systems:
+ Dynamical System of Closed subscheme of Projective Space of dimension 1
+ over Rational Field defined by: x - y
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Closed subscheme of Projective Space of dimension 1
+ over Rational Field defined by: x - y
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
+
+ If a dynamical semigroup is built from dynamical systems with different base rings,
+ all systems will be coerced to the largest base ring::
sage: P. = ProjectiveSpace(QQ, 1)
sage: Q. = ProjectiveSpace(RR, 1)
sage: f = DynamicalSystem([x, y], P)
sage: g = DynamicalSystem([z^2, w^2], Q)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Real Field with 53 bits of precision defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Real Field with 53 bits of precision defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1
+ over Real Field with 53 bits of precision
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1
+ over Real Field with 53 bits of precision
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
::
@@ -138,17 +135,19 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: f = DynamicalSystem(x, A)
sage: g = DynamicalSystem(y^2, B)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Affine Space of dimension 1 over Real Field with 53 bits of precision defined by 2 dynamical systems:
- Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x) to
- (x)
- Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x) to
- (x^2)
+ Dynamical semigroup over Affine Space of dimension 1 over
+ Real Field with 53 bits of precision defined by 2 dynamical systems:
+ Dynamical System of Affine Space of dimension 1 over
+ Real Field with 53 bits of precision
+ Defn: Defined on coordinates by sending (x) to (x)
+ Dynamical System of Affine Space of dimension 1 over
+ Real Field with 53 bits of precision
+ Defn: Defined on coordinates by sending (x) to (x^2)
If a dynamical semigroup is built from dynamical systems over number fields, a composite number field is created
and all systems will be coerced to it. This composite number field contains all of the initial number fields::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: K. = NumberField(r^2 - 2)
sage: P. = ProjectiveSpace(QQ, 1)
@@ -156,16 +155,18 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: f = DynamicalSystem([x, y], P)
sage: g = DynamicalSystem([z^2, w^2], Q)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Number Field in k with defining polynomial r^2 - 2 defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Number Field in k with defining polynomial r^2 - 2
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Number Field in k with defining polynomial r^2 - 2
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Number Field in k with defining polynomial r^2 - 2 defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Number Field in k with defining polynomial r^2 - 2
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over
+ Number Field in k with defining polynomial r^2 - 2
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: K. = NumberField(r^2 - 2)
sage: L. = NumberField(r^2 - 3)
@@ -174,16 +175,19 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: f = DynamicalSystem([x, y], P)
sage: g = DynamicalSystem([z^2, w^2], Q)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over
+ Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: K. = NumberField(r^2 - 2)
sage: L. = NumberField(r^2 - 3)
@@ -192,102 +196,107 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
sage: f = DynamicalSystem(x, P)
sage: g = DynamicalSystem(y^2, Q)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Affine Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1 defined by 2 dynamical systems:
- Dynamical System of Affine Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
- Defn: Defined on coordinates by sending (x) to
- (x)
- Dynamical System of Affine Space of dimension 1 over Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
- Defn: Defined on coordinates by sending (x) to
- (x^2)
+ Dynamical semigroup over Affine Space of dimension 1 over
+ Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
+ defined by 2 dynamical systems:
+ Dynamical System of Affine Space of dimension 1 over
+ Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
+ Defn: Defined on coordinates by sending (x) to (x)
+ Dynamical System of Affine Space of dimension 1 over
+ Number Field in kl with defining polynomial r^4 - 10*r^2 + 1
+ Defn: Defined on coordinates by sending (x) to (x^2)
A dynamical semigroup may contain dynamical systems over function fields::
- sage: R. = QQ[]
- sage: P. = ProjectiveSpace(R, 1)
- sage: f = DynamicalSystem([r * x, y], P)
- sage: g = DynamicalSystem([x, r * y], P)
- sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (r*x : y)
- Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : r*y)
+ sage: R. = QQ[]
+ sage: P. = ProjectiveSpace(R, 1)
+ sage: f = DynamicalSystem([r * x, y], P)
+ sage: g = DynamicalSystem([x, r * y], P)
+ sage: DynamicalSemigroup((f, g))
+ Dynamical semigroup over Projective Space of dimension 1 over Univariate
+ Polynomial Ring in r over Rational Field defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Univariate Polynomial Ring in r over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (r*x : y)
+ Dynamical System of Projective Space of dimension 1 over
+ Univariate Polynomial Ring in r over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : r*y)
- ::
+ ::
- sage: R. = QQ[]
- sage: P. = ProjectiveSpace(R, 1)
- sage: f = DynamicalSystem([r * x, y], P)
- sage: g = DynamicalSystem([x, y], P)
- sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (r*x : y)
- Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
+ sage: R. = QQ[]
+ sage: P. = ProjectiveSpace(R, 1)
+ sage: f = DynamicalSystem([r * x, y], P)
+ sage: g = DynamicalSystem([x, y], P)
+ sage: DynamicalSemigroup((f, g))
+ Dynamical semigroup over Projective Space of dimension 1 over Univariate
+ Polynomial Ring in r over Rational Field defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Univariate Polynomial Ring in r over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (r*x : y)
+ Dynamical System of Projective Space of dimension 1 over
+ Univariate Polynomial Ring in r over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
- ::
+ ::
- sage: R. = QQ[]
- sage: P. = ProjectiveSpace(R, 1)
- sage: f = DynamicalSystem([r * x, y], P)
- sage: g = DynamicalSystem([s * x, y], P)
- sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (r*x : y)
- Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (s*x : y)
+ sage: R. = QQ[]
+ sage: P. = ProjectiveSpace(R, 1)
+ sage: f = DynamicalSystem([r * x, y], P)
+ sage: g = DynamicalSystem([s * x, y], P)
+ sage: DynamicalSemigroup((f, g))
+ Dynamical semigroup over Projective Space of dimension 1 over Multivariate
+ Polynomial Ring in r, s over Rational Field defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Multivariate Polynomial Ring in r, s over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (r*x : y)
+ Dynamical System of Projective Space of dimension 1 over
+ Multivariate Polynomial Ring in r, s over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (s*x : y)
- ::
+ ::
- sage: R. = QQ[]
- sage: P. = ProjectiveSpace(R, 1)
- sage: f = DynamicalSystem([r * x, s * y], P)
- sage: g = DynamicalSystem([s * x, r * y], P)
- sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (r*x : s*y)
- Dynamical System of Projective Space of dimension 1 over Multivariate Polynomial Ring in r, s over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (s*x : r*y)
+ sage: R. = QQ[]
+ sage: P. = ProjectiveSpace(R, 1)
+ sage: f = DynamicalSystem([r * x, s * y], P)
+ sage: g = DynamicalSystem([s * x, r * y], P)
+ sage: DynamicalSemigroup((f, g))
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Multivariate Polynomial Ring in r, s over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Multivariate Polynomial Ring in r, s over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (r*x : s*y)
+ Dynamical System of Projective Space of dimension 1 over
+ Multivariate Polynomial Ring in r, s over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (s*x : r*y)
A dynamical semigroup may contain dynamical systems over finite fields::
sage: F = FiniteField(5)
sage: P. = ProjectiveSpace(F, 1)
sage: DynamicalSemigroup(([x, y], [x^2, y^2]))
- Dynamical semigroup over Projective Space of dimension 1 over Finite Field of size 5 defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Finite Field of size 5
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Finite Field of size 5
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Finite Field of size 5 defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Finite Field of size 5
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over Finite Field of size 5
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
- If a dynamical semigroup is built from dynamical systems over both projective and affine spaces, all systems
- will be homogenized to dynamical systems over projective space::
+ If a dynamical semigroup is built from dynamical systems over both projective and
+ affine spaces, all systems will be homogenized to dynamical systems over projective space::
sage: P. = ProjectiveSpace(QQ, 1)
sage: A. = AffineSpace(QQ, 1)
sage: f = DynamicalSystem([x, y], P)
sage: g = DynamicalSystem(z^2, A)
sage: DynamicalSemigroup((f, g))
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
TESTS::
@@ -299,6 +308,7 @@ class DynamicalSemigroup(Parent, metaclass=InheritComparisonClasscallMetaclass):
::
+ sage: # needs sage.rings.number_field
sage: R. = QQ[]
sage: K. = NumberField(r^2 - 2)
sage: P. = ProjectiveSpace(RR, 1)
@@ -443,13 +453,14 @@ def change_ring(self, new_ring):
sage: P. = ProjectiveSpace(QQ, 1)
sage: f = DynamicalSemigroup(([x, y], [x^2, y^2]))
sage: f.change_ring(RR)
- Dynamical semigroup over Projective Space of dimension 1 over Real Field with 53 bits of precision defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Real Field with 53 bits of precision defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Real Field with 53 bits of precision
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over
+ Real Field with 53 bits of precision
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
"""
new_systems = []
for ds in self.defining_systems():
@@ -516,11 +527,9 @@ def defining_systems(self):
sage: f = DynamicalSemigroup(([x, y], [x^2, y^2]))
sage: f.defining_systems()
(Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : y),
+ Defn: Defined on coordinates by sending (x : y) to (x : y),
Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2))
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2))
"""
return tuple(self._dynamical_systems)
@@ -760,13 +769,12 @@ def specialization(self, assignments):
sage: g = DynamicalSystem([x, r * y], P)
sage: d = DynamicalSemigroup((f, g))
sage: d.specialization({r:2})
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (2*x : y)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : 2*y)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (2*x : y)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : 2*y)
::
@@ -776,13 +784,12 @@ def specialization(self, assignments):
sage: g = DynamicalSystem([x, y], P)
sage: d = DynamicalSemigroup((f, g))
sage: d.specialization({r:2})
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (2*x : y)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (2*x : y)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
::
@@ -792,13 +799,12 @@ def specialization(self, assignments):
sage: g = DynamicalSystem([s * x, y], P)
sage: d = DynamicalSemigroup((f, g))
sage: d.specialization({r:2, s:3})
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (2*x : y)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (3*x : y)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (2*x : y)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (3*x : y)
::
@@ -808,13 +814,15 @@ def specialization(self, assignments):
sage: g = DynamicalSystem([s * x, r * y], P)
sage: d = DynamicalSemigroup((f, g))
sage: d.specialization({s:3})
- Dynamical semigroup over Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (r*x : 3*y)
- Dynamical System of Projective Space of dimension 1 over Univariate Polynomial Ring in r over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (3*x : r*y)
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Univariate Polynomial Ring in r over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over
+ Univariate Polynomial Ring in r over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (r*x : 3*y)
+ Dynamical System of Projective Space of dimension 1 over
+ Univariate Polynomial Ring in r over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (3*x : r*y)
"""
specialized_systems = []
for ds in self.defining_systems():
@@ -1222,13 +1230,12 @@ class DynamicalSemigroup_projective(DynamicalSemigroup):
sage: P. = ProjectiveSpace(QQ, 1)
sage: DynamicalSemigroup_projective(([x, y], [x^2, y^2]))
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x : y)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 : y^2)
+ Dynamical semigroup over Projective Space of dimension 1 over
+ Rational Field defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x : y)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x : y) to (x^2 : y^2)
"""
@staticmethod
@@ -1282,13 +1289,12 @@ def dehomogenize(self, n):
sage: g = DynamicalSystem([x^2, y^2], P)
sage: d = DynamicalSemigroup((f, g))
sage: d.dehomogenize(0)
- Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (y) to
- (y)
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (y) to
- (y^2)
+ Dynamical semigroup over Affine Space of dimension 1 over
+ Rational Field defined by 2 dynamical systems:
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (y) to (y)
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (y) to (y^2)
::
@@ -1297,13 +1303,12 @@ def dehomogenize(self, n):
sage: g = DynamicalSystem([x^2, y^2], P)
sage: d = DynamicalSemigroup((f, g))
sage: d.dehomogenize(1)
- Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (x)
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (x^2)
+ Dynamical semigroup over Affine Space of dimension 1 over
+ Rational Field defined by 2 dynamical systems:
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x) to (x)
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x) to (x^2)
TESTS::
@@ -1317,8 +1322,8 @@ def dehomogenize(self, n):
ValueError: Scheme morphism:
From: Affine Space of dimension 1 over Rational Field
To: Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (1/x) is not a `DynamicalSystem_affine` object
+ Defn: Defined on coordinates by sending (x) to (1/x)
+ is not a `DynamicalSystem_affine` object
"""
new_systems = []
for ds in self.defining_systems():
@@ -1354,13 +1359,12 @@ class DynamicalSemigroup_affine(DynamicalSemigroup):
sage: f = DynamicalSystem(x, A)
sage: g = DynamicalSystem(x^2, A)
sage: DynamicalSemigroup_affine((f, g))
- Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (x)
- Dynamical System of Affine Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x) to
- (x^2)
+ Dynamical semigroup over Affine Space of dimension 1 over
+ Rational Field defined by 2 dynamical systems:
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x) to (x)
+ Dynamical System of Affine Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x) to (x^2)
"""
@staticmethod
@@ -1411,13 +1415,12 @@ def homogenize(self, n):
sage: g = DynamicalSystem(x^2, A)
sage: d = DynamicalSemigroup((f, g))
sage: d.homogenize(1)
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x0 : x1) to
- (x0 + x1 : x1)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x0 : x1) to
- (x0^2 : x1^2)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x0 : x1) to (x0 + x1 : x1)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x0 : x1) to (x0^2 : x1^2)
::
@@ -1426,13 +1429,12 @@ def homogenize(self, n):
sage: g = DynamicalSystem(x^2, A)
sage: d = DynamicalSemigroup((f, g))
sage: d.homogenize((1, 0))
- Dynamical semigroup over Projective Space of dimension 1 over Rational Field defined by 2 dynamical systems:
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x0 : x1) to
- (x1 : x0 + x1)
- Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x0 : x1) to
- (x1^2 : x0^2)
+ Dynamical semigroup over Projective Space of dimension 1 over Rational Field
+ defined by 2 dynamical systems:
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x0 : x1) to (x1 : x0 + x1)
+ Dynamical System of Projective Space of dimension 1 over Rational Field
+ Defn: Defined on coordinates by sending (x0 : x1) to (x1^2 : x0^2)
"""
new_systems = []
for ds in self.defining_systems():
@@ -1466,11 +1468,9 @@ def _standardize_domains_of_(systems):
sage: g = DynamicalSystem(x^2, B)
sage: sage.dynamics.arithmetic_dynamics.dynamical_semigroup._standardize_domains_of_([f, g])
[Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x) to
- (x),
+ Defn: Defined on coordinates by sending (x) to (x),
Dynamical System of Affine Space of dimension 1 over Real Field with 53 bits of precision
- Defn: Defined on coordinates by sending (x) to
- (x^2)]
+ Defn: Defined on coordinates by sending (x) to (x^2)]
"""
identical_domains = True
for ds in systems:
diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py
index d42d3ca8b2d..c82f10aed0d 100644
--- a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py
+++ b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py
@@ -28,39 +28,40 @@
from sage.combinat.subset import Subsets
from sage.matrix.constructor import matrix
from sage.misc.functional import sqrt
+from sage.misc.lazy_import import lazy_import
from sage.misc.misc_c import prod
from sage.parallel.use_fork import p_iter_fork
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.rings.finite_rings.integer_mod_ring import Integers
from sage.rings.integer_ring import ZZ
-from sage.rings.number_field.number_field import NumberField
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.rational_field import QQ
from sage.sets.primes import Primes
from sage.sets.set import Set
from sage.structure.element import is_Matrix
+lazy_import('sage.rings.number_field.number_field', 'NumberField')
+
def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, iso_type=False):
r"""
-
- This function will compute the automorphism group for ``rational_function`` via the method of fixed points
+ Compute the automorphism group for ``rational_function`` via the method of fixed points
ALGORITHM:
- See Algorithm 3 in Faber-Manes-Viray [FMV]_.
+ See Algorithm 3 in Faber-Manes-Viray [FMV]_.
INPUT:
- - ``rational_function`` - Rational Function defined over `\ZZ` or `\QQ`
+ - ``rational_function`` -- Rational Function defined over `\ZZ` or `\QQ`
- - ``return_functions`` - Boolean Value, True will return elements in the automorphism group
- as linear fractional transformations. False will return elements as `PGL2` matrices
+ - ``return_functions`` -- Boolean value; ``True`` will return elements in the automorphism group
+ as linear fractional transformations. ``False`` will return elements as `PGL_2` matrices
- - ``iso_type`` - Boolean - True will cause the classification of the finite automorphism
+ - ``iso_type`` -- Boolean; ``True`` will cause the classification of the finite automorphism
group to also be returned
- OUTPUT: a list of automorphisms that make up the Automorphism Group
+ OUTPUT: a list of automorphisms that make up the automorphism group
of ``rational_function``
EXAMPLES::
@@ -69,7 +70,7 @@ def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False,
sage: rational_function = (z^2 - 2*z - 2)/(-2*z^2 - 2*z + 1)
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_QQ_fixedpoints
sage: automorphism_group_QQ_fixedpoints(rational_function, True)
- [z, 1/z, -z - 1, -z/(z + 1), (-z - 1)/z, -1/(z + 1)]
+ [z, 1/z, -z - 1, -z/(z + 1), (-z - 1)/z, -1/(z + 1)]
::
@@ -77,18 +78,18 @@ def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False,
sage: rational_function = (z^2 + 2*z)/(-2*z - 1)
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_QQ_fixedpoints
sage: automorphism_group_QQ_fixedpoints(rational_function)
- [
+ [
[1 0] [-1 -1] [-2 0] [0 2] [-1 -1] [ 0 -1]
[0 1], [ 0 1], [ 2 2], [2 0], [ 1 0], [ 1 1]
- ]
+ ]
::
sage: F. = PolynomialRing(QQ)
- sage: rational_function = (z^2 - 4*z -3)/(-3*z^2 - 2*z + 2)
+ sage: rational_function = (z^2 - 4*z - 3)/(-3*z^2 - 2*z + 2)
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_QQ_fixedpoints
sage: automorphism_group_QQ_fixedpoints(rational_function, True, True)
- ([z, (-z - 1)/z, -1/(z + 1)], 'Cyclic of order 3')
+ ([z, (-z - 1)/z, -1/(z + 1)], 'Cyclic of order 3')
"""
if rational_function.parent().is_field():
@@ -304,7 +305,7 @@ def height_bound(polynomial):
EXAMPLES::
sage: R. = PolynomialRing(QQ)
- sage: f = (z^3+2*z+6)
+ sage: f = z^3 + 2*z + 6
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import height_bound
sage: height_bound(f)
413526
@@ -345,7 +346,7 @@ def PGL_repn(rational_function):
EXAMPLES::
sage: R. = PolynomialRing(QQ)
- sage: f = ((2*z-1)/(3-z))
+ sage: f = (2*z-1)/(3-z)
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import PGL_repn
sage: PGL_repn(f)
[-2 1]
@@ -377,7 +378,7 @@ def PGL_order(A):
EXAMPLES::
- sage: M = matrix([[0,2],[2,0]])
+ sage: M = matrix([[0,2], [2,0]])
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import PGL_order
sage: PGL_order(M)
2
@@ -418,7 +419,7 @@ def CRT_helper(automorphisms, moduli):
EXAMPLES::
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import CRT_helper
- sage: CRT_helper([[matrix([[4,0],[0,1]]), matrix([[0,1],[1,0]])]],[5])
+ sage: CRT_helper([[matrix([[4,0], [0,1]]), matrix([[0,1], [1,0]])]], [5])
([
[4 0] [0 1]
[0 1], [1 0]
@@ -452,7 +453,7 @@ def CRT_automorphisms(automorphisms, order_elts, degree, moduli):
Given a list of automorphisms over various `Zmod(p^k)`, a list of the
elements orders, an integer degree, and a list of the `p^k` values compute
- a maximal list of automorphisms over `Zmod(M)`, such that for every `j` in `len(moduli)`,
+ a maximal list of automorphisms over `Zmod(M)`, such that for every `j` in ``len(moduli)``,
each element reduces mod ``moduli[j]`` to one of the elements in ``automorphisms[j]`` that
has order = ``degree``
@@ -462,7 +463,7 @@ def CRT_automorphisms(automorphisms, order_elts, degree, moduli):
- ``order_elts`` -- a list of lists of the orders of the elements of ``automorphisms``
- - ``degree`` - a positive integer
+ - ``degree`` -- a positive integer
- ``moduli`` -- list of prime powers, i.e., `p^k`
@@ -470,7 +471,7 @@ def CRT_automorphisms(automorphisms, order_elts, degree, moduli):
EXAMPLES::
- sage: aut = [[matrix([[1,0],[0,1]]), matrix([[0,1],[1,0]])]]
+ sage: aut = [[matrix([[1,0], [0,1]]), matrix([[0,1], [1,0]])]]
sage: ords = [[1,2]]
sage: degree = 2
sage: mods = [5]
@@ -506,7 +507,7 @@ def valid_automorphisms(automorphisms_CRT, rational_function, ht_bound, M,
- ``rational_function`` -- A one variable rational function
- - ``ht_bound`` - a positive integer
+ - ``ht_bound`` -- a positive integer
- ``M`` -- a positive integer, a product of prime powers
@@ -519,7 +520,7 @@ def valid_automorphisms(automorphisms_CRT, rational_function, ht_bound, M,
sage: R. = PolynomialRing(QQ)
sage: F = z^2
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import valid_automorphisms
- sage: valid_automorphisms([matrix(GF(5),[[0,1],[1,0]])], F, 48, 5, True)
+ sage: valid_automorphisms([matrix(GF(5), [[0,1],[1,0]])], F, 48, 5, True)
[1/z]
"""
z = rational_function.parent().gen(0)
@@ -570,8 +571,8 @@ def remove_redundant_automorphisms(automorphisms, order_elts, moduli, integral_a
EXAMPLES::
sage: auts = [[matrix([[1,0],[0,1]]), matrix([[6,0],[0,1]]), matrix([[0,1],[1,0]]),
- ....: matrix([[6,1],[1,1]]), matrix([[1,1],[1,6]]), matrix([[0,6],[1,0]]),
- ....: matrix([[1,6],[1,1]]), matrix([[6,6],[1,6]])]]
+ ....: matrix([[6,1],[1,1]]), matrix([[1,1],[1,6]]), matrix([[0,6],[1,0]]),
+ ....: matrix([[1,6],[1,1]]), matrix([[6,6],[1,6]])]]
sage: ord_elts = [[1, 2, 2, 2, 2, 2, 4, 4]]
sage: mods = [7]
sage: R. = PolynomialRing(QQ)
@@ -625,15 +626,15 @@ def automorphism_group_QQ_CRT(rational_function, prime_lower_bound=4, return_fun
INPUT:
- - ``rational_function`` - a rational function of a univariate polynomial ring over `\QQ`
+ - ``rational_function`` -- a rational function of a univariate polynomial ring over `\QQ`
- - ``prime_lower_bound`` -- (default: 4) a positive integer - a lower bound for the primes to use for
+ - ``prime_lower_bound`` -- (default: 4) a positive integer; a lower bound for the primes to use for
the Chinese Remainder Theorem step
- - ``return_functions`` -- (default: True) boolean - True returns linear fractional transformations
+ - ``return_functions`` -- (default: ``True``) boolean; ``True`` returns linear fractional transformations
False returns elements of `PGL(2,\QQ)`
- - ``iso_type`` -- (default: False) boolean - True returns the isomorphism type of the automorphism group
+ - ``iso_type`` -- (default: ``False``) boolean; ``True`` returns the isomorphism type of the automorphism group
OUTPUT: a complete list of automorphisms of ``rational_function``
@@ -839,11 +840,11 @@ def automorphism_group_FF(rational_function, absolute=False, iso_type=False, ret
- ``rational_function`` -- a rational function defined over the fraction field
of a polynomial ring in one variable with finite field coefficients
- - ``absolute``-- (default: False) boolean - True returns the absolute automorphism group and a field of definition
+ - ``absolute``-- (default: ``False``) boolean; ``True`` returns the absolute automorphism group and a field of definition
- - ``iso_type`` -- (default: False) boolean - True returns the isomorphism type of the automorphism group
+ - ``iso_type`` -- (default: ``False``) boolean; ``True`` returns the isomorphism type of the automorphism group
- - ``return_functions`` -- (default: False) boolean, True returns linear fractional transformations
+ - ``return_functions`` -- (default: ``False``) boolean; ``True`` returns linear fractional transformations
False returns elements of `PGL(2)`
OUTPUT: a list of automorphisms of ``rational_function``
@@ -899,9 +900,9 @@ def automorphism_group_FF(rational_function, absolute=False, iso_type=False, ret
def field_descent(sigma, y):
r"""
- Function for descending an element in a field E to a subfield F.
+ Function for descending an element in a field `E` to a subfield `F`.
- Here F, E must be finite fields or number fields. This function determines
+ Here `F`, `E` must be finite fields or number fields. This function determines
the unique image of subfield which is ``y`` by the embedding ``sigma`` if it exists.
Otherwise returns ``None``.
This functionality is necessary because Sage does not keep track of subfields.
@@ -961,7 +962,7 @@ def rational_function_coefficient_descent(rational_function, sigma, poly_ring):
Here `F`, `E` must be finite fields or number fields.
It determines the unique rational function in fraction field of
- ``poly_ring`` which is the image of ``rational_function`` by ``ssigma``,
+ ``poly_ring`` which is the image of ``rational_function`` by ``sigma``,
if it exists, and otherwise returns ``None``.
INPUT:
@@ -1061,7 +1062,7 @@ def rational_function_reduce(rational_function):
- ``rational_function`` -- rational function `= F/G` in univariate polynomial ring
- OUTPUT: rational function -- `(F/gcd(F,G) ) / (G/gcd(F,G))`
+ OUTPUT: rational function -- `(F/\gcd(F,G)) / (G/\gcd(F,G))`
EXAMPLES::
@@ -1157,7 +1158,7 @@ def automorphism_group_FF_alg2(rational_function):
INPUT:
- - ``rational_function``--a rational function defined over a finite field
+ - ``rational_function`` -- a rational function defined over a finite field
OUTPUT: absolute automorphism group of ``rational_function`` and a ring of definition
@@ -1272,9 +1273,9 @@ def order_p_automorphisms(rational_function, pre_image):
INPUT:
- - ``rational_function``--rational function defined over finite field `F`
+ - ``rational_function`` -- rational function defined over finite field `F`
- - ``pre_image``--set of triples `[x, L, f]`, where `x` is an `F`-rational
+ - ``pre_image`` -- set of triples `[x, L, f]`, where `x` is an `F`-rational
fixed point of ``rational_function``, `L` is the list of `F`-rational
pre-images of `x` (excluding `x`), and `f` is the polynomial defining
the full set of pre-images of `x` (again excluding `x` itself)
@@ -1455,11 +1456,11 @@ def automorphisms_fixing_pair(rational_function, pair, quad):
INPUT:
- - ``rational_function``-- rational function defined over finite field `E`
+ - ``rational_function`` -- rational function defined over finite field `E`
- - ``pair``-- a pair of points of `\mathbb{P}^1(E)`
+ - ``pair`` -- a pair of points of `\mathbb{P}^1(E)`
- - ``quad``-- Boolean: an indicator if this is a quadratic pair of points
+ - ``quad`` -- Boolean: an indicator if this is a quadratic pair of points
OUTPUT: set of automorphisms with order prime to characteristic defined over `E` that fix
the pair, excluding the identity
@@ -1535,14 +1536,14 @@ def automorphism_group_FF_alg3(rational_function):
INPUT:
- - ``rational_function``--a rational function defined over a finite field `F`
+ - ``rational_function`` -- a rational function defined over a finite field `F`
OUTPUT: list of `F`-rational automorphisms of ``rational_function``
EXAMPLES::
sage: R. = PolynomialRing(GF(5^3,'t'))
- sage: f = (3456*z^4)
+ sage: f = 3456*z^4
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import automorphism_group_FF_alg3
sage: automorphism_group_FF_alg3(f)
[z, 1/z]
@@ -1694,14 +1695,14 @@ def automorphism_group_FF_alg3(rational_function):
def which_group(list_of_elements):
r"""
- Given a finite subgroup of `PGL2` determine its isomorphism class.
+ Given a finite subgroup of `PGL_2` determine its isomorphism class.
This function makes heavy use of the classification of finite subgroups of `PGL(2,K)`.
INPUT:
- ``list_of_elements``-- a finite list of elements of `PGL(2,K)`
- that we know a priori form a group
+ that we know a priori form a group
OUTPUT: a string -- the isomorphism type of the group
@@ -1844,9 +1845,10 @@ def conjugating_set_initializer(f, g):
``possible_targets`` tracks multiplier information::
sage: P. = ProjectiveSpace(QQ, 2)
- sage: f = DynamicalSystem([(8*x^7 - 35*x^4*y^3 - 35*x^4*z^3 - 7*x*y^6 - 140*x*y^3*z^3 \
- - 7*x*z^6), (-7*x^6*y - 35*x^3*y^4 - 140*x^3*y*z^3 + 8*y^7 - 35*y^4*z^3 \
- - 7*y*z^6), -7*x^6*z - 140*x^3*y^3*z - 35*x^3*z^4 - 7*y^6*z - 35*y^3*z^4 + 8*z^7])
+ sage: f = DynamicalSystem([
+ ....: 8*x^7 - 35*x^4*y^3 - 35*x^4*z^3 - 7*x*y^6 - 140*x*y^3*z^3 - 7*x*z^6,
+ ....: -7*x^6*y - 35*x^3*y^4 - 140*x^3*y*z^3 + 8*y^7 - 35*y^4*z^3 - 7*y*z^6,
+ ....: -7*x^6*z - 140*x^3*y^3*z - 35*x^3*z^4 - 7*y^6*z - 35*y^3*z^4 + 8*z^7])
sage: from sage.dynamics.arithmetic_dynamics.endPN_automorphism_group import conjugating_set_initializer
sage: source, possible_targets = conjugating_set_initializer(f, f)
sage: P.is_linearly_independent(source, 3)
diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py
index 58df10c4a4c..9a2e5fd6e15 100644
--- a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py
+++ b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py
@@ -22,6 +22,9 @@
# https://www.gnu.org/licenses/
# ****************************************************************************
+from copy import copy
+
+from sage.arith.misc import gcd
from sage.functions.hyperbolic import cosh
from sage.matrix.constructor import matrix
from sage.matrix.matrix_space import MatrixSpace
@@ -33,9 +36,7 @@
from sage.rings.polynomial.binary_form_reduce import covariant_z0, epsinv
from sage.rings.rational_field import QQ
from sage.schemes.affine.affine_space import AffineSpace
-from sage.symbolic.constants import e
-from sage.arith.misc import gcd
-from copy import copy
+
def bCheck(c, v, p, b):
r"""
@@ -89,7 +90,7 @@ def scale(c, v, p):
- ``c`` -- an integer polynomial
- - ``v`` -- an integer - the bound on the exponent from blift
+ - ``v`` -- an integer; the bound on the exponent from :func:`blift`
- ``p`` -- a prime
@@ -151,8 +152,8 @@ def blift(LF, Li, p, k, S=None, all_orbits=False):
sage: R. = PolynomialRing(QQ)
sage: from sage.dynamics.arithmetic_dynamics.endPN_minimal_model import blift
- sage: blift([8*b^3 + 12*b^2 + 6*b + 1, 48*b^2 + 483*b + 117, 72*b + 1341,\
- ....: -24*b^2 + 411*b + 99, -144*b + 1233, -216*b], 2, 3, 2)
+ sage: blift([8*b^3 + 12*b^2 + 6*b + 1, 48*b^2 + 483*b + 117, 72*b + 1341,
+ ....: -24*b^2 + 411*b + 99, -144*b + 1233, -216*b], 2, 3, 2)
[[True, 4]]
"""
@@ -244,8 +245,7 @@ def affine_minimal(vp, return_transformation=False, D=None, quick=False):
sage: affine_minimal(vp, True)
(
Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (X : Y) to
- (X^2 + Y^2 : X*Y)
+ Defn: Defined on coordinates by sending (X : Y) to (X^2 + Y^2 : X*Y)
,
[3 0]
[0 1]
@@ -330,16 +330,16 @@ def affine_minimal(vp, return_transformation=False, D=None, quick=False):
def Min(Fun, p, ubRes, conj, all_orbits=False):
r"""
- Local loop for Affine_minimal, where we check minimality at the prime p.
+ Local loop for :func:`affine_minimal`, where we check minimality at the prime `p`.
- First we bound the possible k in our transformations A = zp^k + b.
+ First we bound the possible `k` in our transformations `A = zp^k + b`.
See Theorems 3.3.2 and 3.3.3 in [Molnar]_.
INPUT:
- ``Fun`` -- a dynamical system on projective space
- - ``p`` - a prime
+ - ``p`` -- a prime
- ``ubRes`` -- integer, the upper bound needed for Th. 3.3.3 in [Molnar]_
@@ -357,7 +357,8 @@ def Min(Fun, p, ubRes, conj, all_orbits=False):
EXAMPLES::
sage: P. = ProjectiveSpace(QQ, 1)
- sage: f = DynamicalSystem_projective([149*x^2 + 39*x*y + y^2, -8*x^2 + 137*x*y + 33*y^2])
+ sage: f = DynamicalSystem_projective([149*x^2 + 39*x*y + y^2,
+ ....: -8*x^2 + 137*x*y + 33*y^2])
sage: from sage.dynamics.arithmetic_dynamics.endPN_minimal_model import Min
sage: Min(f, 3, -27000000, matrix(QQ,[[1, 0],[0, 1]]))
[
@@ -941,6 +942,8 @@ def get_bound_dynamical(F, f, m=1, dynatomic=True, prec=53, emb=None):
sage: get_bound_dynamical(f.dynatomic_polynomial(1), f)
35.5546923182219
"""
+ from sage.symbolic.constants import e
+
def coshdelta(z):
#The cosh of the hyperbolic distance from z = t+uj to j
return (z.norm() + 1)/(2*z.imag())
@@ -998,7 +1001,7 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith
- ``dynatomic`` -- boolean. whether ``F`` is the periodic points or the
formal periodic points of period ``m`` for ``f``
- - ``start_n`` - positive integer. the period used to start trying to
+ - ``start_n`` -- positive integer. the period used to start trying to
create associate binary form ``F``
- ``prec``-- positive integer. precision to use in CC
@@ -1010,7 +1013,7 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith
properties of the map are utilized to choose how to compute minimal
orbit representatives
- - ``check_minimal`` -- (default: True), boolean, whether to check
+ - ``check_minimal`` -- (default: ``True``), boolean, whether to check
if this map is a minimal model
OUTPUT: pair [dynamical system, matrix]
@@ -1020,7 +1023,7 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith
sage: from sage.dynamics.arithmetic_dynamics.endPN_minimal_model import smallest_dynamical
sage: P. = ProjectiveSpace(QQ,1)
sage: f = DynamicalSystem([50*x^2 + 795*x*y + 2120*y^2, 265*x^2 + 106*y^2])
- sage: smallest_dynamical(f) #long time
+ sage: smallest_dynamical(f) # long time
[
Dynamical System of Projective Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x : y) to
@@ -1030,6 +1033,8 @@ def smallest_dynamical(f, dynatomic=True, start_n=1, prec=53, emb=None, algorith
[0 1]
]
"""
+ from sage.symbolic.constants import e
+
def insert_item(pts, item, index):
# binary insertion to maintain list of points left to consider
N = len(pts)
diff --git a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py
index d09b15ab78c..0afff17895c 100644
--- a/src/sage/dynamics/arithmetic_dynamics/generic_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/generic_ds.py
@@ -27,17 +27,21 @@ class initialization directly.
# http://www.gnu.org/licenses/
#*****************************************************************************
+from copy import copy
+
from sage.categories.homset import End
from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
-from sage.schemes.generic.morphism import SchemeMorphism_polynomial
+from sage.misc.lazy_import import lazy_import
+from sage.rings.finite_rings.finite_field_base import FiniteField
+from sage.rings.rational_field import QQ
from sage.schemes.affine.affine_space import is_AffineSpace
from sage.schemes.affine.affine_subscheme import AlgebraicScheme_subscheme_affine
-from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_generic
-from sage.rings.finite_rings.finite_field_base import FiniteField
-from sage.rings.qqbar import AlgebraicField_common
from sage.schemes.berkovich.berkovich_space import is_Berkovich_Cp
-from sage.rings.rational_field import QQ
-from copy import copy
+from sage.schemes.generic.morphism import SchemeMorphism_polynomial
+
+lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic')
+lazy_import('sage.rings.qqbar', 'AlgebraicField_common')
+
class DynamicalSystem(SchemeMorphism_polynomial,
metaclass=InheritComparisonClasscallMetaclass):
@@ -78,14 +82,14 @@ class DynamicalSystem(SchemeMorphism_polynomial,
EXAMPLES::
sage: A. = AffineSpace(QQ,1)
- sage: f = DynamicalSystem_affine([x^2+1])
+ sage: f = DynamicalSystem_affine([x^2 + 1])
sage: type(f)
::
sage: P. = ProjectiveSpace(QQ,1)
- sage: f = DynamicalSystem_projective([x^2+y^2, y^2])
+ sage: f = DynamicalSystem_projective([x^2 + y^2, y^2])
sage: type(f)
@@ -96,8 +100,7 @@ class DynamicalSystem(SchemeMorphism_polynomial,
sage: DynamicalSystem(H([y, x]))
Dynamical System of Projective Space of dimension 1 over Complex Field
with 53 bits of precision
- Defn: Defined on coordinates by sending (x : y) to
- (y : x)
+ Defn: Defined on coordinates by sending (x : y) to (y : x)
:class:`DynamicalSystem` defaults to projective::
@@ -109,16 +112,14 @@ class DynamicalSystem(SchemeMorphism_polynomial,
::
- sage: A. = AffineSpace(QQ, 2)
- sage: DynamicalSystem([y, x], domain=A)
- Dynamical System of Affine Space of dimension 2 over Rational Field
- Defn: Defined on coordinates by sending (x, y) to
- (y, x)
- sage: H = End(A)
- sage: DynamicalSystem(H([y, x]))
- Dynamical System of Affine Space of dimension 2 over Rational Field
- Defn: Defined on coordinates by sending (x, y) to
- (y, x)
+ sage: A. = AffineSpace(QQ, 2)
+ sage: DynamicalSystem([y, x], domain=A)
+ Dynamical System of Affine Space of dimension 2 over Rational Field
+ Defn: Defined on coordinates by sending (x, y) to (y, x)
+ sage: H = End(A)
+ sage: DynamicalSystem(H([y, x]))
+ Dynamical System of Affine Space of dimension 2 over Rational Field
+ Defn: Defined on coordinates by sending (x, y) to (y, x)
Note that ``domain`` is ignored if an endomorphism is passed in::
@@ -134,9 +135,12 @@ class DynamicalSystem(SchemeMorphism_polynomial,
sage: P. = ProjectiveSpace(ZZ, 1)
sage: DynamicalSystem([CC.0*x^2, 4/5*y^2])
- Dynamical System of Projective Space of dimension 1 over Complex Field with 53 bits of precision
+ Dynamical System of
+ Projective Space of dimension 1 over Complex Field with 53 bits of precision
Defn: Defined on coordinates by sending (x : y) to
(1.00000000000000*I*x^2 : 0.800000000000000*y^2)
+
+ sage: # needs sage.rings.finite_rings
sage: P. = ProjectiveSpace(GF(5), 1)
sage: K. = GF(25)
sage: DynamicalSystem([GF(5)(3)*x^2, K(t)*y^2])
@@ -179,7 +183,7 @@ def __init__(self, polys_or_rat_fncts, domain):
sage: from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem
sage: P. = ProjectiveSpace(QQ,1)
- sage: f = DynamicalSystem_projective([x^2+y^2, y^2])
+ sage: f = DynamicalSystem_projective([x^2 + y^2, y^2])
sage: isinstance(f, DynamicalSystem)
True
"""
@@ -239,7 +243,7 @@ def as_scheme_morphism(self):
::
sage: P. = ProjectiveSpace(QQ, 1)
- sage: f = DynamicalSystem_projective([x^2-y^2, y^2])
+ sage: f = DynamicalSystem_projective([x^2 - y^2, y^2])
sage: type(f.as_scheme_morphism())
@@ -253,21 +257,21 @@ def as_scheme_morphism(self):
::
sage: A. = AffineSpace(ZZ, 2)
- sage: f = DynamicalSystem_affine([x^2-2, y^2])
+ sage: f = DynamicalSystem_affine([x^2 - 2, y^2])
sage: type(f.as_scheme_morphism())
::
sage: A. = AffineSpace(QQ, 2)
- sage: f = DynamicalSystem_affine([x^2-2, y^2])
+ sage: f = DynamicalSystem_affine([x^2 - 2, y^2])
sage: type(f.as_scheme_morphism())
::
sage: A. = AffineSpace(GF(3), 2)
- sage: f = DynamicalSystem_affine([x^2-2, y^2])
+ sage: f = DynamicalSystem_affine([x^2 - 2, y^2])
sage: type(f.as_scheme_morphism())
"""
@@ -295,8 +299,7 @@ def change_ring(self, R, check=True):
sage: f = DynamicalSystem_projective([3*x^2, y^2])
sage: f.change_ring(GF(5))
Dynamical System of Projective Space of dimension 1 over Finite Field of size 5
- Defn: Defined on coordinates by sending (x : y) to
- (-2*x^2 : y^2)
+ Defn: Defined on coordinates by sending (x : y) to (-2*x^2 : y^2)
"""
f = self.as_scheme_morphism()
F = f.change_ring(R)
@@ -325,11 +328,10 @@ def specialization(self, D=None, phi=None, homset=None):
sage: R. = PolynomialRing(QQ)
sage: P. = ProjectiveSpace(R, 1)
- sage: f = DynamicalSystem_projective([x^2 + c*y^2,y^2], domain=P)
+ sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2], domain=P)
sage: f.specialization({c:1})
Dynamical System of Projective Space of dimension 1 over Rational Field
- Defn: Defined on coordinates by sending (x : y) to
- (x^2 + y^2 : y^2)
+ Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2)
"""
F = self.as_scheme_morphism().specialization(D, phi, homset)
return F.as_dynamical_system()
@@ -362,8 +364,9 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals
EXAMPLES:
- Note that the number of critical points is 2d-2, but (1:0) has multiplicity 2 in this case::
+ Note that the number of critical points is `2d-2`, but `(1:0)` has multiplicity 2 in this case::
+ sage: # needs sage.libs.singular sage.rings.number_field
sage: P. = ProjectiveSpace(QQ, 1)
sage: f = DynamicalSystem([1/3*x^3 + x*y^2, y^3], domain=P)
sage: f.critical_points()
@@ -376,6 +379,7 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals
::
+ sage: # needs sage.libs.singular sage.rings.number_field
sage: A. = AffineSpace(QQ, 1)
sage: f = DynamicalSystem([z^4 + 2*z^2 + 2], domain=A)
sage: K. = f.field_of_definition_critical(); K
@@ -383,6 +387,7 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals
::
+ sage: # needs sage.libs.singular sage.rings.finite_rings
sage: G. = GF(9)
sage: R. = G[]
sage: R.irreducible_element(3, algorithm='first_lexicographic')
@@ -392,10 +397,11 @@ def field_of_definition_critical(self, return_embedding=False, simplify_all=Fals
sage: f[0].derivative(x).univariate_polynomial().is_irreducible()
True
sage: f.field_of_definition_critical(return_embedding=True, names='b')
- (Finite Field in b of size 3^6, Ring morphism:
- From: Finite Field in a of size 3^2
- To: Finite Field in b of size 3^6
- Defn: a |--> 2*b^5 + 2*b^3 + b^2 + 2*b + 2)
+ (Finite Field in b of size 3^6,
+ Ring morphism:
+ From: Finite Field in a of size 3^2
+ To: Finite Field in b of size 3^6
+ Defn: a |--> 2*b^5 + 2*b^3 + b^2 + 2*b + 2)
"""
ds = copy(self)
space = ds.domain().ambient_space()
@@ -469,13 +475,14 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False,
EXAMPLES::
+ sage: # needs sage.libs.singular sage.rings.number_field
sage: P. = ProjectiveSpace(QQ, 1)
sage: f = DynamicalSystem([x^2, y^2], domain=P)
sage: f.periodic_points(3, minimal=False)
[(0 : 1), (1 : 0), (1 : 1)]
sage: N. = f.field_of_definition_periodic(3); N
Number Field in a with defining polynomial x^6 + x^5 + x^4 + x^3 + x^2 + x + 1
- sage: sorted(f.periodic_points(3,minimal=False, R=N), key=str)
+ sage: sorted(f.periodic_points(3, minimal=False, R=N), key=str)
[(-a^5 - a^4 - a^3 - a^2 - a - 1 : 1),
(0 : 1),
(1 : 0),
@@ -488,6 +495,7 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False,
::
+ sage: # needs sage.libs.singular sage.rings.number_field
sage: A. = AffineSpace(QQ, 1)
sage: f = DynamicalSystem([(z^2 + 1)/(2*z + 1)], domain=A)
sage: K. = f.field_of_definition_periodic(2); K
@@ -497,6 +505,7 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False,
::
+ sage: # needs sage.rings.finite_rings
sage: G. = GF(4)
sage: A. = AffineSpace(G, 1)
sage: f = DynamicalSystem([x^2 + (a+1)*x + 1], domain=A)
@@ -504,10 +513,11 @@ def field_of_definition_periodic(self, n, formal=False, return_embedding=False,
sage: (g-x).univariate_polynomial().factor()
(x + 1) * (x + a + 1) * (x^2 + a*x + 1)
sage: f.field_of_definition_periodic(2, return_embedding=True, names='b')
- (Finite Field in b of size 2^4, Ring morphism:
- From: Finite Field in a of size 2^2
- To: Finite Field in b of size 2^4
- Defn: a |--> b^2 + b)
+ (Finite Field in b of size 2^4,
+ Ring morphism:
+ From: Finite Field in a of size 2^2
+ To: Finite Field in b of size 2^4
+ Defn: a |--> b^2 + b)
"""
ds = copy(self)
n = int(n)
@@ -587,14 +597,16 @@ def field_of_definition_preimage(self, point, n, return_embedding=False, simplif
sage: P. = ProjectiveSpace(QQ, 1)
sage: f = DynamicalSystem([1/3*x^2 + 2/3*x*y, x^2 - 2*y^2], domain=P)
- sage: N. = f.field_of_definition_preimage(P(1,1), 2, simplify_all=True); N
- Number Field in a with defining polynomial x^8 - 4*x^7 - 128*x^6 + 398*x^5 + 3913*x^4 - 8494*x^3 - 26250*x^2 + 30564*x - 2916
+ sage: N. = f.field_of_definition_preimage(P(1,1), 2, # needs sage.rings.number_field
+ ....: simplify_all=True); N
+ Number Field in a with defining polynomial
+ x^8 - 4*x^7 - 128*x^6 + 398*x^5 + 3913*x^4 - 8494*x^3 - 26250*x^2 + 30564*x - 2916
::
sage: A. = AffineSpace(QQ, 1)
sage: f = DynamicalSystem([z^2], domain=A)
- sage: K. = f.field_of_definition_preimage(A(1), 3); K
+ sage: K. = f.field_of_definition_preimage(A(1), 3); K # needs sage.rings.number_field
Number Field in a with defining polynomial z^4 + 1
::
@@ -602,11 +614,13 @@ def field_of_definition_preimage(self, point, n, return_embedding=False, simplif
sage: G = GF(5)
sage: P. = ProjectiveSpace(G, 1)
sage: f = DynamicalSystem([x^2 + 2*y^2, y^2], domain=P)
- sage: f.field_of_definition_preimage(P(2,1), 2, return_embedding=True, names='a')
- (Finite Field in a of size 5^2, Ring morphism:
- From: Finite Field of size 5
- To: Finite Field in a of size 5^2
- Defn: 1 |--> 1)
+ sage: f.field_of_definition_preimage(P(2,1), 2, return_embedding=True, # needs sage.rings.number_field
+ ....: names='a')
+ (Finite Field in a of size 5^2,
+ Ring morphism:
+ From: Finite Field of size 5
+ To: Finite Field in a of size 5^2
+ Defn: 1 |--> 1)
"""
ds = copy(self)
n = int(n)
diff --git a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py
index 9d6836c1e36..44565197717 100644
--- a/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/product_projective_ds.py
@@ -1,7 +1,7 @@
r"""
Dynamical systems for products of projective spaces
-This class builds on the prouct projective space class.
+This class builds on the product projective space class.
The main constructor functions are given by ``DynamicalSystem`` and
``DynamicalSystem_projective``. The constructors function can take either
polynomials or a morphism from which to construct a dynamical system.
@@ -47,19 +47,18 @@ class DynamicalSystem_product_projective(DynamicalSystem,
INPUT:
- - ``polys`` -- a list of ``n_1 + \cdots + n_r`` multi-homogeneous polynomials, all
+ - ``polys`` -- a list of `n_1 + \cdots + n_r` multi-homogeneous polynomials, all
of which should have the same parent
- ``domain`` -- a projective scheme embedded in
- ``P^{n_1-1} \times \cdots \times P^{n_r-1}``
+ `P^{n_1-1} \times \cdots \times P^{n_r-1}`
EXAMPLES::
sage: T. = ProductProjectiveSpaces([2, 1], QQ)
sage: DynamicalSystem_projective([x^2, y^2, z^2, w^2, u^2], domain=T)
Dynamical System of Product of projective spaces P^2 x P^1 over Rational Field
- Defn: Defined by sending (x : y : z , w : u) to
- (x^2 : y^2 : z^2 , w^2 : u^2).
+ Defn: Defined by sending (x : y : z , w : u) to (x^2 : y^2 : z^2 , w^2 : u^2).
"""
def __init__(self, polys, domain):
@@ -86,7 +85,7 @@ def _call_with_args(self, P, check=True):
- ``P`` -- a point in the domain
- - ``check`` -- Boolean - whether or not to perform the input checks
+ - ``check`` -- Boolean; whether or not to perform the input checks
on the image point (Default: ``True``)
OUTPUT: The image point in the codomain
@@ -135,7 +134,8 @@ def nth_iterate(self, P, n, normalize=False):
EXAMPLES::
sage: Z. = ProductProjectiveSpaces([1, 2], QQ)
- sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y], domain=Z)
+ sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y],
+ ....: domain=Z)
sage: P = Z([1, 1, 1, 1, 1])
sage: f.nth_iterate(P, 3)
(1/1872 : 1 , 1 : 1 : 0)
@@ -145,7 +145,7 @@ def nth_iterate(self, P, n, normalize=False):
sage: Z. = ProductProjectiveSpaces([1, 1], ZZ)
sage: f = DynamicalSystem_projective([a*b, b^2, x^3 - y^3, y^2*x], domain=Z)
sage: P = Z([2, 6, 2, 4])
- sage: f.nth_iterate(P, 2, normalize = True)
+ sage: f.nth_iterate(P, 2, normalize=True)
(1 : 3 , 407 : 112)
"""
if P.codomain() != self.domain():
@@ -194,10 +194,12 @@ def orbit(self, P, N, **kwds):
EXAMPLES::
sage: Z. = ProductProjectiveSpaces([1, 2], QQ)
- sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y], domain=Z)
+ sage: f = DynamicalSystem_projective([a^3, b^3 + a*b^2, x^2, y^2 - z^2, z*y],
+ ....: domain=Z)
sage: P = Z([1, 1, 1, 1, 1])
sage: f.orbit(P, 3)
- [(1 : 1 , 1 : 1 : 1), (1/2 : 1 , 1 : 0 : 1), (1/12 : 1 , -1 : 1 : 0), (1/1872 : 1 , 1 : 1 : 0)]
+ [(1 : 1 , 1 : 1 : 1), (1/2 : 1 , 1 : 0 : 1),
+ (1/12 : 1 , -1 : 1 : 0), (1/1872 : 1 , 1 : 1 : 0)]
::
@@ -205,7 +207,8 @@ def orbit(self, P, N, **kwds):
sage: f = DynamicalSystem_projective([a*b, b^2, x^3 - y^3, y^2*x], domain=Z)
sage: P = Z([2, 6, 2, 4])
sage: f.orbit(P, 3, normalize=True)
- [(1 : 3 , 1 : 2), (1 : 3 , -7 : 4), (1 : 3 , 407 : 112), (1 : 3 , 66014215 : 5105408)]
+ [(1 : 3 , 1 : 2), (1 : 3 , -7 : 4),
+ (1 : 3 , 407 : 112), (1 : 3 , 66014215 : 5105408)]
"""
if P.codomain() != self.domain():
raise TypeError("point is not defined over domain of function")
@@ -241,7 +244,7 @@ def orbit(self, P, N, **kwds):
def nth_iterate_map(self, n):
r"""
- Return the nth iterate of this dynamical system.
+ Return the ``n``-th iterate of this dynamical system.
ALGORITHM:
@@ -301,22 +304,22 @@ def cyclegraph(self):
EXAMPLES::
sage: P. = ProductProjectiveSpaces(GF(3), [1,1])
- sage: f = DynamicalSystem_projective([a^2,b^2,c^2,d^2], domain=P)
- sage: f.cyclegraph()
+ sage: f = DynamicalSystem_projective([a^2, b^2, c^2, d^2], domain=P)
+ sage: f.cyclegraph() # needs sage.graphs
Looped digraph on 16 vertices
::
sage: P. = ProductProjectiveSpaces(GF(5), [1,1])
- sage: f = DynamicalSystem_projective([a^2,b^2,c,d], domain=P)
- sage: f.cyclegraph()
+ sage: f = DynamicalSystem_projective([a^2, b^2, c, d], domain=P)
+ sage: f.cyclegraph() # needs sage.graphs
Looped digraph on 36 vertices
::
sage: P. = ProductProjectiveSpaces(GF(2), [1,2])
- sage: f = DynamicalSystem_projective([a^2,b^2,c,d,e], domain=P)
- sage: f.cyclegraph()
+ sage: f = DynamicalSystem_projective([a^2, b^2, c, d, e], domain=P)
+ sage: f.cyclegraph() # needs sage.graphs
Looped digraph on 21 vertices
.. TODO:: Dynamical systems for subschemes of product projective spaces needs work.
diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
index ef1e50c78e9..606d991b692 100644
--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
@@ -58,7 +58,7 @@ class initialization directly.
import sage.rings.abc
from sage.arith.functions import lcm
-from sage.arith.misc import binomial, gcd, is_prime, moebius, next_prime, primes
+from sage.arith.misc import binomial, gcd, integer_ceil as ceil, is_prime, moebius, next_prime, primes
from sage.calculus.functions import jacobian
from sage.categories.fields import Fields
from sage.categories.finite_fields import FiniteFields
@@ -76,17 +76,15 @@ class initialization directly.
from sage.dynamics.arithmetic_dynamics.projective_ds_helper import (
_fast_possible_periods,
_all_periodic_points)
-from sage.functions.other import ceil
-from sage.libs.pari.all import PariError
from sage.matrix.constructor import matrix, identity_matrix
from sage.misc.cachefunc import cached_method
from sage.misc.classcall_metaclass import typecall
from sage.misc.functional import sqrt
+from sage.misc.lazy_import import lazy_import
from sage.misc.mrange import xmrange
from sage.modules.free_module_element import vector
from sage.parallel.ncpus import ncpus
from sage.parallel.use_fork import p_iter_fork
-from sage.rings.algebraic_closure_finite_field import AlgebraicClosureFiniteField_generic
from sage.rings.complex_mpfr import ComplexField
from sage.rings.finite_rings.finite_field_base import FiniteField
from sage.rings.finite_rings.finite_field_constructor import GF
@@ -98,12 +96,9 @@ class initialization directly.
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.flatten import FlatteningMorphism, UnflatteningMorphism
from sage.rings.morphism import RingHomomorphism_im_gens
-from sage.rings.number_field.number_field_ideal import NumberFieldFractionalIdeal
-from sage.rings.padics.factory import Qp
from sage.rings.polynomial.multi_polynomial_ring_base import is_MPolynomialRing
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
-from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics
from sage.rings.quotient_ring import QuotientRing_generic
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RealField
@@ -116,7 +111,16 @@ class initialization directly.
from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace
from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective
from sage.structure.element import get_coercion_model
-from sage.symbolic.constants import e
+
+lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic')
+lazy_import('sage.rings.number_field.number_field_ideal', 'NumberFieldFractionalIdeal')
+lazy_import('sage.rings.padics.factory', 'Qp')
+lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics')
+
+try:
+ from sage.libs.pari.all import PariError
+except ImportError:
+ PariError = ()
class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space,
@@ -195,8 +199,8 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space,
Symbolic Ring elements are not allowed::
- sage: x,y = var('x,y')
- sage: DynamicalSystem_projective([x^2, y^2])
+ sage: x,y = var('x,y') # needs sage.symbolic
+ sage: DynamicalSystem_projective([x^2, y^2]) # needs sage.symbolic
Traceback (most recent call last):
...
ValueError: [x^2, y^2] must be elements of a polynomial ring
@@ -225,8 +229,8 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space,
sage: P. = ProjectiveSpace(CC, 2)
sage: X = P.subscheme([x - y])
- sage: u,v,w = X.coordinate_ring().gens()
- sage: DynamicalSystem_projective([u^2, v^2, w*u], domain=X)
+ sage: u,v,w = X.coordinate_ring().gens() # needs sage.rings.function_field
+ sage: DynamicalSystem_projective([u^2, v^2, w*u], domain=X) # needs sage.rings.function_field
Dynamical System of Closed subscheme of Projective Space of dimension
2 over Complex Field with 53 bits of precision defined by:
x - y
@@ -242,7 +246,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space,
sage: P. = ProjectiveSpace(QQ, 2)
sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, x^2])
sage: X = P.subscheme(y - z)
- sage: f(f(f(X)))
+ sage: f(f(f(X))) # needs sage.rings.function_field
Closed subscheme of Projective Space of dimension 2 over Rational Field
defined by:
y - z
@@ -251,7 +255,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space,
sage: P.