一种有效(但很慢)的方法来获取您想要的东西:
import { Component,ElementRef,Renderer,ViewChild,Renderer2 } from '@angular/core';
@Component({
selector: 'my-app',templateUrl: './app.component.html',styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
left = 0;
@ViewChild('parentTag',{static: false})
parentTag: ElementRef;
@ViewChild('target',{static: false})
target: ElementRef;
constructor(private el:ElementRef,private renderer: Renderer2){
}
move(){
console.log(this.parentTag.nativeElement.clientWidth);
console.log(this.target.nativeElement.scrollWidth);
let left = this.target.nativeElement.scrollWidth -
this.parentTag.nativeElement.clientWidth;
this.renderer.setStyle(this.target.nativeElement,'margin-left','-'+left+'px');
}
stop(){
this.renderer.setStyle(this.target.nativeElement,'0px');
}
}
您实际上想要的是一个逆argsort,您可以在here上找到很多信息
,
numpy.argsort
返回已排序数组的索引
我认为您想要的是numpy.sort
print(numpy.sort(CD,axis=0))
# [[ 5 24 2 1]
# [ 13 33 15 21]
# [ 28 66 29 30]
# [ 28 75 30 35]
# [ 59 78 33 43]
# [ 77 85 41 48]
# [ 80 91 64 50]
# [ 85 93 71 56]
# [ 90 102 77 64]
# [ 91 102 82 71]]
,
也许您只想sort(返回数组的排序副本)而不是argsort
(返回将对数组排序的索引)?
np.sort(cd,axis=1)
#array([[ 48,71,85,90],# [ 2,28,75],# [ 5,15,56,93],# [ 29,43,59,91],# [ 24,35,82],# [ 13,21,77,102],# [ 33,64,# [ 30,66,80],# [ 1,41,78,33,50,77]])
np.sort(cd,axis=0)
#array([[ 5,24,2,1],21],# [ 28,29,30],75,30,35],# [ 59,43],# [ 77,48],# [ 80,91,50],# [ 85,93,56],# [ 90,102,64],# [ 91,82,71]])
本文链接:https://www.f2er.com/3144720.html