diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index aa744303f6..78da096c11 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -113,8 +113,8 @@ jobs: steps: - name: Setup Pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v4 - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v3 diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 187391b1a3..795f34bf72 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -132,13 +132,13 @@ jobs: if: >- (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'scikit-hep/pyhf') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true' && github.repository == 'scikit-hep/pyhf') - uses: pypa/gh-action-pypi-publish@v1.8.10 + uses: pypa/gh-action-pypi-publish@v1.8.11 with: repository-url: https://test.pypi.org/legacy/ print-hash: true - name: Publish distribution 📦 to PyPI if: github.event_name == 'release' && github.event.action == 'published' && github.repository == 'scikit-hep/pyhf' - uses: pypa/gh-action-pypi-publish@v1.8.10 + uses: pypa/gh-action-pypi-publish@v1.8.11 with: print-hash: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae20e15066..a5bea1a3c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: args: ["--fix", "--show-fixes"] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black-jupyter types_or: [python, pyi, jupyter] @@ -50,10 +50,10 @@ repos: rev: 1.16.0 hooks: - id: blacken-docs - additional_dependencies: [black==23.10.1] + additional_dependencies: [black==23.11.0] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6.1 + rev: v1.7.1 # check the oldest and newest supported Pythons hooks: - &mypy diff --git a/docs/contributors.rst b/docs/contributors.rst index c2d0b0a698..d29fd0974b 100644 --- a/docs/contributors.rst +++ b/docs/contributors.rst @@ -33,3 +33,4 @@ Contributors include: - Beojan Stanislaus - Daniel Werner - Jonas Rembser +- Lorenz Gaertner diff --git a/src/pyhf/workspace.py b/src/pyhf/workspace.py index 00abcf77f4..7ce0bc486d 100644 --- a/src/pyhf/workspace.py +++ b/src/pyhf/workspace.py @@ -706,7 +706,9 @@ def rename(self, modifiers=None, samples=None, channels=None, measurements=None) ) @classmethod - def combine(cls, left, right, join='none', merge_channels=False): + def combine( + cls, left, right, join='none', merge_channels=False, validate: bool = True + ): """ Return a new workspace specification that is the combination of the two workspaces. @@ -733,6 +735,7 @@ def combine(cls, left, right, join='none', merge_channels=False): right (~pyhf.workspace.Workspace): Another workspace join (:obj:`str`): How to join the two workspaces. Pick from "none", "outer", "left outer", or "right outer". merge_channels (:obj:`bool`): Whether or not to merge channels when performing the combine. This is only done with "outer", "left outer", and "right outer" options. + validate (:obj:`bool`): Whether to validate against a JSON schema. Returns: ~pyhf.workspace.Workspace: A new combined workspace object @@ -770,7 +773,7 @@ def combine(cls, left, right, join='none', merge_channels=False): 'observations': new_observations, 'version': new_version, } - return cls(newspec) + return cls(newspec, validate=validate) @classmethod def sorted(cls, workspace): diff --git a/tests/test_workspace.py b/tests/test_workspace.py index 55ee0df046..e966d6c3f1 100644 --- a/tests/test_workspace.py +++ b/tests/test_workspace.py @@ -791,6 +791,28 @@ def test_combine_workspace(workspace_factory, join): ) +@pytest.mark.parametrize("join", pyhf.Workspace.valid_joins) +def test_combine_workspace_without_validation(mocker, workspace_factory, join): + ws = workspace_factory() + new_ws = ws.rename( + channels={channel: f"renamed_{channel}" for channel in ws.channels}, + samples={sample: f"renamed_{sample}" for sample in ws.samples}, + modifiers={ + modifier: f"renamed_{modifier}" + for modifier, _ in ws.modifiers + if modifier != "lumi" + }, + measurements={ + measurement: f"renamed_{measurement}" + for measurement in ws.measurement_names + }, + ) + + mocker.patch("pyhf.schema.validate") + pyhf.Workspace.combine(ws, new_ws, join=join, validate=False) + assert pyhf.schema.validate.called is False + + def test_workspace_equality(workspace_factory): ws = workspace_factory() ws_other = workspace_factory()