@@ -182,9 +182,8 @@ def _call(self, x):
182
182
183
183
def __repr__ (self ):
184
184
"""Return ``repr(self)``."""
185
- return '{}({!r} -> {!r}, {!r})' .format (self .__class__ .__name__ ,
186
- self .domain , self .range ,
187
- self .exponent )
185
+ return '{}({!r}, {!r})' .format (self .__class__ .__name__ ,
186
+ self .domain , self .exponent )
188
187
189
188
190
189
class GroupL1Norm (Functional ):
@@ -230,7 +229,7 @@ def __init__(self, vfspace, exponent=None, range=None):
230
229
instability. Infinity gives the supremum norm.
231
230
Default: ``vfspace.exponent``, usually 2.
232
231
range : `Field`, optional
233
- Range of the functional. Default: `vfspace.field`.
232
+ Range of the functional. Default: `` vfspace.field` `.
234
233
235
234
Examples
236
235
--------
@@ -332,8 +331,8 @@ def convex_conj(self):
332
331
333
332
def __repr__ (self ):
334
333
"""Return ``repr(self)``."""
335
- return '{}({!r} -> {!r} , exponent={})' .format (self .__class__ .__name__ ,
336
- self .domain , self . range ,
334
+ return '{}({!r}, exponent={})' .format (self .__class__ .__name__ ,
335
+ self .domain ,
337
336
self .pointwise_norm .exponent )
338
337
339
338
@@ -426,8 +425,8 @@ def convex_conj(self):
426
425
427
426
def __repr__ (self ):
428
427
"""Return ``repr(self)``."""
429
- return '{}({!r} -> {!r} , exponent={})' .format (self .__class__ .__name__ ,
430
- self .domain , self . range ,
428
+ return '{}({!r}, exponent={})' .format (self .__class__ .__name__ ,
429
+ self .domain ,
431
430
self .pointwise_norm .exponent )
432
431
433
432
@@ -473,7 +472,7 @@ def __init__(self, domain, exponent, range=None):
473
472
exponent : int or infinity
474
473
Specifies wich norm to use.
475
474
range : `Field`, optional
476
- Range of the functional. Default: `domain.field`.
475
+ Range of the functional. Default: `` domain.field` `.
477
476
"""
478
477
super (IndicatorLpUnitBall , self ).__init__ (domain = domain , linear = False ,
479
478
range = range )
@@ -543,9 +542,8 @@ def proximal(self):
543
542
544
543
def __repr__ (self ):
545
544
"""Return ``repr(self)``."""
546
- return '{}({!r} -> {!r},{!r})' .format (self .__class__ .__name__ ,
547
- self .domain , self .range ,
548
- self .exponent )
545
+ return '{}({!r},{!r})' .format (self .__class__ .__name__ ,
546
+ self .domain , self .exponent )
549
547
550
548
551
549
class L1Norm (LpNorm ):
@@ -591,8 +589,7 @@ def __init__(self, domain, range=None):
591
589
592
590
def __repr__ (self ):
593
591
"""Return ``repr(self)``."""
594
- return '{}({!r} -> {!r})' .format (self .__class__ .__name__ ,
595
- self .domain , self .range )
592
+ return '{}({!r})' .format (self .__class__ .__name__ , self .domain )
596
593
597
594
598
595
class L2Norm (LpNorm ):
@@ -631,8 +628,7 @@ def __init__(self, domain, range=None):
631
628
632
629
def __repr__ (self ):
633
630
"""Return ``repr(self)``."""
634
- return '{}({!r} -> {!r})' .format (self .__class__ .__name__ ,
635
- self .domain , self .range )
631
+ return '{}({!r})' .format (self .__class__ .__name__ , self .domain )
636
632
637
633
638
634
class L2NormSquared (Functional ):
@@ -712,8 +708,7 @@ def convex_conj(self):
712
708
713
709
def __repr__ (self ):
714
710
"""Return ``repr(self)``."""
715
- return '{}({!r} -> {!r})' .format (self .__class__ .__name__ ,
716
- self .domain , self .range )
711
+ return '{}({!r})' .format (self .__class__ .__name__ , self .domain )
717
712
718
713
719
714
class ConstantFunctional (Functional ):
@@ -733,7 +728,7 @@ def __init__(self, domain, constant, range=None):
733
728
constant : element in ``domain.field``
734
729
The constant value of the functional
735
730
range : `Field`, optional
736
- Range of the functional. Default: `domain.field`.
731
+ Range of the functional. Default: `` domain.field` `.
737
732
"""
738
733
super (ConstantFunctional , self ).__init__ (
739
734
domain = domain , linear = (constant == 0 ), grad_lipschitz = 0 ,
@@ -777,9 +772,8 @@ def convex_conj(self):
777
772
778
773
def __repr__ (self ):
779
774
"""Return ``repr(self)``."""
780
- return '{}({!r} -> {!r}, {!r})' .format (self .__class__ .__name__ ,
781
- self .domain , self .range ,
782
- self .constant )
775
+ return '{}({!r}, {!r})' .format (self .__class__ .__name__ ,
776
+ self .domain , self .constant )
783
777
784
778
785
779
class ZeroFunctional (ConstantFunctional ):
@@ -794,15 +788,14 @@ def __init__(self, domain, range=None):
794
788
domain : `LinearSpace`
795
789
Domain of the functional.
796
790
range : `Field`, optional
797
- Range of the functional. Default: `domain.field`.
791
+ Range of the functional. Default: `` domain.field` `.
798
792
"""
799
793
super (ZeroFunctional , self ).__init__ (domain = domain , constant = 0 ,
800
794
range = range )
801
795
802
796
def __repr__ (self ):
803
797
"""Return ``repr(self)``."""
804
- return '{}({!r} -> {!r})' .format (self .__class__ .__name__ ,
805
- self .domain , self .range )
798
+ return '{}({!r})' .format (self .__class__ .__name__ , self .domain )
806
799
807
800
808
801
class ScalingFunctional (Functional , ScalingOperator ):
@@ -890,7 +883,7 @@ def __init__(self, domain, lower=None, upper=None, range=None):
890
883
The upper bound.
891
884
Default: `+infinity`
892
885
range : `Field`, optional
893
- Range of the functional. Default: `domain.field`.
886
+ Range of the functional. Default: `` domain.field` `.
894
887
895
888
Examples
896
889
--------
@@ -919,9 +912,9 @@ def proximal(self):
919
912
920
913
def __repr__ (self ):
921
914
"""Return ``repr(self)``."""
922
- return '{}({!r} -> {!r} , {!r}, {!r})' .format (self .__class__ .__name__ ,
923
- self .domain , self . range ,
924
- self .lower , self .upper )
915
+ return '{}({!r}, {!r}, {!r})' .format (self .__class__ .__name__ ,
916
+ self .domain ,
917
+ self .lower , self .upper )
925
918
926
919
927
920
class IndicatorNonnegativity (IndicatorBox ):
@@ -947,7 +940,7 @@ def __init__(self, domain, range=None):
947
940
domain : `LinearSpace`
948
941
Domain of the functional.
949
942
range : `Field`, optional
950
- Range of the functional. Default: `domain.field`.
943
+ Range of the functional. Default: `` domain.field` `.
951
944
952
945
Examples
953
946
--------
@@ -963,8 +956,7 @@ def __init__(self, domain, range=None):
963
956
964
957
def __repr__ (self ):
965
958
"""Return ``repr(self)``."""
966
- return '{}({!r} -> {!r})' .format (self .__class__ .__name__ ,
967
- self .domain , self .range )
959
+ return '{}({!r})' .format (self .__class__ .__name__ , self .domain )
968
960
969
961
970
962
class IndicatorZero (Functional ):
@@ -984,7 +976,7 @@ def __init__(self, domain, constant=0, range=None):
984
976
constant : element in ``domain.field``, optional
985
977
The constant value of the functional
986
978
range : `Field`, optional
987
- Range of the functional. Default: `domain.field`.
979
+ Range of the functional. Default: `` domain.field` `.
988
980
989
981
Examples
990
982
--------
@@ -1051,9 +1043,8 @@ def zero_proximal(sigma=1.0):
1051
1043
1052
1044
def __repr__ (self ):
1053
1045
"""Return ``repr(self)``."""
1054
- return '{}({!r} -> {!r}, {!r})' .format (self .__class__ .__name__ ,
1055
- self .domain , self .range ,
1056
- self .constant )
1046
+ return '{}({!r}, {!r})' .format (self .__class__ .__name__ ,
1047
+ self .domain , self .constant )
1057
1048
1058
1049
1059
1050
class KullbackLeibler (Functional ):
@@ -1220,9 +1211,8 @@ def convex_conj(self):
1220
1211
1221
1212
def __repr__ (self ):
1222
1213
"""Return ``repr(self)``."""
1223
- return '{}({!r} -> {!r}, {!r})' .format (self .__class__ .__name__ ,
1224
- self .domain , self .range ,
1225
- self .prior )
1214
+ return '{}({!r}, {!r})' .format (self .__class__ .__name__ ,
1215
+ self .domain , self .prior )
1226
1216
1227
1217
1228
1218
class KullbackLeiblerConvexConj (Functional ):
@@ -1690,7 +1680,14 @@ def __init__(self, *functionals):
1690
1680
# Make a power space if the second argument is an integer
1691
1681
if (len (functionals ) == 2 and isinstance (functionals [1 ], Integral )):
1692
1682
functionals = [functionals [0 ]] * functionals [1 ]
1693
- range = sum (func .range for func in functionals )
1683
+ for func1 in functionals :
1684
+ if all (func1 .range .contains_set (func2 .range )
1685
+ for func2 in functionals ):
1686
+ range = func1 .range
1687
+ break
1688
+ else :
1689
+ raise ValueError ('No functional range contained all other ranges '
1690
+ 'in SeparableSum of {!r}' .format (functionals ))
1694
1691
1695
1692
domains = [func .domain for func in functionals ]
1696
1693
domain = ProductSpace (* domains )
@@ -1777,8 +1774,7 @@ def convex_conj(self):
1777
1774
def __repr__ (self ):
1778
1775
"""Return ``repr(self)``."""
1779
1776
func_repr = ', ' .join (repr (func ) for func in self .functionals )
1780
- return '{}({} -> {!r})' .format (self .__class__ .__name__ ,
1781
- func_repr , self .range )
1777
+ return '{}({})' .format (self .__class__ .__name__ , func_repr )
1782
1778
1783
1779
1784
1780
class QuadraticForm (Functional ):
@@ -2146,10 +2142,9 @@ def convex_conj(self):
2146
2142
2147
2143
def __repr__ (self ):
2148
2144
"""Return ``repr(self)``."""
2149
- return '{}({!r} -> {!r}, {}, {})' .format (self .__class__ .__name__ ,
2150
- self .domain , self .range ,
2151
- self .outernorm .exponent ,
2152
- self .pwisenorm .exponent )
2145
+ return '{}({!r}, {}, {})' .format (self .__class__ .__name__ , self .domain ,
2146
+ self .outernorm .exponent ,
2147
+ self .pwisenorm .exponent )
2153
2148
2154
2149
2155
2150
class IndicatorNuclearNormUnitBall (Functional ):
@@ -2193,7 +2188,7 @@ def __init__(self, domain, outer_exp=1, singular_vector_exp=2, range=None):
2193
2188
singular_vector_exp : {1, 2, inf}, optional
2194
2189
Exponent for the norm for the singular vectors.
2195
2190
range : `Field`, optional
2196
- Range of the functional. Default: `domain.field`.
2191
+ Range of the functional. Default: `` domain.field` `.
2197
2192
Examples
2198
2193
--------
2199
2194
Simple example, nuclear norm of matrix valued function with all ones
@@ -2243,10 +2238,9 @@ def convex_conj(self):
2243
2238
2244
2239
def __repr__ (self ):
2245
2240
"""Return ``repr(self)``."""
2246
- return '{}({!r} -> {!r}, {}, {})' .format (self .__class__ .__name__ ,
2247
- self .domain , self .range ,
2248
- self .__norm .outernorm .exponent ,
2249
- self .__norm .pwisenorm .exponent )
2241
+ return '{}({!r}, {}, {})' .format (self .__class__ .__name__ , self .domain ,
2242
+ self .__norm .outernorm .exponent ,
2243
+ self .__norm .pwisenorm .exponent )
2250
2244
2251
2245
2252
2246
class MoreauEnvelope (Functional ):
0 commit comments