Skip to content

Commit

Permalink
Update python-detect-anomalies.py (#18)
Browse files Browse the repository at this point in the history
Comparison with None performed with equality operators, boolean variable check can be simplified and printing values from request not only ids.
  • Loading branch information
masyanru authored and aahill committed Oct 22, 2019
1 parent ccd8563 commit f4a27f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions quickstarts/python-detect-anomalies.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ def detect_batch(request_data):
result = send_request(endpoint, batch_detection_url, subscription_key, request_data)
print(json.dumps(result, indent=4))

if result.get('code') != None:
if result.get('code') is not None:
print("Detection failed. ErrorCode:{}, ErrorMessage:{}".format(result['code'], result['message']))
else:
# Find and display the positions of anomalies in the data set
anomalies = result["isAnomaly"]
print("Anomalies detected in the following data positions:")

for x in range(len(anomalies)):
if anomalies[x] == True:
print (x)
if anomalies[x]:
print (x, request_data['series'][x]['value'])
# </detectBatch>
"""
Detect if the latest data point in the time series is an anomaly.
Expand All @@ -68,4 +68,4 @@ def detect_latest(request_data):
# <methodCalls>
detect_batch(json_data)
detect_latest(json_data)
# </methodCalls>
# </methodCalls>

0 comments on commit f4a27f0

Please sign in to comment.