How to use the dill.copy function in dill

To help you get started, we’ve selected a few dill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uqfoundation / dill / tests / test_classdef.py View on Github external
def test_slots():
    assert dill.pickles(Y)
    assert dill.pickles(y)
    assert dill.pickles(Y.y)
    assert dill.copy(y).y == value
github uqfoundation / dill / tests / test_module.py View on Github external
def test_module_is_none():
    assert obj.__module__ is None
    assert dill.copy(obj)(3) == obj(3)
github uqfoundation / dill / tests / test_recursive.py View on Github external
def test_super():
    assert dill.copy(obj1(), byref=True)
    assert dill.copy(obj1(), byref=True, recurse=True)
   #assert dill.copy(obj1(), recurse=True) #FIXME: fails __main__.py
    assert dill.copy(obj1())

    assert dill.copy(obj2(), byref=True)
    assert dill.copy(obj2(), byref=True, recurse=True)
   #assert dill.copy(obj2(), recurse=True) #FIXME: fails __main__.py
    assert dill.copy(obj2())

    assert dill.copy(obj3(), byref=True)
    assert dill.copy(obj3(), byref=True, recurse=True)
   #assert dill.copy(obj3(), recurse=True) #FIXME: fails __main__.py
    assert dill.copy(obj3())
github uqfoundation / dill / tests / test_recursive.py View on Github external
def test_super():
    assert dill.copy(obj1(), byref=True)
    assert dill.copy(obj1(), byref=True, recurse=True)
   #assert dill.copy(obj1(), recurse=True) #FIXME: fails __main__.py
    assert dill.copy(obj1())

    assert dill.copy(obj2(), byref=True)
    assert dill.copy(obj2(), byref=True, recurse=True)
   #assert dill.copy(obj2(), recurse=True) #FIXME: fails __main__.py
    assert dill.copy(obj2())

    assert dill.copy(obj3(), byref=True)
    assert dill.copy(obj3(), byref=True, recurse=True)
   #assert dill.copy(obj3(), recurse=True) #FIXME: fails __main__.py
    assert dill.copy(obj3())
github uqfoundation / dill / tests / test_recursive.py View on Github external
def test_partial():
    assert dill.copy(Machine(), byref=True)
    assert dill.copy(Machine(), byref=True, recurse=True)
    if not OLDER:
        assert dill.copy(Machine(), recurse=True)
    assert dill.copy(Machine())
github 3fon3fonov / exostriker / exostriker / lib / detrend_window.py View on Github external
def plotClicked(self,curve,datas):

        if self.ui.click_to_reject.isChecked() == False:
            return

        rem_x,rem_y = datas[0].pos()
        print("Removed x,y: ",rem_x,rem_y)

        self.old_t = dill.copy(self.t)

        self.t            = dill.copy(self.t[self.old_t != rem_x])
        self.flux         = dill.copy(self.flux[self.old_t != rem_x])
        self.flux_err     = dill.copy(self.flux_err[self.old_t != rem_x])
        self.flux_o_c     = dill.copy(self.flux_o_c[self.old_t != rem_x])
        self.flux_err_o_c = dill.copy(self.flux_err_o_c[self.old_t != rem_x])
        self.trend        = dill.copy(self.trend[self.old_t != rem_x])


        self.ui.plot.plotItem.items[1].setData(x=self.t,y=self.flux)
        self.ui.plot.plotItem.items[2].setData(x=self.t, y=self.flux,  
                                   top=self.flux_err, 
                                   bottom=self.flux_err)

        self.ui.plot_2.plotItem.items[1].setData(x=self.t,y=self.flux_o_c)
        self.ui.plot_2.plotItem.items[2].setData(x=self.t, y=self.flux_o_c,  
                                   top=self.flux_err_o_c, 
                                   bottom=self.flux_err_o_c)
github 3fon3fonov / exostriker / exostriker / lib / RV_mod / functions.py View on Github external
def phase_RV_planet_signal(obj,planet):

    if obj.npl ==0 or len(obj.fit_results.rv_model.jd) ==0:
        return
    else:

        copied_obj = dill.copy(obj)

        if(copied_obj.mod_dynamical):
            copied_obj.mod_dynamical = False

        index = planet - 1
        ############################################
        ############# here is the trick!  ##########
        ############################################
        pp0 =  copied_obj.params.planet_params[7*index+0]  # we define a variable to be the planet amplitude Kj

        copied_obj.params.planet_params[7*index+0] = 0.0000001 # then we set Kj to be 0, i.e. remove the j-th planet signal
        copied_obj.fitting(minimize_loglik=True, amoeba_starts=0,
                           outputfiles=[0,1,1],return_flag=False, npoints=int(len(obj.fit_results.model)),
                           model_max=int(max(obj.fit_results.model_jd)-max(copied_obj.fit_results.rv_model.jd)),
                           model_min=int(copied_obj.epoch -min(obj.fit_results.model_jd)))
github 3fon3fonov / exostriker / exostriker / mcmc / make_cornerplot.py View on Github external
dom_amp = (max(dom) - min(dom))/2.0
        
        
        del fit2 
        
        return [
        np.mean(np.array(Prat)),
        np.mean(np.array(dom_amp)),
        np.mean(np.array(theta_1_amp)),
        np.mean(np.array(theta_2_amp))]


    os.chdir('../')
    
    ncpus = 4
    fit2 = dill.copy(fit)
    del fit2.mcmc_sampler

    def partial_func(samp_ii):
        loglik = mcmc_satb(fit2, samp_ii)
        return loglik

    with Pool(ncpus=ncpus) as thread: 
        results = thread.map(partial_func,   [samp_i for samp_i in samples])
 

    thread.close()
    thread.join()
    thread.clear()

        
    os.chdir('./MCMC/')
github 3fon3fonov / exostriker / exostriker / lib / detrend_window.py View on Github external
def init_data(self):

        self.t      = self.parent.tra_data[0]
        self.flux   = self.parent.tra_data[4]
        self.flux_err = self.parent.tra_data[2]
        self.data_file_name = self.parent.tra_data[-1]
        self.old_t = dill.copy(self.t)
        return
github 3fon3fonov / exostriker / lib / detrend_window.py View on Github external
def plotClicked(self,curve,datas):

        if self.ui.click_to_reject.isChecked() == False:
            return

        rem_x,rem_y = datas[0].pos()
        print("Removed x,y: ",rem_x,rem_y)

        self.old_t = dill.copy(self.t)

        self.t            = dill.copy(self.t[self.old_t != rem_x])
        self.flux         = dill.copy(self.flux[self.old_t != rem_x])
        self.flux_err     = dill.copy(self.flux_err[self.old_t != rem_x])
        self.flux_o_c     = dill.copy(self.flux_o_c[self.old_t != rem_x])
        self.flux_err_o_c = dill.copy(self.flux_err_o_c[self.old_t != rem_x])
        self.trend        = dill.copy(self.trend[self.old_t != rem_x])


        self.ui.plot.plotItem.items[1].setData(x=self.t,y=self.flux)
        self.ui.plot.plotItem.items[2].setData(x=self.t, y=self.flux,  
                                   top=self.flux_err, 
                                   bottom=self.flux_err)

        self.ui.plot_2.plotItem.items[1].setData(x=self.t,y=self.flux_o_c)
        self.ui.plot_2.plotItem.items[2].setData(x=self.t, y=self.flux_o_c,  
                                   top=self.flux_err_o_c, 
                                   bottom=self.flux_err_o_c)