Example #1
0
            public void PrintCentroid(StreamWriter outputFile)
            {
                outputFile.Write(string.Format("Centroid {0} = ", Number));
                int count = 0;

                for (var col = 0; col < Features.Cols(); col++)
                {
                    if (!Ignore.Contains(col))
                    {
                        if (count++ > 0)
                        {
                            outputFile.Write(", ");
                        }

                        if (Centroid[col] == Matrix.MISSING)
                        {
                            outputFile.Write("?");
                        }
                        else if (Features.ValueCount(col) < 2)
                        {
                            // continuous
                            outputFile.Write(Centroid[col]);
                        }
                        else
                        {
                            // nominal
                            outputFile.Write(Features.AttrValue(col, (int)Centroid[col]));
                        }
                    }
                }

                outputFile.WriteLine();
            }
        public async Task Invoke(HttpContext httpContext, MetricReporter reporter)
        {
            if (httpContext == null)
            {
                return;
            }

            var path = httpContext.Request.Path.Value;

            if (Ignore.Contains(path))
            {
                await _request.Invoke(httpContext).ConfigureAwait(false);

                return;
            }


            path = MetricPathTrimmer(path);

            var sw = Stopwatch.StartNew();

            try
            {
                await _request.Invoke(httpContext).ConfigureAwait(false);
            }
            finally
            {
                sw.Stop();
                reporter.RegisterRequest();
                reporter.RegisterResponseTime(httpContext.Response.StatusCode, path, sw.Elapsed);
            }
        }
Example #3
0
 public bool IgnoreStep(string alias)
 {
     if (Ignore == null)
     {
         return(false);
     }
     return(Ignore.Contains(alias));
 }
Example #4
0
 /// <summary>
 /// Removes the given regexes.
 /// </summary>
 /// <param name="paths"></param>
 public void RemoveIgnore(params string[] regexes)
 {
     foreach (var regex in regexes)
     {
         if (Ignore.Contains(regex))
         {
             Ignore.Remove(regex);
         }
     }
 }
Example #5
0
 /// <summary>
 /// Conditions for files/fodlers which should not be synced.
 /// </summary>
 /// <param name="paths">Paths</param>
 public void AddIgnore(params string[] regexes)
 {
     foreach (var regex in regexes)
     {
         if (regex != "" && !Ignore.Contains(regex))
         {
             Ignore.Add(regex);
         }
     }
 }
Example #6
0
 public void Recalculate()
 {
     // recalculate the centroid
     for (var col = 0; col < Centroid.Length; col++)
     {
         if (!Ignore.Contains(col))
         {
             Centroid[col] = GetValue(col);
         }
     }
 }
Example #7
0
        static void KeepAsmDefActive()
        {
            var file_name = Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(Selection.activeObject));
            var active    = Ignore.Contains(file_name);

            if (!active)
            {
                Ignore.Add(file_name);
            }
            else
            {
                Ignore.Remove(file_name);
            }

            Menu.SetChecked("Assets/Keep AsmDef active", !active);
        }
Example #8
0
        static bool KeepAsmDefActiveValidate()
        {
            if (Selection.activeObject == null)
            {
                return(false);
            }

            var asset_path = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (!asset_path.Contains(_asm_def_extension))
            {
                return(false);
            }

            Menu.SetChecked("Assets/Keep AsmDef active", Ignore.Contains(Selection.activeObject.name));
            return(AssetDatabase.GetAssetPath(Selection.activeObject).Contains(_asm_def_extension));
        }
Example #9
0
            public double GetError(double[] features)
            {
                double error = 0;

                for (var col = 0; col < Features.Cols(); col++)
                {
                    if (!Ignore.Contains(col))
                    {
                        if (Features.ValueCount(col) < 2)
                        {
                            // continuous
                            if ((Centroid[col] == Matrix.MISSING) || (features[col] == Matrix.MISSING))
                            {
                                error += 1;
                            }
                            else
                            {
                                error += Math.Pow(Centroid[col] - features[col], 2);
                            }
                        }
                        else
                        {
                            // nominal
                            if ((Centroid[col] == Matrix.MISSING) || (features[col] == Matrix.MISSING))
                            {
                                error += 1;
                            }
                            else if (Centroid[col] != features[col])
                            {
                                error += 1;
                            }
                        }
                    }
                }

                return(error);
            }
Example #10
0
        static void ToggleAsmDef()
        {
            var files = Directory.GetFiles(
                Application.dataPath,
                "*" + _asm_def_extension + "*",
                SearchOption.AllDirectories);

            var active   = new List <string>(files.Length);
            var inactive = new List <string>(files.Length);

            foreach (var file in files)
            {
                var file_name      = GetFileName(file);
                var file_name_only = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(file_name));
                if (!Ignore.Contains(file_name_only))
                {
                    if (file.IsHidden())
                    {
                        inactive.Add(file);
                    }
                    else
                    {
                        active.Add(file);
                    }
                }
                else
                {
                    Debug.LogFormat("{0} will be ignored since it's ignored, lol", file_name);
                }
            }

            Debug.LogFormat("Active AsmDef and meta files {0}, inactive files {1}", active.Count, inactive.Count);

            var toggle_list = Hidden ? inactive : active;

            foreach (var item in toggle_list)
            {
                if (!ToggleFile(item, Hidden))
                {
                    Debug.LogErrorFormat("Something went wrong, check");
                }
                else
                {
                    Debug.LogFormat("converted {0}", item);
                }
            }

            Hidden = !Hidden;

            if (active.Count != 0 && inactive.Count != 0)
            {
                Debug.LogWarning("not all AsmDefs are toggled");
                var string_list = active.Count < inactive.Count ? active : inactive;
                foreach (var s in string_list)
                {
                    Debug.LogWarningFormat("AsmDef that is different {0}", s);
                }
            }

            //AssetDatabase.Refresh(ImportAssetOptions.Default);
        }
Example #11
0
        public object Generate()
        {
            var obj = new TSource();

            foreach (var prop in typeof(TSource).GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (Ignore.Contains(prop.Name))
                {
                    continue;
                }

                if (Values.ContainsKey(prop.Name))
                {
                    prop.SetValue(obj, Values[prop.Name], null);
                    continue;
                }

                if (Generators.ContainsKey(prop.Name))
                {
                    try {
                        prop.SetValue(obj, Generators[prop.Name].Generate(), null);
                    } catch (ArgumentException) {
                        throw new ArgumentException($"Mismatching generator type for property {prop.Name}");
                    }
                    continue;
                }

                if (OnlyCustom)
                {
                    continue;
                }

                if (TypeGenerators.ContainsKey(prop.PropertyType))
                {
                    try {
                        prop.SetValue(obj, TypeGenerators[prop.PropertyType].Generate(), null);
                    } catch (ArgumentException) {
                        throw new ArgumentException($"Mismatching generator type for type {prop.PropertyType}");
                    }
                    continue;
                }

                Type type = prop.PropertyType;

                if (type == typeof(string))
                {
                    prop.SetValue(obj, ExtendedRandom.NextString(10), null);
                }
                else if (type == typeof(int) || type == typeof(long) || type == typeof(uint) || type == typeof(ulong))
                {
                    prop.SetValue(obj, Random.Next(1, 500), null);
                }
                else if (type == typeof(byte))
                {
                    prop.SetValue(obj, Random.Next(0, 256), null);
                }
                else if (type == typeof(sbyte))
                {
                    prop.SetValue(obj, Random.Next(-128, 128), null);
                }
                else if (type == typeof(short) || type == typeof(ushort))
                {
                    prop.SetValue(obj, Random.Next(0, 32768), null);
                }
                else if (type == typeof(float) || type == typeof(double) || type == typeof(decimal))
                {
                    prop.SetValue(obj, Convert.ChangeType(ExtendedRandom.NextDouble(0, 500), type), null);
                }
                else if (type == typeof(bool))
                {
                    prop.SetValue(obj, ExtendedRandom.NextBoolean(), null);
                }
                else if (type == typeof(char))
                {
                    prop.SetValue(obj, ExtendedRandom.NextChar(), null);
                }
                else if (type == typeof(Guid))
                {
                    prop.SetValue(obj, Guid.NewGuid(), null);
                }
                else if (type == typeof(DateTime))
                {
                    prop.SetValue(obj, ExtendedRandom.NextDateTime(), null);
                }
            }
            return(obj);
        }