| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -4,6 +4,8 @@ | |
|
|
||
| import datetime | ||
| import logging | ||
| import numbers | ||
| import warnings | ||
|
|
||
| import numpy as np | ||
|
|
||
| Expand Down Expand Up | @@ -1477,9 +1479,14 @@ def have_units(self): | |
| return self.converter is not None or self.units is not None | ||
|
|
||
| def convert_units(self, x): | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis seems to be converting anything numlike, which includes things like pint.Quantity, into an array/masked array before calling convert. That seems like it would break pint, though I will note that our unit tests seem to be passing.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGreat, I’ll check vs pint when I look at the other comments above. Thanks for the reminder...
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOk, I guess I still don't understand how all of this works. 😉 So is_numlike only returns true for things that are basic numbers (or contain them) and don't need converting. I think I'm ok with this code then. Tests passing is always a good thing too. 😄
Sorry, something went wrong.
All reactions
|
||
| # If x is already a number, doesn't need converting | ||
| # If x is already a number, doesn't need converting, but | ||
| # some iterables need to be massaged a bit... | ||
| if munits.ConversionInterface.is_numlike(x): | ||
| return x | ||
| if isinstance(x, list) or isinstance(x, numbers.Number): | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat is the rationale for returning a list as-is instead of running it through np.asarray? Just that the latter is unnecessary? Or are there cases where the conversion would be an error?
Sorry, something went wrong.
All reactions
|
||
| return x | ||
| if issubclass(type(x), np.ma.MaskedArray): | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy is this using issubclass(type(x)... instead of isinstance?
Sorry, something went wrong.
All reactions
|
||
| return np.ma.asarray(x) | ||
| return np.asarray(x) | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIs the point of this whole addition above to short-circuit some of what would otherwise happen in get_converter? I'm not opposed, just confused.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityit seems worse, because calling np.asarray can drop information in some cases, making it unavailable in the call to convert below. Unless I'm missing something...
Sorry, something went wrong.
All reactions
|
||
|
|
||
| if self.converter is None: | ||
| self.converter = munits.registry.get_converter(x) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -419,6 +419,11 @@ def date2num(d): | |
| return _dt64_to_ordinalf(d) | ||
| if not d.size: | ||
| return d | ||
| if hasattr(d, 'dtype'): | ||
| if ((isinstance(d, np.ndarray) and | ||
| np.issubdtype(d.dtype, np.datetime64)) or | ||
| isinstance(d, np.datetime64)): | ||
| return _dt64_to_ordinalf(d) | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat case is this whole block covering? Again, I'm confused.
Sorry, something went wrong.
All reactions
|
||
| return _to_ordinalf_np_vectorized(d) | ||
|
|
||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -616,6 +616,16 @@ def tz_convert(*args): | |
| _test_date2num_dst(pd.date_range, tz_convert) | ||
|
|
||
|
|
||
| def test_dateboxplot_pandas(pd): | ||
| # smoke test that this doesn't fail. | ||
| data = np.random.rand(5, 2) | ||
| years = pd.date_range('1/1/2000', | ||
| periods=2, freq=pd.DateOffset(years=1)).year | ||
| # Does not work | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAnother place I am confused. Is the comment obsolete?
Sorry, something went wrong.
All reactions
|
||
| plt.figure() | ||
| plt.boxplot(data, positions=years) | ||
|
|
||
|
|
||
| def _test_rrulewrapper(attach_tz, get_tz): | ||
| SYD = get_tz('Australia/Sydney') | ||
|
|
||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI don't see any point in removing the "copy=False" kwarg. It saves time, and it is logically what is wanted here. A copy was already made via the column_stack call, so nothing done to coords will affect X or Y.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNot sure. Changed back
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.