Python numpy.ravel() Examples
The following are 30
code examples of numpy.ravel().
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: example_geodynamic_adiabat.py From burnman with GNU General Public License v2.0 | 7 votes |
def compute_depth_gravity_profiles(pressures, densities, surface_gravity, outer_radius): gravity = [surface_gravity] * len(pressures) # starting guess n_gravity_iterations = 5 for i in range(n_gravity_iterations): # Integrate the hydrostatic equation # Make a spline fit of densities as a function of pressures rhofunc = UnivariateSpline(pressures, densities) # Make a spline fit of gravity as a function of depth gfunc = UnivariateSpline(pressures, gravity) # integrate the hydrostatic equation depths = np.ravel(odeint((lambda p, x: 1./(gfunc(x) * rhofunc(x))), 0.0, pressures)) radii = outer_radius - depths rhofunc = UnivariateSpline(radii[::-1], densities[::-1]) poisson = lambda p, x: 4.0 * np.pi * burnman.constants.G * rhofunc(x) * x * x gravity = np.ravel(odeint(poisson, surface_gravity*radii[0]*radii[0], radii)) gravity = gravity / radii / radii return depths, gravity # BEGIN USER INPUTS # Declare the rock we want to use
Example #2
Source File: param_sensitivity.py From scanorama with MIT License | 7 votes |
def test_knn(datasets_dimred, genes, labels, idx, distr, xlabels): knns = [ 5, 10, 50, 100 ] len_distr = len(distr) for knn in knns: integrated = assemble(datasets_dimred[:], knn=knn, sigma=150) X = np.concatenate(integrated) distr.append(sil(X[idx, :], labels[idx])) for d in distr[:len_distr]: print(ttest_ind(np.ravel(X[idx, :]), np.ravel(d))) xlabels.append(str(knn)) print('') plt.figure() plt.boxplot(distr, showmeans=True, whis='range') plt.xticks(range(1, len(xlabels) + 1), xlabels) plt.ylabel('Silhouette Coefficient') plt.ylim((-1, 1)) plt.savefig('param_sensitivity_{}.svg'.format('knn'))
Example #3
Source File: starfm4py.py From starfm4py with GNU General Public License v3.0 | 6 votes |
def block2row(array, row, folder, block_id=None): if array.shape[0] == windowSize: # Parameters name_string = str(block_id[0] + 1) m,n = array.shape u = m + 1 - windowSize v = n + 1 - windowSize # Get Starting block indices start_idx = np.arange(u)[:,None]*n + np.arange(v) # Get offsetted indices across the height and width of input array offset_idx = np.arange(windowSize)[:,None]*n + np.arange(windowSize) # Get all actual indices & index into input array for final output flat_array = np.take(array,start_idx.ravel()[:,None] + offset_idx.ravel()) # Save to (dask) array in .zarr format file_name = path + folder + name_string + 'r' + row + '.zarr' zarr.save(file_name, flat_array) return array # Divide an image in overlapping blocks
Example #4
Source File: lovecat.py From cgpm with Apache License 2.0 | 6 votes |
def _update_diagnostics(state, diagnostics): # Update logscore. cc_logscore = diagnostics.get('logscore', np.array([])) new_logscore = map(float, np.ravel(cc_logscore).tolist()) state.diagnostics['logscore'].extend(new_logscore) # Update column_crp_alpha. cc_column_crp_alpha = diagnostics.get('column_crp_alpha', []) new_column_crp_alpha = map(float, np.ravel(cc_column_crp_alpha).tolist()) state.diagnostics['column_crp_alpha'].extend(list(new_column_crp_alpha)) # Update column_partition. def convert_column_partition(assignments): return [ (col, int(assgn)) for col, assgn in zip(state.outputs, assignments) ] new_column_partition = diagnostics.get('column_partition_assignments', []) if len(new_column_partition) > 0: assert len(new_column_partition) == len(state.outputs) trajectories = np.transpose(new_column_partition)[0].tolist() state.diagnostics['column_partition'].extend( map(convert_column_partition, trajectories))
Example #5
Source File: test_core.py From recruit with Apache License 2.0 | 6 votes |
def test_minmax_func(self): # Tests minimum and maximum. (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d # max doesn't work if shaped xr = np.ravel(x) xmr = ravel(xm) # following are true because of careful selection of data assert_equal(max(xr), maximum.reduce(xmr)) assert_equal(min(xr), minimum.reduce(xmr)) assert_equal(minimum([1, 2, 3], [4, 0, 9]), [1, 0, 3]) assert_equal(maximum([1, 2, 3], [4, 0, 9]), [4, 2, 9]) x = arange(5) y = arange(5) - 2 x[3] = masked y[0] = masked assert_equal(minimum(x, y), where(less(x, y), x, y)) assert_equal(maximum(x, y), where(greater(x, y), x, y)) assert_(minimum.reduce(x) == 0) assert_(maximum.reduce(x) == 4) x = arange(4).reshape(2, 2) x[-1, -1] = masked assert_equal(maximum.reduce(x, axis=None), 2)
Example #6
Source File: param_sensitivity.py From scanorama with MIT License | 6 votes |
def test_alpha(datasets_dimred, genes, labels, idx, distr, xlabels): alphas = [ 0, 0.05, 0.20, 0.50 ] len_distr = len(distr) for alpha in alphas: integrated = assemble(datasets_dimred[:], alpha=alpha, sigma=150) X = np.concatenate(integrated) distr.append(sil(X[idx, :], labels[idx])) for d in distr[:len_distr]: print(ttest_ind(np.ravel(X[idx, :]), np.ravel(d))) xlabels.append(str(alpha)) print('') plt.figure() plt.boxplot(distr, showmeans=True, whis='range') plt.xticks(range(1, len(xlabels) + 1), xlabels) plt.ylabel('Silhouette Coefficient') plt.ylim((-1, 1)) plt.savefig('param_sensitivity_{}.svg'.format('alpha'))
Example #7
Source File: Blending.py From fuku-ml with MIT License | 6 votes |
def prediction(self, input_data='', mode='test_data'): prediction = {} prediction_sum = 0 for model in self.models: prediction = model.prediction(input_data, mode) prediction_sum = prediction_sum + prediction['prediction'] prediction_return = float(prediction_sum / len(self.models)) if mode == 'future_data': data = input_data.split() input_data_x = [float(v) for v in data] input_data_x = np.ravel(input_data_x) return {"input_data_x": input_data_x, "input_data_y": None, "prediction": prediction_return} else: data = input_data.split() input_data_x = [float(v) for v in data[:-1]] input_data_x = np.ravel(input_data_x) input_data_y = float(data[-1]) return {"input_data_x": input_data_x, "input_data_y": input_data_y, "prediction": prediction_return}
Example #8
Source File: Blending.py From fuku-ml with MIT License | 6 votes |
def prediction(self, input_data='', mode='test_data'): prediction = {} vote = [] for model in self.models: prediction = model.prediction(input_data, mode) vote.append(prediction['prediction']) prediction_return = max(set(vote), key=vote.count) if mode == 'future_data': data = input_data.split() input_data_x = [float(v) for v in data] input_data_x = np.ravel(input_data_x) return {"input_data_x": input_data_x, "input_data_y": None, "prediction": prediction_return} else: data = input_data.split() input_data_x = [float(v) for v in data[:-1]] input_data_x = np.ravel(input_data_x) input_data_y = float(data[-1]) return {"input_data_x": input_data_x, "input_data_y": input_data_y, "prediction": prediction_return}
Example #9
Source File: param_sensitivity.py From scanorama with MIT License | 6 votes |
def test_sigma(datasets_dimred, genes, labels, idx, distr, xlabels): sigmas = [ 10, 50, 100, 200 ] len_distr = len(distr) for sigma in sigmas: integrated = assemble(datasets_dimred[:], sigma=sigma) X = np.concatenate(integrated) distr.append(sil(X[idx, :], labels[idx])) for d in distr[:len_distr]: print(ttest_ind(np.ravel(X[idx, :]), np.ravel(d))) xlabels.append(str(sigma)) print('') plt.figure() plt.boxplot(distr, showmeans=True, whis='range') plt.xticks(range(1, len(xlabels) + 1), xlabels) plt.ylabel('Silhouette Coefficient') plt.ylim((-1, 1)) plt.savefig('param_sensitivity_{}.svg'.format('sigma'))
Example #10
Source File: test_core.py From recruit with Apache License 2.0 | 6 votes |
def test_ravel(self): # Tests ravel a = array([[1, 2, 3, 4, 5]], mask=[[0, 1, 0, 0, 0]]) aravel = a.ravel() assert_equal(aravel._mask.shape, aravel.shape) a = array([0, 0], mask=[1, 1]) aravel = a.ravel() assert_equal(aravel._mask.shape, a.shape) # Checks that small_mask is preserved a = array([1, 2, 3, 4], mask=[0, 0, 0, 0], shrink=False) assert_equal(a.ravel()._mask, [0, 0, 0, 0]) # Test that the fill_value is preserved a.fill_value = -99 a.shape = (2, 2) ar = a.ravel() assert_equal(ar._mask, [0, 0, 0, 0]) assert_equal(ar._data, [1, 2, 3, 4]) assert_equal(ar.fill_value, -99) # Test index ordering assert_equal(a.ravel(order='C'), [1, 2, 3, 4]) assert_equal(a.ravel(order='F'), [1, 3, 2, 4])
Example #11
Source File: btypes.py From revrand with Apache License 2.0 | 6 votes |
def ravel(parameter, random_state=None): """ Flatten a ``Parameter``. Parameters ---------- parameter: Parameter A ``Parameter`` object Returns ------- flatvalue: ndarray a flattened array of shape ``(prod(parameter.shape),)`` flatbounds: list a list of bound tuples of length ``prod(parameter.shape)`` """ flatvalue = np.ravel(parameter.rvs(random_state=random_state)) flatbounds = [parameter.bounds for _ in range(np.prod(parameter.shape, dtype=int))] return flatvalue, flatbounds
Example #12
Source File: param_sensitivity.py From scanorama with MIT License | 6 votes |
def test_perplexity(datasets_dimred, genes, labels, idx, distr, xlabels): X = np.concatenate(datasets_dimred) perplexities = [ 10, 100, 500, 2000 ] len_distr = len(distr) for perplexity in perplexities: embedding = fit_tsne(X, perplexity=perplexity) distr.append(sil(embedding[idx, :], labels[idx])) for d in distr[:len_distr]: print(ttest_ind(np.ravel(X[idx, :]), np.ravel(d))) xlabels.append(str(perplexity)) print('') plt.figure() plt.boxplot(distr, showmeans=True, whis='range') plt.xticks(range(1, len(xlabels) + 1), xlabels) plt.ylabel('Silhouette Coefficient') plt.ylim((-1, 1)) plt.savefig('param_sensitivity_{}.svg'.format('perplexity'))
Example #13
Source File: param_sensitivity.py From scanorama with MIT License | 6 votes |
def test_approx(datasets_dimred, genes, labels, idx, distr, xlabels): integrated = assemble(datasets_dimred[:], approx=False, sigma=150) X = np.concatenate(integrated) distr.append(sil(X[idx, :], labels[idx])) len_distr = len(distr) for d in distr[:len_distr]: print(ttest_ind(np.ravel(X[idx, :]), np.ravel(d))) xlabels.append('Exact NN') print('') plt.figure() plt.boxplot(distr, showmeans=True, whis='range') plt.xticks(range(1, len(xlabels) + 1), xlabels) plt.ylabel('Silhouette Coefficient') plt.ylim((-1, 1)) plt.savefig('param_sensitivity_{}.svg'.format('approx'))
Example #14
Source File: qchem_inter_rf.py From pyscf with Apache License 2.0 | 6 votes |
def kernel_qchem_inter_rf_pos_neg(self, **kw): """ This is constructing the E_m-E_n and E_n-E_m matrices """ h_rpa = diagflat(concatenate((ravel(self.FmE),-ravel(self.FmE)))) print(h_rpa.shape) nf = self.nfermi[0] nv = self.norbs-self.vstart[0] vs = self.vstart[0] neh = nf*nv x = self.mo_coeff[0,0,:,:,0] pab2v = self.pb.get_ac_vertex_array() self.pmn2v = pmn2v = einsum('nb,pmb->pmn', x[:nf,:], einsum('ma,pab->pmb', x[vs:,:], pab2v)) pmn2c = einsum('qp,pmn->qmn', self.hkernel_den, pmn2v) meri = einsum('pmn,pik->mnik', pmn2c, pmn2v).reshape((nf*nv,nf*nv)) #print(meri.shape) #meri.fill(0.0) h_rpa[:neh, :neh] = h_rpa[:neh, :neh]+meri h_rpa[:neh, neh:] = h_rpa[:neh, neh:]+meri h_rpa[neh:, :neh] = h_rpa[neh:, :neh]-meri h_rpa[neh:, neh:] = h_rpa[neh:, neh:]-meri edif, s2z = np.linalg.eig(h_rpa) print(abs(h_rpa-h_rpa.transpose()).sum()) print('edif', edif.real*27.2114) return
Example #15
Source File: OptimalProjection.py From scattertext with Apache License 2.0 | 6 votes |
def morista_index(points): # Morisita Index of Dispersion N = points.shape[1] ims = [] for i in range(1, N): bins, _, _ = np.histogram2d(points[0], points[1], i) # I_M = Q * (\sum_{k=1}^{Q}{n_k * (n_k - 1)})/(N * (N _ 1)) Q = len(bins) # num_quadrants # Eqn 1. I_M = Q * np.sum(np.ravel(bins) * (np.ravel(bins) - 1)) / (N * (N - 1)) ims.append([i, I_M]) return np.array(ims).T[1].max()
Example #16
Source File: tf_transformer_test.py From spark-deep-learning with Apache License 2.0 | 6 votes |
def _check_transformer_output(transformer, dataset, expected): """ Given a transformer and a spark dataset, check if the transformer produces the expected results. """ analyzed_df = tfs.analyze(dataset) out_df = transformer.transform(analyzed_df) # Collect transformed values out_colnames = list(_output_mapping.values()) _results = [] for row in out_df.select(out_colnames).collect(): curr_res = [row[colname] for colname in out_colnames] _results.append(np.ravel(curr_res)) out_tgt = np.hstack(_results) _err_msg = 'not close => shape {} != {}, max_diff {} > {}' max_diff = np.max(np.abs(expected - out_tgt)) err_msg = _err_msg.format(expected.shape, out_tgt.shape, max_diff, _all_close_tolerance) assert np.allclose(expected, out_tgt, atol=_all_close_tolerance), err_msg
Example #17
Source File: pre.py From skan with BSD 3-Clause "New" or "Revised" License | 6 votes |
def hyperball(ndim, radius): """Return a binary morphological filter containing pixels within `radius`. Parameters ---------- ndim : int The number of dimensions of the filter. radius : int The radius of the filter. Returns ------- ball : array of bool, shape [2 * radius + 1,] * ndim The required structural element """ size = 2 * radius + 1 center = [(radius,) * ndim] coords = np.mgrid[[slice(None, size),] * ndim].reshape(ndim, -1).T distances = np.ravel(spatial.distance_matrix(coords, center)) selector = distances <= radius ball = np.zeros((size,) * ndim, dtype=bool) ball.ravel()[selector] = True return ball
Example #18
Source File: layer.py From burnman with GNU General Public License v2.0 | 6 votes |
def _compute_gravity(self, density, gravity_bottom): """ Computes the gravity of a layer Used by _evaluate_eos() """ # Create a spline fit of density as a function of radius rhofunc = UnivariateSpline(self.radii, density) # Numerically integrate Poisson's equation def poisson(p, x): return 4.0 * np.pi * \ constants.G * rhofunc(x) * x * x grav = np.ravel( odeint( poisson, gravity_bottom * self.radii[0] * self.radii[0], self.radii)) if self.radii[0] == 0: grav[0] = 0 grav[1:] = grav[1:] / self.radii[1:] / self.radii[1:] else: grav[:] = grav[:] / self.radii[:] / self.radii[:] return grav
Example #19
Source File: test_sq.py From pyqmc with MIT License | 6 votes |
def test_big_cell(): import time a = 1 ncell = (2, 2, 2) Lvecs = np.diag(ncell) * a unit_cell = np.zeros((4, 3)) unit_cell[1:] = (np.ones((3, 3)) - np.eye(3)) * a / 2 grid = np.meshgrid(*map(np.arange, ncell), indexing="ij") shifts = np.stack(list(map(np.ravel, grid)), axis=1) supercell = (shifts[:, np.newaxis] + unit_cell[np.newaxis]).reshape(1, -1, 3) configs = supercell.repeat(1000, axis=0) configs += np.random.randn(*configs.shape) * 0.1 df = run(Lvecs, configs, 8) df = df.groupby("qmag").mean().reset_index() large_q = df[-35:-10]["Sq"] mean = np.mean(large_q - 1) rms = np.sqrt(np.mean((large_q - 1) ** 2)) assert np.abs(mean) < 0.01, mean assert rms < 0.1, rms
Example #20
Source File: accumulators.py From pyqmc with MIT License | 6 votes |
def __init__(self, qlist=None, Lvecs=None, nq=4): """ Inputs: qlist: (n, 3) array-like. If qlist is provided, Lvecs and nq are ignored Lvecs: (3, 3) array-like of lattice vectors. Required if qlist is None nq: int, if qlist is nonzero, use a uniform grid of shape (nq, nq, nq) """ if qlist is not None: self.qlist = qlist else: assert ( Lvecs is not None ), "need to provide either list of q vectors or lattice vectors" Gvecs = np.linalg.inv(Lvecs).T * 2 * np.pi qvecs = list(map(np.ravel, np.meshgrid(*[np.arange(nq)] * 3))) qvecs = np.stack(qvecs, axis=1) self.qlist = np.dot(qvecs, Gvecs)
Example #21
Source File: grid.py From python-control with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __call__(self, transform_xy, x1, y1, x2, y2): x_, y_ = np.linspace(x1, x2, self.nx), np.linspace(y1, y2, self.ny) x, y = np.meshgrid(x_, y_) lon, lat = transform_xy(np.ravel(x), np.ravel(y)) with np.errstate(invalid='ignore'): if self.lon_cycle is not None: lon0 = np.nanmin(lon) # Changed from 180 to 360 to be able to span only # 90-270 (left hand side) lon -= 360. * ((lon - lon0) > 360.) if self.lat_cycle is not None: lat0 = np.nanmin(lat) # Changed from 180 to 360 to be able to span only # 90-270 (left hand side) lat -= 360. * ((lat - lat0) > 360.) lon_min, lon_max = np.nanmin(lon), np.nanmax(lon) lat_min, lat_max = np.nanmin(lat), np.nanmax(lat) lon_min, lon_max, lat_min, lat_max = \ self._adjust_extremes(lon_min, lon_max, lat_min, lat_max) return lon_min, lon_max, lat_min, lat_max
Example #22
Source File: imgproc.py From graph_distillation with Apache License 2.0 | 6 votes |
def inpaint(img, threshold=1): h, w = img.shape[:2] if len(img.shape) == 3: # RGB mask = np.all(img == 0, axis=2).astype(np.uint8) img = cv2.inpaint(img, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA) else: # depth mask = np.where(img > threshold) xx, yy = np.meshgrid(np.arange(w), np.arange(h)) xym = np.vstack((np.ravel(xx[mask]), np.ravel(yy[mask]))).T img = np.ravel(img[mask]) interp = interpolate.NearestNDInterpolator(xym, img) img = interp(np.ravel(xx), np.ravel(yy)).reshape(xx.shape) return img
Example #23
Source File: test_exponentials_transition_hypers.py From cgpm with Apache License 2.0 | 5 votes |
def test_transition_hypers(cctype): name, arg = cctype model = cu.cctype_class(name)( outputs=[0], inputs=None, distargs=arg, rng=gu.gen_rng(10)) D, Zv, Zc = tu.gen_data_table( 50, [1], [[.33, .33, .34]], [name], [arg], [.8], rng=gu.gen_rng(1)) hypers_previous = model.get_hypers() for rowid, x in enumerate(np.ravel(D)[:25]): model.incorporate(rowid, {0:x}, None) model.transition_hypers(N=3) hypers_new = model.get_hypers() assert not all( np.allclose(hypers_new[hyper], hypers_previous[hyper]) for hyper in hypers_new) for rowid, x in enumerate(np.ravel(D)[:25]): model.incorporate(rowid+25, {0:x}, None) model.transition_hypers(N=3) hypers_newer = model.get_hypers() assert not all( np.allclose(hypers_new[hyper], hypers_newer[hyper]) for hyper in hypers_newer) # In general inference should improve the log score. # logpdf_score = model.logpdf_score() # model.transition_hypers(N=200) # assert model.logpdf_score() > logpdf_score
Example #24
Source File: disabled_test_simulate_univariate.py From cgpm with Apache License 2.0 | 5 votes |
def launch_2samp_inference_quality(cctype, distargs): """Performs check of posterior predictive on gpmcc simulations.""" # Training and test samples D = simulate_synthetic(NUM_TRAIN+NUM_TEST, cctype, distargs) D_train, D_test = D[:NUM_TRAIN], D[NUM_TRAIN:] D_posteriors = generate_gpmcc_posteriors( cctype, distargs, D_train, NUM_ITERS, NUM_SECONDS) for Dp in D_posteriors: plot_simulations( cctype, np.ravel(D_train), np.ravel(D_test[:NUM_TRAIN]), np.ravel(Dp)) pvals = [two_sample_test(cctype, np.ravel(D_test), np.ravel(Dp)) for Dp in D_posteriors] print 'cctype, pvals: {}, {}'.format(cctype, pvals) assert any([p > 0.05 for p in pvals])
Example #25
Source File: disabled_test_simulate_univariate.py From cgpm with Apache License 2.0 | 5 votes |
def launch_2samp_sanity_diff(cctype, distargs): """Ensure that 2-sample tests on different population rejects H0.""" # Training and test samples D = simulate_synthetic(NUM_TRAIN+NUM_TEST, cctype, distargs) D_train = D[:NUM_TRAIN] D_posteriors = generate_gpmcc_posteriors( cctype, distargs, D_train, None, 0.01) pvals = [two_sample_test(cctype, np.ravel(D_train), np.ravel(Dp)) for Dp in D_posteriors] print 'cctype, pvals: {}, {}'.format(cctype, pvals) assert all(p < 0.01 for p in pvals)
Example #26
Source File: test_draw.py From skan with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_pipeline_plot_existing_fig(test_image, test_thresholded, test_skeleton, test_stats): fig = Figure() draw.pipeline_plot(test_image, test_thresholded, test_skeleton, test_stats, figure=fig) fig, axes = plt.subplots(2, 2, sharex=True, sharey=True) draw.pipeline_plot(test_image, test_thresholded, test_skeleton, test_stats, figure=fig, axes=np.ravel(axes))
Example #27
Source File: tf_transformer_test.py From spark-deep-learning with Apache License 2.0 | 5 votes |
def _get_expected_result(gin, local_features): """ Running the graph in the :py:obj:`TFInputGraph` object and compute the expected results. :param: gin, a :py:obj:`TFInputGraph` :return: expected results in NumPy array """ graph = tf.Graph() with tf.Session(graph=graph) as sess, graph.as_default(): # Build test graph and transformers from here tf.import_graph_def(gin.graph_def, name='') # Build the results _results = [] for row in local_features: fetches = [tfx.get_tensor(tnsr_name, graph) for tnsr_name, _ in _output_mapping.items()] feed_dict = {} for colname, tnsr_name in _input_mapping.items(): tnsr = tfx.get_tensor(tnsr_name, graph) feed_dict[tnsr] = np.array(row[colname])[np.newaxis, :] curr_res = sess.run(fetches, feed_dict=feed_dict) _results.append(np.ravel(curr_res)) expected = np.hstack(_results) return expected
Example #28
Source File: utilities.py From qcqp with MIT License | 5 votes |
def flatten_vars(xs, n): ret = np.empty(n) ind = 0 for x in xs: size = x.size[0]*x.size[1] ret[ind:ind+size] = np.ravel(x.value, order='F') return ret
Example #29
Source File: _core.py From recruit with Apache License 2.0 | 5 votes |
def _args_adjust(self): if is_integer(self.bins): # create common bin edge values = (self.data._convert(datetime=True)._get_numeric_data()) values = np.ravel(values) values = values[~isna(values)] hist, self.bins = np.histogram( values, bins=self.bins, range=self.kwds.get('range', None), weights=self.kwds.get('weights', None)) if is_list_like(self.bottom): self.bottom = np.array(self.bottom)
Example #30
Source File: text_transformers.py From cdQA with Apache License 2.0 | 5 votes |
def idf_(self): # if _idf_diag is not set, this will raise an attribute error, # which means hasattr(self, "idf_") is False return np.ravel(self._idf_diag.sum(axis=0))