| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
QT tests are failing - not this PR |
Sorry, something went wrong.
There was a problem hiding this comment.
Can you add a test that the error is not being raised when using pandas?
Sorry, something went wrong.
|
100% agree that pandas datetimes + bar should be tested. OTOH, I'm not 100% convinced its matplotlib that should be responsible for those tests if the pandas datetime unit converters are registered, which they are in this case. See #11664 for where I propose we explictly unregister pandas datetime unit conversion so then we can test our own converters (which work with basic pandas objects without the need for their converters). This was prompted by import pandas no longer registering their converters by default. They backed down on that change, but may re-impliment it at some point. Not to say pandas' own converters shouldn't work - but it seems that they should be responsible for reporting breakages to us (like this one). However, I'm open to the idea we should fully test pandas if that is how it should be done. For this particular case, I'm pretty ignorant about how the user got to the point where bar worked at all (#13186), so I'm hesitant to add to the tests. But if someone knoweledgeable of pandas wanted to add or propose a test, I'm more than happy for that to go in... |
Sorry, something went wrong.
|
Have we reported the breakage to pandas? If that is the case, we may want to simply add a test and a comment that this should be fixed in pandas version XXX, and remove the work around and and the test when times come. |
Sorry, something went wrong.
|
Hmm, looking at it again, I guess pandas thinks its a ValueError because self.freq is None. In any case, not convinced this needs a test from our end, but the change should go in to make the except clause here as liberal as possible. In fact I'd argue its should be a bare except - if adding convert(x+dx) fails for any reason give us the old behaviour of just calling convert(dx) |
Sorry, something went wrong.
|
... ah apparently except Exception is the way to do this cleanly without a dangerous bare exception. Hopefully that is deemed OK by folks... |
Sorry, something went wrong.
| if delist: | ||
| dx = dx[0] | ||
| except (TypeError, AttributeError) as e: | ||
| except Exception: |
There was a problem hiding this comment.
please leave a comment justifying (briefly) the nonspecific catch-everything behavior.
Sorry, something went wrong.
There was a problem hiding this comment.
Doesn't that catch everything?
Sorry, something went wrong.
There was a problem hiding this comment.
In principle I'm ok with except Exception:, but for targetted code. That's a pretty big try block to be catching with Exception--a lot of unexpected behavior could happen in those lines. Is it possible to just wrap the try around dx = [convert(x0 + ddx) - x for ddx in dx]?
Sorry, something went wrong.
FIX: make exception in bar for convert(x+dx) more liberal
|
The current solution catches all exceptions, which we should avoid. It means will accidentally catch errors and exception we don't want to catch. I don't think the proposed solution is reasonable (sorry!) |
Sorry, something went wrong.
|
(I need to run, but I'll review this more carefully in the next day or so) |
Sorry, something went wrong.
|
@NelleV I'm happy to go back to explicit exception types, but except Exceptions is the pep-8 way to make exception as liberal as possible:
so I thought this would be OK. |
Sorry, something went wrong.
|
@jklymak But making catching exception as liberal as possible is not good practice. It means the code "works", in cases where it should probably fail. It actually happened to me several time with Matplotlib that the plot would show and be wrong due to broad error catching such as this one. I'll dismiss my review, as I am about to board a plane and will be offline for the next 24h, but I think it is better to be as narrow and explicit as possible when catching errors. |
Sorry, something went wrong.
Not available in the near future to review this PR.
|
Tightened exception @dopplershift I can't make the try-except block shorter because the error is sometimes in the procedure that gets the first element. Just to be clear - the idea is "try some stuff to get this to work. If that fails just do what we did before this PR". So having this try/except block makes things a bit better at no cost (other than code complexity). OTOH I don't feel passionately about this solution. If someone has a better solution for bar that would be great. |
Sorry, something went wrong.
|
@jklymak That's fine--but then for a block that big, I agree with @NelleV that we should be as specific as possible in the exceptions caught. IMHO except Exception: is only ok when there's one specific line that you're catching errors from. |
Sorry, something went wrong.
|
@dopplershift sure, but is the new version OK? It has three explicit errors. |
Sorry, something went wrong.
There was a problem hiding this comment.
@jklymak Sorry, new version is fine. Was holding off on review due to failing CI and lack of time to dig in.
Sorry, something went wrong.
|
That PR was missing a test. I'll create a PR to fix this. |
Sorry, something went wrong.
|
Oops. Thanks. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Closes #13186
Follow up to #12903 where we try and do math first for bar (x+dx) before units conversion. Pandas throws a ValueError for a previously working case. This adds that to the allowable excepts...
PR Checklist