Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/libs/singular/function_factory.py
4037 views
1
"""
2
libSingular: Function Factory.
3
4
AUTHORS:
5
6
- Martin Albrecht (2010-01): initial version
7
8
"""
9
#*****************************************************************************
10
# Copyright (C) 2010 Martin Albrecht <[email protected]>
11
#
12
# Distributed under the terms of the GNU General Public License (GPL)
13
# http://www.gnu.org/licenses/
14
#*****************************************************************************
15
16
from sage.libs.singular.function import singular_function, lib, list_of_functions
17
18
class SingularFunctionFactory(object):
19
"""
20
A convenient interface to libsingular functions.
21
"""
22
def __getattr__(self, name):
23
"""
24
EXAMPLE::
25
26
sage: groebner = sage.libs.singular.ff.groebner
27
sage: groebner
28
groebner (singular function)
29
30
sage: primdecSY = sage.libs.singular.ff.primdec__lib.primdecSY
31
sage: primdecSY
32
primdecSY (singular function)
33
"""
34
if name.startswith("_"):
35
raise AttributeError("Singular Function Factory has no attribute '%s'"%name)
36
37
try:
38
return singular_function(name)
39
except NameError:
40
if name.endswith("__lib"):
41
name = name[:-5]
42
lib(name+".lib")
43
return SingularFunctionFactory()
44
else:
45
raise NameError("function or package '%s' unknown."%(name))
46
47
def trait_names(self):
48
"""
49
EXAMPLE::
50
51
sage: "groebner" in sage.libs.singular.ff.trait_names()
52
True
53
"""
54
return list_of_functions()
55
56