public void Insert(Patronus patronus) { string sqlite = @"insert into Patronus (Identifier) values (@patronusIdentifier);"; SQLiteConnection connection = new SQLiteConnection(connectionString); connection.Execute(sqlite, new { patronusIdentifier = patronus.Identifier }); }
public void TestBigConvolution() { // 1 2 3 4 // 5 6 7 8 // 9 10 11 12 // 13 14 15 16 // 1 2 // 3 4 var matrix = Patronus.Random(-10, 10, 30, 30); var kernel = Patronus.Random(-5, 10, 9, 9); var windowSize = kernel.Sizes; var strides = new List <int>() { 3, 3 }; var padding = 3; Matrix <int> result = new Convolution <int>(windowSize, kernel, strides, padding) { Param = matrix }; Print(matrix); Print(kernel); Print(result); }
public Patronus GetById(int id) { string sqlite = "select * from Patronus where Id = " + id + ";"; SQLiteConnection connection = new SQLiteConnection(connectionString); Patronus patronus = connection.Query <Patronus>(sqlite).FirstOrDefault(); return(patronus); }
public void TestReshapeTwoNegativeIndexInvalidFactor() { var matrix = Patronus.Sequence(1, 2, 2, 2); Assert.Throws <InvalidOperationException>(() => { matrix.Reshape(1, 3, -1); }); }
public void TestReshapeNegativeIndex2() { var matrix = Patronus.Sequence(1, 2, 2, 2); var result = matrix.Reshape(1, -1, 2); var expected = Patronus.Sequence(1, 1, 4, 2); Print(matrix, result, expected); Assert.True(expected.Equals(result)); }
public bool Post(PatronusModel patronusModel) { try { PatronusRepository patronusRepository = new PatronusRepository(); Patronus patronus = new Patronus(); patronus.Identifier = patronusModel.Identifier; patronusRepository.Insert(patronus); return(true); } catch { return(false); } }
public bool Update(Patronus patronus) { string sqlite = @"update Patronus set Identifier = @patronusIdentifier where Patronus.Id = @patronusId"; SQLiteConnection connection = new SQLiteConnection(connectionString); try { connection.ExecuteScalar(sqlite, new { patronusIdentifier = patronus.Identifier, patronusId = patronus.Id }); return(true); } catch { return(false); } }
public void TestConvolution() { // 1 2 3 4 // 5 6 7 8 // 9 10 11 12 // 13 14 15 16 // 1 2 // 3 4 var matrix = Patronus.Sequence(1, 4, 4); var kernel = new List <int>() { 1, 2, 3, 4 }; var windowSize = new List <int>() { 2, 2 }; var strides = new List <int>() { 1, 1 }; var padding = 0; Matrix <int> result = new Convolution <int>(windowSize, kernel, strides, padding) { Param = matrix }; var expected = Patronus.From <int>( 1 * 1 + 2 * 2 + 5 * 3 + 6 * 4, 2 * 1 + 3 * 2 + 6 * 3 + 7 * 4, 3 * 1 + 4 * 2 + 7 * 3 + 8 * 4, 5 * 1 + 6 * 2 + 9 * 3 + 10 * 4, 6 * 1 + 7 * 2 + 10 * 3 + 11 * 4, 7 * 1 + 8 * 2 + 11 * 3 + 12 * 4, 9 * 1 + 10 * 2 + 13 * 3 + 14 * 4, 10 * 1 + 11 * 2 + 14 * 3 + 15 * 4, 11 * 1 + 12 * 2 + 15 * 3 + 16 * 4 ).Reshape(3, 3); Print(matrix, result, expected); Assert.True(expected.Equals(result)); }
public bool Update(PatronusModel patronusModel) { PatronusRepository patronusRepository = new PatronusRepository(); Patronus patronus = new Patronus(); try { patronus.Id = patronusModel.Id; patronus.Identifier = patronusModel.Identifier; patronusRepository.Update(patronus); return(true); } catch { return(false); } }
public PatronusModel GetById(int id) { PatronusRepository patronusRepository = new PatronusRepository(); try { Patronus patronus = patronusRepository.GetById(id); PatronusModel patronusModel = new PatronusModel(); patronusModel.Id = patronus.Id; patronusModel.Identifier = patronus.Identifier; return(patronusModel); } catch { return(null); } }
public Wizzard GetById(int id) { string sqLite = @"select * from Wizzard left join Species on Wizzard.SpeciesId = Species.Id left join Gender on Wizzard.GenderId = Gender.Id left join House on Wizzard.HouseId = House.Id left join Ancestry on Wizzard.AncestryId = Ancestry.Id left join Colour eye on Wizzard.EyeColourId = eye.Id left join Colour hair on Wizzard.HairColourId = hair.Id left join Wand on Wizzard.WandId = Wand.Id left join Material mWood on Wand.WoodMaterialId = mWood.Id left join MaterialType mtWood on mWood.MaterialTypeId = mtWood.Id left join Material mCore on Wand.CoreMaterialId = mCore.Id left join MaterialType mtCore on mCore.MaterialTypeId = mtCore.Id left join Patronus on Wizzard.PatronusId = Patronus.Id where Wizzard.Id = " + id + ";"; SQLiteConnection connection = new SQLiteConnection(connectionString); Wizzard wizzard = connection.Query <Wizzard> (sqLite, new[] { typeof(Wizzard), typeof(Species), typeof(Gender), typeof(House), typeof(Ancestry), typeof(Colour), typeof(Colour), typeof(Wand), typeof(Material), typeof(MaterialType), typeof(Material), typeof(MaterialType), typeof(Patronus) } , objects => { Wizzard _wizzard = objects[0] as Wizzard; Species species = objects[1] as Species; Gender gender = objects[2] as Gender; House house = objects[3] as House; Ancestry ancestry = objects[4] as Ancestry; Colour eyeColour = objects[5] as Colour; Colour hairColour = objects[6] as Colour; Wand wand = objects[7] as Wand; Material woodMaterial = objects[8] as Material; MaterialType mt1 = objects[9] as MaterialType; Material coreMaterial = objects[10] as Material; MaterialType mt2 = objects[11] as MaterialType; Patronus patronus = objects[12] as Patronus; _wizzard.Species = species; _wizzard.Gender = gender; _wizzard.House = house; _wizzard.Ancestry = ancestry; _wizzard.EyeColour = eyeColour; _wizzard.HairColour = hairColour; _wizzard.Wand = wand; if (wand != null) { wand.WoodMaterial = woodMaterial; if (woodMaterial != null) { wand.WoodMaterial.MaterialType = mt1; } wand.CoreMaterial = coreMaterial; if (coreMaterial != null) { wand.CoreMaterial.MaterialType = mt2; } } _wizzard.Patronus = patronus; return(_wizzard); }, splitOn: "Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id").FirstOrDefault(); return(wizzard); }
public List <Wizzard> Get() { string sqLite = @"SELECT * FROM Wizzard LEFT JOIN Species on wizzard.SpeciesId = Species.Id LEFT JOIN Gender on wizzard.GenderId = Gender.Id LEFT JOIN House on wizzard.HouseId = House.Id LEFT JOIN Ancestry on wizzard.AncestryId = Ancestry.Id LEFT JOIN Colour c on wizzard.EyeColourId = c.Id LEFT JOIN Colour c2 on wizzard.HairColourId = c2.Id LEFT JOIN Wand on wizzard.WandId = Wand.Id LEFT JOIN Material m1 on Wand.WoodMaterialId = M1.Id LEFT JOIN MaterialType mt1 on m1.MaterialTypeId = mt1.Id LEFT JOIN Material m2 on Wand.CoreMaterialId = M2.Id LEFT JOIN MaterialType mt2 on m2.MaterialTypeId = mt2.Id LEFT JOIN patronus on wizzard.PatronusId = Patronus.Id"; SQLiteConnection connection = new SQLiteConnection(connectionString); List <Wizzard> wizzards = connection.Query <Wizzard> (sqLite, new[] { typeof(Wizzard), typeof(Species), typeof(Gender), typeof(House), typeof(Ancestry), typeof(Colour), typeof(Colour), typeof(Wand), typeof(Material), typeof(MaterialType), typeof(Material), typeof(MaterialType), typeof(Patronus) } , objects => { Wizzard wizzard = objects[0] as Wizzard; Species species = objects[1] as Species; Gender gender = objects[2] as Gender; House house = objects[3] as House; Ancestry ancestry = objects[4] as Ancestry; Colour eyeColour = objects[5] as Colour; Colour hairColour = objects[6] as Colour; Wand wand = objects[7] as Wand; Material woodMaterial = objects[8] as Material; MaterialType mt1 = objects[9] as MaterialType; Material coreMaterial = objects[10] as Material; MaterialType mt2 = objects[11] as MaterialType; Patronus patronus = objects[12] as Patronus; wizzard.Species = species; wizzard.Gender = gender; wizzard.House = house; wizzard.Ancestry = ancestry; wizzard.EyeColour = eyeColour; wizzard.HairColour = hairColour; wizzard.Wand = wand; if (wand != null) { wand.WoodMaterial = woodMaterial; if (woodMaterial != null) { wand.WoodMaterial.MaterialType = mt1; } wand.CoreMaterial = coreMaterial; if (coreMaterial != null) { wand.CoreMaterial.MaterialType = mt2; } } wizzard.Patronus = patronus; return(wizzard); }, splitOn: "Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id").ToList(); return(wizzards); }