@@ -35,9 +35,7 @@ def get_superposition_set(d, ds):
3535 return [tuple (item ) for item in returnset ]
3636
3737
38- def get_setting (
39- system , N , U = None , d = None , ds = None
40- ): # I have to add bases and NFMT stuff here!
38+ def get_setting (system , N , U = None , d = None , ds = None , basis_vect = None ):
4139
4240 if system not in systems :
4341 raise ValueError ("System not found." )
@@ -52,18 +50,18 @@ def get_setting(
5250 bwl = [np .full (len (u ), tmp [len (u )], "int32" ) for u in U ]
5351
5452 if systems [system ] == NFMTtools :
55- if len (basis_vect ) == 0 :
56- ValueError (
53+ if basis_vect is None or len (basis_vect ) == 0 :
54+ raise ValueError (
5755 "please call get_setting with basis_vect for a NFMT transform."
5856 )
5957 if len (basis_vect ) < d :
60- ValueError ("basis_vect must have an entry for every dimension." )
58+ raise ValueError ("basis_vect must have an entry for every dimension." )
6159 return [
6260 Setting (
6361 u = U [idx ],
6462 mode = systems [system ],
6563 bandwidths = np .array (bwl [idx ], "int32" ),
66- bases = basis_vect [U [ idk ]],
64+ bases = [ basis_vect [j ] for j in U [ idx ]],
6765 )
6866 for idx in range (len (U ))
6967 ]
@@ -92,18 +90,18 @@ def get_setting(
9290 bwl [i ] = np .full (len (u ), N [i ])
9391
9492 if systems [system ] == NFMTtools :
95- if len (basis_vect ) == 0 :
96- ValueError (
93+ if basis_vect is None or len (basis_vect ) == 0 :
94+ raise ValueError (
9795 "please call get_setting with basis_vect for a NFMT transform."
9896 )
99- if len (basis_vect ) < max (max (u ) for u in U ):
100- ValueError ("basis_vect must have an entry for every dimension." )
97+ if len (basis_vect ) <= max (max (u ) for u in U if len ( u ) > 0 ):
98+ raise ValueError ("basis_vect must have an entry for every dimension." )
10199 return [
102100 Setting (
103101 u = u ,
104102 mode = systems [system ],
105103 bandwidths = np .array (bwl [i ], "int32" ),
106- bases = basis_vect [u ],
104+ bases = [ basis_vect [j ] for j in u ],
107105 )
108106 for i , u in enumerate (U )
109107 ]
@@ -131,18 +129,18 @@ def get_setting(
131129 bwl [i ] = N [i ]
132130
133131 if systems [system ] == NFMTtools :
134- if len (basis_vect ) == 0 :
135- ValueError (
132+ if basis_vect is None or len (basis_vect ) == 0 :
133+ raise ValueError (
136134 "please call get_setting with basis_vect for a NFMT transform."
137135 )
138- if len (basis_vect ) < max (max (u ) for u in U ):
139- ValueError ("basis_vect must have an entry for every dimension." )
136+ if len (basis_vect ) <= max (max (u ) for u in U if len ( u ) > 0 ):
137+ raise ValueError ("basis_vect must have an entry for every dimension." )
140138 return [
141139 Setting (
142140 u = U [idx ],
143141 mode = systems [system ],
144142 bandwidths = np .array (bwl [idx ], "int32" ),
145- bases = basis_vect [U [ idk ]],
143+ bases = [ basis_vect [j ] for j in U [ idx ]],
146144 )
147145 for idx in range (len (U ))
148146 ]
@@ -197,11 +195,11 @@ def __init__(
197195
198196 if system == "mixed" :
199197 if len (basis_vect ) == 0 :
200- ValueError (
198+ raise ValueError (
201199 "please call GroupedTransform with basis_vect for a NFMT transform."
202200 )
203201 if len (basis_vect ) != X .shape [1 ]:
204- ValueError ("basis_vect must have an entry for every dimension." )
202+ raise ValueError ("basis_vect must have an entry for every dimension." )
205203
206204 if system in {"exp" , "chui1" , "chui2" , "chui3" , "chui4" }:
207205 if np .min (X ) < - 0.5 or np .max (X ) >= 0.5 :
@@ -214,14 +212,14 @@ def __init__(
214212
215213 cosine_mask = basis_vals > 0
216214 if np .sum (cosine_mask ) > 0 :
217- if (np .min (X [cosine_mask , : ]) < 0 ) or (np .max (X [cosine_mask , : ]) > 1 ):
215+ if (np .min (X [:, cosine_mask ]) < 0 ) or (np .max (X [:, cosine_mask ]) > 1 ):
218216 raise ValueError (
219217 "Nodes must be between 0 and 1 for cosine or Chebyshev dimensions."
220218 )
221219
222220 exp_mask = ~ cosine_mask
223221 if np .sum (exp_mask ) > 0 :
224- if (np .min (X [exp_mask , : ]) < - 0.5 ) or (np .max (X [exp_mask , : ]) > 0.5 ):
222+ if (np .min (X [:, exp_mask ]) < - 0.5 ) or (np .max (X [:, exp_mask ]) > 0.5 ):
225223 raise ValueError (
226224 "Nodes must be between -0.5 and 0.5 for exponentional dimensions."
227225 )
@@ -236,7 +234,9 @@ def __init__(
236234 self .parallel = parallel
237235
238236 if len (settings ) == 0 :
239- self .settings = get_setting (system = system , N = N , U = U , d = d , ds = ds )
237+ self .settings = get_setting (
238+ system = system , N = N , U = U , d = d , ds = ds , basis_vect = basis_vect
239+ )
240240 else :
241241 self .settings = settings
242242
@@ -278,8 +278,9 @@ def __init__(
278278 )
279279 elif system == "mixed" :
280280 matrix = np .array (
281- s1 .mode .get_matrix (bandwidths = s1 .bandwidths , X = X [:, u1 ].T ),
282- bases = s1 .bases ,
281+ s1 .mode .get_matrix (
282+ bandwidths = s1 .bandwidths , X = X [:, u1 ].T , bases = s1 .bases
283+ )
283284 )
284285 for s in self .settings [1 :]:
285286 if len (s .bandwidths ) == 0 :
@@ -290,8 +291,9 @@ def __init__(
290291 [
291292 matrix ,
292293 np .array (
293- s .mode .get_matrix (s .bandwidths , X [:, u ].T ),
294- bases = s .bases ,
294+ s .mode .get_matrix (
295+ s .bandwidths , X [:, u ].T , bases = s .bases
296+ )
295297 ),
296298 ]
297299 )
@@ -433,7 +435,7 @@ def get_matrix(self):
433435 u1 = (0 ,)
434436 else :
435437 u1 = s1 .u
436- F_direct = s1 .mode .get_matrix (s . bdanwidths , self .X [:, u1 ].T , bases = s .bases )
438+ F_direct = s1 .mode .get_matrix (s1 . bandwidths , self .X [:, u1 ].T , bases = s1 .bases )
437439 for idx , s in enumerate (self .settings ):
438440 if idx == 0 :
439441 continue
@@ -443,6 +445,7 @@ def get_matrix(self):
443445 u = s .u
444446 mat = s .mode .get_matrix (s .bandwidths , self .X [:, u ].T , s .bases )
445447 F_direct = np .hstack ([F_direct , mat ])
448+ return F_direct
446449 else :
447450 s1 = self .settings [0 ]
448451 if len (s1 .bandwidths ) == 0 :
0 commit comments