How to use float method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

15.1.2.3-1.js

Source:15.1.2.3-1.js Github

copy

Full Screen

1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */2/* ***** BEGIN LICENSE BLOCK *****3 * Version: MPL 1.1/GPL 2.0/LGPL 2.14 *5 * The contents of this file are subject to the Mozilla Public License Version6 * 1.1 (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * http://www.mozilla.org/MPL/9 *10 * Software distributed under the License is distributed on an "AS IS" basis,11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License12 * for the specific language governing rights and limitations under the13 * License.14 *15 * The Original Code is Mozilla Communicator client code, released16 * March 31, 1998.17 *18 * The Initial Developer of the Original Code is19 * Netscape Communications Corporation.20 * Portions created by the Initial Developer are Copyright (C) 199821 * the Initial Developer. All Rights Reserved.22 *23 * Contributor(s):24 *25 * Alternatively, the contents of this file may be used under the terms of26 * either the GNU General Public License Version 2 or later (the "GPL"), or27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),28 * in which case the provisions of the GPL or the LGPL are applicable instead29 * of those above. If you wish to allow use of your version of this file only30 * under the terms of either the GPL or the LGPL, and not to allow others to31 * use your version of this file under the terms of the MPL, indicate your32 * decision by deleting the provisions above and replace them with the notice33 * and other provisions required by the GPL or the LGPL. If you do not delete34 * the provisions above, a recipient may use your version of this file under35 * the terms of any one of the MPL, the GPL or the LGPL.36 *37 * ***** END LICENSE BLOCK ***** */38gTestfile = '15.1.2.3-1.js';39/**40 File Name: 15.1.2.3.js41 ECMA Section: 15.1.2.3 Function properties of the global object:42 parseFloat( string )43 Description: The parseFloat function produces a number value dictated44 by the interpretation of the contents of the string45 argument defined as a decimal literal.46 When the parseFloat function is called, the following47 steps are taken:48 1. Call ToString( string ).49 2. Remove leading whitespace Result(1).50 3. If neither Result(2) nor any prefix of Result(2)51 satisfies the syntax of a StrDecimalLiteral,52 return NaN.53 4. Compute the longest prefix of Result(2) which might54 be Resusult(2) itself, that satisfies the syntax of55 a StrDecimalLiteral56 5. Return the number value for the MV of Result(4).57 Note that parseFloate may interpret only a leading58 portion of the string as a number value; it ignores any59 characters that cannot be interpreted as part of the60 notation of a decimal literal, and no indication is given61 that such characters were ignored.62 StrDecimalLiteral::63 Infinity64 DecimalDigits.DecimalDigits opt ExponentPart opt65 .DecimalDigits ExponentPart opt66 DecimalDigits ExponentPart opt67 Author: christine@netscape.com68 Date: 28 october 199769*/70var SECTION = "15.1.2.3-1";71var VERSION = "ECMA_1";72var TITLE = "parseFloat(string)";73var BUGNUMBER="none";74startTest();75writeHeaderToLog( SECTION + " "+ TITLE);76new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length );77new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") );78new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length );79new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") );80new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "prototype", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") );81new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() );82new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') );83new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') );84new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) );85new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) );86new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") );87new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") );88new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') );89new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") );90new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) );91new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") );92new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') );93new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") );94new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) );95new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") );96new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") );97new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") );98new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") );99new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") );100new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") );101new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") );102new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") );103new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") );104new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") );105new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") );106new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") );107new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") );108new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") );109new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") );110new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") );111new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") );112new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") );113new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") );114new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") );115new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") );116new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") );117new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") );118new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") );119new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") );120new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") );121new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") );122new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") );123new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") );124new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") );125new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") );126new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") );127new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") );128new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") );129new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") );130new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") );131new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") );132new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") );133new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") );134new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") );135new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") );136new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") );137new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") );138new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") );139new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") );140// StrDecimalLiteral::: .DecimalDigits ExponentPart opt141new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") );142new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") );143new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") );144new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") );145new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") );146new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") );147new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") );148new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") );149new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") );150new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") );151new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") );152new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") );153// StrDecimalLiteral::: DecimalDigits ExponentPart opt154new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") );155new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") );156new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") );157new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") );158new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") );159new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") );160new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") );161new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") );162new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") );163new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) );164new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) );165new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) );166new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) );167new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) );168new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) );169new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) );170new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) );171new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) );172new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) );173new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) );174new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) );175new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) );176new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) );177new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) );178new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) );179new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) );180new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) );181new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) );182new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) );183new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) );184new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) );185new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) );186new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) );187new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) );188new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) );189new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) );190new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) );191new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) );192new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) );193new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) );194new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) );195new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) );196new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) );197new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) );198new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) );199// StrDecimalLiteral::: .DecimalDigits ExponentPart opt200new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) );201new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) );202new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) );203new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) );204new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) );205new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) );206new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) );207new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) );208// StrDecimalLiteral::: DecimalDigits ExponentPart opt209new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) );210new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) );211new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) );212new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) );213new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) );214new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) );215// hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral)216new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0"));217new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1"));218new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2"));219new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3"));220new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4"));221new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5"));222new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6"));223new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7"));224new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8"));225new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9"));226new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa"));227new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb"));228new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc"));229new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd"));230new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe"));231new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf"));232new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA"));233new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB"));234new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC"));235new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD"));236new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE"));237new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF"));238new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0"));239new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1"));240new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2"));241new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3"));242new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4"));243new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5"));244new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6"));245new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7"));246new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8"));247new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9"));248new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa"));249new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb"));250new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc"));251new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd"));252new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe"));253new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf"));254new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA"));255new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB"));256new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC"));257new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD"));258new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE"));259new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF"));260new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF "));261// hex literals should still succeed262new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0));263new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1));264new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2));265new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3));266new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4));267new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5));268new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6));269new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7));270new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8));271new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9));272new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa));273new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb));274new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc));275new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd));276new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe));277new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf));278new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA));279new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB));280new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC));281new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD));282new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE));283new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF));284new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0));285new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1));286new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2));287new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3));288new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4));289new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5));290new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6));291new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7));292new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8));293new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9));294new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa));295new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb));296new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc));297new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd));298new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe));299new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf));300new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA));301new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB));302new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC));303new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD));304new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE));305new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF));306// A StringNumericLiteral may not use octal notation307new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00"));308new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01"));309new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02"));310new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03"));311new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04"));312new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05"));313new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06"));314new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07"));315new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010"));316new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011"));317// A StringNumericLIteral may have any number of leading 0 digits318new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001"));319new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001"));320new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 "));321// an octal numeric literal should be treated as an octal322new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00));323new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01));324new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02));325new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03));326new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04));327new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05));328new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06));329new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07));330new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010));331new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011));332// A StringNumericLIteral may have any number of leading 0 digits333new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001));334new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001));335// make sure it's reflexive336new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI));337new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2));338new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10));339new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E));340new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E));341new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2));342new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2));343new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+''));344new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+''));345new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+''));346new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+''));347new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+''));348new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+''));349new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+''));...

Full Screen

Full Screen

15.1.2.3-2.js

Source:15.1.2.3-2.js Github

copy

Full Screen

1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */2/* ***** BEGIN LICENSE BLOCK *****3 * Version: MPL 1.1/GPL 2.0/LGPL 2.14 *5 * The contents of this file are subject to the Mozilla Public License Version6 * 1.1 (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * http://www.mozilla.org/MPL/9 *10 * Software distributed under the License is distributed on an "AS IS" basis,11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License12 * for the specific language governing rights and limitations under the13 * License.14 *15 * The Original Code is Mozilla Communicator client code, released16 * March 31, 1998.17 *18 * The Initial Developer of the Original Code is19 * Netscape Communications Corporation.20 * Portions created by the Initial Developer are Copyright (C) 199821 * the Initial Developer. All Rights Reserved.22 *23 * Contributor(s):24 *25 * Alternatively, the contents of this file may be used under the terms of26 * either the GNU General Public License Version 2 or later (the "GPL"), or27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),28 * in which case the provisions of the GPL or the LGPL are applicable instead29 * of those above. If you wish to allow use of your version of this file only30 * under the terms of either the GPL or the LGPL, and not to allow others to31 * use your version of this file under the terms of the MPL, indicate your32 * decision by deleting the provisions above and replace them with the notice33 * and other provisions required by the GPL or the LGPL. If you do not delete34 * the provisions above, a recipient may use your version of this file under35 * the terms of any one of the MPL, the GPL or the LGPL.36 *37 * ***** END LICENSE BLOCK ***** */38gTestfile = '15.1.2.3-2.js';39/**40 File Name: 15.1.2.3-2.js41 ECMA Section: 15.1.2.3 Function properties of the global object:42 parseFloat( string )43 Description: The parseFloat function produces a number value dictated44 by the interpretation of the contents of the string45 argument defined as a decimal literal.46 When the parseFloat function is called, the following47 steps are taken:48 1. Call ToString( string ).49 2. Remove leading whitespace Result(1).50 3. If neither Result(2) nor any prefix of Result(2)51 satisfies the syntax of a StrDecimalLiteral,52 return NaN.53 4. Compute the longest prefix of Result(2) which might54 be Resusult(2) itself, that satisfies the syntax of55 a StrDecimalLiteral56 5. Return the number value for the MV of Result(4).57 Note that parseFloate may interpret only a leading58 portion of the string as a number value; it ignores any59 characters that cannot be interpreted as part of the60 notation of a decimal literal, and no indication is given61 that such characters were ignored.62 StrDecimalLiteral::63 Infinity64 DecimalDigits.DecimalDigits opt ExponentPart opt65 .DecimalDigits ExponentPart opt66 DecimalDigits ExponentPart opt67 Author: christine@netscape.com68 Date: 28 october 199769*/70var SECTION = "15.1.2.3-2";71var VERSION = "ECMA_1";72startTest();73var BUGNUMBER="none";74new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) );75new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) );76new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") );77new TestCase( SECTION, "parseFloat(' Infinity')", Number.POSITIVE_INFINITY, parseFloat("Infinity") );78// new TestCase( SECTION, "parseFloat(Infinity)", Number.POSITIVE_INFINITY, parseFloat(Infinity) );79new TestCase( SECTION, "parseFloat(' 0')", 0, parseFloat(" 0") );80new TestCase( SECTION, "parseFloat(' -0')", -0, parseFloat(" -0") );81new TestCase( SECTION, "parseFloat(' +0')", 0, parseFloat(" +0") );82new TestCase( SECTION, "parseFloat(' 1')", 1, parseFloat(" 1") );83new TestCase( SECTION, "parseFloat(' -1')", -1, parseFloat(" -1") );84new TestCase( SECTION, "parseFloat(' +1')", 1, parseFloat(" +1") );85new TestCase( SECTION, "parseFloat(' 2')", 2, parseFloat(" 2") );86new TestCase( SECTION, "parseFloat(' -2')", -2, parseFloat(" -2") );87new TestCase( SECTION, "parseFloat(' +2')", 2, parseFloat(" +2") );88new TestCase( SECTION, "parseFloat(' 3')", 3, parseFloat(" 3") );89new TestCase( SECTION, "parseFloat(' -3')", -3, parseFloat(" -3") );90new TestCase( SECTION, "parseFloat(' +3')", 3, parseFloat(" +3") );91new TestCase( SECTION, "parseFloat(' 4')", 4, parseFloat(" 4") );92new TestCase( SECTION, "parseFloat(' -4')", -4, parseFloat(" -4") );93new TestCase( SECTION, "parseFloat(' +4')", 4, parseFloat(" +4") );94new TestCase( SECTION, "parseFloat(' 5')", 5, parseFloat(" 5") );95new TestCase( SECTION, "parseFloat(' -5')", -5, parseFloat(" -5") );96new TestCase( SECTION, "parseFloat(' +5')", 5, parseFloat(" +5") );97new TestCase( SECTION, "parseFloat(' 6')", 6, parseFloat(" 6") );98new TestCase( SECTION, "parseFloat(' -6')", -6, parseFloat(" -6") );99new TestCase( SECTION, "parseFloat(' +6')", 6, parseFloat(" +6") );100new TestCase( SECTION, "parseFloat(' 7')", 7, parseFloat(" 7") );101new TestCase( SECTION, "parseFloat(' -7')", -7, parseFloat(" -7") );102new TestCase( SECTION, "parseFloat(' +7')", 7, parseFloat(" +7") );103new TestCase( SECTION, "parseFloat(' 8')", 8, parseFloat(" 8") );104new TestCase( SECTION, "parseFloat(' -8')", -8, parseFloat(" -8") );105new TestCase( SECTION, "parseFloat(' +8')", 8, parseFloat(" +8") );106new TestCase( SECTION, "parseFloat(' 9')", 9, parseFloat(" 9") );107new TestCase( SECTION, "parseFloat(' -9')", -9, parseFloat(" -9") );108new TestCase( SECTION, "parseFloat(' +9')", 9, parseFloat(" +9") );109new TestCase( SECTION, "parseFloat(' 3.14159')", 3.14159, parseFloat(" 3.14159") );110new TestCase( SECTION, "parseFloat(' -3.14159')", -3.14159, parseFloat(" -3.14159") );111new TestCase( SECTION, "parseFloat(' +3.14159')", 3.14159, parseFloat(" +3.14159") );112new TestCase( SECTION, "parseFloat(' 3.')", 3, parseFloat(" 3.") );113new TestCase( SECTION, "parseFloat(' -3.')", -3, parseFloat(" -3.") );114new TestCase( SECTION, "parseFloat(' +3.')", 3, parseFloat(" +3.") );115new TestCase( SECTION, "parseFloat(' 3.e1')", 30, parseFloat(" 3.e1") );116new TestCase( SECTION, "parseFloat(' -3.e1')", -30, parseFloat(" -3.e1") );117new TestCase( SECTION, "parseFloat(' +3.e1')", 30, parseFloat(" +3.e1") );118new TestCase( SECTION, "parseFloat(' 3.e+1')", 30, parseFloat(" 3.e+1") );119new TestCase( SECTION, "parseFloat(' -3.e+1')", -30, parseFloat(" -3.e+1") );120new TestCase( SECTION, "parseFloat(' +3.e+1')", 30, parseFloat(" +3.e+1") );121new TestCase( SECTION, "parseFloat(' 3.e-1')", .30, parseFloat(" 3.e-1") );122new TestCase( SECTION, "parseFloat(' -3.e-1')", -.30, parseFloat(" -3.e-1") );123new TestCase( SECTION, "parseFloat(' +3.e-1')", .30, parseFloat(" +3.e-1") );124// StrDecimalLiteral::: .DecimalDigits ExponentPart opt125new TestCase( SECTION, "parseFloat(' .00001')", 0.00001, parseFloat(" .00001") );126new TestCase( SECTION, "parseFloat(' +.00001')", 0.00001, parseFloat(" +.00001") );127new TestCase( SECTION, "parseFloat(' -0.0001')", -0.00001, parseFloat(" -.00001") );128new TestCase( SECTION, "parseFloat(' .01e2')", 1, parseFloat(" .01e2") );129new TestCase( SECTION, "parseFloat(' +.01e2')", 1, parseFloat(" +.01e2") );130new TestCase( SECTION, "parseFloat(' -.01e2')", -1, parseFloat(" -.01e2") );131new TestCase( SECTION, "parseFloat(' .01e+2')", 1, parseFloat(" .01e+2") );132new TestCase( SECTION, "parseFloat(' +.01e+2')", 1, parseFloat(" +.01e+2") );133new TestCase( SECTION, "parseFloat(' -.01e+2')", -1, parseFloat(" -.01e+2") );134new TestCase( SECTION, "parseFloat(' .01e-2')", 0.0001, parseFloat(" .01e-2") );135new TestCase( SECTION, "parseFloat(' +.01e-2')", 0.0001, parseFloat(" +.01e-2") );136new TestCase( SECTION, "parseFloat(' -.01e-2')", -0.0001, parseFloat(" -.01e-2") );137// StrDecimalLiteral::: DecimalDigits ExponentPart opt138new TestCase( SECTION, "parseFloat(' 1234e5')", 123400000, parseFloat(" 1234e5") );139new TestCase( SECTION, "parseFloat(' +1234e5')", 123400000, parseFloat(" +1234e5") );140new TestCase( SECTION, "parseFloat(' -1234e5')", -123400000, parseFloat(" -1234e5") );141new TestCase( SECTION, "parseFloat(' 1234e+5')", 123400000, parseFloat(" 1234e+5") );142new TestCase( SECTION, "parseFloat(' +1234e+5')", 123400000, parseFloat(" +1234e+5") );143new TestCase( SECTION, "parseFloat(' -1234e+5')", -123400000, parseFloat(" -1234e+5") );144new TestCase( SECTION, "parseFloat(' 1234e-5')", 0.01234, parseFloat(" 1234e-5") );145new TestCase( SECTION, "parseFloat(' +1234e-5')", 0.01234, parseFloat(" +1234e-5") );146new TestCase( SECTION, "parseFloat(' -1234e-5')", -0.01234, parseFloat(" -1234e-5") );147new TestCase( SECTION, "parseFloat(' .01E2')", 1, parseFloat(" .01E2") );148new TestCase( SECTION, "parseFloat(' +.01E2')", 1, parseFloat(" +.01E2") );149new TestCase( SECTION, "parseFloat(' -.01E2')", -1, parseFloat(" -.01E2") );150new TestCase( SECTION, "parseFloat(' .01E+2')", 1, parseFloat(" .01E+2") );151new TestCase( SECTION, "parseFloat(' +.01E+2')", 1, parseFloat(" +.01E+2") );152new TestCase( SECTION, "parseFloat(' -.01E+2')", -1, parseFloat(" -.01E+2") );153new TestCase( SECTION, "parseFloat(' .01E-2')", 0.0001, parseFloat(" .01E-2") );154new TestCase( SECTION, "parseFloat(' +.01E-2')", 0.0001, parseFloat(" +.01E-2") );155new TestCase( SECTION, "parseFloat(' -.01E-2')", -0.0001, parseFloat(" -.01E-2") );156// StrDecimalLiteral::: DecimalDigits ExponentPart opt157new TestCase( SECTION, "parseFloat(' 1234E5')", 123400000, parseFloat(" 1234E5") );158new TestCase( SECTION, "parseFloat(' +1234E5')", 123400000, parseFloat(" +1234E5") );159new TestCase( SECTION, "parseFloat(' -1234E5')", -123400000, parseFloat(" -1234E5") );160new TestCase( SECTION, "parseFloat(' 1234E+5')", 123400000, parseFloat(" 1234E+5") );161new TestCase( SECTION, "parseFloat(' +1234E+5')", 123400000, parseFloat(" +1234E+5") );162new TestCase( SECTION, "parseFloat(' -1234E+5')", -123400000, parseFloat(" -1234E+5") );163new TestCase( SECTION, "parseFloat(' 1234E-5')", 0.01234, parseFloat(" 1234E-5") );164new TestCase( SECTION, "parseFloat(' +1234E-5')", 0.01234, parseFloat(" +1234E-5") );165new TestCase( SECTION, "parseFloat(' -1234E-5')", -0.01234, parseFloat(" -1234E-5") );166// hex cases should all return NaN167new TestCase( SECTION, "parseFloat(' 0x0')", 0, parseFloat(" 0x0"));168new TestCase( SECTION, "parseFloat(' 0x1')", 0, parseFloat(" 0x1"));169new TestCase( SECTION, "parseFloat(' 0x2')", 0, parseFloat(" 0x2"));170new TestCase( SECTION, "parseFloat(' 0x3')", 0, parseFloat(" 0x3"));171new TestCase( SECTION, "parseFloat(' 0x4')", 0, parseFloat(" 0x4"));172new TestCase( SECTION, "parseFloat(' 0x5')", 0, parseFloat(" 0x5"));173new TestCase( SECTION, "parseFloat(' 0x6')", 0, parseFloat(" 0x6"));174new TestCase( SECTION, "parseFloat(' 0x7')", 0, parseFloat(" 0x7"));175new TestCase( SECTION, "parseFloat(' 0x8')", 0, parseFloat(" 0x8"));176new TestCase( SECTION, "parseFloat(' 0x9')", 0, parseFloat(" 0x9"));177new TestCase( SECTION, "parseFloat(' 0xa')", 0, parseFloat(" 0xa"));178new TestCase( SECTION, "parseFloat(' 0xb')", 0, parseFloat(" 0xb"));179new TestCase( SECTION, "parseFloat(' 0xc')", 0, parseFloat(" 0xc"));180new TestCase( SECTION, "parseFloat(' 0xd')", 0, parseFloat(" 0xd"));181new TestCase( SECTION, "parseFloat(' 0xe')", 0, parseFloat(" 0xe"));182new TestCase( SECTION, "parseFloat(' 0xf')", 0, parseFloat(" 0xf"));183new TestCase( SECTION, "parseFloat(' 0xA')", 0, parseFloat(" 0xA"));184new TestCase( SECTION, "parseFloat(' 0xB')", 0, parseFloat(" 0xB"));185new TestCase( SECTION, "parseFloat(' 0xC')", 0, parseFloat(" 0xC"));186new TestCase( SECTION, "parseFloat(' 0xD')", 0, parseFloat(" 0xD"));187new TestCase( SECTION, "parseFloat(' 0xE')", 0, parseFloat(" 0xE"));188new TestCase( SECTION, "parseFloat(' 0xF')", 0, parseFloat(" 0xF"));189new TestCase( SECTION, "parseFloat(' 0X0')", 0, parseFloat(" 0X0"));190new TestCase( SECTION, "parseFloat(' 0X1')", 0, parseFloat(" 0X1"));191new TestCase( SECTION, "parseFloat(' 0X2')", 0, parseFloat(" 0X2"));192new TestCase( SECTION, "parseFloat(' 0X3')", 0, parseFloat(" 0X3"));193new TestCase( SECTION, "parseFloat(' 0X4')", 0, parseFloat(" 0X4"));194new TestCase( SECTION, "parseFloat(' 0X5')", 0, parseFloat(" 0X5"));195new TestCase( SECTION, "parseFloat(' 0X6')", 0, parseFloat(" 0X6"));196new TestCase( SECTION, "parseFloat(' 0X7')", 0, parseFloat(" 0X7"));197new TestCase( SECTION, "parseFloat(' 0X8')", 0, parseFloat(" 0X8"));198new TestCase( SECTION, "parseFloat(' 0X9')", 0, parseFloat(" 0X9"));199new TestCase( SECTION, "parseFloat(' 0Xa')", 0, parseFloat(" 0Xa"));200new TestCase( SECTION, "parseFloat(' 0Xb')", 0, parseFloat(" 0Xb"));201new TestCase( SECTION, "parseFloat(' 0Xc')", 0, parseFloat(" 0Xc"));202new TestCase( SECTION, "parseFloat(' 0Xd')", 0, parseFloat(" 0Xd"));203new TestCase( SECTION, "parseFloat(' 0Xe')", 0, parseFloat(" 0Xe"));204new TestCase( SECTION, "parseFloat(' 0Xf')", 0, parseFloat(" 0Xf"));205new TestCase( SECTION, "parseFloat(' 0XA')", 0, parseFloat(" 0XA"));206new TestCase( SECTION, "parseFloat(' 0XB')", 0, parseFloat(" 0XB"));207new TestCase( SECTION, "parseFloat(' 0XC')", 0, parseFloat(" 0XC"));208new TestCase( SECTION, "parseFloat(' 0XD')", 0, parseFloat(" 0XD"));209new TestCase( SECTION, "parseFloat(' 0XE')", 0, parseFloat(" 0XE"));210new TestCase( SECTION, "parseFloat(' 0XF')", 0, parseFloat(" 0XF"));211// A StringNumericLiteral may not use octal notation212new TestCase( SECTION, "parseFloat(' 00')", 0, parseFloat(" 00"));213new TestCase( SECTION, "parseFloat(' 01')", 1, parseFloat(" 01"));214new TestCase( SECTION, "parseFloat(' 02')", 2, parseFloat(" 02"));215new TestCase( SECTION, "parseFloat(' 03')", 3, parseFloat(" 03"));216new TestCase( SECTION, "parseFloat(' 04')", 4, parseFloat(" 04"));217new TestCase( SECTION, "parseFloat(' 05')", 5, parseFloat(" 05"));218new TestCase( SECTION, "parseFloat(' 06')", 6, parseFloat(" 06"));219new TestCase( SECTION, "parseFloat(' 07')", 7, parseFloat(" 07"));220new TestCase( SECTION, "parseFloat(' 010')", 10, parseFloat(" 010"));221new TestCase( SECTION, "parseFloat(' 011')", 11, parseFloat(" 011"));222// A StringNumericLIteral may have any number of leading 0 digits223new TestCase( SECTION, "parseFloat(' 001')", 1, parseFloat(" 001"));224new TestCase( SECTION, "parseFloat(' 0001')", 1, parseFloat(" 0001"));225// A StringNumericLIteral may have any number of leading 0 digits226new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001));227new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001));228// make sure it' s reflexive229new TestCase( SECTION, "parseFloat( ' ' +Math.PI+' ')", Math.PI, parseFloat( ' ' +Math.PI+' '));230new TestCase( SECTION, "parseFloat( ' ' +Math.LN2+' ')", Math.LN2, parseFloat( ' ' +Math.LN2+' '));231new TestCase( SECTION, "parseFloat( ' ' +Math.LN10+' ')", Math.LN10, parseFloat( ' ' +Math.LN10+' '));232new TestCase( SECTION, "parseFloat( ' ' +Math.LOG2E+' ')", Math.LOG2E, parseFloat( ' ' +Math.LOG2E+' '));233new TestCase( SECTION, "parseFloat( ' ' +Math.LOG10E+' ')", Math.LOG10E, parseFloat( ' ' +Math.LOG10E+' '));234new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT2+' ')", Math.SQRT2, parseFloat( ' ' +Math.SQRT2+' '));235new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT1_2+' ')", Math.SQRT1_2, parseFloat( ' ' +Math.SQRT1_2+' '));...

Full Screen

Full Screen

models.py

Source:models.py Github

copy

Full Screen

1from django.contrib.auth.models import User2from django.db import models3class SavedFood(models.Model):4 """5 A user-specific cached food item from the food API.6 Goes by a (either default or set) name.7 Encapsulates individual food items nutritional data.8 """9 user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='saved_foods')10 name = models.CharField(max_length=60)11 brand = models.CharField(max_length=60, null=True)12 image_url = models.URLField(null=True)13 # Serving info14 serving_qty = models.IntegerField()15 serving_unit = models.CharField(max_length=20)16 serving_weight_g = models.IntegerField()17 calories = models.FloatField(help_text="kcal", blank=True, null=True)18 # Fats (Macro)19 total_fat = models.FloatField(help_text="g", blank=True, null=True)20 saturated_fat = models.FloatField(help_text="g", blank=True, null=True)21 monounsaturated_fat = models.FloatField(help_text="g", blank=True, null=True)22 polyunsaturated_fat = models.FloatField(help_text="g", blank=True, null=True)23 trans_fat = models.FloatField(help_text="g", blank=True, null=True)24 omega_3_ala = models.FloatField(help_text="g", blank=True, null=True)25 omega_3_epa = models.FloatField(help_text="g", blank=True, null=True)26 omega_3_dpa = models.FloatField(help_text="g", blank=True, null=True)27 omega_3_dha = models.FloatField(help_text="g", blank=True, null=True)28 omega_3_ete = models.FloatField(help_text="g", blank=True, null=True)29 omega_6_la = models.FloatField(help_text="g", blank=True, null=True)30 omega_6_gla = models.FloatField(help_text="g", blank=True, null=True)31 omega_6_ea = models.FloatField(help_text="g", blank=True, null=True)32 omega_6_dgla = models.FloatField(help_text="g", blank=True, null=True)33 omega_6_aa = models.FloatField(help_text="g", blank=True, null=True)34 cholesterol = models.FloatField(help_text="mg", blank=True, null=True)35 phytosterol = models.FloatField(help_text="mg", blank=True, null=True)36 # Carbohydrates (Macro)37 total_carbs = models.FloatField(help_text="g", blank=True, null=True)38 fiber = models.FloatField(help_text="g", blank=True, null=True)39 total_sugar = models.FloatField(help_text="g", blank=True, null=True)40 added_sugar = models.FloatField(help_text="g", blank=True, null=True)41 fructose = models.FloatField(help_text="g", blank=True, null=True)42 galactose = models.FloatField(help_text="g", blank=True, null=True)43 lactose = models.FloatField(help_text="g", blank=True, null=True)44 dextrose = models.FloatField(help_text="g", blank=True, null=True)45 maltose = models.FloatField(help_text="g", blank=True, null=True)46 starch = models.FloatField(help_text="g", blank=True, null=True)47 sucrose = models.FloatField(help_text="g", blank=True, null=True)48 # Protein/amino acids (Macro)49 total_protein = models.FloatField(help_text="g", blank=True, null=True)50 alanine = models.FloatField(help_text="g", blank=True, null=True)51 arginine = models.FloatField(help_text="g", blank=True, null=True)52 aspartic_acid = models.FloatField(help_text="g", blank=True, null=True)53 cystine = models.FloatField(help_text="g", blank=True, null=True)54 glycine = models.FloatField(help_text="g", blank=True, null=True)55 histidine = models.FloatField(help_text="g", blank=True, null=True)56 hydroxyproline = models.FloatField(help_text="g", blank=True, null=True)57 isoleucine = models.FloatField(help_text="g", blank=True, null=True)58 leucine = models.FloatField(help_text="g", blank=True, null=True)59 lysine = models.FloatField(help_text="g", blank=True, null=True)60 phenylalanine = models.FloatField(help_text="g", blank=True, null=True)61 proline = models.FloatField(help_text="g", blank=True, null=True)62 serine = models.FloatField(help_text="g", blank=True, null=True)63 threonine = models.FloatField(help_text="g", blank=True, null=True)64 tryptophan = models.FloatField(help_text="g", blank=True, null=True)65 # Elemental/mineral nutrients (Micro)66 sodium = models.FloatField(help_text="g", blank=True, null=True)67 potassium = models.FloatField(help_text='mg', blank=True, null=True)68 calcium = models.FloatField(help_text="mg", blank=True, null=True)69 iron = models.FloatField(help_text="mg", blank=True, null=True)70 magnesium = models.FloatField(help_text="mg", blank=True, null=True)71 phosphorus = models.FloatField(help_text="mg", blank=True, null=True)72 manganese = models.FloatField(help_text="mg", blank=True, null=True)73 selenium = models.FloatField(help_text="mg", blank=True, null=True)74 zinc = models.FloatField(help_text="mg", blank=True, null=True)75 copper = models.FloatField(help_text="mg", blank=True, null=True)76 fluoride = models.FloatField(help_text="µg", blank=True, null=True)77 # Vitamins/compound nutrients (Micro)78 folate = models.FloatField(help_text="µg", blank=True, null=True)79 folic_acid = models.FloatField(help_text="µg", blank=True, null=True)80 carotene_a = models.FloatField(help_text="µg", blank=True, null=True)81 carotene_b = models.FloatField(help_text="µg", blank=True, null=True)82 vitamin_d = models.FloatField(help_text="µg", blank=True, null=True)83 vitamin_d2 = models.FloatField(help_text="µg", blank=True, null=True)84 vitamin_d3 = models.FloatField(help_text="µg", blank=True, null=True)85 choline = models.FloatField(help_text="mg", blank=True, null=True)86 betaine = models.FloatField(help_text="mg", blank=True, null=True)87 lycopine = models.FloatField(help_text="µg", blank=True, null=True)88 niacin = models.FloatField(help_text="mg", blank=True, null=True)89 menaquinone_4 = models.FloatField(help_text="µg", blank=True, null=True)90 pantothenic_acid = models.FloatField(help_text="mg", blank=True, null=True)91 retinol = models.FloatField(help_text="µg", blank=True, null=True)92 riboflavin = models.FloatField(help_text="mg", blank=True, null=True)93 thiamin = models.FloatField(help_text="mg", blank=True, null=True)94 vitamin_e = models.FloatField(help_text="mg", blank=True, null=True)95 vitamin_b12 = models.FloatField(help_text="µg", blank=True, null=True)96 vitamin_b6 = models.FloatField(help_text="mg", blank=True, null=True)97 vitamin_c = models.FloatField(help_text="mg", blank=True, null=True)98 vitamin_k = models.FloatField(help_text="µg", blank=True, null=True)99 # Pharmacological100 alcohol = models.FloatField(help_text="g", blank=True, null=True)101 caffeine = models.FloatField(help_text="mg", blank=True, null=True)102 theobromine = models.FloatField(help_text="mg", blank=True, null=True)103 # Biological analysis104 ash = models.FloatField(help_text="g", blank=True, null=True) # Represents mineral content of food105 water = models.FloatField(help_text="g", blank=True, null=True)106 class Meta:107 ordering = ['name']108 @property109 def fields(self):110 return self._meta.fields111 112 113 def __str__(self):114 if self.brand:115 return f'{self.name} - {self.brand}'116 else:117 return f'{self.name} - USDA'118class FoodGroup(models.Model):119 """120 A user-specific grouping of (SavedFood instances or other FoodGroup instances).121 """122 user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='grouped_foods')123 # Collection of individual foods encapulated by this group124 grouped_foods = models.ManyToManyField(SavedFood, related_name='foods')125 # Collection of other food groups encapsulated by this group126 grouped_groups = models.ManyToManyField('self', related_name='groups')127 name = models.CharField(max_length=60)128 # Totals evaluted from the ManytoMany relationships129 # Serving info130 serving_weight_g = models.IntegerField()131 calories = models.FloatField(help_text="kcal", blank=True, null=True)132 # Fats (Macro)133 total_fat = models.FloatField(help_text="g", blank=True, null=True)134 saturated_fat = models.FloatField(help_text="g", blank=True, null=True)135 monounsaturated_fat = models.FloatField(help_text="g", blank=True, null=True)136 polyunsaturated_fat = models.FloatField(help_text="g", blank=True, null=True)137 trans_fat = models.FloatField(help_text="g", blank=True, null=True)138 omega_3_ala = models.FloatField(help_text="g", blank=True, null=True)139 omega_3_epa = models.FloatField(help_text="g", blank=True, null=True)140 omega_3_dpa = models.FloatField(help_text="g", blank=True, null=True)141 omega_3_dha = models.FloatField(help_text="g", blank=True, null=True)142 omega_3_ete = models.FloatField(help_text="g", blank=True, null=True)143 omega_6_la = models.FloatField(help_text="g", blank=True, null=True)144 omega_6_gla = models.FloatField(help_text="g", blank=True, null=True)145 omega_6_ea = models.FloatField(help_text="g", blank=True, null=True)146 omega_6_dgla = models.FloatField(help_text="g", blank=True, null=True)147 omega_6_aa = models.FloatField(help_text="g", blank=True, null=True)148 cholesterol = models.FloatField(help_text="mg", blank=True, null=True)149 phytosterol = models.FloatField(help_text="mg", blank=True, null=True)150 # Carbohydrates (Macro)151 total_carbs = models.FloatField(help_text="g", blank=True, null=True)152 fiber = models.FloatField(help_text="g", blank=True, null=True)153 total_sugar = models.FloatField(help_text="g", blank=True, null=True)154 added_sugar = models.FloatField(help_text="g", blank=True, null=True)155 fructose = models.FloatField(help_text="g", blank=True, null=True)156 galactose = models.FloatField(help_text="g", blank=True, null=True)157 lactose = models.FloatField(help_text="g", blank=True, null=True)158 dextrose = models.FloatField(help_text="g", blank=True, null=True)159 maltose = models.FloatField(help_text="g", blank=True, null=True)160 starch = models.FloatField(help_text="g", blank=True, null=True)161 sucrose = models.FloatField(help_text="g", blank=True, null=True)162 # Protein/amino acids (Macro)163 total_protein = models.FloatField(help_text="g", blank=True, null=True)164 alanine = models.FloatField(help_text="g", blank=True, null=True)165 arginine = models.FloatField(help_text="g", blank=True, null=True)166 aspartic_acid = models.FloatField(help_text="g", blank=True, null=True)167 cystine = models.FloatField(help_text="g", blank=True, null=True)168 glycine = models.FloatField(help_text="g", blank=True, null=True)169 histidine = models.FloatField(help_text="g", blank=True, null=True)170 hydroxyproline = models.FloatField(help_text="g", blank=True, null=True)171 isoleucine = models.FloatField(help_text="g", blank=True, null=True)172 leucine = models.FloatField(help_text="g", blank=True, null=True)173 lysine = models.FloatField(help_text="g", blank=True, null=True)174 phenylalanine = models.FloatField(help_text="g", blank=True, null=True)175 proline = models.FloatField(help_text="g", blank=True, null=True)176 serine = models.FloatField(help_text="g", blank=True, null=True)177 threonine = models.FloatField(help_text="g", blank=True, null=True)178 tryptophan = models.FloatField(help_text="g", blank=True, null=True)179 # Elemental/mineral nutrients (Micro)180 sodium = models.FloatField(help_text="g", blank=True, null=True)181 potassium = models.FloatField(help_text='mg', blank=True, null=True)182 calcium = models.FloatField(help_text="mg", blank=True, null=True)183 iron = models.FloatField(help_text="mg", blank=True, null=True)184 magnesium = models.FloatField(help_text="mg", blank=True, null=True)185 phosphorus = models.FloatField(help_text="mg", blank=True, null=True)186 manganese = models.FloatField(help_text="mg", blank=True, null=True)187 selenium = models.FloatField(help_text="mg", blank=True, null=True)188 zinc = models.FloatField(help_text="mg", blank=True, null=True)189 copper = models.FloatField(help_text="mg", blank=True, null=True)190 fluoride = models.FloatField(help_text="µg", blank=True, null=True)191 # Vitamins/compound nutrients (Micro)192 folate = models.FloatField(help_text="µg", blank=True, null=True)193 folic_acid = models.FloatField(help_text="µg", blank=True, null=True)194 carotene_a = models.FloatField(help_text="µg", blank=True, null=True)195 carotene_b = models.FloatField(help_text="µg", blank=True, null=True)196 vitamin_d = models.FloatField(help_text="µg", blank=True, null=True)197 vitamin_d2 = models.FloatField(help_text="µg", blank=True, null=True)198 vitamin_d3 = models.FloatField(help_text="µg", blank=True, null=True)199 choline = models.FloatField(help_text="mg", blank=True, null=True)200 betaine = models.FloatField(help_text="mg", blank=True, null=True)201 lycopine = models.FloatField(help_text="µg", blank=True, null=True)202 niacin = models.FloatField(help_text="mg", blank=True, null=True)203 menaquinone_4 = models.FloatField(help_text="µg", blank=True, null=True)204 pantothenic_acid = models.FloatField(help_text="mg", blank=True, null=True)205 retinol = models.FloatField(help_text="µg", blank=True, null=True)206 riboflavin = models.FloatField(help_text="mg", blank=True, null=True)207 thiamin = models.FloatField(help_text="mg", blank=True, null=True)208 vitamin_e = models.FloatField(help_text="mg", blank=True, null=True)209 vitamin_b12 = models.FloatField(help_text="µg", blank=True, null=True)210 vitamin_b6 = models.FloatField(help_text="mg", blank=True, null=True)211 vitamin_c = models.FloatField(help_text="mg", blank=True, null=True)212 vitamin_k = models.FloatField(help_text="µg", blank=True, null=True)213 # Pharmacological214 alcohol = models.FloatField(help_text="g", blank=True, null=True)215 caffeine = models.FloatField(help_text="mg", blank=True, null=True)216 theobromine = models.FloatField(help_text="mg", blank=True, null=True)217 # Biological analysis218 ash = models.FloatField(help_text="g", blank=True, null=True) # Represents mineral content of food219 water = models.FloatField(help_text="g", blank=True, null=True)220 def __str__(self):221 return self.name222class FoodLog(FoodGroup):223 """224 A user-specific, day-specific grouping of FoodGroup and/or SavedFood instances.225 Inherits from FoodGroup model.226 Functions like a food group, but is associated with a specific date227 """228 date = models.DateField()229 # Is '{date} - {username}'230 # This is a unique identifier; each user has only one log per given day...

Full Screen

Full Screen

echo_scan.py

Source:echo_scan.py Github

copy

Full Screen

...9 self.time_increment = 0.010 self.scan_time = 0.032999999821211 self.range_min = 0.44999998807912 self.range_max = 10.013 self.ranges = [1.6017869710922241, 1.5993984937667847, 1.5970163345336914, 1.5946406126022339, 1.5899080038070679, 1.587551236152649, 1.5852009057998657, 1.5828567743301392, 1.5805190801620483, 1.5781877040863037, 1.573543667793274, 1.5712313652038574, 1.5689250230789185, 1.5666249990463257, 1.5643314123153687, 1.5597628355026245, 1.557487964630127, 1.555219292640686, 1.5529569387435913, 1.5507009029388428, 1.5484508275985718, 1.543969750404358, 1.541738510131836, 1.5395134687423706, 1.537294626235962, 1.5350819826126099, 1.532875418663025, 1.5306751728057861, 1.5262932777404785, 1.5241113901138306, 1.5219359397888184, 1.5197663307189941, 1.5176030397415161, 1.5154459476470947, 1.5132948160171509, 1.509011149406433, 1.5068786144256592, 1.5047519207000732, 1.5026315450668335, 1.5005172491073608, 1.4984089136123657, 1.4963067770004272, 1.4942106008529663, 1.4900367259979248, 1.4879589080810547, 1.4858869314193726, 1.4838212728500366, 1.4817615747451782, 1.4797078371047974, 1.4776601791381836, 1.475618600845337, 1.4735828638076782, 1.4695298671722412, 1.4675122499465942, 1.4655007123947144, 1.463495135307312, 1.4614955186843872, 1.4595019817352295, 1.4575142860412598, 1.4555326700210571, 1.453959345817566, 1.4563707113265991, 1.4587963819503784, 1.463692307472229, 1.4661625623703003, 1.468647837638855, 1.4711482524871826, 1.4736639261245728, 1.4761948585510254, 1.4787415266036987, 1.4813034534454346, 1.4838812351226807, 1.4864749908447266, 1.4890846014022827, 1.4917103052139282, 1.4943522214889526, 1.4996850490570068, 1.5023763179779053, 1.5050842761993408, 1.507809042930603, 1.5105509757995605, 1.5133097171783447, 1.5160858631134033, 1.5188794136047363, 1.5216903686523438, 1.5245190858840942, 1.5273653268814087, 1.5302298069000244, 1.5331121683120728, 1.536012887954712, 1.5389318466186523, 1.5418692827224731, 1.5448254346847534, 1.5478003025054932, 1.550794243812561, 1.5568393468856812, 1.5598909854888916, 1.5629620552062988, 1.5660529136657715, 1.5691637992858887, 1.5722944736480713, 1.575445532798767, 1.5786168575286865, 1.5818088054656982, 1.5850214958190918, 1.5882549285888672, 1.591509461402893, 1.5947853326797485, 1.5980823040008545, 1.6014010906219482, 1.6047414541244507, 1.60810387134552, 1.6114884614944458, 1.614895224571228, 1.6183245182037354, 1.6217764616012573, 1.625251293182373, 1.628749132156372, 1.632270336151123, 1.635814905166626, 1.63938307762146, 1.642975091934204, 1.6465911865234375, 1.6502315998077393, 1.6538965702056885, 1.6575859785079956, 1.6613004207611084, 1.6650398969650269, 1.66880464553833, 1.6725950241088867, 1.6764111518859863, 1.680253267288208, 1.6841216087341309, 1.688016414642334, 1.691937804222107, 1.6958861351013184, 1.6998616456985474, 1.703864574432373, 1.707895040512085, 1.7119535207748413, 1.7160398960113525, 1.720154881477356, 1.724298357963562, 1.7284706830978394, 1.7326722145080566, 1.736903190612793, 1.7411638498306274, 1.7454544305801392, 1.7497752904891968, 1.7541265487670898, 1.758508563041687, 1.762921690940857, 1.7673660516738892, 1.7718422412872314, 1.7763501405715942, 1.7808904647827148, 1.7854632139205933, 1.7900686264038086, 1.7947074174880981, 1.799379587173462, 1.804085373878479, 1.8088253736495972, 1.8135995864868164, 1.8184086084365845, 1.82325279712677, 1.8281322717666626, 1.8330473899841309, float('nan'), 1.8379987478256226, 1.8429863452911377, 1.8480106592178345, 1.8530722856521606, 1.8581713438034058, 1.8633081912994385, 1.8684831857681274, 1.8736969232559204, 1.8789494037628174, 1.8842413425445557, 1.8895729780197144, 1.8949447870254517, 1.9003571271896362, 1.9058103561401367, 1.9113048315048218, 1.9168411493301392, 1.922419786453247, 1.9280407428741455, 1.9337048530578613, 1.9394124746322632, 1.9451638460159302, 1.9509596824645996, float('nan'), 1.9568002223968506, 1.9626860618591309, 1.9686177968978882, 1.9745956659317017, 1.98062002658844, 1.9866917133331299, 1.9928109645843506, 1.9989783763885498, 2.0051944255828857, 2.0114598274230957, 2.017774820327759, 2.024139881134033, 2.0305559635162354, 2.0370230674743652, 2.0435423851013184, 2.0501136779785156, float('nan'), 2.0567383766174316, 2.0634162425994873, 2.070148468017578, 2.076935052871704, 2.0837771892547607, 2.0906753540039062, 2.0976297855377197, 2.1046414375305176, 2.111711025238037, 2.1188390254974365, 2.126025915145874, 2.133272647857666, 2.14057993888855, 2.1479480266571045, float('nan'), 2.1553781032562256, 2.162870407104492, 2.170426368713379, 2.1780459880828857, 2.185730218887329, 2.1934800148010254, 2.2012956142425537, 2.2091784477233887, 2.2171287536621094, 2.2251477241516113, 2.233236074447632, 2.241394281387329, 2.2496235370635986, float('nan'), 2.2579245567321777, 2.266298294067383, 2.274745464324951, 2.283267021179199, 2.2918639183044434, 2.300536632537842, 2.3092870712280273, 2.318115234375, 2.3270223140716553, 2.3360095024108887, 2.3450775146484375, 2.3542277812957764, float('nan'), 2.3634607791900635, 2.3727781772613525, 2.3821802139282227, 2.3916687965393066, 2.4012441635131836, 2.4109082221984863, 2.420661687850952, 2.4305055141448975, 2.440441608428955, 2.450470209121704, 2.4605932235717773, float('nan'), 2.470811367034912, 2.481126308441162, 2.491539478302002, 2.50205135345459, 2.5126638412475586, 2.5233781337738037, 2.534195899963379, 2.5451180934906006, 2.5561463832855225, 2.567282199859619, float('nan'), 2.578526735305786, 2.589881658554077, 2.601348400115967, 2.612928628921509, 2.6246237754821777, 2.6364352703094482, 2.6483654975891113, 2.6604154109954834, 2.672586441040039, 2.6848812103271484, 2.6973013877868652, float('nan'), 2.7098476886749268, 2.7225229740142822, 2.735328435897827, 2.7482666969299316, float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), float('nan'), 2.110891342163086, 2.105895519256592, 2.10093355178833, 2.0960049629211426, 2.0911099910736084, 2.086247682571411, 2.08141827583313, 2.0766215324401855, 2.07185697555542, 2.067124128341675, 2.06242299079895, 2.057753324508667, 2.053114891052246, 2.0485072135925293, 2.0439300537109375, 2.0393831729888916, 2.0348665714263916, 2.0303797721862793, 2.0259225368499756, 2.0214946269989014, 2.0170958042144775, 2.012726068496704, 2.0083847045898438, 2.0040717124938965, 1.9997872114181519, 1.9955304861068726, 1.9913016557693481, 1.9871001243591309, 1.9829258918762207, float('nan'), 1.978778600692749, 1.9746581315994263, 1.9705644845962524, 1.9664971828460693, 1.9624559879302979, 1.9584407806396484, 1.954451322555542, 1.950487494468689, 1.9465491771697998, 1.9426356554031372, 1.9387474060058594, 1.9348838329315186, 1.9310448169708252, 1.9272300004959106, 1.923439621925354, 1.919673204421997, 1.9122116565704346, 1.9085159301757812, 1.904843807220459, 1.9011945724487305, 1.8975681066513062, 1.8939646482467651, 1.8903834819793701, 1.8868247270584106, 1.8832882642745972, 1.8797738552093506, 1.8762812614440918, 1.8728102445602417, 1.8693609237670898, 1.865932822227478, 1.8625259399414062, 1.8591402769088745, 1.855775237083435, 1.852431058883667, 1.8491075038909912, 1.8458043336868286, 1.8425214290618896, 1.8392585515975952, 1.8360158205032349, 1.8327927589416504, 1.8295894861221313, 1.826405644416809, 1.823241114616394, 1.8200958967208862, 1.816969871520996, 1.8138625621795654, 1.810774326324463, 1.8077046871185303, 1.8046534061431885, 1.8016207218170166, 1.795609951019287, 1.7926315069198608, 1.7896710634231567, 1.7867282629013062, 1.783803105354309, 1.7808955907821655, 1.7780052423477173, 1.7751322984695435, 1.7722764015197754, 1.769437313079834, 1.7666151523590088, 1.7638099193572998, 1.7610210180282593, 1.758249044418335, 1.7554931640625, 1.752753496170044, 1.7473227977752686, 1.744631290435791, 1.7419557571411133, 1.7392957210540771, 1.7366514205932617, 1.734022617340088, 1.7314090728759766, 1.7288107872009277, 1.7262277603149414, 1.723659873008728, 1.721106767654419, 1.7185685634613037, 1.713536262512207, 1.7110419273376465, 1.7085621356964111, 1.7060965299606323, 1.7036452293395996, 1.7012081146240234, 1.6987850666046143, 1.696375846862793, 1.6939804553985596, 1.6915990114212036, 1.686876654624939, 1.6845358610153198, 1.6822082996368408, 1.679894208908081, 1.6775932312011719, 1.6753053665161133, 1.6730304956436157, 1.6707686185836792, 1.6662832498550415, 1.6640595197677612, 1.661848545074463, 1.6596500873565674, 1.6574639081954956, 1.655290126800537, 1.6531286239624023, 1.6509792804718018, 1.646716833114624, 1.6446034908294678, 1.6425020694732666, 1.640412449836731, 1.6383345127105713, 1.6362680196762085, 1.6342133283615112, 1.6301380395889282, 1.628117322921753, 1.626107931137085, 1.6241097450256348, 1.6221226453781128, 1.6201465129852295, 1.6162270307540894, 1.6142836809158325, 1.6123509407043457, 1.6104289293289185, 1.6085172891616821, 1.6066166162490845, 1.6028459072113037, 1.6009763479232788, 1.5991168022155762, 1.597267508506775, 1.5954283475875854, 1.5917800664901733, 1.5899710655212402, 1.5881717205047607, 1.5863823890686035, 1.5846025943756104, 1.5828325748443604, 1.5793213844299316, 1.5775799751281738, 1.5758482217788696, 1.5741256475448608, 1.5724124908447266, 1.5707085132598877]14 self.intensities = []15 16# We will use the class we created above to assign values to the "scan_data" variable. 17scan_data = create_scan_data()18 19# Just for fun, let's print the value of the maximum angle:20print(scan_data.angle_max)21# Let's also print the number of values in the "ranges" list:22print(len(scan_data.ranges))23# *********************************************24# Now, for your homework, you are asked to 25# write some Python code to do the following:26#27# 1) What is the sweep angle of the scanner, ...

Full Screen

Full Screen

bfloat16_test.py

Source:bfloat16_test.py Github

copy

Full Screen

...29 epsilon = float.fromhex("1.0p-7")30 return [31 0.0, 1.0, -1, 0.5, -0.5, epsilon, 1.0 + epsilon, 1.0 - epsilon,32 -1.0 - epsilon, -1.0 + epsilon, 3.5, 42.0, 255.0, 256.0,33 float("inf"), float("-inf"), float("nan")]34 def _assertFloatIdentical(self, v, w):35 if math.isnan(v):36 self.assertTrue(math.isnan(w))37 else:38 self.assertEqual(v, w)39 def testRoundTripToFloat(self):40 for v in self.float_values():41 self._assertFloatIdentical(v, float(bfloat16(v)))42 def testRoundTripToInt(self):43 for v in [-256, -255, -34, -2, -1, 0, 1, 2, 10, 47, 128, 255, 256, 512]:44 self.assertEqual(v, int(bfloat16(v)))45 def testStr(self):46 self.assertEqual("0", str(bfloat16(0.0)))47 self.assertEqual("1", str(bfloat16(1.0)))48 self.assertEqual("-3.5", str(bfloat16(-3.5)))49 self.assertEqual("0.0078125", str(bfloat16(float.fromhex("1.0p-7"))))50 self.assertEqual("inf", str(bfloat16(float("inf"))))51 self.assertEqual("-inf", str(bfloat16(float("-inf"))))52 self.assertEqual("nan", str(bfloat16(float("nan"))))53 def testRepr(self):54 self.assertEqual("bfloat16(0)", repr(bfloat16(0)))55 self.assertEqual("bfloat16(1)", repr(bfloat16(1)))56 self.assertEqual("bfloat16(-3.5)", repr(bfloat16(-3.5)))57 self.assertEqual("bfloat16(0.0078125)",58 repr(bfloat16(float.fromhex("1.0p-7"))))59 self.assertEqual("bfloat16(inf)", repr(bfloat16(float("inf"))))60 self.assertEqual("bfloat16(-inf)", repr(bfloat16(float("-inf"))))61 self.assertEqual("bfloat16(nan)", repr(bfloat16(float("nan"))))62 def testHash(self):63 self.assertEqual(0, hash(bfloat16(0.0)))64 self.assertEqual(0x3f80, hash(bfloat16(1.0)))65 self.assertEqual(0x7fc0, hash(bfloat16(float("nan"))))66 # Tests for Python operations67 def testNegate(self):68 for v in self.float_values():69 self._assertFloatIdentical(-v, float(-bfloat16(v)))70 def testAdd(self):71 self._assertFloatIdentical(0, float(bfloat16(0) + bfloat16(0)))72 self._assertFloatIdentical(1, float(bfloat16(1) + bfloat16(0)))73 self._assertFloatIdentical(0, float(bfloat16(1) + bfloat16(-1)))74 self._assertFloatIdentical(5.5, float(bfloat16(2) + bfloat16(3.5)))75 self._assertFloatIdentical(1.25, float(bfloat16(3.5) + bfloat16(-2.25)))76 self._assertFloatIdentical(float("inf"),77 float(bfloat16(float("inf")) + bfloat16(-2.25)))78 self._assertFloatIdentical(float("-inf"),79 float(bfloat16(float("-inf")) + bfloat16(-2.25)))80 self.assertTrue(math.isnan(float(bfloat16(3.5) + bfloat16(float("nan")))))81 def testSub(self):82 self._assertFloatIdentical(0, float(bfloat16(0) - bfloat16(0)))83 self._assertFloatIdentical(1, float(bfloat16(1) - bfloat16(0)))84 self._assertFloatIdentical(2, float(bfloat16(1) - bfloat16(-1)))85 self._assertFloatIdentical(-1.5, float(bfloat16(2) - bfloat16(3.5)))86 self._assertFloatIdentical(5.75, float(bfloat16(3.5) - bfloat16(-2.25)))87 self._assertFloatIdentical(float("-inf"),88 float(bfloat16(-2.25) - bfloat16(float("inf"))))89 self._assertFloatIdentical(float("inf"),90 float(bfloat16(-2.25) - bfloat16(float("-inf"))))91 self.assertTrue(math.isnan(float(bfloat16(3.5) - bfloat16(float("nan")))))92 def testMul(self):93 self._assertFloatIdentical(0, float(bfloat16(0) * bfloat16(0)))94 self._assertFloatIdentical(0, float(bfloat16(1) * bfloat16(0)))95 self._assertFloatIdentical(-1, float(bfloat16(1) * bfloat16(-1)))96 self._assertFloatIdentical(-7.875, float(bfloat16(3.5) * bfloat16(-2.25)))97 self._assertFloatIdentical(float("-inf"),98 float(bfloat16(float("inf")) * bfloat16(-2.25)))99 self._assertFloatIdentical(float("inf"),100 float(bfloat16(float("-inf")) * bfloat16(-2.25)))101 self.assertTrue(math.isnan(float(bfloat16(3.5) * bfloat16(float("nan")))))102 def testDiv(self):103 self.assertTrue(math.isnan(float(bfloat16(0) / bfloat16(0))))104 self._assertFloatIdentical(float("inf"), float(bfloat16(1) / bfloat16(0)))105 self._assertFloatIdentical(-1, float(bfloat16(1) / bfloat16(-1)))106 self._assertFloatIdentical(-1.75, float(bfloat16(3.5) / bfloat16(-2)))107 self._assertFloatIdentical(float("-inf"),108 float(bfloat16(float("inf")) / bfloat16(-2.25)))109 self._assertFloatIdentical(float("inf"),110 float(bfloat16(float("-inf")) / bfloat16(-2.25)))111 self.assertTrue(math.isnan(float(bfloat16(3.5) / bfloat16(float("nan")))))112 def testLess(self):113 for v in self.float_values():114 for w in self.float_values():115 self.assertEqual(v < w, bfloat16(v) < bfloat16(w))116 def testLessEqual(self):117 for v in self.float_values():118 for w in self.float_values():119 self.assertEqual(v <= w, bfloat16(v) <= bfloat16(w))120 def testGreater(self):121 for v in self.float_values():122 for w in self.float_values():123 self.assertEqual(v > w, bfloat16(v) > bfloat16(w))124 def testGreaterEqual(self):125 for v in self.float_values():126 for w in self.float_values():127 self.assertEqual(v >= w, bfloat16(v) >= bfloat16(w))128 def testEqual(self):129 for v in self.float_values():130 for w in self.float_values():131 self.assertEqual(v == w, bfloat16(v) == bfloat16(w))132 def testNotEqual(self):133 for v in self.float_values():134 for w in self.float_values():135 self.assertEqual(v != w, bfloat16(v) != bfloat16(w))136 def testNan(self):137 a = np.isnan(bfloat16(float("nan")))138 self.assertTrue(a)139 np.testing.assert_allclose(np.array([1.0, a]), np.array([1.0, a]))140 a = np.array(141 [bfloat16(1.34375),142 bfloat16(1.4375),143 bfloat16(float("nan"))],144 dtype=dtypes.bfloat16.as_numpy_dtype)145 b = np.array(146 [bfloat16(1.3359375),147 bfloat16(1.4375),148 bfloat16(float("nan"))],149 dtype=dtypes.bfloat16.as_numpy_dtype)150 np.testing.assert_allclose(151 a, b, rtol=0.1, atol=0.1, equal_nan=True, err_msg="", verbose=True)152class Bfloat16NumPyTest(test.TestCase):153 def testDtype(self):154 self.assertEqual(bfloat16, np.dtype(bfloat16))155 def testArray(self):156 x = np.array([[1, 2, 3]], dtype=bfloat16)157 self.assertEqual(bfloat16, x.dtype)158 self.assertEqual("[[bfloat16(1) bfloat16(2) bfloat16(3)]]", str(x))159 self.assertAllEqual(x, x)160 self.assertAllClose(x, x)161 self.assertTrue((x == x).all())162 def testComparisons(self):...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { float } = require('fast-check');2const fc = require('fast-check');3const arb = float({min: 0, max: 1, next: true});4fc.assert(5 fc.property(arb, (n) => {6 return n >= 0 && n <= 1;7 })8);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { float } = require('fast-check');3const { floatNext } = require('fast-check');4fc.assert(5 fc.property(float(), (a) => {6 return a >= 0 && a <= 1;7 })8);9fc.assert(10 fc.property(floatNext(), (a) => {11 return a >= 0 && a <= 1;12 })13);14const fc = require('fast-check');15const { float } = require('fast-check');16const { floatNext } = require('fast-check');17fc.assert(18 fc.property(float(), (a) => {19 return a >= 0 && a <= 1;20 })21);22fc.assert(23 fc.property(floatNext(), (a) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { float } = require('fast-check');2const randomFloat = float();3console.log(randomFloat);4const randomFloat2 = float({max: 10});5console.log(randomFloat2);6const randomFloat3 = float({max: 10, next: true});7console.log(randomFloat3);8const randomFloat4 = float({max: 10, next: true});9console.log(randomFloat4);10const randomFloat5 = float({min: 10, max: 20});11console.log(randomFloat5);12const randomFloat6 = float({min: 10, max: 20, next: true});13console.log(randomFloat6);14const randomFloat7 = float({min: 10, max: 20, next: true});15console.log(randomFloat7);16const randomFloat8 = float({min: 10, max: 20, next: true});17console.log(randomFloat8);18const randomFloat9 = float({min: 10, max: 20, next: true});19console.log(randomFloat9);20const randomFloat10 = float({min: 10, max: 20, next: true});21console.log(randomFloat10);22const randomFloat11 = float({min: 10, max: 20, next: true});23console.log(randomFloat11);24const randomFloat12 = float({min: 10, max: 20, next: true});25console.log(randomFloat12);26const randomFloat13 = float({min: 10, max: 20, next: true});27console.log(randomFloat13);28const randomFloat14 = float({min

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {float} = require('fast-check-monorepo');3const a = float(0, 1, 2);4const b = float(0, 1, 2);5const c = float(0, 1, 2);6const d = float(0, 1, 2);7const e = float(0, 1, 2);8fc.assert(9 fc.property(a, b, c, d, e, (a, b, c, d, e) => {10 return a <= 1 && a >= 0;11 })12);13const fc = require('fast-check');14const {float} = require('fast-check-monorepo');15const a = float(0, 1, 2);16const b = float(0, 1, 2);17const c = float(0, 1, 2);18const d = float(0, 1, 2);19const e = float(0, 1, 2);20fc.assert(21 fc.property(a, b, c, d, e, (a, b, c, d, e) => {22 return a <= 1 && a >= 0;23 })24);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { float } = require('fast-check');2const randomFloat = float();3console.log(randomFloat);4const randomFloat2 = float({max: 10});5console.log(randomFloat2);6const randomFloat3 = float({max: 10, next: true});7console.log(randomFloat3);8const randomFloat4 = float({max: 10, next: true});9console.log(randomFloat4);10const randomFloat5 = float({min: 10, max: 20});11console.log(randomFloat5);12const randomFloat6 = float({min: 10, max: 20, next: true});13console.log(randomFloat6);14const randomFloat7 = float({min: 10, max: 20, next: true});15console.log(randomFloat7);16const randomFloat8 = float({min: 10, max: 20, next: true});17console.log(randomFloat8);18const randomFloat9 = float({min: 10, max: 20, next: true});19console.log(randomFloat9);20const randomFloat10 = float({min: 10, max: 20, next: true});21console.log(randomFloat10);22const randomFloat11 = float({min: 10, max: 20, next: true});23console.log(randomFloat11);24const randomFloat12 = float({min: 10, max: 20, next: true});25console.log(randomFloat12);26const randomFloat13 = float({min: 10, max: 20, next: true});27console.log(randomFloat13);28const randomFloat14 = float({min

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {float} = require('fast-check-monorepo');3const a = float(0, 1, 2);4const b = float(0, 1, 2);5const c = float(0, 1, 2);6const d = float(0, 1, 2);7const e = float(0, 1, 2);8fc.assert(9 fc.property(a, b, c, d, e, (a, b, c, d, e) => {10 return a <= 1 && a >= 0;11 })12);13const fc = require('fast-check');14const {float} = require('fast-check-monorepo');15const a = float(0, 1, 2);16const b = float(0, 1, 2);17const c = float(0, 1, 2);18const d = float(0, 1, 2);19const e = float(0, 1, 2);20fc.assert(21 fc.property(a, b, c, d, e, (a, b, c, d, e) => {22 return a <= 1 && a >= 0;23 })24);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful