Python numpy.RankWarning() Examples
The following are 5
code examples of numpy.RankWarning().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: stats.py From faceswap with GNU General Public License v3.0 | 6 votes |
def __init__(self, session, display="loss", loss_keys=["loss"], selections=["raw"], avg_samples=500, smooth_amount=0.90, flatten_outliers=False, is_totals=False): logger.debug("Initializing %s: (session: %s, display: %s, loss_keys: %s, selections: %s, " "avg_samples: %s, smooth_amount: %s, flatten_outliers: %s, is_totals: %s", self.__class__.__name__, session, display, loss_keys, selections, avg_samples, smooth_amount, flatten_outliers, is_totals) warnings.simplefilter("ignore", np.RankWarning) self.session = session self.display = display self.loss_keys = loss_keys self.selections = selections self.is_totals = is_totals self.args = {"avg_samples": avg_samples, "smooth_amount": smooth_amount, "flatten_outliers": flatten_outliers} self.iterations = 0 self.stats = None self.refresh() logger.debug("Initialized %s", self.__class__.__name__)
Example #2
Source File: transposer.py From artisan with GNU General Public License v3.0 | 5 votes |
def calcTimeResults(self): res = [] if self.aw.qmc.transMappingMode == 0: # discrete mapping # adding CHARGE fits = self.calcDiscretefits([0] + self.profileTimes,[0] + self.targetTimes) for i in range(4): if self.profileTimes[i] is not None and fits[i+1] is not None: res.append(numpy.poly1d(fits[i+1])(self.profileTimes[i])) else: res.append(None) else: with warnings.catch_warnings(): warnings.filterwarnings('error') try: fit = self.calcTimePolyfit() # that that this fit is already applied to numpy.polyfit !! for i in range(4): if fit is not None and self.profileTimes[i] is not None: res.append(fit(self.profileTimes[i])) else: res.append(None) except numpy.RankWarning: pass except: pass return res # returns the list of results temperatures and the polyfit or None as second result
Example #3
Source File: transposer.py From artisan with GNU General Public License v3.0 | 4 votes |
def calcTempResults(self): res = [] fit = None if self.aw.qmc.transMappingMode == 0: # discrete mapping fits = self.calcDiscretefits(self.profileTemps,self.targetTemps) for i in range(5): if self.profileTemps[i] is not None and fits[i] is not None: res.append(numpy.poly1d(fits[i])(self.profileTemps[i])) else: res.append(None) active_fits = list(filter(lambda x: x[1][1] is not None,zip(fits,zip(self.profileTemps,self.targetTemps)))) if len(active_fits) > 0 and len(active_fits) < 3: fit = self.aw.fit2str(fits[0]) else: formula = "" last_target = None for f,tpl in reversed(active_fits[:-1]): if last_target is None: formula = self.aw.fit2str(f) else: formula = "({} if x<{} else {})".format(self.aw.fit2str(f), last_target, formula) last_target = tpl[1] fit = formula else: with warnings.catch_warnings(): warnings.filterwarnings('error') try: fit = self.calcTempPolyfit() # numpy.poly1d not yet applied to this fit p = numpy.poly1d(fit) for i in range(5): if fit is not None and self.profileTemps[i] is not None: res.append(p(self.profileTemps[i])) else: res.append(None) except numpy.RankWarning: pass except: pass return res,fit # returns target times based on the phases target
Example #4
Source File: transposer.py From artisan with GNU General Public License v3.0 | 4 votes |
def applyTimeTransformation(self): # first update the targets self.targetTimes = self.getTargetTimes() if all(v is None for v in self.targetTimes): target_times, target_phases = self.getTargetPhases() if all(v is None for v in target_times + target_phases): self.aw.qmc.timex = self.org_timex[:] self.aw.qmc.extratimex = copy.deepcopy(self.org_extratimex) return False else: self.targetTimes = self.getTargetPhasesTimes() # calculate the offset of 00:00 offset = self.forgroundOffset() # apply either the discrete or the polyfit mappings if self.aw.qmc.transMappingMode == 0: # discrete mapping fits = self.calcDiscretefits([0] + self.profileTimes,[0] + self.targetTimes) self.aw.qmc.timex = self.applyDiscreteTimeMapping(self.org_timex,fits) # apply to the extra timex self.aw.qmc.extratimex = [] for timex in self.org_extratimex: try: timex_trans = self.applyDiscreteTimeMapping(timex,fits) except: timex_trans = timex self.aw.qmc.extratimex.append(timex_trans) else: # polyfit mappings with warnings.catch_warnings(): warnings.filterwarnings('error') try: fit = self.calcTimePolyfit() # the fit returned here is already applied to numpy.poly1d if fit is not None: self.aw.qmc.timex = [fit(tx-offset) for tx in self.org_timex] if len(self.aw.qmc.timex) > 0 and self.aw.qmc.timeindex[0] != -1: foffset = self.aw.qmc.timex[0] self.aw.qmc.timex = [tx+foffset for tx in self.aw.qmc.timex] extratimex = [] for timex in self.org_extratimex: offset = 0 if self.aw.qmc.timeindex[0] != -1: offset = timex[self.aw.qmc.timeindex[0]] new_timex = [fit(tx-offset) for tx in timex] if len(new_timex) > 0 and self.aw.qmc.timeindex[0] != -1: foffset = new_timex[0] new_timex = [tx+foffset for tx in new_timex] extratimex.append(new_timex) self.aw.qmc.extratimex = extratimex except numpy.RankWarning: pass return True # returns False if no transformation was applied
Example #5
Source File: transposer.py From artisan with GNU General Public License v3.0 | 4 votes |
def applyTempTransformation(self): # first update the targets self.targetTemps = self.getTargetTemps() if all(v is None for v in self.targetTemps): self.aw.qmc.temp2 = self.org_temp2[:] return False # apply either the discrete or the polyfit mappings if self.aw.qmc.transMappingMode == 0: # discrete mappings, length 5 fits = self.calcDiscretefits(self.profileTemps,self.targetTemps) self.aw.qmc.temp2 = [] for i in range(len(self.org_temp2)): # first fit is to be applied for all readings before DRY j = 0 if self.aw.qmc.timeindex[6] > 0 and i >= self.aw.qmc.timeindex[6]: # last fit counts after DROP j = 4 elif self.aw.qmc.timeindex[4] > 0 and i >= self.aw.qmc.timeindex[4]: j = 3 # after SCs elif self.aw.qmc.timeindex[2] > 0 and i >= self.aw.qmc.timeindex[2]: j = 2 # after FCs elif self.aw.qmc.timeindex[1] > 0 and i >= self.aw.qmc.timeindex[1]: j = 1 # after DRY fit = numpy.poly1d(fits[j]) # fit to be applied tp = self.org_temp2[i] if tp is None or tp == -1: self.aw.qmc.temp2.append(tp) else: self.aw.qmc.temp2.append(fit(tp)) return True else: # polyfit mappings with warnings.catch_warnings(): warnings.filterwarnings('error') try: fit = numpy.poly1d(self.calcTempPolyfit()) if fit is not None: self.aw.qmc.temp2 = [(-1 if (temp is None) or (temp == -1) else fit(temp)) for temp in self.org_temp2] except numpy.RankWarning: pass return True # tables