Python scipy.sign() Examples
The following are 8
code examples of scipy.sign().
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
scipy
, or try the search function
.
Example #1
Source File: phaseplane.py From compneuro with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _classify(self): if self.dimension == 2: print "Use fixedpoint_2D class" real_evals = (isreal(self.evals[0]), isreal(self.evals[1])) equal_evals = abs(self.evals[0] - self.evals[1]) < self.eps zero_evals = (abs(self.evals[0]) < self.eps, abs(self.evals[1]) < self.eps) ## if alltrue(real_evals): ## sign_evals = (sign(self.evals[0]), sign(self.evals[1])) ## if sign_evals[0] == sign_evals[1]: ## self.classification = 'node-like' ## else: ## self.classification = 'saddle-like' ## else: ## self.classification = 'spiral-like' real_parts = real(self.evals) if alltrue(real_parts<0): self.stability = 's' elif alltrue(real_parts==0): self.stability = 'c' else: self.stability = 'u' self.degenerate = sometrue(zero_evals) or equal_evals
Example #2
Source File: phaseplane.py From compneuro with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _classify(self): real_evals = (isreal(self.evals[0]), isreal(self.evals[1])) equal_evals = abs(self.evals[0] - self.evals[1]) < self.eps zero_evals = (abs(self.evals[0]) < self.eps, abs(self.evals[1]) < self.eps) if alltrue(real_evals): sign_evals = (sign(self.evals[0]), sign(self.evals[1])) if sign_evals[0] == sign_evals[1]: self.classification = 'node' else: self.classification = 'saddle' else: self.classification = 'spiral' real_parts = real(self.evals) if alltrue(real_parts<0): self.stability = 's' elif alltrue(real_parts==0): self.stability = 'c' else: self.stability = 'u' self.degenerate = sometrue(zero_evals) or equal_evals
Example #3
Source File: sum_stats_parsers.py From ldpred with MIT License | 6 votes |
def get_beta(pval_read, raw_beta, beta_read, line_dict, header_dict, se, z_from_se, N, eff_type, se_inferred_zscores): if eff_type=='BLUP': return raw_beta if z_from_se: assert se in header_dict, "SE was not specified in summary statistics provided, which is necessary when the 'z_from_se' flag is used." se_read = float(line_dict[header_dict[se]]) if se_read==0 or not isfinite(se_read): return None se_inferred_zscores += 1 return get_beta_from_se(beta_read, se_read, eff_type, raw_beta, N) else: if pval_read==0 or not isfinite(stats.norm.ppf(pval_read)): #Attempt to Parse SEs to infer Z-score if not se in header_dict: return None else: se_read = float(line_dict[header_dict[se]]) if se_read==0 or not isfinite(se_read): return None se_inferred_zscores += 1 return get_beta_from_se(beta_read, se_read, eff_type, raw_beta, N) else: return sp.sign(raw_beta) * stats.norm.ppf(pval_read / 2.0)/ sp.sqrt(N)
Example #4
Source File: nomo_axis.py From pynomo with GNU General Public License v3.0 | 5 votes |
def find_tick_directions(list, f, g, side, start, stop, full_angle=False, extra_angle=0, turn_relative=False): """ finds tick directions and angles """ angles = [] # following two values make unit vector dx_units = [] dy_units = [] turn = _determine_turn_(f=f, g=g, start=start, stop=stop, side=side, turn_relative=turn_relative) for idx, u in enumerate(list): if u != list[-1]: du = (list[idx + 1] - list[idx]) * 1e-6 else: if len(list) > 1: du = (list[-1] - list[-2]) * 1e-6 else: # only one element in list du = abs(stop - start) * 1e-6 # print u dx = (f(u + du) - f(u)) * turn dy = (g(u + du) - g(u)) * turn dx_unit = dx / math.sqrt(dx ** 2 + dy ** 2) dy_unit = dy / math.sqrt(dx ** 2 + dy ** 2) if not full_angle: if dy_unit != 0.0: angle = -math.atan(dx_unit / dy_unit) * 180.0 / math.pi else: angle = 0.0 if full_angle: if dy_unit != 0.0: angle = -math.atan(dx_unit / dy_unit) * 180.0 / math.pi else: angle = 0.0 if scipy.sign(dx_unit) < 0.0 and scipy.sign(dy_unit) < 0.0: angle = angle - 180.0 if scipy.sign(dy_unit) < 0.0 <= scipy.sign(dx_unit): angle += 180.0 angle += extra_angle dx_units.append(dx_unit) dy_units.append(dy_unit) angles.append(angle) return dx_units, dy_units, angles
Example #5
Source File: phaseplane.py From compneuro with BSD 3-Clause "New" or "Revised" License | 5 votes |
def concavity(self, xdata): """Concavity scalar +/- 1 or 0 at x is returned for scalar x, otherwise array of such scalars for 1D array x. Positive values mean concave "up" in the plane.""" return np.sign(self.curvature(xdata))
Example #6
Source File: autorec.py From DeepRec with GNU General Public License v3.0 | 5 votes |
def execute(self, train_data, test_data): self.train_data = self._data_process(train_data) self.train_data_mask = scipy.sign(self.train_data) init = tf.global_variables_initializer() self.sess.run(init) for epoch in range(self.epochs): if self.verbose: print("Epoch: %04d;" % (epoch)) self.train(train_data) if (epoch) % self.T == 0: print("Epoch: %04d; " % (epoch), end='') self.test(test_data)
Example #7
Source File: autorec.py From DeepRec with GNU General Public License v3.0 | 5 votes |
def execute(self, train_data, test_data): self.train_data = self._data_process(train_data.transpose()) self.train_data_mask = scipy.sign(self.train_data) init = tf.global_variables_initializer() self.sess.run(init) for epoch in range(self.epochs): self.train(train_data) if (epoch) % self.T == 0: print("Epoch: %04d; " % (epoch), end='') self.test(test_data)
Example #8
Source File: sum_stats_parsers.py From ldpred with MIT License | 5 votes |
def get_beta_from_se(beta_read, se_read, eff_type, raw_beta, N): if se_read==0: return if eff_type=='LINREG' or eff_type=='LOGOR': abs_beta = sp.absolute(beta_read)/se_read elif eff_type=='OR': abs_beta = sp.absolute(1-beta_read)/se_read else: raise Exception('Unknown effect type') return sp.sign(raw_beta) * abs_beta/ sp.sqrt(N)