@@ -189,7 +189,7 @@ def set_source(self, source):
189189 self : Function
190190 Returns the Function instance.
191191 """
192- _ = self ._check_user_input (
192+ * _ , interpolation , extrapolation = self ._check_user_input (
193193 source ,
194194 self .__inputs__ ,
195195 self .__outputs__ ,
@@ -277,10 +277,10 @@ def source_function(_):
277277 self .source = source
278278 # Update extrapolation method
279279 if self .__extrapolation__ is None :
280- self .set_extrapolation ()
280+ self .set_extrapolation (extrapolation )
281281 # Set default interpolation for point source if it hasn't
282282 if self .__interpolation__ is None :
283- self .set_interpolation ()
283+ self .set_interpolation (interpolation )
284284 else :
285285 # Updates interpolation coefficients
286286 self .set_interpolation (self .__interpolation__ )
@@ -560,14 +560,12 @@ def set_discrete(
560560 # Create nodes to evaluate function
561561 xs = np .linspace (lower [0 ], upper [0 ], sam [0 ])
562562 ys = np .linspace (lower [1 ], upper [1 ], sam [1 ])
563- xs , ys = np .meshgrid (xs , ys )
564- xs , ys = xs .flatten (), ys .flatten ()
565- mesh = [[xs [i ], ys [i ]] for i in range (len (xs ))]
563+ xs , ys = np .array (np .meshgrid (xs , ys )).reshape (2 , xs .size * ys .size )
566564 # Evaluate function at all mesh nodes and convert it to matrix
567- zs = np .array (self .get_value (mesh ))
568- self .set_source (np .concatenate (([xs ], [ys ], [zs ])).transpose ())
565+ zs = np .array (self .get_value (xs , ys ))
569566 self .__interpolation__ = "shepard"
570567 self .__extrapolation__ = "natural"
568+ self .set_source (np .concatenate (([xs ], [ys ], [zs ])).transpose ())
571569 return self
572570
573571 def set_discrete_based_on_model (
@@ -664,11 +662,8 @@ def set_discrete_based_on_model(
664662 # Create nodes to evaluate function
665663 xs = model_function .source [:, 0 ]
666664 ys = model_function .source [:, 1 ]
667- xs , ys = np .meshgrid (xs , ys )
668- xs , ys = xs .flatten (), ys .flatten ()
669- mesh = [[xs [i ], ys [i ]] for i in range (len (xs ))]
670665 # Evaluate function at all mesh nodes and convert it to matrix
671- zs = np .array (self .get_value (mesh ))
666+ zs = np .array (self .get_value (xs , ys ))
672667 self .set_source (np .concatenate (([xs ], [ys ], [zs ])).transpose ())
673668
674669 interp = (
@@ -2860,6 +2855,8 @@ def _check_user_input(
28602855
28612856 # check source for data type
28622857 # if list or ndarray, check for dimensions, interpolation and extrapolation
2858+ if isinstance (source , Function ):
2859+ source = source .get_source ()
28632860 if isinstance (source , (list , np .ndarray , str , Path )):
28642861 # Deal with csv or txt
28652862 if isinstance (source , (str , Path )):
0 commit comments