rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if selected: self.set_selected(selected, jump=True) else: self.set_selected(None, jump=True)
self.set_selected(selected, jump=True)
def fill(self, songs): restore = self.__restore_values selected = (restore and restore.pop(0)) or self.get_selected() model = self.get_model() if len(model) == len(selected): selected = None self.inhibit() model.clear() self._add(songs) self.uninhibit() if selected: self.set_selected(selected, jump=True) else: self.set...
values = map(util.escape, self.__format(song)) for row in self.get_model(): if row[0] in values:
values = self.__get_format_keys(song) for row in self.__model: if row[0] != ALL and row[1].key in values:
def scroll(self, song): values = map(util.escape, self.__format(song)) for row in self.get_model(): if row[0] in values: self.scroll_to_cell( row.path[0], use_align=True, row_align=0.5) sel = self.get_selection() sel.unselect_all() sel.select_path(row.path[0]) break
try: model, rows = self.get_selection().get_selected_rows()
try: model, paths = self.get_selection().get_selected_rows()
def get_selected(self): try: model, rows = self.get_selection().get_selected_rows() except AttributeError: return [] else: return [model[row][0] for row in rows]
else: return [model[row][0] for row in rows]
else: if not paths: return [] if model[paths[0]][0] == ALL: return [model[p][1].key for p in paths[1:]] + [None] else: return [model[p][1].key for p in paths]
def get_selected(self): try: model, rows = self.get_selection().get_selected_rows() except AttributeError: return [] else: return [model[row][0] for row in rows]
model = self.get_model()
model = self.__model if not len(model): return
def set_selected(self, values, jump=False): model = self.get_model() selection = self.get_selection() if values == self.get_selected(): model, rows = selection.get_selected_rows() for row in rows: self.scroll_to_cell(row) break return elif values is None and selection.path_is_selected((0,)): return
if values == self.get_selected(): model, rows = selection.get_selected_rows() for row in rows: self.scroll_to_cell(row)
if values is None and selection.path_is_selected((0,)): self.scroll_to_cell((0,)) return elif values == self.get_selected(): model, paths = selection.get_selected_rows() for path in paths: self.scroll_to_cell(path)
def set_selected(self, values, jump=False): model = self.get_model() selection = self.get_selection() if values == self.get_selected(): model, rows = selection.get_selected_rows() for row in rows: self.scroll_to_cell(row) break return elif values is None and selection.path_is_selected((0,)): return
elif values is None and selection.path_is_selected((0,)): return
if values is None: selection.select_path((0,)) if jump: self.scroll_to_cell((0,)) return
def set_selected(self, values, jump=False): model = self.get_model() selection = self.get_selection() if values == self.get_selected(): model, rows = selection.get_selected_rows() for row in rows: self.scroll_to_cell(row) break return elif values is None and selection.path_is_selected((0,)): return
first = 0 if values is None: selection.select_path((0,)) else: for row in model: if row[0] in values: selection.select_path(row.path) first = first or row.path[0] if first == 0: selection.select_path((0,)) if jump and len(model): self.scroll_to_cell(first)
first = None if None in values: selection.select_path((0,)) first = ((0,)) for row in model: if row[0] != ALL and row[1].key in values: selection.select_path(row.path) first = first or row.path if jump and first: self.scroll_to_cell(first)
def set_selected(self, values, jump=False): model = self.get_model() selection = self.get_selection() if values == self.get_selected(): model, rows = selection.get_selected_rows() for row in rows: self.scroll_to_cell(row) break return elif values is None and selection.path_is_selected((0,)): return
model = self.get_model()
if len(self.tags) == 1 and tag in self.tags: self.set_selected(values, jump) return
def set_selected_by_tag(self, tag, values, jump=False): model = self.get_model() pattern_values = [] values = set(values) for row in model: if row[1]: song = iter(row[1]).next() if set(song.list(tag)) & values: pattern_values.append(row[0]) self.set_selected(pattern_values, jump)
values = set(values) for row in model: if row[1]: song = iter(row[1]).next() if set(song.list(tag)) & values: pattern_values.append(row[0])
for type, data in self.__model: if type == SONGS: for value in values: if data.all_have(tag, value): pattern_values.append(data.key) break if "" in values: pattern_values.append("")
def set_selected_by_tag(self, tag, values, jump=False): model = self.get_model() pattern_values = [] values = set(values) for row in model: if row[1]: song = iter(row[1]).next() if set(song.list(tag)) & values: pattern_values.append(row[0]) self.set_selected(pattern_values, jump)
def __get_songs(self):
def __get_selected_songs(self, sort=False):
def __get_songs(self): model, rows = self.get_selection().get_selected_rows() s = set() if rows and rows[0] == (0,): for row in model: if row[1]: s.update(row[1]) else: for row in rows: s.update(model[row][1]) return s
if rows and rows[0] == (0,):
if not rows: return s if model[rows[0]][0] == ALL:
def __get_songs(self): model, rows = self.get_selection().get_selected_rows() s = set() if rows and rows[0] == (0,): for row in model: if row[1]: s.update(row[1]) else: for row in rows: s.update(model[row][1]) return s
if row[1]: s.update(row[1])
if row[0] != ALL: s |= row[1].songs
def __get_songs(self): model, rows = self.get_selection().get_selected_rows() s = set() if rows and rows[0] == (0,): for row in model: if row[1]: s.update(row[1]) else: for row in rows: s.update(model[row][1]) return s
s.update(model[row][1])
s |= model[row][1].songs if sort: return sorted(s, key=operator.attrgetter("sort_key"))
def __get_songs(self): model, rows = self.get_selection().get_selected_rows() s = set() if rows and rows[0] == (0,): for row in model: if row[1]: s.update(row[1]) else: for row in rows: s.update(model[row][1]) return s
prefs.connect('clicked', Preferences) select.connect('clicked', self.__all)
s = prefs.connect('clicked', Preferences) self.connect_object('destroy', prefs.disconnect, s) s = select.connect('clicked', self.__all) self.connect_object('destroy', select.disconnect, s)
def __init__(self, library, player): super(PanedBrowser, self).__init__(library, player, limit=False)
def can_filter(self, key):
def __get_filter_pane(self, key): """Get the best pane for filtering etc.""" canditates = []
def can_filter(self, key): for pane in self.__panes: if (key in pane.tags or (key in PEOPLE and "~people" in pane.tags)): return True else: return False
return True else: return False
canditates.append((len(pane.tags), pane)) canditates.sort() return (canditates and canditates[0][1]) or None def can_filter(self, key): return (self.__get_filter_pane(key) is not None)
def can_filter(self, key): for pane in self.__panes: if (key in pane.tags or (key in PEOPLE and "~people" in pane.tags)): return True else: return False
self.__panes[-1].inhibit() for pane in self.__panes: if (key in pane.tags or (key in PEOPLE and "~people" in pane.tags)): pane.set_selected_by_tag(key, values, True) else: pane.set_selected(None, True) self.__panes[-1].uninhibit() self.__panes[-1].get_selection().emit('changed')
filter_pane = self.__get_filter_pane(key) for pane in self.__panes: if pane is filter_pane: filter_pane.set_selected_by_tag(key, values, True) return pane.set_selected(None, True)
def filter(self, key, values): self.__panes[-1].inhibit() for pane in self.__panes: if (key in pane.tags or (key in PEOPLE and "~people" in pane.tags)): pane.set_selected_by_tag(key, values, True) else: pane.set_selected(None, True) self.__panes[-1].uninhibit() self.__panes[-1].get_selection().emit('changed')
for pane in self.__panes: if (key in pane.tags or (key in PEOPLE and "~people" in pane.tags)): return [util.unescape(row[0]) for row in pane.get_model() if row[0] and not row[0].startswith("<")] else: return []
filter_pane = self.__get_filter_pane(key) for pane in self.__panes: if pane is filter_pane: return filter_pane.list(key) pane.set_selected(None, True) return []
def list(self, key): for pane in self.__panes: if (key in pane.tags or (key in PEOPLE and "~people" in pane.tags)): return [util.unescape(row[0]) for row in pane.get_model() if row[0] and not row[0].startswith("<")] else: return []
selected.append("\t".join(pane.get_selected()))
values = pane.get_selected() all = None in values if all: values.remove(None) all = str(int(bool(all))) values.insert(0, all) selected.append("\t".join(values))
def save(self): super(PanedBrowser, self).save() selected = [] for pane in self.__panes: selected.append("\t".join(pane.get_selected())) config.set("browsers", "pane_selection", "\n".join(selected))
PanedBrowser.Pane.set_restore([sel.split("\t") for sel in selected])
pane_values = [sel.split("\t") for sel in selected] for pane in pane_values: try: if int(pane[0]): pane[0] = None else: del pane[0] except (ValueError, IndexError): pass PanedBrowser.Pane.set_restore(pane_values)
def restore(self): super(PanedBrowser, self).restore() selected = config.get("browsers", "pane_selection").split("\n") PanedBrowser.Pane.set_restore([sel.split("\t") for sel in selected])
int(prop_get(prop_if, 'partition-type')) == 0:
int(prop_get(prop_if, 'partition-type'), 16) == 0:
def __build_dev(self, path): """Return the right device instance by determining the supported AccessProtocol""" prop_if = self.__get_dev_prop_interface(path) prop_get = self.__get_dev_property
self.bin.set_state(gst.STATE_PLAYING)
if not self._inhibit_play: self.bin.set_state(gst.STATE_PLAYING)
def _set_paused(self, paused): if paused != self._paused: self._paused = paused if self.song: if not self.bin: if self.__init_pipeline(): self.bin.set_property('uri', self.song("~uri")) else: # Backend error; show message and halt playback ErrorMessage(None, _("Output Error"), _("GStreamer output pipeline could not be ...
try: self._times = config.get("plugins", self._pref_name).split()[:7]
try: self._times = config.get("plugins", self._pref_name).split(' ')[:7]
def __init__(self): try: self._times = config.get("plugins", self._pref_name).split()[:7] except: pass else: self._times = (self._times + ["HH:MM"] * 7)[:7] gobject.timeout_add(30000, self._check)
alb = album[0].comma("album").replace('"', '') art = get_artist(album).replace('"', '') sq.set_text('"%s" AND artist:"%s" AND tracks:%d' % (alb, art, get_trackcount(album)) )
alb = '"%s"' % album[0].comma("album").replace('"', '') art = get_artist(album) if art: alb = '%s AND artist:"%s"' % (alb, art.replace('"', '')) sq.set_text('%s AND tracks:%d' % (alb, get_trackcount(album)) )
def __init__(self, album, cache): self.album = album
**NOTE: precision loss if P,Q in the infinite disc INPUT: - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points) OUTPUT: the Coleman integrals \int_P^Q w_i for w_i basis elements
Computes the Coleman integrals on basis differentials INPUT: - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points) OUTPUT: the Coleman integrals \int_P^Q w_i for w_i basis elements
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
dim = 2*self.genus()
prec = K.precision_cap() g = self.genus() dim = 2*g
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
L = [f(R(PP[0]), R(PP[1])) for f in forms]
L = [f(PP[0], PP[1]) for f in forms]
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
A simple example, integrating dx::
A simple example, integrating dx:
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
Yet another example::
Yet another example:
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
R = self.base_ring()[str(self.variables()[0])]
if self.is_constant(): R = self.base_ring()[self.parent().variable_names()[0]] else: R = self.base_ring()[str(self.variables()[0])]
def univariate_polynomial(self, R=None): """ Returns a univariate polynomial associated to this multivariate polynomial. INPUT: - ``R`` - (default: None) PolynomialRing If this polynomial is not in at most one variable, then a ValueError exception is raised. This is checked using the is_univariate() method. The n...
def eval(self, command, **kwds):
def eval(self, command, *args, **kwds):
def eval(self, command, **kwds): """ Evaluates commands.
'scilab-5.0...'
'scilab-...'
def version(self): """ Returns the version of the Scilab software used.
The log function also works in finite fields as long as the base is generator of the multiplicative group::
The log function also works in finite fields as long as the argument lies in the multiplicative group generated by the base::
def log(x, base=None): """ Return the logarithm of x to the given base. Calls the ``log`` method of the object x when computing the logarithm, thus allowing use of logarithm on any object containing a ``log`` method. In other words, log works on more than just real numbers. EXAMPLES:: sage: log(e^2) 2 sage: log(1024...
ValueError: base (=3) for discrete log must generate multiplicative group
ValueError: No discrete log of 8 found to base 3 sage: log(F(9), 3) 2
def log(x, base=None): """ Return the logarithm of x to the given base. Calls the ``log`` method of the object x when computing the logarithm, thus allowing use of logarithm on any object containing a ``log`` method. In other words, log works on more than just real numbers. EXAMPLES:: sage: log(e^2) 2 sage: log(1024...
- ``m``, ``n`` - two moduli, or None.
- ``m``, ``n`` - (default: ``None``) two moduli, or ``None``.
def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ...
If ``m``, ``n`` are not None, returns a solution `x` to the
If ``m``, ``n`` are not ``None``, returns a solution `x` to the
def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ...
n`, if one exists; which is if and only if `a\equiv b\pmod{\gcd(m,n)}` by the Chinese Remainder Theorem. The solution `x` is only well-defined modulo lcm`(m,n)`.
n`, if one exists. By the Chinese Remainder Theorem, a solution to the simultaneous congruences exists if and only if `a\equiv b\pmod{\gcd(m,n)}`. The solution `x` is only well-defined modulo `\text{lcm}(m,n)`.
def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ...
EXAMPLES::
.. SEEALSO:: - :func:`CRT_list` EXAMPLES: Using ``crt`` by giving it pairs of residues and moduli::
def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ...
sage: crt(13,20,100,301)
sage: crt(13, 20, 100, 301) 28013 sage: crt([2, 1], [3, 5]) 11 sage: crt([13, 20], [100, 301])
def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ...
if isinstance(a,list): return CRT_list(a,b) g, alpha, beta = XGCD(m,n) q,r = (b-a).quo_rem(g) if r!=0: raise ValueError, "No solution to crt problem since gcd(%s,%s) does not divide %s-%s"%(m,n,a,b) return (a+q*alpha*m) % lcm(m,n)
if isinstance(a, list): return CRT_list(a, b) g, alpha, beta = XGCD(m, n) q, r = (b - a).quo_rem(g) if r != 0: raise ValueError("No solution to crt problem since gcd(%s,%s) does not divide %s-%s" % (m, n, a, b)) return (a + q*alpha*m) % lcm(m, n)
def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ...
def valuation(m, p): """ The exact power of p that divides m. m should be an integer or rational (but maybe other types work too.) This actually just calls the m.valuation() method. If m is 0, this function returns rings.infinity.
def valuation(m,*args1, **args2): """ This actually just calls the m.valuation() method. See the documentation of m.valuation() for a more precise description. Use of this function by developers is discouraged. Use m.valuation() instead. .. NOTE:: This is not always a valuation in the mathematical sense. For more inf...
def valuation(m, p): """ The exact power of p that divides m. m should be an integer or rational (but maybe other types work too.) This actually just calls the m.valuation() method. If m is 0, this function returns rings.infinity. EXAMPLES:: sage: valuation(512,2) 9 sage: valuation(1,2) 0 sage: valuation(5/9, 3) -...
""" if hasattr(m, 'valuation'): return m.valuation(p) if m == 0: import sage.rings.all return sage.rings.all.infinity if is_FractionFieldElement(m): return valuation(m.numerator()) - valuation(m.denominator()) r = 0 power = p while not (m % power): r += 1 power *= p return r
sage: y = QQ['y'].gen() sage: valuation(y^3, y) 3 sage: x = QQ[['x']].gen() sage: valuation((x^3-x^2)/(x-4)) 2 sage: valuation(4r,2r) 2 """ if isinstance(m,(int,long)): m=ZZ(m) return m.valuation(*args1, **args2)
def valuation(m, p): """ The exact power of p that divides m. m should be an integer or rational (but maybe other types work too.) This actually just calls the m.valuation() method. If m is 0, this function returns rings.infinity. EXAMPLES:: sage: valuation(512,2) 9 sage: valuation(1,2) 0 sage: valuation(5/9, 3) -...
sage: cmp(P1xP1, 1)
sage: cmp(P1xP1, 1) * cmp(1, P1xP1)
def __cmp__(self, right): r""" Compare ``self`` and ``right``.
- ``algorithm`` - string (default: 'gmp') - ``'gmp'`` - use the GMP C-library factorial function
- ``algorithm`` - string (default: 'gmp'): - ``'gmp'`` - use the GMP C-library factorial function
def factorial(n, algorithm='gmp'): r""" Compute the factorial of `n`, which is the product `1\cdot 2\cdot 3 \cdots (n-1)\cdot n`. INPUT: - ``n`` - an integer - ``algorithm`` - string (default: 'gmp') - ``'gmp'`` - use the GMP C-library factorial function - ``'pari'`` - use PARI's factorial function OUTPUT: an...
modulo `m\*n`.
modulo `m*n`.
def crt(a,b,m=None,n=None): r""" Use the Chinese Remainder Theorem to find some `x` such that `x=a \bmod m` and `x=b \bmod n`. Note that `x` is only well-defined modulo `m\*n`. EXAMPLES:: sage: crt(2, 1, 3, 5) -4 sage: crt(13,20,100,301) -2087 You can also use upper case:: sage: c = CRT(2,3, 3, 5); c 8 sage: c % 3 ...
sage: r.install_package('Hmisc') [1] 4 5 6 """ if UNAME == "Darwin": warn = "** You are using OS X. Unfortunately, the R optional package system currently doesn't support OS X very well. We are working on this. **" else: warn = None if warn is not None: print warn
sage: r.install_packages('aaMI') ... R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. ... Please restart Sage in order to use 'aaMI'. """
def install_packages(self, package_name): """ Install an R package into Sage's R installation.
print "Please restart Sage or restart the R interface (via r.restart()) in order to use '%s'."%package_name if warn is not None: print warn
print "Please restart Sage in order to use '%s'."%package_name
def install_packages(self, package_name): """ Install an R package into Sage's R installation.
command = 'magma'
command = 'sage-native-execute magma'
def __init__(self, maxread=10000, script_subdirectory=None, logfile=None, server=None, server_tmpdir=None, user_config=False): """ INPUT: - ``maxread`` - affects buffering - ``script_subdirectory`` - directory where scripts are read from - ``logfile`` - output logged to this file - ``server`` - address of remo...
console('magma')
console('sage-native-execute magma')
def magma_console(): """ Run a command line Magma session. EXAMPLES:: sage: magma_console() # not tested Magma V2.14-9 Sat Oct 11 2008 06:36:41 on one [Seed = 1157408761] Type ? for help. Type <Ctrl>-D to quit. > Total time: 2.820 seconds, Total memory usage: 3.95MB """ console('magma')
'Sphere center 1.0 2.0 3.0 Rad 0.015 texture84'
'Sphere center 1.0 2.0 3.0 Rad 0.015 texture85'
def tachyon_repr(self, render_params): """ Returns representation of the point suitable for plotting using the Tachyon ray tracer.
['g obj_1', 'usemtl texture86']
['g obj_1', 'usemtl texture87']
def obj_repr(self, render_params): """ Returns complete representation of the point as a sphere.
'FCylinder base 1.0 0.0 0.0 apex 0.999950000417 0.00999983333417 0.0001 rad 0.005 texture126'
'FCylinder base 1.0 0.0 0.0 apex 0.999950000417 0.00999983333417 0.0001 rad 0.005 texture127'
def tachyon_repr(self, render_params): """ Returns representation of the line suitable for plotting using the Tachyon ray tracer.
if any([type(arg).__module__ == 'numpy' for arg in args]):
if any([type(arg).__module__ == 'numpy' and type(arg).__name__ == "ndarray" for arg in args]):
def _call_element_(self, _the_element, *args, **kwds): """ Calling a callable symbolic expression returns a symbolic expression with the appropriate arguments substituted. EXAMPLES:: sage: var('a, x, y, z') (a, x, y, z) sage: f(x,y) = a + 2*x + 3*y + z sage: f (x, y) |--> a + 2*x + 3*y + z sage: f(1,2) a + z + 8 sage...
""" S = self.__heilbronn_operator(self, [[-d,0, 0,d]], 1)
We test that the sign issue at sage: M = Newforms(Gamma1(13),names = 'a')[0].modular_symbols(sign=0) sage: M.diamond_bracket_operator(4) Hecke module morphism defined by the matrix [ 0 0 1 -1] [-1 -1 0 1] [-1 -1 0 0] [ 0 -1 1 -1] Domain: Modular Symbols subspace of dimension 4 of Modular Symbols space ... Codom...
def diamond_bracket_operator(self, d): r""" Return the diamond bracket d operator on this modular symbols space.
def induced_subgraph_search(self, G):
def subgraph_search(self, G, induced=False):
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
Returns an induced copy of `G` in self.
Returns a copy of ``G`` in ``self``.
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
- ``G`` -- the graph whose copy we are looking for in ``self``
- ``G`` -- the graph whose copy we are looking for in ``self``. - ``induced`` -- boolean (default: ``False``). Whether or not to search for an induced copy of ``G`` in ``self``. OUTPUT: - If ``induced=False``, return a copy of ``G`` in this graph. Otherwise, return an induced copy of ``G`` in ``self``. If ``G`` is t...
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
Brute-force
Brute-force search.
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
A Petersen Graph contains a `P_5` ::
The Petersen graph contains the path graph `P_5`::
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
sage: h1 = g.induced_subgraph_search(graphs.PathGraph(5)) sage: h1
sage: h1 = g.subgraph_search(graphs.PathGraph(5)); h1
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
It also contains a Claw (`K_{1,3}`):: sage: h2 = g.induced_subgraph_search(graphs.ClawGraph()) sage: h2
It also contains the claw `K_{1,3}`:: sage: h2 = g.subgraph_search(graphs.ClawGraph()); h2
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
Of course both copies are isomorphic to the graphs we were looking for :: sage: h1.is_isomorphic(graphs.PathGraph(5))
sage: I2 = g.subgraph_search(graphs.ClawGraph(), induced=True); I2 Subgraph of (Petersen graph): Graph on 4 vertices sage: I2.vertices() [0, 1, 4, 5] Of course the induced copies are isomorphic to the graphs we were looking for:: sage: I1.is_isomorphic(graphs.PathGraph(5))
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
sage: h2.is_isomorphic(graphs.ClawGraph())
sage: I2.is_isomorphic(graphs.ClawGraph())
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
However, as it contains no induced subgraphs isomorphic to `P_6`, an exception is raised in this case :: sage: g.induced_subgraph_search(graphs.PathGraph(6)) Traceback (most recent call last): ... ValueError: No induced copy of the graph exists
However, the Petersen graph does not contain a subgraph isomorphic to `K_3`:: sage: g.subgraph_search(graphs.CompleteGraph(3)) is None True Nor does it contain a nonempty induced subgraph isomorphic to `P_6`:: sage: g.subgraph_search(graphs.PathGraph(6), induced=True) is None True The empty graph is a subgraph of e...
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
H = subgraph_search(self, G, induced = True)
from sage.graphs.graph_generators import GraphGenerators if G.order() == 0: return GraphGenerators().EmptyGraph() H = subgraph_search(self, G, induced=induced)
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
raise ValueError('No induced copy of the graph exists') return self.subgraph(H) def subgraph_search(self, G): r""" Returns an of `G` included in self. INPUT: - ``G`` -- the graph whose copy we are looking for in ``self`` ALGORITHM: Brute-force EXAMPLES: A Petersen Graph contains a `P_5` :: sage: g = graphs.Pet...
return None
def induced_subgraph_search(self, G): r""" Returns an induced copy of `G` in self.
linewidths = options['linewidths']
linewidths = options.get('linewidths',None)
def _render_on_subplot(self, subplot): """ TESTS:
linestyles = options['linestyles']
linestyles = options.get('linestyles',None)
def _render_on_subplot(self, subplot): """ TESTS:
@suboptions('label', fontsize=9, colors=None, inline=None, inline_spacing=3, fmt="%1.2f")
@suboptions('label', fontsize=9, colors='blue', inline=None, inline_spacing=3, fmt="%1.2f")
def _render_on_subplot(self, subplot): """ TESTS:
If fill is True (the default), then we may have to color the labels so that we can see them::
We can change the color of the labels if so desired::
def contour_plot(f, xrange, yrange, **options): r""" ``contour_plot`` takes a function of two variables, `f(x,y)` and plots contour lines of the function over the specified ``xrange`` and ``yrange`` as demonstrated below. ``contour_plot(f, (xmin, xmax), (ymin, ymax), ...)`` INPUT: - ``f`` -- a function of two variab...
sage: f = attrcall('core', 3) sage: loads(dumps(f))
sage: f = attrcall('core', 3); f
def __init__(self, name, args, kwds): """ TESTS:: sage: f = attrcall('core', 3) sage: loads(dumps(f)) *.core(3) """ self.name = name self.args = args self.kwds = kwds
def __eq__(self, other): """ Equality testing EXAMPLES:: sage: attrcall('core', 3, flatten = True) == attrcall('core', 3, flatten = True) True sage: attrcall('core', 2) == attrcall('core', 3) False sage: attrcall('core', 2) == 1 False """ return self.__class__ == other.__class__ and self.__dict__ == other.__dict__ d...
def __repr__(self): """ Returns a string representation of this object. The star in the output represents the object passed into self. EXAMPLES:: sage: attrcall('core', 3) *.core(3) sage: attrcall('hooks', flatten=True) *.hooks(flatten=True) sage: attrcall('hooks', 3, flatten=True) *.hooks(3, flatten=True) """ s = "...
if not principal_flag: pi = K.uniformizer(P, 'negative') pie = pi a1 /= pie pie *= pi a2 /= pie pie *= pi a3 /= pie pie *= pi a4 /= pie pie *= pi pie *= pi a6 /= pie
if pi_neg is None: if principal_flag: pi_neg = pi else: pi_neg = K.uniformizer(P, 'negative') pi_neg2 = pi_neg*pi_neg pi_neg3 = pi_neg*pi_neg2 pi_neg4 = pi_neg*pi_neg3 pi_neg6 = pi_neg4*pi_neg2 a1 /= pi_neg a2 /= pi_neg2 a3 /= pi_neg3 a4 /= pi_neg4 a6 /= pi_neg6
def _pcubicroots(b, c, d): r""" Local function returning the number of roots of `x^3 + b*x^2 + c*x + d` modulo `P`, counting multiplicities """ return sum([rr[1] for rr in PolynomialRing(F, 'x')([d, c, b, 1]).roots()],0)
if len(value) > parent.degree(): raise ValueError, "list too long" self.__value = pari(0).Mod(parent._pari_modulus())*parent._pari_one() for i in range(len(value)): self.__value = self.__value + pari(int(value[i])).Mod(parent._pari_modulus())*pari("a^%s"%i)
self.__value = (pari(value).Polrev("a") * parent._pari_one()).Mod(parent._pari_modulus())
def __init__(self, parent, value, check=True): """ Create element of a finite field. EXAMPLES:: sage: from sage.rings.finite_rings.finite_field_ext_pari import FiniteField_ext_pari sage: k = FiniteField_ext_pari(9,'a') sage: a = k(11); a 2 sage: a.parent() Finite Field in a of size 3^2 sage: V = k.vector_space(); v =...
flags = [re.IGNORECASE]
flags = re.IGNORECASE
sage: 'divisors' in _search_src_or_doc('src', '^ *def prime', interact=False)
flags = []
flags = 0
sage: 'divisors' in _search_src_or_doc('src', '^ *def prime', interact=False)
if re.search(string, line, *flags):
if re.search(string, line, flags):
sage: 'divisors' in _search_src_or_doc('src', '^ *def prime', interact=False)
if re.search(string, line, *flags)]
if re.search(string, line, flags)]
sage: 'divisors' in _search_src_or_doc('src', '^ *def prime', interact=False)
re.MULTILINE, *flags),
re.MULTILINE | flags),
sage: 'divisors' in _search_src_or_doc('src', '^ *def prime', interact=False)
sage: V = VectorSpace(QQ,5,sparse=True) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U
sage: VV = VectorSpace(QQ,5,sparse=True) sage: UU = VV.submodule([ VV.gen(i) - VV.gen(0) for i in range(1,5) ]) sage: print UU
def _repr_(self): """ The printing representation of self. EXAMPLES:: sage: V = VectorSpace(QQ,5) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U # indirect doctest Vector space of degree 5 and dimension 4 over Rational Field Basis matrix: [ 1 0 0 0 -1] [ 0 1 0 0 -1] [ 0 0 1 ...
sage: V = VectorSpace(QQ,5,sparse=True) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U
sage: VV = VectorSpace(QQ,5,sparse=True) sage: UU = VV.submodule([ VV.gen(i) - VV.gen(0) for i in range(1,5) ]) sage: print UU
def _repr_(self): """ The default printing representation of self. EXAMPLES:: sage: V = VectorSpace(QQ,5) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U # indirect doctest Vector space of degree 5 and dimension 4 over Rational Field Basis matrix: [ 1 0 0 0 -1] [ 0 1 0 0 -1] [ 0...
more planar areas get fewer triangles, and areas with higher curvature get more triangles
more planar areas get fewer triangles, and areas with higher curvature get more triangles.
def get_colors(self, list): """ Parameters: list: an iterable collection of values which can be cast into colors -- typically an RGB triple, or an RGBA 4-tuple Returns: a list of single parameters which can be passed into the set_color method of the Triangle or SmoothTriangle objects generated by this factory. TESTS:...
- ``solution_dict`` - bool (default: False); if True, return a list of dictionaries containing the solutions.
- ``solution_dict`` - bool (default: False); if True or non-zero, return a list of dictionaries containing the solutions. If there are no solutions, return an empty list (rather than a list containing an empty dictionary). Likewise, if there's only a single solution, return a list containing one dictionary with that s...
def solve(f, *args, **kwds): r""" Algebraically solve an equation or system of equations (over the complex numbers) for given variables. Inequalities and systems of inequalities are also supported. INPUT: - ``f`` - equation or system of equations (given by a list or tuple) - ``*args`` - variables to solve for. - ...
If we ask for a dictionary for the solutions, we get it::
If we ask for dictionaries containing the solutions, we get them::
def solve(f, *args, **kwds): r""" Algebraically solve an equation or system of equations (over the complex numbers) for given variables. Inequalities and systems of inequalities are also supported. INPUT: - ``f`` - equation or system of equations (given by a list or tuple) - ``*args`` - variables to solve for. - ...
TESTS:: sage: solve([sin(x)==x,y^2==x],x,y) [sin(x) == x, y^2 == x]
def solve(f, *args, **kwds): r""" Algebraically solve an equation or system of equations (over the complex numbers) for given variables. Inequalities and systems of inequalities are also supported. INPUT: - ``f`` - equation or system of equations (given by a list or tuple) - ``*args`` - variables to solve for. - ...
TESTS:: sage: solve([sin(x)==x,y^2==x],x,y) [sin(x) == x, y^2 == x] sage: solve(0==1,x) Traceback (most recent call last): ... TypeError: object of type 'bool' has no len() Test if the empty list is returned, too, when (a list of) dictionaries (is) are requested ( sage: solve([0==1],x) [] sage: solve([0==1],x,soluti...
def solve(f, *args, **kwds): r""" Algebraically solve an equation or system of equations (over the complex numbers) for given variables. Inequalities and systems of inequalities are also supported. INPUT: - ``f`` - equation or system of equations (given by a list or tuple) - ``*args`` - variables to solve for. - ...
if 'solution_dict' in kwds and kwds['solution_dict']==True:
if kwds.get('solution_dict', False): if len(sol_list)==0: return []
def solve(f, *args, **kwds): r""" Algebraically solve an equation or system of equations (over the complex numbers) for given variables. Inequalities and systems of inequalities are also supported. INPUT: - ``f`` - equation or system of equations (given by a list or tuple) - ``*args`` - variables to solve for. - ...
- ``solution_dict`` - (default: False) if True, return a list of dictionaries containing the solutions.
- ``solution_dict`` - bool (default: False); if True or non-zero, return a list of dictionaries containing the solutions. If there are no solutions, return an empty list (rather than a list containing an empty dictionary). Likewise, if there's only a single solution, return a list containing one dictionary with that s...
def solve_mod(eqns, modulus, solution_dict = False): r""" Return all solutions to an equation or list of equations modulo the given integer modulus. Each equation must involve only polynomials in 1 or many variables. By default the solutions are returned as `n`-tuples, where `n` is the number of variables appearing an...
We solve an simple equation modulo 2::
We solve a simple equation modulo 2::
def solve_mod(eqns, modulus, solution_dict = False): r""" Return all solutions to an equation or list of equations modulo the given integer modulus. Each equation must involve only polynomials in 1 or many variables. By default the solutions are returned as `n`-tuples, where `n` is the number of variables appearing an...
if solution_dict == True:
if solution_dict:
def solve_mod(eqns, modulus, solution_dict = False): r""" Return all solutions to an equation or list of equations modulo the given integer modulus. Each equation must involve only polynomials in 1 or many variables. By default the solutions are returned as `n`-tuples, where `n` is the number of variables appearing an...
We solve an simple equation modulo 2::
We solve a simple equation modulo 2::
def solve_mod_enumerate(eqns, modulus): r""" Return all solutions to an equation or list of equations modulo the given integer modulus. Each equation must involve only polynomials in 1 or many variables. The solutions are returned as `n`-tuples, where `n` is the number of variables appearing anywhere in the given equa...
Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
Returns the Hasse invariant of this elliptic curve. OUTPUT: The Hasse invariant of this elliptic curve, as an element of the base field. This is only defined over fields of positive characteristic, and is an element of the field which is zero if and only if the curve is supersingular. Over a field of characteristic...
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
return self.a2()+self.a1()**2
return self.b2() elif p == 5: return self.c4() elif p == 7: return -self.c6()
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
A map from '(' to open_symbol and ')' to close_symbol and otherwise an error is raised.
A map from ``'('`` to ``open_symbol`` and ``')'`` to ``close_symbol`` and otherwise an error is raised. The values of the constants ``open_symbol`` and ``close_symbol`` are subject to change. This is the inverse map of :func:`replace_symbols`. INPUT: - ``x`` -- either an opening or closing parenthesis. OUTPUT: - If...
def replace_parens(x): r""" A map from '(' to open_symbol and ')' to close_symbol and otherwise an error is raised. EXAMPLES:: sage: from sage.combinat.dyck_word import replace_parens sage: replace_parens('(') 1 sage: replace_parens(')') 0 sage: replace_parens(1) Traceback (most recent call last): ... ValueError """ ...
A map from open_symbol to '(' and close_symbol to ')' and otherwise an error is raised.
A map from ``open_symbol`` to ``'('`` and ``close_symbol`` to ``')'`` and otherwise an error is raised. The values of the constants ``open_symbol`` and ``close_symbol`` are subject to change. This is the inverse map of :func:`replace_parens`. INPUT: - ``x`` -- either ``open_symbol`` or ``close_symbol``. OUTPUT: - I...
def replace_symbols(x): r""" A map from open_symbol to '(' and close_symbol to ')' and otherwise an error is raised. EXAMPLES:: sage: from sage.combinat.dyck_word import replace_symbols sage: replace_symbols(1) '(' sage: replace_symbols(0) ')' sage: replace_symbols(3) Traceback (most recent call last): ... ValueError...
Returns a Dyck word object or a head of a Dyck word object if the Dyck word is not complete
Returns a Dyck word object or a head of a Dyck word object if the Dyck word is not complete.
def DyckWord(dw=None, noncrossing_partition=None): r""" Returns a Dyck word object or a head of a Dyck word object if the Dyck word is not complete EXAMPLES:: sage: dw = DyckWord([1, 0, 1, 0]); dw [1, 0, 1, 0] sage: print dw ()() sage: print dw.height() 1 sage: dw.to_noncrossing_partition() [[1], [2]] :: sage: Dyck...
TODO: In functions where a Dyck word is necessary, an error should be raised (e.g. a_statistic, b_statistic)?
TODO: In functions where a Dyck word is necessary, an error should be raised (e.g. ``a_statistic``, ``b_statistic``)?
def DyckWord(dw=None, noncrossing_partition=None): r""" Returns a Dyck word object or a head of a Dyck word object if the Dyck word is not complete EXAMPLES:: sage: dw = DyckWord([1, 0, 1, 0]); dw [1, 0, 1, 0] sage: print dw ()() sage: print dw.height() 1 sage: dw.to_noncrossing_partition() [[1], [2]] :: sage: Dyck...
report the position for the parenthesis that matches the one at position ``pos``
Report the position for the parenthesis that matches the one at position ``pos``.
def associated_parenthesis(self, pos): r""" report the position for the parenthesis that matches the one at position ``pos``
- ``pos`` - the index of the parenthesis in the list
- ``pos`` - the index of the parenthesis in the list.
def associated_parenthesis(self, pos): r""" report the position for the parenthesis that matches the one at position ``pos``