From 0e50e853a1b1bbb85bd634aa80d26f5a24ff237e Mon Sep 17 00:00:00 2001 From: ShivangiReja <45216704+ShivangiReja@users.noreply.github.com> Date: Tue, 8 Sep 2020 19:16:54 -0700 Subject: [PATCH] [Anomaly Detector] Move sample code under the right snippet (#15003) [Anomaly Detector] Move code under the right snippet --- .../samples/Sample1_DetectEntireSeriesAnomaly.md | 6 +++--- .../samples/Sample2_DetectLastPointAnomaly.md | 6 +++--- .../samples/Sample3_DetectChangePoint.md | 3 --- .../tests/samples/Sample1_DetectEntireSeriesAnomaly.cs | 6 +++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample1_DetectEntireSeriesAnomaly.md b/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample1_DetectEntireSeriesAnomaly.md index e410413ff36a..756c1aca7edc 100644 --- a/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample1_DetectEntireSeriesAnomaly.md +++ b/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample1_DetectEntireSeriesAnomaly.md @@ -19,9 +19,6 @@ var credential = new AzureKeyCredential(apiKey); //create client AnomalyDetectorClient client = new AnomalyDetectorClient(endpointUri, credential); - -//read data -string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "samples", "data", "request-data.csv"); ``` ## Load time series and create DetectRequest @@ -33,6 +30,9 @@ Call `File.ReadAllLines` with the file path and create a list of `TimeSeriesPoin Make a `DetectRequest` object with the series of points, and `TimeGranularity.Daily` for the granularity (or periodicity) of the data points. ```C# Snippet:ReadSeriesData +//read data +string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "samples", "data", "request-data.csv"); + List list = File.ReadAllLines(datapath, Encoding.UTF8) .Where(e => e.Trim().Length != 0) .Select(e => e.Split(',')) diff --git a/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample2_DetectLastPointAnomaly.md b/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample2_DetectLastPointAnomaly.md index 3d60ce7115ff..511c133f69ab 100644 --- a/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample2_DetectLastPointAnomaly.md +++ b/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample2_DetectLastPointAnomaly.md @@ -19,9 +19,6 @@ var credential = new AzureKeyCredential(apiKey); //create client AnomalyDetectorClient client = new AnomalyDetectorClient(endpointUri, credential); - -//read data -string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "samples", "data", "request-data.csv"); ``` ## Load time series and create DetectRequest @@ -33,6 +30,9 @@ Call `File.ReadAllLines` with the file path and create a list of `TimeSeriesPoin Make a `DetectRequest` object with the series of points, and `TimeGranularity.Daily` for the granularity (or periodicity) of the data points. ```C# Snippet:ReadSeriesData +//read data +string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "samples", "data", "request-data.csv"); + List list = File.ReadAllLines(datapath, Encoding.UTF8) .Where(e => e.Trim().Length != 0) .Select(e => e.Split(',')) diff --git a/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample3_DetectChangePoint.md b/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample3_DetectChangePoint.md index 57648bbb6016..70addc8e704f 100644 --- a/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample3_DetectChangePoint.md +++ b/sdk/anomalydetector/Azure.AI.AnomalyDetector/samples/Sample3_DetectChangePoint.md @@ -19,9 +19,6 @@ var credential = new AzureKeyCredential(apiKey); //create client AnomalyDetectorClient client = new AnomalyDetectorClient(endpointUri, credential); - -//read data -string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "samples", "data", "request-data.csv"); ``` ## Load time series and create ChangePointDetectRequest diff --git a/sdk/anomalydetector/Azure.AI.AnomalyDetector/tests/samples/Sample1_DetectEntireSeriesAnomaly.cs b/sdk/anomalydetector/Azure.AI.AnomalyDetector/tests/samples/Sample1_DetectEntireSeriesAnomaly.cs index 8c158cd6828f..359490085a76 100644 --- a/sdk/anomalydetector/Azure.AI.AnomalyDetector/tests/samples/Sample1_DetectEntireSeriesAnomaly.cs +++ b/sdk/anomalydetector/Azure.AI.AnomalyDetector/tests/samples/Sample1_DetectEntireSeriesAnomaly.cs @@ -31,13 +31,13 @@ public async Task DetectEntireSeriesAnomaly() //create client AnomalyDetectorClient client = new AnomalyDetectorClient(endpointUri, credential); - //read data - string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "samples", "data", "request-data.csv"); - #endregion #region Snippet:ReadSeriesData + //read data + string datapath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "samples", "data", "request-data.csv"); + List list = File.ReadAllLines(datapath, Encoding.UTF8) .Where(e => e.Trim().Length != 0) .Select(e => e.Split(','))