Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print both digits of the exponent in scientific notation form for flo… #282

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

citrusvanilla
Copy link

@citrusvanilla citrusvanilla commented May 1, 2021

…at parameters with values >= 10,000 in the ScreenLogger

An extraneous whitespace character in the string formatter for the ScreenLogger is causing the smaller of the two default scientific notation exponent digits in the number formatter for the parameters to be cut off for floats with values of 10,000.0 or more. This only pertains to the current default cell size of 9 and default precision of 4. The issue persists for other combinations of default cell size and default precisions whose difference is not in excess of 5 (one character for decimal, one for 'e', one for '+', and two for exponent).

current behavior:

default_cell_size = 9
default_precision = 4

def format_number(x):
    if isinstance(x, int):
        s = "{x:< {s}}".format(
            x=x,
            s=default_cell_size,
        )
    else:
        s = "{x:< {s}.{p}}".format(
            x=x,
            s=default_cell_size,
            p=default_precision,
        )

    if len(s) > default_cell_size:
        if "." in s:
            return s[:default_cell_size]
        else:
            return s[:default_cell_size - 3] + "..."
    return s

test_vals = [
    123, 123.45, 1234, 1234.5, 12345,
    12345.6789, 123456.78901, 123456789
]

for number in test_vals:
    print(format_number(number))

prints (with a leading white space):

 123     
 123.5   
 1234    
 1.234e+0
 12345   
 1.235e+0
 1.235e+0
 12345...

Dropping the extraneous white space retains both of the exponents digits:

default_cell_size = 9
default_precision = 4

def format_number(x):
    if isinstance(x, int):
        s = "{x:<{s}}".format(
            x=x,
            s=default_cell_size,
        )
    else:
        s = "{x:<{s}.{p}}".format(
            x=x,
            s=default_cell_size,
            p=default_precision,
        )

    if len(s) > default_cell_size:
        if "." in s:
            return s[:default_cell_size]
        else:
            return s[:default_cell_size - 3] + "..."
    return s

test_vals = [
    123, 123.45, 1234, 1234.5, 12345,
    12345.6789, 123456.78901, 123456789
]

for number in test_vals:
    print(format_number(number))

prints:

123      
123.5    
1234     
1.234e+03
12345    
1.235e+04
1.235e+05
123456789

…at parameters with values >= 10,000 in the ScreenLogger
@codecov-commenter
Copy link

codecov-commenter commented May 1, 2021

Codecov Report

Merging #282 (f5cfc60) into master (91441fe) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #282   +/-   ##
=======================================
  Coverage   98.44%   98.44%           
=======================================
  Files           7        7           
  Lines         387      387           
  Branches       39       39           
=======================================
  Hits          381      381           
  Misses          3        3           
  Partials        3        3           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91441fe...f5cfc60. Read the comment docs.

@bwheelz36 bwheelz36 self-requested a review July 29, 2022 15:52
Copy link
Collaborator

@bwheelz36 bwheelz36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@bwheelz36 bwheelz36 merged commit 1aaa255 into bayesian-optimization:master Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants