Reset the GLI module internal data structures; mostly useful for testing
17121
def reset # :nodoc:
      switches.clear
      flags.clear
      @commands = nil
      @commands_declaration_order = []
      @flags_declaration_order = []
      @switches_declaration_order = []
      @version = nil
      @config_file = nil
      @use_openstruct = false
      @prog_desc = nil
      @error_block = false
      @pre_block = false
      @post_block = false
      @default_command = :help
      @autocomplete = false
      @around_block = nil
      @subcommand_option_handling_strategy = :legacy
      @argument_handling_strategy = :loose
      clear_nexts
    end
1296679
def reset(self):
    
    self.bumpPhases = np.empty((2,0), dtype="float")
    self.phaseDisplacement = np.empty((0,2), dtype="float")
    self.cellsForActivePhases = np.empty(0, dtype="int")
    self.activeCells = np.empty(0, dtype="int")
    self.learningCells = np.empty(0, dtype="int")
    self.sensoryAssociatedCells = np.empty(0, dtype="int")
1035224
function restore_allstate(res)
{
    if (gli_windowlist || gli_streamlist || gli_filereflist)
        throw('restore_allstate: glkapi module has already been launched');

    /* We build and register all the bare objects first. (In reverse
       order so that the linked lists come out right way around.) */

    for (var ix=res.windows.length-1; ix>=0; ix--) {
        var obj = res.windows[ix];
        var win = {
            type: obj.type, rock: obj.rock, disprock: obj.disprock,
            style: obj.style, hyperlink: obj.hyperlink
        };
        GiDispa.class_register('window', win, win.disprock);

        win.prev = null;
        win.next = gli_windowlist;
        gli_windowlist = win;
        if (win.next)
            win.next.prev = win;
    }

    for (var ix=res.streams.length-1; ix>=0; ix--) {
        var obj = res.streams[ix];
        var str = {
            type: obj.type, rock: obj.rock, disprock: obj.disprock,
            unicode: obj.unicode, isbinary: obj.isbinary,
            readcount: obj.readcount, writecount: obj.writecount,
            readable: obj.readable, writable: obj.writable,
            streaming: obj.streaming
        };
        GiDispa.class_register('stream', str, str.disprock);

        str.prev = null;
        str.next = gli_streamlist;
        gli_streamlist = str;
        if (str.next)
            str.next.prev = str;
    }

    for (var ix=res.filerefs.length-1; ix>=0; ix--) {
        var obj = res.filerefs[ix];
        var fref = {
            type: obj.type, rock: obj.rock, disprock: obj.disprock,
            filename: obj.filename, textmode: obj.textmode,
            filetype: obj.filetype, filetypename: obj.filetypename
        };
        GiDispa.class_register('fileref', fref, fref.disprock);

        fref.prev = null;
        fref.next = gli_filereflist;
        gli_filereflist = fref;
        if (fref.next)
            fref.next.prev = fref;
    }

    /* ...Now we fill in the cross-references. */

    for (var ix=0; ix<res.windows.length; ix++) {
        var obj = res.windows[ix];
        var win = GiDispa.class_obj_from_id('window', obj.disprock);

        win.parent = GiDispa.class_obj_from_id('window', obj.parent);
        win.str = GiDispa.class_obj_from_id('stream', obj.str);
        win.echostr = GiDispa.class_obj_from_id('stream', obj.echostr);

        win.bbox = { 
            left: obj.bbox.left, right: obj.bbox.right,
            top: obj.bbox.top, bottom: obj.bbox.bottom 
        };

        win.input_generation = null;
        if (obj.char_request || obj.line_request)
            win.input_generation = event_generation;
        win.linebuf = null;
        if (obj.linebuf !== undefined) {
            // should clone that object
            win.linebuf = obj.linebuf.arr;
            GiDispa.retain_array(win.linebuf, obj.linebuf);
        }
        win.char_request = obj.char_request;
        win.line_request = obj.line_request;
        win.char_request_uni = obj.char_request_uni;
        win.line_request_uni = obj.line_request_uni;
        win.hyperlink_request = obj.hyperlink_request;
        win.mouse_request = obj.mouse_request;
        win.echo_line_input = obj.echo_line_input;
        win.request_echo_line_input = obj.request_echo_line_input;
        win.line_input_terminators = obj.line_input_terminators.slice(0);
        //### should have a request_line_input_terminators as well

        switch (win.type) {
        case Const.wintype_TextBuffer:
            win.accum = [];
            win.accumstyle = win.style;
            win.accumhyperlink = win.hyperlink;
            win.content = obj.reserve.slice(0);
            win.clearcontent = false;
            win.reserve = [];
            break;
        case Const.wintype_TextGrid:
            win.gridwidth = obj.gridwidth;
            win.gridheight = obj.gridheight;
            win.lines = [];
            for (var jx=0; jx<obj.lines.length; jx++) {
                var ln = obj.lines[jx];
                win.lines.push({
                        dirty: true,
                        chars: ln.chars.slice(0),
                        styles: ln.styles.slice(0),
                        hyperlinks: ln.hyperlinks.slice(0)
                    });
            }
            win.cursorx = obj.cursorx;
            win.cursory = obj.cursory;
            break;
        case Const.wintype_Graphics:
            win.graphwidth = obj.graphwidth;
            win.graphheight = obj.graphheight;
            win.content = obj.reserve.slice(0);
            win.reserve = [];
            break;
        case Const.wintype_Pair:
            win.pair_dir = obj.pair_dir;
            win.pair_division = obj.pair_division;
            win.pair_key = GiDispa.class_obj_from_id('window', obj.pair_key);
            win.pair_keydamage = false;
            win.pair_size = obj.pair_size;
            win.pair_hasborder = obj.pair_hasborder;
            win.pair_vertical = obj.pair_vertical;
            win.pair_backward = obj.pair_backward;
            win.child1 = GiDispa.class_obj_from_id('window', obj.child1);
            win.child2 = GiDispa.class_obj_from_id('window', obj.child2);
            break;
        }
    }

    for (var ix=0; ix<res.streams.length; ix++) {
        var obj = res.streams[ix];
        var str = GiDispa.class_obj_from_id('stream', obj.disprock);

        /* Defaults first... */
        str.win = null;
        str.ref = null;
        str.file = null;

        str.buf = null;
        str.bufpos = 0;
        str.buflen = 0;
        str.bufeof = 0;
        str.timer_id = null;
        str.flush_func = null;
        str.fstream = null;

        switch (str.type) {

        case strtype_Window:
            str.win = GiDispa.class_obj_from_id('window', obj.win);
            break;

        case strtype_Memory:
            if (obj.buf !== undefined) {
                // should clone that object
                str.buf = obj.buf.arr;
                GiDispa.retain_array(str.buf, obj.buf);
            }
            str.buflen = obj.buflen;
            str.bufpos = obj.bufpos;
            str.bufeof = obj.bufeof;
            break;

        case strtype_Resource:
            str.resfilenum = obj.resfilenum;
            var el = GiLoad.find_data_chunk(str.resfilenum);
            if (el) {
                str.buf = el.data;
            }
            str.buflen = obj.buflen;
            str.bufpos = obj.bufpos;
            str.bufeof = obj.bufeof;
            break;

        case strtype_File:
            str.origfmode = obj.origfmode;
            if (!Dialog.streaming) {
                str.ref = obj.ref;
                str.buflen = obj.buflen;
                str.bufpos = obj.bufpos;
                str.bufeof = obj.bufeof;

                var content = Dialog.file_read(str.ref);
                if (content == null) {
                    /* The file was somehow deleted. Create an empty
                       file (even in read mode). */
                    content = [];
                    Dialog.file_write(str.ref, '', true);
                }
                str.buf = content;

                /* If the file has been shortened, we might have to
                   trim bufeof to fit within it. The game might see
                   the file pos mysteriously move; sorry. */
                str.bufeof = content.length;
                if (str.bufpos > str.bufeof)
                    str.bufpos = str.bufeof;
            }
            else {
                str.ref = obj.ref;
                str.fstream = Dialog.file_fopen(str.origfmode, str.ref);
                if (!str.fstream) {
                    /* This is the panic case. We can't reopen the stream,
                       but the game expects an open stream! We'll just
                       have to open a temporary file; the user will never
                       get their data, but at least the game won't crash.
                       (Better policy would be to prompt the user for
                       a new file location...) */
                    var tempref = Dialog.file_construct_temp_ref(str.ref.usage);
                    str.fstream = Dialog.file_fopen(str.origfmode, tempref);
                    if (!str.fstream)
                        throw('restore_allstate: could not reopen even a temp stream for: ' + str.ref.filename);
                }

                if (str.origfmode != Const.filemode_WriteAppend) {
                    /* Jump to the last known filepos. */
                    str.fstream.fseek(obj.filepos, Const.seekmode_Start);
                }

                str.buffer4 = new str.fstream.BufferClass(4);
            }
            break;

        }
    }

    for (var ix=0; ix<res.filerefs.length; ix++) {
        var obj = res.filerefs[ix];
        var fref = GiDispa.class_obj_from_id('fileref', obj.disprock);

        fref.ref = obj.ref; // should deep clone
    }

    gli_rootwin = GiDispa.class_obj_from_id('window', res.rootwin);
    gli_currentstr = GiDispa.class_obj_from_id('stream', res.currentstr);

    if (res.timer_interval)
        glk_request_timer_events(res.timer_interval);

    /* Stash this for the next (first) GlkOte.update call. */
    gli_autorestore_glkstate = res.glkote;
}
323621
function restorePackState(gl, options) {
  if (options.colorspaceConversion !== undefined) {
    gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, lastPackState.colorspaceConversion);
  }
  if (options.premultiplyAlpha !== undefined) {
    gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, lastPackState.premultiplyAlpha);
  }
  if (options.flipY !== undefined) {
    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, lastPackState.flipY);
  }
}
1022134
def reset!
      Dir.chdir(@gl_admin.working_dir) do
        @gl_admin.git.reset({:hard => true}, 'HEAD')
        @gl_admin.git.clean({:d => true, :q => true, :f => true})
      end
      reload!
    end
999151
function freeGLResources(glResources) {
  const gl = glResources.gl;

  // Delete each program
  Object.keys(glResources.programs).forEach((programName) => {
    const program = glResources.programs[programName];
    const shaders = program.shaders;

    let count = shaders.length;

    // Delete shaders
    while (count) {
      count -= 1;
      gl.deleteShader(shaders[count]);
    }

    // Delete program
    gl.deleteProgram(program);
  });

  // Delete framebuffers
  Object.keys(glResources.framebuffers).forEach((fbName) => {
    gl.deleteFramebuffer(glResources.framebuffers[fbName]);
  });

  // Delete textures
  Object.keys(glResources.textures).forEach((textureName) => {
    gl.deleteTexture(glResources.textures[textureName]);
  });

  // Delete buffers
  Object.keys(glResources.buffers).forEach((bufferName) => {
    gl.deleteBuffer(glResources.buffers[bufferName]);
  });
}
1262376
def cleanup(self):
        ""
        if self.m_glVertBuffer != 0:
            glDeleteBuffers(1, (self.m_glIndexBuffer,))
            glDeleteVertexArrays( 1, (self.m_glVertArray,) )
            glDeleteBuffers(1, (self.m_glVertBuffer,))
            self.m_glIndexBuffer = 0
            self.m_glVertArray = 0
            self.m_glVertBuffer = 0
789269
def reset(self):
        
        self.solved = False
        self.niter = 0
        self.iter_mis = []
        self.F = None
        self.system.dae.factorize = True
85108
def _reset(self):
        '''
        
        '''
        self.__cmd = ['zypper', '--non-interactive']
        self.__exit_code = 0
        self.__call_result = dict()
        self.__error_msg = ''
        self.__env = salt.utils.environment.get_module_environment(globals())

        # Call config
        self.__xml = False
        self.__no_lock = False
        self.__no_raise = False
        self.__refresh = False
        self.__ignore_repo_failure = False
        self.__systemd_scope = False
        self.__root = None

        # Call status
        self.__called = False
638115
public static void resetMask() {
		GL.glDepthMask(true);
		GL.glClearDepth(0);
		GL.glClear(SGL.GL_DEPTH_BUFFER_BIT);
		GL.glDepthMask(false);
		
		GL.glDisable(SGL.GL_DEPTH_TEST);
	}
1231304
def reset(self, params, repetition):
    
    self.startTime = time.time()
    print(params)
    seed = params["seed"] + repetition
    torch.manual_seed(seed)
    np.random.seed(seed)
    random.seed(seed)

    # Get our directories correct
    self.dataDir = os.path.join(params["datadir"], "speech_commands")
    self.resultsDir = os.path.join(params["path"], params["name"], "plots")

    if not os.path.exists(self.resultsDir):
      os.makedirs(self.resultsDir)

    self.use_cuda = not params["no_cuda"] and torch.cuda.is_available()
    if self.use_cuda:
      print("*********using cuda!")
    self.device = torch.device("cuda" if self.use_cuda else "cpu")

    self.use_preprocessed_dataset = False
    self.loadDatasets(params)

    # Parse 'n' and 'k' parameters
    n = params["n"]
    k = params["k"]
    if isinstance(n, basestring):
      n = map(int, n.split("_"))
    if isinstance(k, basestring):
      k = map(int, k.split("_"))

    if params["model_type"] == "cnn":
      c1_out_channels = params["c1_out_channels"]
      c1_k = params["c1_k"]
      if isinstance(c1_out_channels, basestring):
        c1_out_channels = map(int, c1_out_channels.split("_"))
      if isinstance(c1_k, basestring):
        c1_k = map(int, c1_k.split("_"))

      # Parse 'c1_input_shape; parameter
      if "c1_input_shape" in params:
        c1_input_shape = map(int, params["c1_input_shape"].split("_"))
      else:
        c1_input_shape = (1, 32, 32)

      sp_model = SparseNet(
        inputSize=c1_input_shape,
        outputSize=len(self.train_loader.dataset.classes),
        outChannels=c1_out_channels,
        c_k=c1_k,
        kernelSize=5,
        stride=1,
        dropout=params["dropout"],
        n=n,
        k=k,
        boostStrength=params["boost_strength"],
        weightSparsity=params["weight_sparsity"],
        weightSparsityCNN=params["weight_sparsity_cnn"],
        boostStrengthFactor=params["boost_strength_factor"],
        kInferenceFactor=params["k_inference_factor"],
        useBatchNorm=params["use_batch_norm"],
        normalizeWeights=params.get("normalize_weights", False)
      )
    elif params["model_type"] == "resnet9":
      sp_model = resnet9(num_classes=len(self.train_loader.dataset.classes),
                         in_channels=1)
    elif params["model_type"] == "linear":
      sp_model = SparseNet(
        n=n,
        k=k,
        inputSize=32*32,
        outputSize=len(self.train_loader.dataset.classes),
        boostStrength=params["boost_strength"],
        weightSparsity=params["weight_sparsity"],
        boostStrengthFactor=params["boost_strength_factor"],
        kInferenceFactor=params["k_inference_factor"],
        dropout=params["dropout"],
        useBatchNorm=params["use_batch_norm"],
        normalizeWeights=params.get("normalize_weights", False)
      )
    else:
      raise RuntimeError("Unknown model type")

    if torch.cuda.device_count() > 1:
      print("Using", torch.cuda.device_count(), "GPUs")
      sp_model = torch.nn.DataParallel(sp_model)

    self.model = sp_model.to(self.device)
    self.learningRate = params["learning_rate"]
    self.optimizer = self.createOptimizer(params, self.model)
    self.lr_scheduler = self.createLearningRateScheduler(params, self.optimizer)
945542
def reset_parameters(self, init_weight):
        
        stdv = 1. / math.sqrt(self.num_units)
        self.linear_att.data.uniform_(-init_weight, init_weight)

        if self.normalize:
            self.normalize_scalar.data.fill_(stdv)
            self.normalize_bias.data.zero_()
83352
def gpu_mem_restore(func):
    ""
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        tb_clear_frames = os.environ.get('FASTAI_TB_CLEAR_FRAMES', None)
        if not IS_IN_IPYTHON or tb_clear_frames=="0":
            return func(*args, **kwargs)

        try:
            return func(*args, **kwargs)
        except Exception as e:
            if ("CUDA out of memory" in str(e) or
                "device-side assert triggered" in str(e) or
                tb_clear_frames == "1"):
                type, val, tb = get_ref_free_exc_info() # must!
                gc.collect()
                if "device-side assert triggered" in str(e):
                    warn("""When 'device-side assert triggered' error happens, it's not possible to recover and you must restart the kernel to continue. Use os.environ['CUDA_LAUNCH_BLOCKING']="1" before restarting to debug""")
                raise type(val).with_traceback(tb) from None
            else: raise # re-raises the exact last exception
    return wrapper
438342
def clear_globals_reload_modules(self):
        """"""

        self.code_array.clear_globals()
        self.code_array.reload_modules()

        # Clear result cache
        self.code_array.result_cache.clear()
874958
def OnClearGlobals(self, event):
        """"""

        msg = _("Deleting globals and reloading modules cannot be undone."
                " Proceed?")
        short_msg = _("Really delete globals and modules?")

        choice = self.main_window.interfaces.get_warning_choice(msg, short_msg)

        if choice:
            self.main_window.grid.actions.clear_globals_reload_modules()

            statustext = _("Globals cleared and base modules reloaded.")
            post_command_event(self.main_window, self.main_window.StatusBarMsg,
                               text=statustext)
672036
def reset(self):
        
        self._solver.reset()

        # Memory versioning.
        self._mem_instance = 0

        self._mem_init = smtsymbol.BitVecArray(self._address_size, 8, "MEM_{}".format(self._mem_instance))
        self._mem_curr = self.make_array(self._address_size, "MEM_{}".format(self._mem_instance))

        self._var_name_mappers = {}
1335769
public final void reset()
  {

    m_lastChunk = 0;
    m_firstFree = 0;

    // Recover the original chunk size
    FastStringBuffer innermost = this;

    while (innermost.m_innerFSB != null)
    {
      innermost = innermost.m_innerFSB;
    }

    m_chunkBits = innermost.m_chunkBits;
    m_chunkSize = innermost.m_chunkSize;
    m_chunkMask = innermost.m_chunkMask;

    // Discard the hierarchy
    m_innerFSB = null;
    m_array = new char[16][0];
    m_array[0] = new char[m_chunkSize];
  }