question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: implicit conversion of strings to exponent. (tabulate converting types)

See original GitHub issue

This is a bug is converting strings like this 20200407_2 to exponent values.

>>> print(tabulate.tabulate([ [93, '20200310.2'], [65, '20200407_2'] ]))
--  -----------
93  2.02003e+07
65  2.02004e+08
--  -----------

surprising that float will convert this one at all as it has an underscore in it.

>>> float('20200407_2')
202004072.0

Anyway tabulate should not be converting types at all.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
MikeBusuttilcommented, Dec 27, 2020

@pete312 I was able to fix the issue by invoking the disable_numparse argument: print(tabulate.tabulate([ [93, '20200310.2'], [65, '20200407_2'] ], disable_numparse=True))

0reactions
pete312commented, Feb 22, 2021

@astanin The end point of tabulate is text align and is display only. Auto convert int to str is fine but going back is not consistent in regression. Meaning tabulate will output different results python 3.6 than prior versions of python 3. because python 3.6 allows an int to be defined as 20200407_2 and not before 3.6. However “20200407_2” and 20200407_2 are not equal. Also the output of print(20200407_2) is not the same as string “20200407_2”.

>>> 20200407_2 == "20200407_2"
False
>>> print(20200407_2), print("20200407_2")
202004072
20200407_2
(None, None)

To me this means tabulate is incorrectly converting a previously string type to an int type. Output will differ after 3.6 with this default set to True. It will not break if set to False. Usually regression test failure are considered as bugs. “Undefined behavior” or “Inconsistant Feature”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does implicit conversion from some numeric values work ...
It tries to convert your string to a numeric(3,2) because that's the type on the right of the multiplication 1. If you can...
Read more >
Passing a String Where It Isn't Expected:Exploring the Implicit ...
Looking at a method signature reveals the expected argument types but not what types can be implicitly converted to those expected types.
Read more >
Avoid Implicit Data Conversion in WHERE Clause
A VARCHAR2 or CHAR value can be implicitly converted to NUMBER or DATE type value by Oracle. Similarly, a NUMBER or DATA type...
Read more >
Implicit and Explicit Conversions - Visual Basic - Microsoft Learn
The following table shows the available conversion keywords. Type conversion keyword, Converts an expression to data type, Allowable data types ...
Read more >
Conversion rules | BigQuery - Google Cloud
Literal conversion is evaluated at analysis time, and gives an error if the input literal cannot be converted successfully to the target type....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found