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

Better error message when initializing with invisible columns #634

Merged
merged 9 commits into from
Mar 2, 2022

Conversation

danielhuppmann
Copy link
Member

@danielhuppmann danielhuppmann commented Mar 1, 2022

Please confirm that this PR has done the following:

  • Tests Added
  • Documentation Added
  • Name of contributors Added to AUTHORS.rst
  • Description in RELEASE_NOTES.md Added

Description of PR

Per a user support request for the Scenario Explorer upload, we noticed that an xlsx file which has an "invisible" column (e.g., a whitespace in a column to the right of the data) raises a generic

ValueError: IamDataFrame constructor not properly called!

This is not really helpful to users.

This PR restructures the try-except such that a user will receive a more intelligible error message including the column name:

ValueError: Empty cells in `data` (columns: 'unnamed: 7'):
...

@danielhuppmann danielhuppmann self-assigned this Mar 1, 2022
@danielhuppmann danielhuppmann changed the title Io/na column Better error message when initializing with invisible columns Mar 1, 2022
@codecov
Copy link

codecov bot commented Mar 1, 2022

Codecov Report

Merging #634 (d5e95e1) into main (38897ff) will increase coverage by 0.0%.
The diff coverage is 95.4%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #634   +/-   ##
=====================================
  Coverage   94.6%   94.6%           
=====================================
  Files         57      57           
  Lines       5651    5658    +7     
=====================================
+ Hits        5347    5355    +8     
+ Misses       304     303    -1     
Impacted Files Coverage Δ
pyam/utils.py 91.2% <85.7%> (+0.4%) ⬆️
pyam/core.py 94.9% <100.0%> (-0.1%) ⬇️
tests/test_io.py 100.0% <100.0%> (ø)

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 38897ff...d5e95e1. Read the comment docs.

@phackstock
Copy link
Contributor

Since this is a draft PR, should I review this or is it not ready yet?

@danielhuppmann danielhuppmann marked this pull request as ready for review March 1, 2022 09:01
Copy link
Contributor

@phackstock phackstock left a comment

Choose a reason for hiding this comment

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

Looks good overall.
A few small comments below.

pyam/core.py Outdated Show resolved Hide resolved
pyam/utils.py Show resolved Hide resolved
pyam/utils.py Show resolved Hide resolved
pyam/utils.py Show resolved Hide resolved
Copy link
Contributor

@phackstock phackstock left a comment

Choose a reason for hiding this comment

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

Looks good to me.
One small stylistic comment below.

pyam/core.py Outdated Show resolved Hide resolved
Co-authored-by: Philip Hackstock <p.hackstock@gmx.at>
@danielhuppmann danielhuppmann merged commit 7826d18 into IAMconsortium:main Mar 2, 2022
@danielhuppmann danielhuppmann deleted the io/na-column branch March 2, 2022 09:59
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.

2 participants