Skip to content

Commit

Permalink
Switch to a pyproject.toml (#163)
Browse files Browse the repository at this point in the history
* initial tomlification attempt

* fix completeness

* fix completeness for real

* use correct length

* update buiild workflow

* fix dynamic versioning

---------

Co-authored-by: Kevin Dalton <[email protected]>
  • Loading branch information
kmdalton and kmdalton authored Aug 13, 2024
1 parent 98d51f8 commit 844708d
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install .[dev]
- name: Test with pytest
run: |
python setup.py test
pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install packaging setuptools twine wheel
python -m pip install --upgrade pip build
python -m pip install packaging setuptools twine wheel
- name: Publish the Python package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
20 changes: 12 additions & 8 deletions careless/stats/completeness.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,30 @@ def __init__(self):
def run_analysis(args):
ds = rs.read_mtz(args.mtz)
results = rs.stats.compute_completeness(ds, bins=args.bins)
results = results['completeness']

if args.output is not None:
results.to_csv(args.output)
else:
print(results.to_string())

#Move overall to the beginning
results = results.iloc[np.roll(np.arange(len(results)), 1)]
results = results.reset_index()
xlabel = 'Resolution Range (Å)'
results = results.rename(columns={'index' : xlabel})

if args.output is not None:
results.to_csv(args.output, index=False)
else:
print(results.to_string(index=False))

ax = sns.lineplot(
data=results.reset_index().melt('index'),
x='index',
data=results.reset_index().melt(xlabel),
x=xlabel,
y='value',
hue='variable_1',
hue='variable',
palette='Dark2',
)
plt.xticks(rotation=45, rotation_mode='anchor', ha='right')
plt.legend(title="")
plt.ylabel(r"Completeness")
plt.xlabel("Resolution ($\mathrm{\AA}$)")
plt.grid(which='both', axis='both', ls='dashdot')
plt.tight_layout()

Expand Down
57 changes: 57 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "careless"
authors=[
{name="Kevin M. Dalton", email="[email protected]"}
]
description = "Merging crystallography data without much physics."
readme = "README.md"
dynamic = ["version"]
requires-python = ">= 3.9,<3.12"
dependencies = [
"reciprocalspaceship>=0.9.16",
"tqdm",
"tensorflow",
"tf_keras",
"tensorflow-probability[tf]",
"matplotlib",
"seaborn",
"ray",
]
optional-dependencies.dev = [
"pytest",
"pytest-cov",
"pytest-xdist",
]
license={text = "MIT"}

[project.urls]
Repository = "https://github.com/rs-station/careless"
Examples = "https://github.com/rs-station/careless-examples"
Issues = "https://github.com/rs-station/careless/issues"

[project.scripts]
careless = "careless.careless:main"
"careless.ccanom" = "careless.stats.ccanom:main"
"careless.cchalf" = "careless.stats.cchalf:main"
"careless.ccpred" = "careless.stats.ccpred:main"
"careless.image_ccpred" = "careless.stats.image_cc:main"
"careless.filter_image" = "careless.stats.filter_by_image_cc:main"
"careless.plot_history" = "careless.stats.history:main"
"careless.bfactor" = "careless.stats.prior_b:main"
"careless.apply_bfactor" = "careless.stats.rescale:main"
"careless.completeness" = "careless.stats.completeness:main"
"careless.rsplit" = "careless.stats.rsplit:main"
"careless.xds2mtz" = "careless.io.xds:main"

[tool.pytest.ini_options]
addopts = "-n auto --cov=careless --cov-config=.coveragerc --cov-report xml"
testpaths = [
"tests",
]

[tool.setuptools.dynamic]
version = {file = "careless/VERSION"}
5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

72 changes: 0 additions & 72 deletions setup.py

This file was deleted.

3 changes: 2 additions & 1 deletion tests/stats/test_completeness.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ def test_completeness(merged_mtz, bins):
assert exists(png)

df = pd.read_csv(csv)
assert len(df) == bins + 2

assert len(df) == bins + 1

0 comments on commit 844708d

Please sign in to comment.