Data providing function:

    Make sure to have every relevant import statement included here and return data as
    used in model function below. This function is separated from model() so that hyperopt
    won't reload data for each evaluation run.
354045
def data():
    
    from keras.datasets import mnist
    from keras.utils import np_utils
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x_train = x_train.reshape(60000, 784)
    x_test = x_test.reshape(10000, 784)
    x_train = x_train.astype('float32')
    x_test = x_test.astype('float32')
    x_train /= 255
    x_test /= 255
    nb_classes = 10
    y_train = np_utils.to_categorical(y_train, nb_classes)
    y_test = np_utils.to_categorical(y_test, nb_classes)
    return x_train, y_train, x_test, y_test
713646
def _init_design_chooser(self):
        

        # If objective function was not provided, we require some initial sample data
        if self.f is None and (self.X is None or self.Y is None):
            raise InvalidConfigError("Initial data for both X and Y is required when objective function is not provided")

        # Case 1:
        if self.X is None:
            self.X = initial_design(self.initial_design_type, self.space, self.initial_design_numdata)
            self.Y, _ = self.objective.evaluate(self.X)
        # Case 2
        elif self.X is not None and self.Y is None:
            self.Y, _ = self.objective.evaluate(self.X)
1132089
function(data, param, value) {
    if(_definition[param]) {
      var paramInstance = Param(param, value, _definition[param]);
      _definition[param].param.forEach(function(p) {
        data[p] = paramInstance;
      });

    } else {
      // Unsupported if operating in strict mode
      if(_useStrict) {
        throw(new Error('Invalid argument syntax ('+param+')'));

      } else {
        data[param] = Param(param, value);
      }
    }
  }
1169457
def restore_model(cls, data):
    
    obj = cls()
    for field in data:
        setattr(obj, field, data[field][Field.VALUE])

    return obj
412465
def _process_data(*kwarg_names):
    
    def _data_decorator(func):
        @functools.wraps(func)
        def _mark_with_data(*args, **kwargs):
            data = kwargs.pop('data', None)
            if data is None:
                return func(*args, **kwargs)
            else:
                data_args = [data[i] if hashable(data, i) else i for i in args]
                data_kwargs = {
                   kw: data[kwargs[kw]] if hashable(data, kwargs[kw]) else kwargs[kw] for kw in set(kwarg_names).intersection(list(kwargs.keys()))
                }
                try:
                    # if any of the plots want to use the index_data, they can
                    # use it by referring to this attribute.
                    data_kwargs['index_data'] = data.index
                except AttributeError as e:
                    pass
                kwargs_update = kwargs.copy()
                kwargs_update.update(data_kwargs)
                return func(*data_args, **kwargs_update)

        return _mark_with_data
    return _data_decorator
613283
def return_main_dataset(self):
        
        if not self.main_dataset['source']:
            raise exceptions.UserError('Source is empty')

        extraction_code = self.main_dataset["source"]

        extraction_function = functions.import_object_from_string_code(extraction_code,
                                                                       "extract_main_dataset")
        try:
            X, y = extraction_function()
        except Exception as e:
            raise exceptions.UserError('User code exception', exception_message=str(e))

        X, y = np.array(X), np.array(y)

        return X, y
949207
def __parse(self, function_meta):
        
        self._func = get_mapping_function(
            function_meta["func_name"],
            self.functions_mapping
        )
        self.func_name = self._func.__name__
        self._args = prepare_lazy_data(
            function_meta.get("args", []),
            self.functions_mapping,
            self.check_variables_set
        )
        self._kwargs = prepare_lazy_data(
            function_meta.get("kwargs", {}),
            self.functions_mapping,
            self.check_variables_set
        )

        if self.func_name == "load_csv_file":
            if len(self._args) != 1 or self._kwargs:
                raise exceptions.ParamsError("P() should only pass in one argument!")
            self._args = [self._args[0]]
        elif self.func_name == "get_os_environ":
            if len(self._args) != 1 or self._kwargs:
                raise exceptions.ParamsError("ENV() should only pass in one argument!")
            self._args = [self._args[0]]
784931
function (file, importOptions = {}) {
        var self = this;

        // Step 1: Handle converting the file to usable data
        return this.loadFile(file).then(function (importData) {
            // Step 2: Let the importers pre-process the data
            return self.preProcess(importData);
        }).then(function (importData) {
            // Step 3: Actually do the import
            // @TODO: It would be cool to have some sort of dry run flag here
            return self.doImport(importData, importOptions);
        }).then(function (importData) {
            // Step 4: Report on the import
            return self.generateReport(importData);
        }).finally(() => self.cleanUp()); // Step 5: Cleanup any files
    }
1041500
def touch_model(self, model, **data):
        '''
        
        '''

        instance, created = model.objects.get_or_create(**data)

        if not created:
            if instance.updated < self.import_start_datetime:
                instance.save()     # Updates updated field

        return (instance, created)
324451
function importData(arr, outdivid) {
      $(outdivid).empty(); // flush messages

      // find number of datapoints
      N = arr.length;
      var t = [];
      SUCC(outdivid, "found " + N + " data points");
      if(N === 0) { FAIL(outdivid, 'no data points found?'); return; }
      
      // find dimensionality and enforce consistency
      D = arr[0].length;
      for(var i=0;i<N;i++) {
        var d = arr[i].length;
        if(d !== D) { FAIL(outdivid, 'data dimension not constant: line ' + i + ' has ' + d + ' entries.'); return; }
      }
      SUCC(outdivid, "data dimensionality is " + (D-1));
      
      // go through columns of data and figure out what they are
      var colstats = [];
      for(var i=0;i<D;i++) {
        var res = guessColumn(arr, i);
        colstats.push(res);
        if(D > 20 && i>3 && i < D-3) {
          if(i==4) {
            SUCC(outdivid, "..."); // suppress output for too many columns
          }
        } else {
          SUCC(outdivid, "column " + i + " looks " + (res.numeric ? "numeric" : "NOT numeric") + " and has " + res.num + " unique elements");
        }
      }

      return {arr: arr, colstats: colstats};
   }
1007460
def has_data(self, datatype, mode, disp):
        

        # Imports
        from ..error import RepoError

        # Just try to get the data. Simply pass up all exceptions except for
        #  those if the group or data doesn't exist. DO re-raise a non-bound
        #  repo. Initialize value to DATA PRESENT (True) for case where data
        #  is present and the 'try' succeeds.
        retval = True
        try:
            self.get_data(datatype, mode, disp)
        except RepoError as RErr:
            if RErr.tc in (RErr.DATA, RErr.GROUP):
                retval = False
            ## end if
        ## end try

        # Should be good to return
        return retval
795450
def get_data(self, typename, init_func=None):
    
    if typename not in self.data_products:
      if not init_func:
        return None
      self.data_products[typename] = init_func()
    return self.data_products.get(typename)
420442
def _loadData(self, data):
        
        self._setValue = None
        self.id = data.attrib.get('id')
        self.label = data.attrib.get('label')
        self.summary = data.attrib.get('summary')
        self.type = data.attrib.get('type')
        self.default = self._cast(data.attrib.get('default'))
        self.value = self._cast(data.attrib.get('value'))
        self.hidden = utils.cast(bool, data.attrib.get('hidden'))
        self.advanced = utils.cast(bool, data.attrib.get('advanced'))
        self.group = data.attrib.get('group')
        self.enumValues = self._getEnumValues(data)
736026
function getData (moduleName, require) {
    // get module - throws error if not defined
    var module = getModule(moduleName)
    // if require flag is set throw error if data is not defined
    if (require === true && !defined(module.meta.data)) {
        throw new Error(`no data for ${moduleName}`)
    }
    // return data if any
    return module.meta.data
}
452096
def use_schema(schema, list_view=False, locations=None):
    

    def decorator(func):
        @functools.wraps(func)
        def wrapped(*args, **kwargs):
            use_args_wrapper = parser.use_args(schema, locations=locations)
            # Function wrapped with use_args
            func_with_args = use_args_wrapper(func)
            ret = func_with_args(*args, **kwargs)
            # Serialize and jsonify the return value
            return jsonify(schema.dump(ret, many=list_view).data)

        return wrapped

    return decorator
528884
function() {
    const self = this;
    const outBindPrep = this._prepOutbindings(
      this.single.insert,
      this.single.returning
    );
    const outBinding = outBindPrep.outBinding;
    const returning = outBindPrep.returning;
    const insertValues = outBindPrep.values;

    if (
      Array.isArray(insertValues) &&
      insertValues.length === 1 &&
      _.isEmpty(insertValues[0])
    ) {
      return this._addReturningToSqlAndConvert(
        'insert into ' +
          this.tableName +
          ' (' +
          this.formatter.wrap(this.single.returning) +
          ') values (default)',
        outBinding[0],
        this.tableName,
        returning
      );
    }

    if (
      _.isEmpty(this.single.insert) &&
      typeof this.single.insert !== 'function'
    ) {
      return '';
    }

    const insertData = this._prepInsert(insertValues);

    const sql = {};

    if (_.isString(insertData)) {
      return this._addReturningToSqlAndConvert(
        'insert into ' + this.tableName + ' ' + insertData,
        outBinding[0],
        this.tableName,
        returning
      );
    }

    if (insertData.values.length === 1) {
      return this._addReturningToSqlAndConvert(
        'insert into ' +
          this.tableName +
          ' (' +
          this.formatter.columnize(insertData.columns) +
          ') values (' +
          this.formatter.parameterize(insertData.values[0]) +
          ')',
        outBinding[0],
        this.tableName,
        returning
      );
    }

    const insertDefaultsOnly = insertData.columns.length === 0;
    sql.returning = returning;
    sql.sql =
      'begin ' +
      _.map(insertData.values, function(value, index) {
        const parameterizedValues = !insertDefaultsOnly
          ? self.formatter.parameterize(value, self.client.valueForUndefined)
          : '';
        let subSql = 'insert into ' + self.tableName;

        if (insertDefaultsOnly) {
          // No columns given so only the default value
          subSql +=
            ' (' +
            self.formatter.wrap(self.single.returning) +
            ') values (default)';
        } else {
          subSql +=
            ' (' +
            self.formatter.columnize(insertData.columns) +
            ') values (' +
            parameterizedValues +
            ')';
        }

        let returningClause = '';
        let intoClause = '';
        // ToDo review if this code is still needed or could be dropped
        // eslint-disable-next-line no-unused-vars
        let usingClause = '';
        let outClause = '';

        _.each(value, function(val) {
          if (!(val instanceof BlobHelper)) {
            usingClause += ' ?,';
          }
        });
        usingClause = usingClause.slice(0, -1);

        // Build returning and into clauses
        _.each(outBinding[index], function(ret) {
          const columnName = ret.columnName || ret;
          returningClause += self.formatter.wrap(columnName) + ',';
          intoClause += ' ?,';
          outClause += ' out ?,';

          // Add Helpers to bindings
          if (ret instanceof BlobHelper) {
            return self.formatter.bindings.push(ret);
          }
          self.formatter.bindings.push(new ReturningHelper(columnName));
        });

        // Strip last comma
        returningClause = returningClause.slice(0, -1);
        intoClause = intoClause.slice(0, -1);
        outClause = outClause.slice(0, -1);

        if (returningClause && intoClause) {
          subSql += ' returning ' + returningClause + ' into' + intoClause;
        }

        // Pre bind position because subSql is an execute immediate parameter
        // later position binding will only convert the ? params
        subSql = self.formatter.client.positionBindings(subSql);
        const parameterizedValuesWithoutDefaultAndBlob = parameterizedValues
          .replace('DEFAULT, ', '')
          .replace(', DEFAULT', '')
          .replace('EMPTY_BLOB(), ', '')
          .replace(', EMPTY_BLOB()', '');
        return (
          "execute immediate '" +
          subSql.replace(/'/g, "''") +
          (parameterizedValuesWithoutDefaultAndBlob || value
            ? "' using "
            : '') +
          parameterizedValuesWithoutDefaultAndBlob +
          (parameterizedValuesWithoutDefaultAndBlob && outClause ? ',' : '') +
          outClause +
          ';'
        );
      }).join(' ') +
      'end;';

    sql.outBinding = outBinding;
    if (returning[0] === '*') {
      // Generate select statement with special order by
      // to keep the order because 'in (..)' may change the order
      sql.returningSql = function() {
        return (
          'select * from ' +
          self.tableName +
          ' where ROWID in (' +
          this.outBinding
            .map(function(v, i) {
              return ':' + (i + 1);
            })
            .join(', ') +
          ')' +
          ' order by case ROWID ' +
          this.outBinding
            .map(function(v, i) {
              return 'when CHARTOROWID(:' + (i + 1) + ') then ' + i;
            })
            .join(' ') +
          ' end'
        );
      };
    }

    return sql;
  }
621413
def _wrapped(self):
        

        # It is possible for a callable instance without __name__ attribute or/and
        # __module__ attribute to be wrapped here. For example, functools.partial. In this case,
        # we should avoid wrapping the attributes from the wrapped function to the wrapper
        # function. So, we take out these attribute names from the default names to set and
        # then manually assign it after being wrapped.
        assignments = tuple(
            a for a in functools.WRAPPER_ASSIGNMENTS if a != '__name__' and a != '__module__')

        @functools.wraps(self.func, assigned=assignments)
        def wrapper(*args):
            return self(*args)

        wrapper.__name__ = self._name
        wrapper.__module__ = (self.func.__module__ if hasattr(self.func, '__module__')
                              else self.func.__class__.__module__)

        wrapper.func = self.func
        wrapper.returnType = self.returnType
        wrapper.evalType = self.evalType
        wrapper.deterministic = self.deterministic
        wrapper.asNondeterministic = functools.wraps(
            self.asNondeterministic)(lambda: self.asNondeterministic()._wrapped())
        return wrapper