python-3.5

Finding index of largest negative and smallest positive element in array

99封情书 提交于 2019-12-11 18:23:43
问题 I have an array as follows: import numpy as np Arr = np.array([-10, -8, -8, -6, -2, 2, 4, 19]) How do I find the index of largest negative and smallest positive number? i.e in the above example index of -2 and 2. 回答1: You can try, for max of negative: list(Arr).index(max(Arr[Arr<0])) In above, Arr[Arr<0] will get all numbers less than 0 or negative and applying max to the list will give max of negative. Then, it can be used with index to get the index of number in list. And for min of

Installing TensorFlow on Raspbian Stretch 2019-11-13 has Python compatibility problems

我与影子孤独终老i 提交于 2019-12-11 16:42:45
问题 With a new SD card and Raspbian version Stretch 2018-11-13: sudo apt install -y python3-pip python3-dev python-virtualenv virtualenv -p python3.5 --system-site-packages myenv source myenv/bin/activate pip3 install --upgrade tensorflow $ python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow /home/pi/myenv/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning:

How to install xgboost on PythonAnywhere?

独自空忆成欢 提交于 2019-12-11 16:35:45
问题 i am trying this : git clone --recursive https://github.com/dmlc/xgboost cd xgboost make -j4 cd python-package python setup.py install but i get the following error: ~/xgboost $ python setup.py develop --user python: can't open file 'setup.py': [Errno 2] No such file or directory how can i install xgboost or something similar(xgb magic,lightgbm ) on PythonAnywhere? 来源: https://stackoverflow.com/questions/46800464/how-to-install-xgboost-on-pythonanywhere

requests disappear after queueing in scrapy

好久不见. 提交于 2019-12-11 15:59:33
问题 Scrapy seems to complete without processing all the requests. I know this because i am logging before and after queueing the request and I can clearly see that. I am logging in both parse and error callback methods and none of them got called for those missing requests. How can I debug what happened to those requests? 回答1: You need to add dont_filter=True when re-queueing the request. Though the request may not match other request but Scrapy remembers what requests it has already made and it

AttributeError: module 'cv2' has no attribute 'face'

北慕城南 提交于 2019-12-11 15:56:36
问题 I tried to install opencv3.4.0 on a raspberry3 following this guide: https://www.life2coding.com/install-opencv-3-4-0-python-3-raspberry-pi-3/ Now the problem is that I could not figure out why python3 gives me the error: AttributeError: module 'cv2' has no attribute 'face' This happens, whenever I try to execute face_recognizer = cv2.face.LBPHFaceRecognizer_create() I already installed opencv3.4.0 and also the additional modules: opencv3.4.0_contrib. I know that "face" needs to be part of

Memory Leak with import_array() for numpy Python3.5

回眸只為那壹抹淺笑 提交于 2019-12-11 15:26:02
问题 Could someone suggest a fix for this problem? When I use import_array(), Valgrind reports memory leak of 157528 bytes. Here is the small piece of code to replicate the problem on Ubuntu16.04 and Python3.5 #include <Python.h> #include "numpy/arrayobject.h" int main(int argc, char *argv[]) { Py_Initialize(); import_array(); Py_Finalize(); return 0; } Here are the relevant pieces of Valgrind report. ==85642== **2,689** bytes in 2 blocks are definitely lost in loss record 1,044 of 1,100 ==85642==

Error when submitting the gcloud task to google cloud ML engine

社会主义新天地 提交于 2019-12-11 15:16:32
问题 I am new to the Google ML Cloud engine. I would like to post the Keras model to the cloud to train, but I always get this error: I master-replica-0 Running module trainer.bot. master-replica-0 I master-replica-0 Downloading the package: gs://zadravecm-bot/jobs/test_job4/packages/84f3c60920e885020405e1eb7afa5f509313d2a5406a1f1551a81b81993ac66c/trainer-1.0.tar.gz master-replica-0 I master-replica-0 Running command: gsutil -q cp gs://zadravecm-bot/jobs/test_job4/packages

Difference between instance attributes and class attributes

做~自己de王妃 提交于 2019-12-11 15:12:28
问题 I'm trying to learn about the instance and class attributes in python. Then am a little confused: is this_obj.var an instance attribute or it belongs to the class attribute. The code is below class Myclass (object): var = 10 this_obj = Myclass() this_obj.somevar = 12 that_obj = Myclass() that_obj.somevar = 12 回答1: Instance and class attributes can be kind of confusing to understand at first. The best way of thinking about it is to pay attention to the name. Instance attributes are owned by

Insert byte into sql server varbinary(max) column using pymssql

落爺英雄遲暮 提交于 2019-12-11 07:36:37
问题 I'm attempting to insert a byte or byte array into Sql Server table using Python 3.5 and the pymssql package. I keep getting a pymssql.ProgrammingError after attempting to insert. I've used the following link and question as a reference but I'm still having trouble: Explicit Convert of Varbinary(max) column Insert binary file into MSSQL db (varbinary) with python pymssql I've verified I have permission and can insert other data types into the sql server database. Below is the table structure.

Trying get a live plot for a GUI with PyQt5

故事扮演 提交于 2019-12-11 07:30:08
问题 Right now through reading and asking questions I have gotten to a point where I can display the numerical values on LCDs, but now would like to make a graph. In the Picture below there is a picture that I am going to have as a backdrop for the graph. For a Dyno the important information that is gathered is Torque and HorsePower. These I have being calculated with my Python 3.5 Code and the data is being gathered by using an arduino. For my graph I actually want to plot two lines at the same