好吧我认为matplotlib已经下载但是我的新脚本出现了这个错误:
/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py:621: DeprecationWarning: Use the new widget gtk.Tooltip
self.tooltips = gtk.Tooltips()
Traceback (most recent call last):
File "vector_final", line 42, in <module>
plt.hist(data, num_bins)
File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 2008, in hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, **kwargs)
File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 7098, in hist
w = [None]*len(x)
TypeError: len() of unsized object
Run Code Online (Sandbox Code Playgroud)
我的代码是:#!/ usr/bin/python
l=[]
with open("testdata") as f:
line = f.next()
f.next()# skip headers
nat = int(line.split()[0])
print nat
for line in …Run Code Online (Sandbox Code Playgroud) 我正在开发一个基本上允许用户为其个人资料输入一些信息的屏幕。该屏幕上有一个按钮,用户可以使用该按钮来选择自己的性别。我想将这些按钮设置为圆形,因此为了实现此目的,我将这些按钮的圆角半径设置为其高度的一半。要进入此屏幕,有两种方法,一种是创建个人资料,第二种是编辑个人资料。问题是,当您创建配置文件时,UIButton 被捏住并且无法正确舍入,但是当我编辑我的配置文件时,它会正确舍入,即使它是完全相同的代码,唯一的区别是当您打开时在编辑您的个人资料的屏幕上,我启用了导航栏。
我用来圆整按钮的代码在这里:
maleButton.layer.borderColor = maleButtonColor.cgColor
maleButton.setTitleColor(maleButtonColor, for: .normal)
maleButton.layer.cornerRadius = maleButton.frame.size.height / 2
Run Code Online (Sandbox Code Playgroud)
这发生在一个被调用的函数中: viewDidLayoutSubviews()
这些按钮的差异如下所示: 注意** 这些是完全相同的按钮,唯一的区别是第二张图片中的背景颜色已更改,以表明用户已选择该按钮,因为他们正在编辑其个人资料。
我打印了按钮的高度、宽度和角半径:
正如您在这两种情况下所看到的,拐角半径恰好是高度的一半,因此它应该正确舍入,但事实并非如此。这很奇怪,因为它在工作和不工作的不同情况下都是完全相同的代码和相同的视图控制器。这个问题一直困扰着我,希望有人能帮忙解答一下。谢谢!
我已经设置了垃圾箱的参数,我想找到当数据点落在特定垃圾箱范围内时如何向垃圾箱添加一个,本质上是计算每个垃圾箱范围内有多少数据点,以便我可以使用当我把它画出来时,这就是“频率”。
我的垃圾箱范围是通过以下方式设置的:
bins = [(i*bin_width, (i+1)*bin_width) for i in range(num_bins)]
Run Code Online (Sandbox Code Playgroud)
我的数据看起来像这样:
2.55619101399
2.55619101399
2.55619101399
3.615
4.42745271008
2.55619101399
2.55619101399
2.55619101399
4.42745271008
3.615
2.55619101399
4.42745271008
5.71581687075
5.71581687075
3.615
2.55619101399
2.55619101399
2.55619101399
2.55619101399
2.55619101399
Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用Google ML 人脸检测 iOS 库, 但存在一个问题,它不能与前置摄像头配合使用,只有当我在手机上使用后置摄像头时才能检测到人脸。我打印了方向,正面和背面之间的所有内容都匹配。它似乎适用于我的 iPhone X 的正面和背面,但是当我在 iPhone 11 和 iPhone X max 上对其进行测试时,它仅适用于后置摄像头。我不确定是什么导致了这种不一致。我使用的代码如下,注意所有传入 photoVerification 函数的图像首先通过 fixedOrientation 函数运行以确保一致性:
func photoVerification(image: UIImage?) {
guard let imageFace = image else { return }
//Enhanced Face Detection
let options = FaceDetectorOptions()
options.performanceMode = .accurate
//Initialize face detector with given options
let faceDetector = FaceDetector.faceDetector(options: options)
// Initialize a VisionImage object with the given UIImage.
let visionImage = VisionImage(image: imageFace)
visionImage.orientation = imageFace.imageOrientation
print("$$The Images Orientation is: ",imageFace.imageOrientation.rawValue)
faceDetector.process(visionImage) { faces, …Run Code Online (Sandbox Code Playgroud) ios ×2
python ×2
swift ×2
bin ×1
google-mlkit ×1
matplotlib ×1
sorting ×1
uibutton ×1
uikit ×1
xcode ×1