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

Ops with scalars and vectors #82

Merged
merged 19 commits into from
Jul 31, 2020
Merged

Ops with scalars and vectors #82

merged 19 commits into from
Jul 31, 2020

Conversation

znicholls
Copy link
Collaborator

@znicholls znicholls commented Jul 30, 2020

Pull request

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Example added (either to an existing notebook or as a new notebook, where applicable)
  • Description in CHANGELOG.rst added

Adding to CHANGELOG.rst

Please add a single line in the changelog notes similar to one of the following:

- (`#XX <https://github.com/openscm/scmdata/pull/XX>`_) Added feature which does something
- (`#XX <https://github.com/openscm/scmdata/pull/XX>`_) Fixed bug identified in (`#YY <https://github.com/openscm/scmdata/issues/YY>`_)

@znicholls
Copy link
Collaborator Author

@lewisjared making this work with pint will require some thinking so let's release 0.6.2 without it and add later

@codecov
Copy link

codecov bot commented Jul 30, 2020

Codecov Report

Merging #82 into master will increase coverage by 0.17%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #82      +/-   ##
==========================================
+ Coverage   94.72%   94.89%   +0.17%     
==========================================
  Files          15       15              
  Lines        1648     1665      +17     
  Branches      362      366       +4     
==========================================
+ Hits         1561     1580      +19     
+ Misses         59       58       -1     
+ Partials       28       27       -1     
Impacted Files Coverage Δ
src/scmdata/run.py 93.43% <100.00%> (+0.45%) ⬆️
src/scmdata/timeseries.py 90.42% <100.00%> (+1.26%) ⬆️

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 b9d03f6...f63bc0b. Read the comment docs.

@znicholls znicholls marked this pull request as ready for review July 30, 2020 06:46
@znicholls
Copy link
Collaborator Author

Alright @lewisjared turns out this was easier than I thought. Can you take a look? Not sure how to better document the Pint support...?

@znicholls
Copy link
Collaborator Author

Also it turns out xarray has a bit of unit support already (e.g. pydata/xarray#3643) so we should be able to switch Timeseries across at some point in future without too many headaches.

@znicholls
Copy link
Collaborator Author

Other question, do the errors which come from using wrong shape data for ops make sense?

Copy link
Collaborator

@lewisjared lewisjared left a comment

Choose a reason for hiding this comment

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

Brilliant!

Is it simple to add pow? I guess that is a different case as only a unitless scalar make sense. x ^ 2 [GtC / a] doesn't really make sense??

tests/unit/test_ops.py Show resolved Hide resolved
tests/unit/test_ops.py Show resolved Hide resolved
tests/unit/test_timeseries.py Outdated Show resolved Hide resolved
@znicholls
Copy link
Collaborator Author

Is it simple to add pow?

I don't know. I don't think it will be as simple because it should be dimensionless as you say. One for another PR/new issue?

@lewisjared
Copy link
Collaborator

Other question, do the errors which come from using wrong shape data for ops make sense?

Maybe not. I don't think that the ops follow broadcasting rules. The case where other.shape == (1, 3) doesn't work (with the length check removed) so maybe the message about broadcasting is a lie. Perhaps the length check should be testing for identical shapes? Technically I think a array of shape (n_times) works, but it might be simpler to only support scalars or identically shaped 2d arrays?

@znicholls
Copy link
Collaborator Author

Technically I think a array of shape (n_times) works, but it might be simpler to only support scalars or identically shaped 2d arrays?

I think so too

@lewisjared lewisjared added this to the v0.6.2 milestone Jul 30, 2020
@znicholls znicholls changed the title Add test of ops with scalars Ops with scalars and vectors Jul 31, 2020
@znicholls znicholls marked this pull request as draft July 31, 2020 00:36
@znicholls
Copy link
Collaborator Author

@lewisjared this should be good to go, outstanding issues:

  • remaining threads
  • docs (do you want anything more?)

@znicholls znicholls marked this pull request as ready for review July 31, 2020 01:22
@znicholls znicholls mentioned this pull request Jul 31, 2020
5 tasks
@znicholls znicholls added the enhancement New feature or request label Jul 31, 2020
@lewisjared
Copy link
Collaborator

I think the docs could be tricky so that's a future us problem

@lewisjared lewisjared merged commit 048acd7 into master Jul 31, 2020
@znicholls znicholls deleted the ops-with-scalars branch July 31, 2020 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants