-
Notifications
You must be signed in to change notification settings - Fork 85
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
revert: Allow 0-dimensional shape tensors #972
Conversation
a89b2a7
to
0434d7a
Compare
@kratsg @lukasheinrich Still a few things to iron out, but feedback now is welcome. |
0d2869a
to
c3b4f34
Compare
The |
952dbd0
to
1d6c9c7
Compare
This is missing tests for the |
Codecov Report
@@ Coverage Diff @@
## master #972 +/- ##
==========================================
- Coverage 96.65% 96.63% -0.02%
==========================================
Files 59 59
Lines 3284 3265 -19
Branches 447 447
==========================================
- Hits 3174 3155 -19
Misses 69 69
Partials 41 41
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This still has an annoying doctest issue, which is actually a problem, but I'll go ahead and let people start to review as this is mostly done. |
Fixing the dotctest error with diff --git a/src/pyhf/optimize/opt_scipy.py b/src/pyhf/optimize/opt_scipy.py
index 408754f6..eb551bbf 100644
--- a/src/pyhf/optimize/opt_scipy.py
+++ b/src/pyhf/optimize/opt_scipy.py
@@ -28,7 +28,7 @@ class scipy_optimizer(object):
Returns:
bestfit parameters
-
+
"""
fixed_vals = fixed_vals or []
indices = [i for i, _ in fixed_vals]
@@ -49,5 +49,5 @@ class scipy_optimizer(object):
log.error(result)
raise
if return_fitted_val:
- return result.x, result.fun
+ return result.x, result.fun[0]
return result.x then causes |
|
No, if you give # On this branch
>>> import pyhf
>>> pyhf.set_backend("numpy")
>>> pyhf.tensorlib.clip(pyhf.tensorlib.astensor(1.), 0, max_value=None)
1.0
>>> pyhf.tensorlib.clip(1., 0, max_value=None)
1.0 |
The
that the CI is showing right now seems to be some form of Issue #964 as if I apply the following digg diff --git a/tests/test_infer.py b/tests/test_infer.py
index 08953981..1cb16ae4 100644
--- a/tests/test_infer.py
+++ b/tests/test_infer.py
@@ -144,11 +144,12 @@ def test_inferapi_pyhf_independence():
return tensorlib.astensor([main + constraint])
model = NonPyhfModel([5, 50, 7])
- cls = pyhf.infer.hypotest(
- 1.0, model.expected_data(model.config.suggested_init()), model
- )
+ data = pyhf.tensorlib.astensor(model.expected_data(model.config.suggested_init()))
+ data = 1.05 * data
+ cls = pyhf.infer.hypotest(1.0, data, model)
+ print(cls)
- assert np.isclose(cls[0], 0.7267836451638846)
+ # assert np.isclose(cls[0], 0.7267836451638846) the In Issue #964 @kratsg mentions that PR #951 should fix this sort of problem. I still need to review the PR, but can you also elaborate on how the PR achieves this? |
I have things almost passing if I rebase this (in another branch) off of PR #951, so I'm going to put this back into draft mode and then we can come back to this after we've finished the other PR. |
As many other manipulations eventually call torch.Tensor.view just skip steps and call it directly c.f. https://pytorch.org/docs/stable/tensors.html#torch.Tensor.view
019f2c7
to
385a6f8
Compare
I've queued this up. When it gets merged, I'll create a minor release from v0.4.4 → v0.5.0 which includes the following 24 change(s) [including this PR]: If you make any more changes, you probably want to re-trigger me again by removing the bumpversion/minor label and then adding it back again.
|
Triggered by #972 via GitHub Actions.
Description
Resolves #954
This PR allows for tensors to take any shape, even empty
()
shapes. This effectively reverts PR #413. It also enforces that the optimizers return the objective function as a scalar (shape()
), resulting in the test statistic being a scalar.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: