public void ConversionTable_TransposeCycleEqualsOriginal() { var row1 = new List <string> { "Energy", "Erg", "Joule", "Kilocalorie", "Kilowatt hour" }; var row2 = new List <string> { "Erg", "1", "1.00E-07", "2.39E-11", "2.78E-14" }; var row3 = new List <string> { "Joule", "", "1", ".000239006", "2.78E-07" }; var row4 = new List <string> { "Kilocalorie", "", "", "1", ".00116222" }; var row5 = new List <string> { "Kilowatt hour", "", "", "", "1" }; var table = new List <List <string> >(); table.Add(row1); table.Add(row2); table.Add(row3); table.Add(row4); table.Add(row5); var transposedTable = new ConversionTable(table, table[0][0]); var originalTable = new ConversionTable(table, table[0][0]); Assert.AreEqual(transposedTable.Transpose().Transpose(), originalTable); }
public void ConversionTable_GetConversionValueWithNullUnit() { var row1 = new List <string> { "Energy", "Erg", "Joule", "Kilocalorie", "Kilowatt hour" }; var row2 = new List <string> { "Erg", "1", "1.00E-07", "2.39E-11", "2.78E-14" }; var row3 = new List <string> { "Joule", "", "1", ".000239006", "2.78E-07" }; var row4 = new List <string> { "Kilocalorie", "", "", "1", ".00116222" }; var row5 = new List <string> { "Kilowatt hour", "", "", "", "1" }; var table = new List <List <string> >(); table.Add(row1); table.Add(row2); table.Add(row3); table.Add(row4); table.Add(row5); var conversionTable = new ConversionTable(table, table[0][0]); var conversionValue = conversionTable.GetConversionValue(null, "Kilocalorie"); var expectedValue = new ConversionValue(); Assert.AreEqual(expectedValue, conversionValue); }
private void StartNetworks() { //Based off of http://www.poeex.info/index/index/table/1 var rates = new Dictionary <CurrencyType, float>() { { CurrencyType.ChromaticOrb, 1f / 13f }, { CurrencyType.OrbOfAlteration, 1f / 13f }, { CurrencyType.JewellersOrb, 1f / 7f }, { CurrencyType.OrbOfChance, 1f / 5f }, { CurrencyType.CartographersChisel, 1 / 4f }, { CurrencyType.OrbOfFusing, 1f / 2f }, { CurrencyType.OrbOfAlchemy, 1f / 3.5f }, { CurrencyType.OrbOfScouring, 1f / 1.8f }, { CurrencyType.BlessedOrb, 1f / 1.3f }, { CurrencyType.OrbOfRegret, 1f }, { CurrencyType.RegalOrb, 1.3f }, { CurrencyType.GemcuttersPrism, 1.8f }, { CurrencyType.DivineOrb, 17f }, { CurrencyType.ExaltedOrb, 50f }, { CurrencyType.VaalOrb, 1f }, }; var conversionTable = new ConversionTable(rates); trainer = new NetworkTrainer(conversionTable); trainer.StartTraining(); }
public Conversion(int unitCode, float unitValue, ConversionTable conversionTable, Unit unit) { if (unitValue < 0) throw new NegativeInputException("Input is negative please fix"); _untValue.Code = unitCode; _untValue.Value = unitValue; _tblConversion = conversionTable; _unit = unit; }
public void TestConversionRateToZeroWeight() { CurrencyType wantedCurrency = CurrencyType.Unknown; Currency sourceCurrency = new Currency(CurrencyType.ChaosOrb, 1f); ConversionTable conversionTable = new ConversionTable(); Currency convertedCurrency = conversionTable.ConvertTo(sourceCurrency, wantedCurrency); Assert.AreEqual(0, convertedCurrency.Value, 0); }
public Conversion(int unitCode, float unitValue, ConversionTable conversionTable, Unit unit) { if (unitValue < 0) { throw new NegativeInputException("Input is negative please fix"); } _untValue.Code = unitCode; _untValue.Value = unitValue; _tblConversion = conversionTable; _unit = unit; }
internal static byte ToKeyCode(KeyEventArgs keyEventArgs) { var key = keyEventArgs.Key; if (key == Key.System) { key = keyEventArgs.SystemKey; } KeyCode value = KeyCode.KEY_NONE; ConversionTable.TryGetValue(key, out value); return((byte)value); }
public void TestConversionRateFromDecimalToCheaper() { CurrencyType wantedCurrency = CurrencyType.OrbOfAlchemy; Currency sourceCurrency = new Currency(CurrencyType.ExaltedOrb, 5.5f); ConversionTable conversionTable = new ConversionTable( new Dictionary <CurrencyType, float> { { wantedCurrency, 0.2f }, } ); Currency convertedCurrency = conversionTable.ConvertTo(sourceCurrency, wantedCurrency); Assert.AreEqual(27.5f, convertedCurrency.Value, 0.001f); }
public void TestConversionRateFromDecimalToMoreExpensive() { CurrencyType wantedCurrency = CurrencyType.ExaltedOrb; Currency sourceCurrency = new Currency(CurrencyType.ChaosOrb, 2.5f); ConversionTable conversionTable = new ConversionTable( new Dictionary <CurrencyType, float> { { wantedCurrency, 10f } } ); Currency convertedCurrency = conversionTable.ConvertTo(sourceCurrency, wantedCurrency); Assert.AreEqual(0.25f, convertedCurrency.Value, 0.001f); }
public void TestConversionRateFromUnitToCheaper() { CurrencyType wantedCurrency = CurrencyType.OrbOfAlchemy; Currency sourceCurrency = new Currency(CurrencyType.ChaosOrb, 1f); ConversionTable conversionTable = new ConversionTable( new Dictionary <CurrencyType, float> { { wantedCurrency, 0.01f } } ); Currency convertedCurrency = conversionTable.ConvertTo(sourceCurrency, wantedCurrency); Assert.AreEqual(100f, convertedCurrency.Value, 0.001f); }
public void TestFusingToExaltedOrbs() { CurrencyType wantedCurrency = CurrencyType.ExaltedOrb; Currency sourceCurrency = new Currency(CurrencyType.OrbOfFusing, 6f); ConversionTable conversionTable = new ConversionTable( new Dictionary <CurrencyType, float> { { CurrencyType.ExaltedOrb, 50 }, { CurrencyType.OrbOfFusing, 1 / 12f } } ); Currency convertedCurrency = conversionTable.ConvertTo(sourceCurrency, wantedCurrency); Assert.AreEqual(0.01f, convertedCurrency.Value, 0.001f); }
public static double ConvertTo(this Unit unit, double fromValue, Unit targetUnit) { Dictionary <Unit, decimal> inner; decimal factor; if (ConversionTable.TryGetValue(unit, out inner) && inner.TryGetValue(targetUnit, out factor)) { return(Convert.ToDouble(factor * (decimal)fromValue)); } else { throw new NotImplementedException(String.Format( "No factor defined for conversion from {0} to {1}.", unit.ToString(), targetUnit.ToString())); } }
public NetworkTrainer(ConversionTable table) { this.conversionTable = table; this.lastCycleResult = new TrainingCycleResult(SupportedItemTypes); POEStash.OnStashUpdated += POEStash_OnStashUpdated; }