Skip to main content

Posts

Scipy Integration Method to implement Integration Result

scipy.integrate  library has single integration, double, triple, multiple, Gaussian quadrate, Romberg, Trapezoidal and Simpson's rules. Integration for Single value range:- quad() is used to represent single integration in scipy. from scipy import integrate # take f(x) function as f f = lambda x : x**2 #single integration with a = 0 & b = 1   integration = integrate.quad(f, 0 , 1) print(integration) .............................................................................. Double Integration Example in Scipy:- from scipy import integrate import numpy as np #import square root function from math lib from math import sqrt # set  fuction f(x) f = lambda x, y : 64 *x*y # lower limit of second integral p = lambda x : 0 # upper limit of first integral q = lambda y : sqrt(1 - 2*y**2) # perform double integration integration = integrate.dblquad(f , 0 , 2/4,  p, q) print(integration)             

Image Processing with SciPy – scipy.ndimage

scipy.ndimage is a submodule of SciPy which is mostly used for performing an image related operation It is now deprecated we can not use the misc package on the latest version scipy. If we want to show image and perform an operation on images then we can use  imageio package to write and read images with the following code. import imageio f=imageio.imread('img.jpg') import matplotlib.pyplot as plt plt.imshow(f) plt.show() #note you can upload your own images to show the image(img.jpg). If we want to flip the images of the actual image using this then we can use flipud() of numpy import numpy as np flip_ud_face = np.flipud(f) plt.imshow(flip_ud_face) plt.show() Rotate the image at particular angle in scipy. import numpy as np from scipy import ndimage, misc s=ndimage.rotate(f, 45) plt.imshow(s) plt.show() Code to blur image import numpy as np from scipy import ndimage, misc #s=ndimage.rotate(f, 45) s=ndimage.gaussian_filter(f, sigma=3) plt.imshow(s) plt.show() http://scipy...

Data Science SCIPY for Gradient evaluation with optimization

SCIPY provide an optimize package to provide optimization to linear-gradient evaluation using multiple algorithms Optimization and Fit in SciPy – scipy.optimize Optimization provides a useful algorithm for minimization of curve fitting, multidimensional or scalar, and root fitting. %matplotlib inline import matplotlib.pyplot as plt from scipy import optimize import numpy as np fre = 5 #Sample rate fre_samp = 50 t = np.linspace(0, 2, 2 * fre_samp, endpoint = False ) a = np.sin(fre * 2 * np.pi * t) def function(a): return a*2 + 20 * np.sin(a) plt.plot(a, function(a)) plt.show() #use BFGS algorithm for optimization optimize.fmin_bfgs(function, 0) Nelder –Mead Algorithm: Nelder-Mead algorithm selects through method parameter. It provides the most straightforward way of minimization for fair behaved function. Nelder – Mead algorithm is not used for gradient evaluations because it may take a longer time to find the solution. import numpy as np from scipy import optimize...

Uncontrolled Functional Component with RadioButton, ListBox, DropdownList and Checkbox

 Uncontrolled Functional Component with RadioButton, ListBox, DropdownList and Checkbox: Example of RadioButton: import { useRef , useState } from "react" ; function RadioExampleNew () {     const course1 = useRef ()     const course2 = useRef ()     const course3 = useRef ()     const [ res , setRes ] = useState ( undefined )     function displayCourse ( e )     {         if ( course1 . current . checked )         {             setRes ( course1 . current . value )         }         else   if ( course2 . current . checked )             {                 setRes ( course2 . current . value )             }             else             {   ...

What is git and github,What is difference between git and github?

 What are git and GitHub, What is the difference between git and GitHub? Git:- It is a command-line console editor that is used to execute the git command, create a local repository, add files, remove files, create a branch, remove a branch, add files under the branch, show files under the branch, current branch status, push the file into remote, pull the file from remote. means if we want to add any data under GitHub(remote) then you should execute the git command. download git console from here Download git Github:- it is a cloud repository that is used to store data under a cloud, it is VCS means version control system. It is an open-source cloud web application that can be simply operated.  Open  https://github.com/ and create an account under it. Some important git command 1)  git init:-   it is used to initialize the git local repository under the current working directory 2)  git add file-  It is used to add working files under the git local re...

Testng example to perform Integration Testing of Owner Module

 Test-ng example to perform  Integration Testing of Owner Module:- In this example, we will perform a complete integration testing operation from Owner Login with valid data and navigate to the dashboard page, click on add room options then click on the logout link. again create another test case to check login operation with invalid credentials. Code Specification:- 1)  uses two annotations of @Test to write test cases 2)  BeforeMethod annotation to execute Code before each Test case method and AfterMethod annotation to execute code after each test case. Complete Code Description:- package scs; import java.time.Duration; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class TestNGExample...

What is extends in Django? How to create standard template design in Django

  It is used to provide the extendibility of parent template or base template to child template. If we want to create a master-child template in the Django application then we use extends operation in Django. Child pages inherit the complete functionality of the base template. Syntax of base template or master template <html> <head> </head> <body> <div id="container"> <header> </header> <section> {% block blockame %}     Content Place Holder   {% endblock %} </section> <footer> </footer> </div> </body> </html> Syntax of child page:- {% extends 'appname/parentpage.html' %} {% block blockname %}     hello {% endblock %} Now I am providing the code of the base.html or master.html file:- <!DOCTYPE html> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="/static/style.css"> </head> <body...