def test_working_multiple(self):
     """Testing that the filter return the expected results with valid data"""
     postcodelatlng = [50.827973, -4.543798]
     radius = 10
     dictList = get_dict_list()
     actualOutput = filterData(dictList, postcodelatlng, radius)
     expectedOutput = [{
         'Crime ID': '1',
         'Longitude': '-4.543798',
         'Latitude': '50.830723',
         'Distance': 0.3057864802417903
     }, {
         'Crime ID': '2',
         'Longitude': '-4.544117',
         'Latitude': '50.827973',
         'Distance': 0.022405434837250257
     }, {
         'Crime ID': '3',
         'Longitude': '-4.548403',
         'Latitude': '50.828185',
         'Distance': 0.32429614137803187
     }, {
         'Crime ID': '4',
         'Longitude': '-4.551129',
         'Latitude': '50.828441',
         'Distance': 0.5175240380244737
     }, {
         'Crime ID': '5',
         'Longitude': '-4.551129',
         'Latitude': '50.828441',
         'Distance': 0.5175240380244737
     }]
     self.assertEqual(actualOutput, expectedOutput)
 def test_radius(self):
     """Testing that the filter returns empty list when radius is 0"""
     dictList = get_dict_list()
     postcodelatlng = [50.827974, -4.543799]
     radius = 0
     actualOutput = filterData(dictList, postcodelatlng, radius)
     expectedOutput = []
     self.assertEqual(actualOutput, expectedOutput)
 def test_empty_input(self):
     """Testing that the filter returns the expected results with only one input"""
     #Testing Empty input
     dictList = []
     postcodelatlng = [50.830723, -4.543798]
     radius = 100
     actualOutput = filterData(dictList, postcodelatlng, radius)
     expectedOutput = []
     self.assertEqual(actualOutput, expectedOutput)
 def test_not_list(self):
     """Testing that empty list retunred if input is not a list - not error"""
     test_data = get_dict_list()
     dictList = test_data[0]
     postcodelatlng = [50.830723, -4.543798]
     radius = 1000
     actualOutput = filterData(dictList, postcodelatlng, radius)
     expectedOutput = []
     self.assertEqual(actualOutput, expectedOutput)
 def test_same_coord(self):
     """Testing one result returned if radius is 0 and input empty"""
     #Testing Empty input
     dictList = []
     postcodelatlng = [51.830723, -4.543798]
     radius = 0
     actualOutput = filterData(dictList, postcodelatlng, radius)
     expectedOutput = []
     self.assertEqual(actualOutput, expectedOutput)
 def test_working_single(self):
     """Testing that the filter returns the expected results with only one input"""
     test_data = get_dict_list()
     dictList = [test_data[0]]
     postcodelatlng = [51.830723, -4.543798]
     radius = 1000
     actualOutput = filterData(dictList, postcodelatlng, radius)
     expectedOutput = [{
         'Crime ID': '1',
         'Longitude': '-4.543798',
         'Latitude': '50.830723',
         'Distance': 111.19508372419087
     }]
     self.assertEqual(actualOutput, expectedOutput)
Example #7
0
def getGravSample(scale_ratio, OG, calibration_constant):
    raw_data = loadcell.getreadings(no_load_samples)
    filtered_data = filter.filterData(raw_data)
    gravity = loadcell.get_density(filtered_data, scale_ratio, OG,
                                   calibration_constant)
    return gravity
Example #8
0
#Setting defualt screen
view = 0

#Get info from database
print('Collecting info from databse')
current_brew_id = db.getCurrentBrewId()
brew_name = db.getBrewInfo('BrewName', current_brew_id)
brewer = db.getBrewInfo('Brewer', current_brew_id)
target_temp = db.getBrewInfo('TargetTemp', current_brew_id)
OG = db.getBrewInfo('OG', current_brew_id)
FG = db.getBrewInfo('TargetFG', current_brew_id)

#Lag funksjon for dette
calibration_constant = db.getBrewInfo('CalibrationConstant', current_brew_id)
if calibration_constant == None:
    calibration_constant = filter.filterData(loadcell.getreadings(100))
    db.addCalibrationConstant(current_brew_id, calibration_constant)
else:
    calibration_constant = int(calibration_constant)

#Initialize sampling
print('Initializing sampling')
start_sample_time = time.time()
start_average_time = time.time()
temp_samples = []
grav_samples = []
time.sleep(1)

#Take initial spot sample
print('Collecting initial sample')
initial_temp = getTempSample()
Example #9
0
import filter

no_readings = 1000

while (1):
    try:
        known_sg1 = float(
            input(
                'Please enter a known specific gravity for the 1st. point of calibration: '
            ))
        break
    except ValueError:
        print('You have not entered a number')

print('Measuring. Wait until prompted')
known_data1 = filter.filterData(loadcell.getreadings(no_readings))
print('Measuring done')
print('Raw data corresponding ti 1st. point of calibration: {:f}'.format(
    known_data1))

while (1):
    try:
        known_sg2 = float(
            input(
                'Please enter a known specific gravity for the 2nd. point of calibration: '
            ))
        if known_sg1 == known_sg2:
            print('Please enter a new specific gravity')
            continue
        break
    except ValueError: