|
3 | 3 | wrong_big = 45.3e6 # [use-standard-scientific-notation]
|
4 | 4 | uppercase_e_wrong = 45.3E6 # [use-standard-scientific-notation]
|
5 | 5 | wrong_small = 0.00012e-26 # [use-standard-scientific-notation]
|
| 6 | +uppercase_e_wrong_small = 0.00012E-26 # [use-standard-scientific-notation] |
6 | 7 | wrong_negative_and_big = -10e3 # [use-standard-scientific-notation]
|
7 | 8 | actual_trolling = 11000e26 # [use-standard-scientific-notation]
|
8 | 9 | scientific_double_digit = 12e8 # [use-standard-scientific-notation]
|
|
25 | 26 | correct_decimal_only = 3.14
|
26 | 27 | negative_correct = -5.67e-8
|
27 | 28 | correct_small_exponent = 1.5e1
|
28 |
| -correct_tiny_exponent = 9.0e0 |
29 |
| -correct_precise = 6.02214076e23 |
| 29 | +actually_nine = 9e0 |
| 30 | +actually_one = 1.0e0 |
| 31 | + |
30 | 32 |
|
31 | 33 | hex_constant = 0x1e4 # Hexadecimal, not scientific notation
|
| 34 | +hex_constant_bad = 0x10e4 |
32 | 35 | binary_constant = 0b1010
|
33 | 36 | octal_constant = 0o1234
|
34 | 37 | inside_string = "Temperature: 10e3 degrees"
|
|
39 | 42 | in_variable_name = measurement_10e3 = 45
|
40 | 43 | inside_f_string = f"Value is {1.0} not 10e6"
|
41 | 44 |
|
42 |
| -# Potential false negatives |
43 |
| -barely_violation = 9.99e0 # Should this be 9.99? |
44 |
| -integer_sci = int(1e10) # Integer call with scientific notation |
45 | 45 | complex_number = 1.5e3 + 2.5e3j # Complex number with scientific notation
|
46 |
| -tuple_of_sci = (1.2e4, 3.4e5) |
47 |
| -list_of_sci = [5.6e6, 7.8e7] |
48 |
| -dict_with_sci = {"a": 9.1e8, "b": 1.2e9} |
| 46 | +# false negative for complex numbers: |
| 47 | +complex_number_wrong = 15e3 + 25e3j # [use-standard-scientific-notation] |
49 | 48 |
|
50 |
| -# Mathematical operations |
51 |
| -addition = 1.0e3 + 2.0e3 |
52 |
| -multiplication = 1.0e3 * 2.0 |
53 |
| -division = 1.0e3 / 2.0 |
54 |
| -power = 1.0e3 ** 2.0 |
55 | 49 |
|
56 |
| -# Function calls with scientific notation |
57 |
| -def function_with_sci(param=1.0e3, other_param=2.0e3): |
| 50 | +#+1: [use-standard-scientific-notation, use-standard-scientific-notation] |
| 51 | +def function_with_sci(param=10.0e3, other_param=20.0e3): |
58 | 52 | return param, other_param
|
59 | 53 |
|
60 |
| -result = function_with_sci(2.0e3) |
61 |
| -positional_and_keyword = function_with_sci(1.0, other_param=3.0e4) |
| 54 | +#+1: [use-standard-scientific-notation, use-standard-scientific-notation] |
| 55 | +result = function_with_sci(20.0e3, 10.0e3) |
| 56 | + |
| 57 | +valid_underscore_int = 1_000_000 |
| 58 | +valid_underscore_float = 1_000_000.12345 |
| 59 | +valid_underscore_float_exp = 123_000_000.12345e12_000_000 # [use-standard-scientific-notation] |
| 60 | +valid_underscore_float_exp_cap = 123_000_000.12345E123_000_000 # [use-standard-scientific-notation] |
62 | 61 |
|
63 |
| -# Assignments with operations |
64 |
| -a = 1 |
65 |
| -a += 1.0e3 |
66 |
| -b = 2 |
67 |
| -b *= 2.0e3 |
| 62 | +invalid_underscore_octal = 0o123_456 # octal with underscores bypassed |
| 63 | +invalid_underscore_hexa = 0x12c_456 # hexa with underscores bypassed |
68 | 64 |
|
69 |
| -# Scientific notation in different contexts |
70 |
| -inside_list_comp = [x * 2 for x in [1.0e3, 2.0e3]] |
71 |
| -inside_dict_comp = {str(x): x for x in [3.0e3, 4.0e3]} |
72 |
| -inside_generator = (x + 1 for x in [5.0e3, 6.0e3]) |
| 65 | +invalid_underscore_float_no_int = .123_456 # [esoteric-underscore-grouping] |
| 66 | +invalid_underscore_float_no_frac = 123_456.123_456 # [esoteric-underscore-grouping] |
| 67 | +incorrect_sci_underscore = 1.234_567e6 # [esoteric-underscore-grouping] |
| 68 | +incorrect_sci_uppercase = 1.234_567E6 # [esoteric-underscore-grouping] |
| 69 | +incorrect_sci_underscore_exp = 1.2e1_0 # [esoteric-underscore-grouping] |
| 70 | +invalid_underscore_float = 1_234.567_89 # [esoteric-underscore-grouping] |
| 71 | +invalid_underscore_binary = 0b1010_1010 # [esoteric-underscore-grouping] |
| 72 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 73 | +wrong_big_underscore = 45.3_45e6 |
| 74 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 75 | +wrong_small_underscore = 0.000_12e-26 |
| 76 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 77 | +scientific_double_digit_underscore = 1_2e8 |
| 78 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 79 | +scientific_triple_digit_underscore = 12_3e3 |
| 80 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 81 | +invalid_underscore_sci = 1_234.567_89e10 |
| 82 | +invalid_underscore_sci_exp = 1.2e1_0 # [esoteric-underscore-grouping] |
| 83 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 84 | +invalid_underscore_sci_combined = 1_2.3_4e5_6 |
| 85 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 86 | +invalid_uppercase_sci = 1_234.567_89E10 |
| 87 | +edge_underscore_1 = 1_0e6 # [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 88 | +mixed_underscore_1 = 1_000_000.0e-3 # [use-standard-scientific-notation] |
| 89 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 90 | +mixed_underscore_2 = 0.000_001e3 |
| 91 | +mixed_underscore_3 = 1_0.0e2 # [use-standard-scientific-notation, esoteric-underscore-grouping] |
73 | 92 |
|
74 |
| -# Boundary cases for normalization |
75 |
| -boundary_small = 9.999e0 # Almost 10, but not quite |
76 |
| -boundary_large = 1.001e0 # Just above 1 |
77 |
| -boundary_case = 1.0e0 # Equal to 1 |
| 93 | +# Complex numbers with underscores |
| 94 | +complex_underscore = 1.5_6e3 + 2.5_6e3j # [esoteric-underscore-grouping] |
| 95 | +#+1: [use-standard-scientific-notation, esoteric-underscore-grouping] |
| 96 | +complex_underscore_wrong = 15_6e2 + 25_6e2j |
78 | 97 |
|
79 |
| -# Constants from physics/science (correctly formatted) |
80 |
| -speed_of_light = 2.99792458e8 # m/s |
81 |
| -planck_constant = 6.62607015e-34 # J⋅s |
82 |
| -electron_charge = 1.602176634e-19 # C |
| 98 | +#+2: [esoteric-underscore-grouping, esoteric-underscore-grouping] |
| 99 | +#+1: [use-standard-scientific-notation, use-standard-scientific-notation] |
| 100 | +def function_with_underscore(param=10.0_0e3, other_param=20.0_0e3): |
| 101 | + return param, other_param |
0 commit comments