检查数组是否是更大数组的一部分

时间:2019-03-30 18:11:51

标签: python numpy

我正在尝试检查一维numpy数组是否是较大的二维数组的一部分。我可以使用许多for循环来执行此操作,但我想还有一种更Python化的方法可以执行此操作。

我必须做的尝试:

1darray = np.array([0,0,0])
2darray = np.array([[0,0,1],[0,1,0],[1,0,0]]) 
1darray in 2darray 

但是此代码返回 True ,只要1darray中的元素之一出现在2darray中的某处即可。但是我想检查整个数组是否是较大数组中的一行,所以我希望此代码返回 False ,而我希望此代码返回 True

1darray = np.array([0,0,1])
2darray = np.array([[0,0,1],[0,1,0],[1,0,0]]) 
1darray in 2darray 

我将不胜感激,非常感谢!

1 个答案:

答案 0 :(得分:4)

您可以使用render() { let grid = null; let results = null; let resultsGrid = null; ... if (this.state.examComplete == false) { ... no errors were triggered here before adding the else below. } else { let examBoard = this.board; let falsePos = this.state.falsePositives; let tumorDetections = this.state.tumorsConfig; this.setState({results: [...this.state.results,{examBoard, falsePos, tumorDetections}] }); this.setState({examAttempts: this.state.examAttempts + 1}); restart = <button onClick={this.restartExam} style={{ margin: '10px', fontSize: '125%' }}>Restart the exam</button> resultsGrid = <div className={styles.inline}> {this.state.results.map(result => ( <ResultsGrid palpatedCells={result.examBoard} falsePositives={result.falsePos} tumors={result.tumorDetections} /> ))} </div> } return ( <div> <h3>Exam Grid</h3> <br /> {end} {restart} {detectionOutput} <div className={styles.container}> {grid} </div> <div> {resultsGrid} {data} </div> </div> ); override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { self.setValues(value: languageArray[indexPath.row]) // Upload new language settings to the server // Here I want to set the language of my app to the selected value: languageArray[indexPath.row] // For example, languageArray[indexPath.row] is "en" var array = tableView.visibleCells for i in 0 ..< array.count { let cells: UITableViewCell = array[i] cells.accessoryType = .none } let cell:UITableViewCell! = tableView.cellForRow(at: indexPath) cell.accessoryType = .checkmark } 函数来实现这一目的。

any()