-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Python tests and their coverage
- Loading branch information
1 parent
b41d304
commit a46a9fb
Showing
8 changed files
with
254 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,57 @@ | ||
import pytest | ||
import subprocess | ||
|
||
|
||
class PDF: | ||
def xfxQ(self, pid, x, q): | ||
return self.xfxQ2(pid, x, q**2) | ||
|
||
def xfxQ2(self, pid, x, q2): | ||
if pid in range(-6, 6): | ||
return x * (1 - x) | ||
else: | ||
return 0.0 | ||
|
||
def xfxQ(self, pid, x, q): | ||
return self.xfxQ2(pid, x, q**2) | ||
|
||
def alphasQ(self, q): | ||
return 1.0 | ||
|
||
# Define the Toy Polarized PDF set | ||
def polarized_pdf(self, pid, x, q2): | ||
return 2.0 | ||
|
||
# Define the Toy Unpolarized PDF set | ||
def unpolarized_pdf(self, pid, x, q2): | ||
return 1.0 | ||
|
||
|
||
@pytest.fixture | ||
def pdf(): | ||
return PDF() | ||
|
||
|
||
@pytest.fixture | ||
def download_objects(tmp_path_factory): | ||
def _download_fk(objname: str) -> None: | ||
download_dir = tmp_path_factory.mktemp("data") | ||
file_path = download_dir / f"{objname}" | ||
args = [ | ||
"wget", | ||
"--no-verbose", | ||
"--no-clobber", | ||
"-P", | ||
f"{download_dir}", | ||
f"https://data.nnpdf.science/pineappl/test-data/{objname}", | ||
] | ||
|
||
try: | ||
_ = subprocess.run( | ||
args, | ||
stdout=subprocess.DEVNULL, | ||
stderr=subprocess.DEVNULL, | ||
) | ||
return file_path | ||
except OSError as error: | ||
msg = f"Failed to execute the command {args}." | ||
raise EnvironmentError(msg) from error | ||
|
||
return _download_fk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.