Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Making the copy of IndexedFreeModuleElement idempotent since it is im…
Browse files Browse the repository at this point in the history
…mutable.
  • Loading branch information
tscrim committed Aug 29, 2022
1 parent 12be2d9 commit 958359f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/sage/modules/with_basis/indexed_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ An element in an indexed free module
AUTHORS:
- Travis Scrimshaw (03-2017): Moved code from :mod:`sage.combinat.free_module`.
- Travis Scrimshaw (29-08-2022): Implemented an idempotent copy.
"""

#*****************************************************************************
# Copyright (C) 2017 Travis Scrimshaw <tcscrims at gmail.com>
# Copyright (C) 2017, 2022 Travis Scrimshaw <tcscrims at 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
Expand Down Expand Up @@ -180,6 +181,32 @@ cdef class IndexedFreeModuleElement(ModuleElement):
for k, v in state[1].iteritems():
setattr(self, k, v)
def __copy__(self):
r"""
Return ``self`` since ``self`` is immutable.
EXAMPLES::
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: x = F.an_element()
sage: copy(x) is x
True
"""
return self
def __deepcopy__(self, memo=None):
r"""
Return ``self`` since ``self`` is immutable.
EXAMPLES::
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: x = F.an_element()
sage: deepcopy(x) is x
True
"""
return self
cpdef dict monomial_coefficients(self, bint copy=True):
"""
Return the internal dictionary which has the combinatorial objects
Expand Down

0 comments on commit 958359f

Please sign in to comment.