diff --git a/.github/workflows/delete-old-runs.yml b/.github/workflows/delete-old-runs.yml new file mode 100644 index 00000000..9be19de2 --- /dev/null +++ b/.github/workflows/delete-old-runs.yml @@ -0,0 +1,72 @@ +# This workflow will delete old workflow runs based on the input parameters. +# https://github.com/Mattraks/delete-workflow-runs + +name: Delete old workflow runs + +on: + # Run monthly, at 00:00 on the 1st day of month. + schedule: + - cron: '0 0 1 * *' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + inputs: + days: + description: 'Number of days.' + required: true + default: 30 + minimum_runs: + description: 'The minimum runs to keep for each workflow.' + required: true + default: 6 + delete_workflow_pattern: + description: 'The name or filename of the workflow. if not set then it will target all workflows.' + required: false + delete_workflow_by_state_pattern: + description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually' + required: true + default: "All" + type: choice + options: + - "All" + - active + - deleted + - disabled_inactivity + - disabled_manually + delete_run_by_conclusion_pattern: + description: 'Remove workflow by conclusion: action_required, cancelled, failure, skipped, success' + required: true + default: "All" + type: choice + options: + - "All" + - action_required + - cancelled + - failure + - skipped + - success + dry_run: + description: 'Only log actions, do not perform any delete operations.' + required: false + +jobs: + del-runs: + + runs-on: ubuntu-latest + + permissions: + actions: write + + steps: + - name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: ${{ github.event.inputs.days }} + keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} + delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }} + delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }} + delete_run_by_conclusion_pattern: ${{ github.event.inputs.delete_run_by_conclusion_pattern }} + dry_run: ${{ github.event.inputs.dry_run }} diff --git a/.github/workflows/ossar-analysis.yml b/.github/workflows/ossar-analysis.yml new file mode 100644 index 00000000..00a6662c --- /dev/null +++ b/.github/workflows/ossar-analysis.yml @@ -0,0 +1,39 @@ +# Integrates a collection of open source static analysis tools with GitHub code scanning. +# https://github.com/github/ossar-action + +name: Run security static analysis + +on: + # Runs on pull requests + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + ossar-analysis: + # OSSAR runs on windows-latest. + # ubuntu-latest and macos-latest support coming soon + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + - name: Run open source static analysis tools + uses: github/ossar-action@main + id: ossar + + - name: Upload results to Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ steps.ossar.outputs.sarifFile }} diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 00000000..a19fc230 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,40 @@ +# Builds a Python package and publish it to PyPI when a new tag is created. + +name: Upload release to PyPI + +on: + # Runs on creating a new tag starting with 'v', e.g. 'v1.0.3' + push: + tags: + - 'v*' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + pypi-publish: + + runs-on: ubuntu-latest + + steps: + - name: Check-out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Upgrade package installer for Python + run: pip install --upgrade pip + + - name: Install Python dependencies + run: pip install '.[dev]' + + - name: Create Python package + run: python -m build + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml deleted file mode 100644 index a94aac36..00000000 --- a/.github/workflows/pypi_publish.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This workflow will -# - build distribution package, pure python wheel -# - publish produced distribution package to PyPI -# -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Publish Python Package - -on: - push: - tags: - - 'v*' - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - - name: Install dependencies and build - run: | - pip install -e '.[dev]' - python -m build - - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml deleted file mode 100644 index db64a3b1..00000000 --- a/.github/workflows/python-ci.yml +++ /dev/null @@ -1,102 +0,0 @@ -# This workflow will for a variety of Python versions -# - install the code base -# - lint the code base -# - test the code base -# - upload the test coverage to codecov -# -# It will also -# - build the package -# - check the package -# -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: CI using pip - -# Trigger the workflow on push, pull request and manual trigger -on: [push, pull_request, workflow_call] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - Code_Consistency: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 - - name: Suggestion to fix issues - if: ${{ failure() }} - run: | - echo "::notice::In project root run 'python -m ruff check . --fix' and commit changes to fix issues." - exit 1 - - Code_Testing: - - runs-on: ${{ matrix.os }} - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - strategy: - max-parallel: 4 - matrix: - python-version: ['3.9', '3.10', '3.11'] - os: [macos-latest, ubuntu-latest, windows-latest] - - steps: - - name: Check-out repository - uses: actions/checkout@v4 - - - name: Set up Python environment - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Enable extra repository - shell: bash - run: | - pip config --user set global.extra-index-url https://easyscience.github.io/pypi/ - pip config --user set global.trusted-host easyscience.github.io - - - name: Install dependencies - run: | - pip install -e '.[dev]' - - - name: Test with tox - run: | - pip install tox tox-gh-actions coverage - tox - - # - name: Upload coverage - # uses: codecov/codecov-action@v3 - # with: - # name: Pytest coverage - # env_vars: OS,PYTHON,GITHUB_ACTIONS,GITHUB_ACTION,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_HEAD_REF,GITHUB_RUN_ID,GITHUB_SHA,COVERAGE_FILE - # env: - # OS: ${{ matrix.os }} - # PYTHON: ${{ matrix.python-version }} - - Package_Testing: - # disable this job temporarily - if: false - runs-on: ubuntu-latest - # if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - - name: Enable extra repository - shell: bash - run: | - pip config --user set global.extra-index-url https://easyscience.github.io/pypi/ - pip config --user set global.trusted-host easyscience.github.io - - - name: Install dependencies and build - run: | - pip install -e '.[dev]' - python -m build - - - name: Check Build - run: | - cd ./dist - pytest ../ diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..219909f9 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,18 @@ +# Drafts your next Release notes as pull requests are merged into default branch + +name: Update release draft + +on: + # Runs on pushes targeting the default branch + push: + branches: [master] + +jobs: + update-release-draft: + + runs-on: ubuntu-latest + + steps: + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-and-package.yaml b/.github/workflows/test-and-package.yaml new file mode 100644 index 00000000..695450fa --- /dev/null +++ b/.github/workflows/test-and-package.yaml @@ -0,0 +1,161 @@ +# This workflow will for a variety of Python versions +# - install the code base +# - lint the code base +# - test the code base +# - upload the test coverage to codecov +# +# It will also +# - build the package +# - check the package +# +# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Test code and build package + +# Trigger the workflow on push, pull request and manual trigger +on: [push, pull_request, workflow_call] + +# Allow only one concurrent workflow, skipping runs queued between the run in-progress and latest queued. +# And cancel in-progress runs. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + + # Job 1: Check code consistency + code-consistency: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Check validity of pyproject.toml + run: | + pip install 'validate-pyproject[all]' + validate-pyproject pyproject.toml + + - name: Install Python linter and code formatter and run in the project root + run: | + pip install ruff + ruff check . + + - name: Suggestion to fix linter issues + if: ${{ failure() }} + run: | + echo "In project root run 'ruff check . --fix' and commit changes to fix issues." + exit 1 + + # Job 2: Test code and upload coverage to Codecov + code-testing: + needs: code-consistency # previous job 'code-consistency' need to be finished first + + # current job matrix. if modified, remember to UPDATE the strategy in the next job + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04, windows-2022, macos-13, macos-14] + python-version: ['3.10', '3.11', '3.12'] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade package installer for Python + run: python -m pip install --upgrade pip + + - name: Install Python dependencies + run: pip install '.[dev]' + + - name: Run tests and create coverage report + run: > + pytest tests/ + --cov=./ + --cov-report=xml:coverage/coverage.xml + --junitxml=./coverage/junit.xml + --color=yes + -n auto + + #- name: Upload test results to Codecov + # if: ${{ !cancelled() }} + # uses: codecov/test-results-action@v1 + # with: + # files: ./coverage/junit.xml + # fail_ci_if_error: true # optional (default = false) + # name: Pytest results + # token: ${{ secrets.CODECOV_TOKEN }} + + #- name: Upload coverage report to Codecov + # uses: codecov/codecov-action@v4 + # with: + # files: ./coverage/coverage.xml + # env_vars: OS,PYTHON + # fail_ci_if_error: true # optional (default = false) + # name: Pytest coverage + # token: ${{ secrets.CODECOV_TOKEN }} + # env: + # OS: ${{ matrix.os }} + # PYTHON: ${{ matrix.python-version }} + + - name: Create Python package # dist/*.whl + run: python -m build --wheel --outdir dist + + - name: Upload zipped Python package for next job + uses: actions/upload-artifact@v4 + with: + name: EasyDiffractionLib_py${{ matrix.python-version }}_${{ matrix.os }}_${{ runner.arch }} + path: | + dist/*.whl + tests/ + if-no-files-found: "error" + compression-level: 0 + + # Job 3: Test the package + package-testing: + needs: code-testing # previous job 'code-testing' need to be finished first + + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04, windows-2022, macos-13, macos-14] + python-version: ['3.10', '3.11', '3.12'] + + runs-on: ${{ matrix.os }} + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade package installer for Python + run: python -m pip install --upgrade pip + + - name: Download zipped Python package from previous job + uses: actions/download-artifact@v4 + with: # name or path are taken from the upload step of the previous job + name: EasyDiffractionLib_py${{ matrix.python-version }}_${{ matrix.os }}_${{ runner.arch }} + path: . # directory to extract downloaded zipped artifacts + + - name: Install Python package from previous job + shell: bash + run: pip install dist/*.whl + + - name: Run tests + run: | + pip install pytest pytest-xdist + pytest tests/ -n auto --color=yes diff --git a/.github/workflows/test-ipynb.yml b/.github/workflows/test-ipynb.yml index 84378450..98114fd6 100644 --- a/.github/workflows/test-ipynb.yml +++ b/.github/workflows/test-ipynb.yml @@ -1,22 +1,24 @@ -name: Testing Jupyter Notebooks +# Runs tests on Jupyter notebooks -on: - push: - branches: - - "**" - pull_request: - branches: - - "**" - workflow_dispatch: +name: Test Jupyter notebooks + +# Trigger the workflow on push, pull request and manual trigger +on: [push, pull_request, workflow_call] + +# Allow only one concurrent workflow, skipping runs queued between the run in-progress and latest queued. +# And cancel in-progress runs. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: - test: + test-ipynb: timeout-minutes: 30 strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: [ubuntu-24.04, windows-2022, macos-13, macos-14] python-version: ['3.10', '3.11', '3.12'] runs-on: ${{ matrix.os }} @@ -34,10 +36,14 @@ jobs: shell: bash run: python -m pip install --upgrade pip - - name: Install Python dependences - shell: bash + - name: Install Python dependencies run: pip install '.[dev,charts]' - name: Run tests on Jupyter Notebooks shell: bash - run: pytest --nbmake examples/*ipynb --nbmake-timeout=300 -n=auto + run: > + pytest + --nbmake examples/*ipynb + --nbmake-timeout=300 + --color=yes + -n=auto diff --git a/.github/workflows/verify-pr-labels.yml b/.github/workflows/verify-pr-labels.yml index a66bf9ca..85a31d8e 100644 --- a/.github/workflows/verify-pr-labels.yml +++ b/.github/workflows/verify-pr-labels.yml @@ -1,19 +1,21 @@ -# This action will verify if a pull request has at least one -# label from a set of valid labels before it can be merged. +# Verifies if a pull request has at least one label from a set of valid labels before it can be merged. + +name: Verify pull request labels -name: Verify PR labels on: + # Runs on pull requests to a repository pull_request_target: types: [opened, labeled, unlabeled, synchronize] jobs: - check_pr_labels: + verify-pr-labels: + runs-on: ubuntu-latest - name: Verify that the PR has a valid label + steps: - - name: Verify PR label action + + - name: Verify pull request labels uses: jesusvasquez333/verify-pr-label-action@v1.4.0 - id: verify-pr-label with: github-token: ${{ secrets.GITHUB_TOKEN }} valid-labels: chore, fix, bugfix, bug, enhancement, feature, dependencies, documentation diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 6772351b..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,42 +0,0 @@ -repos: -- repo: https://github.com/psf/black - rev: 22.3.0 # Replace by any tag/version: https://github.com/psf/black/tags - hooks: - - id: black - language_version: python3 # Should be a command that runs python3.6+ - -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 # Use the ref you want to point at - hooks: - - id: trailing-whitespace - - id: check-yaml - - id: check-xml -# - id: requirements-txt-fixer - - id: check-toml - - id: pretty-format-json - - id: detect-private-key -#- repo: local -# hooks: -# - id: export_dev_requirements -# name: Export dev requirements -# language: system -# pass_filenames: false -# entry: peodd -o requirements-dev.txt -# - id: export-requirements -# name: Export requeriments.txt -# language: system -# pass_filenames: false -# entry: poetry export --without-hashes -o requirements.txt -# files: ^(pyproject.toml|poetry.lock)$ -# - id: export-setup -# name: Export setup.py -# language: system -# pass_filenames: false -# entry: ~/anaconda3/bin/poetry2setup > setup.py -- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.3.0 - hooks: - - id: pretty-format-yaml - args: [--autofix, --indent, '2'] - - id: pretty-format-toml - args: [--autofix] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff452ee8..019a583d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing -When contributing to the EasyDiffractionLib repository, please first discuss the change you wish to make via issue, -email, or any other method with the owners of this repository before making a change. +When contributing, please first discuss the change you wish to make via issue, +email, or any other method with the owners of this repository before making a change. Please note we have a code of conduct, please follow it in all your interactions with the project. @@ -11,7 +11,7 @@ Please note we have a code of conduct, please follow it in all your interactions build. 2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters. -3. Increase the version numbers in any examples files and the README.md to the new version that this +3. Increase the version numbers in any example files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you. @@ -21,7 +21,7 @@ Please note we have a code of conduct, please follow it in all your interactions ### Our Pledge In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and +contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and diff --git a/LICENSE b/LICENSE index 111a1bb3..f893b208 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2021-2022, European Spallation Source +Copyright (c) 2024, EasyDiffractionLib contributors (https://github.com/EasyScience/EasyDiffractionLib) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 4515feff..1da9290d 100644 --- a/README.md +++ b/README.md @@ -1,140 +1,24 @@ -# [![Unit Tests][20]][21] ![Release][31] [![Downloads][70]][71] [![Lines of code][81]](<>) [![Total lines][80]](<>) [![Files][82]](<>) [![License][50]][51] [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/easyscience/easydiffractionlib/master) + -[![](http://github-actions.40ants.com/easyscience/easydiffractionlib/matrix.svg)](https://github.com/easyscience/easydiffractionlib/actions) +EasyDiffraction is a Python library for calculating neutron powder diffraction pattern based on a structural model and refining its parameters against experimental data. - +Easydiffraction library is the foundation of the [EasyDiffraction application](https://github.com/EasyScience/EasyDiffractionApp), an intuitive graphical user interface that aims to simplify and speed up the analysis of diffraction experiments. -**Easydiffraction** is a Python library which provides: - -* Scripting interface to simulate and analyse neutron diffraction patterns. -* Multiple optimization algorithms to minimize models to experimental data: [Lmfit](https://lmfit.github.io/lmfit-py/), [Bumps](https://github.com/bumps/bumps) and [DFO_LS](https://github.com/numericalalgorithmsgroup/dfols). -* Multiple calculation engines: [CrysPy](https://github.com/ikibalin/cryspy), [CrysFML](https://www.ill.eu/sites/fullprof/php/programs24b7.html?pagina=Crysfml). - -**Easydiffraction** library is the foundation of [**EasyDiffraction** application](https://github.com/easyscience/easydiffractionapp), an intuitive application which endeavors simplifying and accelerating the analysis of diffraction experiments. - -## Getting Started - -Currently, easydiffraction is in beta and has not been released on PyPI. Please use the alternative method given below to install easydiffraction from our GitHub repository. - -### Install EasyDiffraction python library - -* Create and go to, e.g., **easydiffraction** directory (*optional*) - ``` - mkdir easydiffraction && cd easydiffraction - ``` -* Create virtual environment and activate it (*optional*) - ``` - python -m venv .venv - source .venv/bin/activate - ``` -* Upgrade pip (*optional*) - ``` - pip install --upgrade pip - ``` -* Install **easydiffraction** - ``` - pip install easydiffraction --extra-index-url https://easyscience.github.io/pypi - ``` - -## Examples - -### Jupyter Notebook examples that use EasyDiffraction - -#### Locally - -* Install **easydiffraction**, including `charts` extras for visualization - ``` - pip install 'easydiffraction[charts]' --extra-index-url https://easyscience.github.io/pypi - ``` -* Install Jupyter Notebook - ``` - pip install notebook - ``` -* Download **EasyDiffractionLib** Jupyter Notebook [examples](https://github.com/easyscience/easydiffractionlib/tree/master/examples) from GitHub, e.g., using **svn** (*if not done already*) - ``` - svn export https://github.com/easyscience/easydiffractionlib/branches/master/examples - ``` -* Run Jupyter Notebook server - ``` - jupyter notebook examples/ - ``` -* In webbrowser open - ``` - http://localhost:8888/ - ``` -* Select one of the ***.ipynb** files - -#### Via Google Colab (interactive, requires google account) - -##### Neutron powder diffraction - -* [Fitting, constant wavelength, La0.5Ba0.5CoO3 - HRPT@PSI](https://colab.research.google.com/github/easyscience/easydiffractionlib/blob/master/examples/Fitting_PD-NEUT-CW_LBCO-HRPT.ipynb) -* [Fitting, time-of-flight, Si - SEPD@Argonne](https://colab.research.google.com/github/easyscience/easydiffractionlib/blob/master/examples/Fitting_PD-NEUT-TOF_Si-SEPD.ipynb) -* [Fitting, time-of-flight, Na2Ca3Al2F14 - WISH@ISIS](https://colab.research.google.com/github/easyscience/easydiffractionlib/blob/master/examples/Fitting_PD-NEUT-TOF_NCAF-WISH.ipynb) - -#### Via nbviewer (non-interactive preview) - -##### Neutron powder diffraction - -* [Fitting, constant wavelength, La0.5Ba0.5CoO3 - HRPT@PSI](https://nbviewer.org/github/easyscience/easydiffractionlib/blob/master/examples/Fitting_PD-NEUT-CW_LBCO-HRPT.ipynb) -* [Fitting, time-of-flight, Si - SEPD@Argonne](https://nbviewer.org/github/easyscience/easydiffractionlib/blob/master/examples/Fitting_PD-NEUT-TOF_Si-SEPD.ipynb) -* [Fitting, time-of-flight, Na2Ca3Al2F14 - WISH@ISIS](https://nbviewer.org/github/easyscience/easydiffractionlib/blob/master/examples/Fitting_PD-NEUT-TOF_NCAF-WISH.ipynb) - -## Test - -Testing is run via `pytest`, though it is not installed by default. Install it with: -``` -pip install pytest -``` - -The installation can be verified by running the test suite: -``` -python -m pytest -``` +* Website: https://easydiffraction.org +* Documentation: https://docs.easydiffraction.org/lib/ +* Source code: https://github.com/EasyScience/EasyDiffractionLib +* Bug reports: https://github.com/EasyScience/EasyDiffractionLib/issues ## Contributing -We absolutely welcome contributions. **EasyDiffraction** is maintained by the ESS and on a volunteer basis and thus we need to foster a community that can support user questions and develop new features to make this software a useful tool for all users while encouraging every member of the community to share their ideas. - -## License -**EasyDiffraction** is licenced under the BSD-3-Clause license, [DFO_LS](https://github.com/numericalalgorithmsgroup/dfols) is subject to the GPL license. - - - -[20]: https://github.com/easyscience/easydiffractionlib/actions/workflows/unit_test.yml/badge.svg - -[21]: https://github.com/easyscience/easydiffractionlib/actions - - - - -[31]: https://img.shields.io/badge/release-v0.0.9--alpha-orange - -[32]: https://img.shields.io/pypi/v/easyscience.svg - -[33]: https://pypi.org/project/easyscience +We absolutely welcome contributions, and our goal is for EasyDiffraction to be a community-driven open source project developed by a diverse group of contributors. - +EasyDiffraction is currently maintained by [European Spallation Source ERIC](https://ess.eu), Sweden. -[50]: https://img.shields.io/github/license/easyscience/easydiffractionlib.svg +If you are interested in contributing directly to the code, please see [CONTRIBUTING.md](https://raw.githubusercontent.com/EasyScience/EasyDiffractionLib/master/CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests. -[51]: https://github.com/easyscience/easydiffractionlib/blob/master/LICENSE.md - - - - -[70]: https://img.shields.io/pypi/dm/easyscience.svg - -[71]: https://pypi.org/project/easyscience - - - -[80]: https://tokei.rs/b1/github/easyscience/easydiffractionlib - -[81]: https://tokei.rs/b1/github/easyscience/easydiffractionlib?category=code - -[82]: https://tokei.rs/b1/github/easyscience/easydiffractionlib?category=files +## License -[83]: https://www.codefactor.io/repository/github/easyscience/easydiffractionlib/badge +EasyDiffraction is licensed under the [BSD 3-Clause License](https://raw.githubusercontent.com/EasyScience/EasyDiffractionLib/master/LICENSE). -[84]: https://www.codefactor.io/repository/github/easyscience/easydiffractionlib +[DFO_LS](https://github.com/numericalalgorithmsgroup/dfols) is subject to the GPL license. diff --git a/easydiffraction/Job.py b/easydiffraction/Job.py index 1e43cae6..7f9090a4 100644 --- a/easydiffraction/Job.py +++ b/easydiffraction/Job.py @@ -921,7 +921,7 @@ def get_parent_name(self, unique_name: str) -> str: if re.match('^Powder1DParameters_[0-9]+$', item): str_name += ".pattern" if re.match('^PointBackground_[0-9]+$', item): - container_idx = int(re.sub("\D", "", item)) - 1 + container_idx = int(re.sub(r"\D", "", item)) - 1 str_name += f".backgrounds[{container_idx}]" if re.match('^BackgroundPoint_[0-9]+$', item): name = global_object.map.get_item_by_key(item).name diff --git a/easydiffraction/Profiles/P1D.py b/easydiffraction/Profiles/P1D.py index d7bd8d79..a0cc22a9 100644 --- a/easydiffraction/Profiles/P1D.py +++ b/easydiffraction/Profiles/P1D.py @@ -73,12 +73,14 @@ class Powder1DParameters(BaseObj): _defaults = { "zero_shift": { "name": "zero_shift", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "units": "degree", "value": 0.0, "fixed": True, }, "scale": { "name": "scale", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_phase/", "value": 1, "fixed": True, "enabled": False, @@ -184,52 +186,62 @@ class Instrument1DCWParameters(BaseObj): _defaults = { "wavelength": { "name": "wavelength", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_diffrn_radiation_wavelength/", "units": "angstrom", "value": 1.54056, "fixed": True, }, "resolution_u": { "name": "resolution_u", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0002, "fixed": True, }, "resolution_v": { "name": "resolution_v", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": -0.0002, "fixed": True, }, "resolution_w": { "name": "resolution_w", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.012, "fixed": True, }, "resolution_x": { "name": "resolution_x", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, }, "resolution_y": { "name": "resolution_y", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, }, "reflex_asymmetry_p1": { "name": "reflex_asymmetry_p1", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, }, "reflex_asymmetry_p2": { "name": "reflex_asymmetry_p2", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, }, "reflex_asymmetry_p3": { "name": "reflex_asymmetry_p3", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, }, "reflex_asymmetry_p4": { "name": "reflex_asymmetry_p4", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, } @@ -296,72 +308,88 @@ class Instrument1DTOFParameters(BaseObj): _defaults = { "ttheta_bank": { "name": "ttheta_bank", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "units": "deg", "value": 145.00, "fixed": True, }, "dtt1": { "name": "dtt1", - "units": "deg", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", + "units": "microsec/angstrom", "value": 6167.24700, "fixed": True, }, "dtt2": { "name": "dtt2", - "units": "deg", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", + "units": "microsec/angstrom**2", "value": -2.28000, "fixed": True, }, "sigma0": { "name": "sigma0", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", + "units": "microsec**2", "value": 0.409, "fixed": True, }, "sigma1": { "name": "sigma1", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", + "units": "microsec**2/angstrom**2", "value": 8.118, "fixed": True, }, "sigma2": { "name": "sigma2", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", + "units": "microsec**2/angstrom**4", "value": 0.0, "fixed": True, }, "gamma0": { "name": "gamma0", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, "enabled": False, }, "gamma1": { "name": "gamma1", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, "enabled": False, }, "gamma2": { "name": "gamma2", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, "enabled": False, }, "alpha0": { "name": "alpha0", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.0, "fixed": True, }, "alpha1": { "name": "alpha1", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.29710, "fixed": True, }, "beta0": { "name": "beta0", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.04182, "fixed": True, }, "beta1": { "name": "beta1", + "url": "https://docs.easydiffraction.org/lib/project/dictionaries/_pd_instr/", "value": 0.00224, "fixed": True, }, diff --git a/examples/Change_minimizer.ipynb b/examples/Change_minimizer.ipynb index a6ac2352..128c30fd 100644 --- a/examples/Change_minimizer.ipynb +++ b/examples/Change_minimizer.ipynb @@ -38,8 +38,8 @@ "colab" ], "ExecuteTime": { - "end_time": "2024-10-28T10:50:40.979466Z", - "start_time": "2024-10-28T10:50:40.968260Z" + "end_time": "2024-10-29T13:54:11.999796Z", + "start_time": "2024-10-29T13:54:11.981259Z" } }, "source": [ @@ -70,8 +70,8 @@ "id": "33934041eaae166f", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:43.753157Z", - "start_time": "2024-10-28T10:50:40.981477Z" + "end_time": "2024-10-29T13:54:15.009394Z", + "start_time": "2024-10-29T13:54:12.001884Z" } }, "source": "import easydiffraction as ed", @@ -97,8 +97,8 @@ "id": "180e216d55b3f144", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:43.808239Z", - "start_time": "2024-10-28T10:50:43.797566Z" + "end_time": "2024-10-29T13:54:15.061398Z", + "start_time": "2024-10-29T13:54:15.051828Z" } }, "source": "job = ed.Job()", @@ -122,8 +122,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:44.202597Z", - "start_time": "2024-10-28T10:50:43.912369Z" + "end_time": "2024-10-29T13:54:15.482457Z", + "start_time": "2024-10-29T13:54:15.190001Z" } }, "cell_type": "code", @@ -154,8 +154,8 @@ "id": "5184de9d741bddb4", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:44.213165Z", - "start_time": "2024-10-28T10:50:44.206742Z" + "end_time": "2024-10-29T13:54:15.493021Z", + "start_time": "2024-10-29T13:54:15.486730Z" } }, "source": [ @@ -205,18 +205,18 @@ "id": "238c54cda578c7e7", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:44.245274Z", - "start_time": "2024-10-28T10:50:44.238070Z" + "end_time": "2024-10-29T13:54:15.503865Z", + "start_time": "2024-10-29T13:54:15.496848Z" } }, "source": "job.show_crystal_structure(id='lbco')", "outputs": [ { "data": { - "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", + "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ - "
\n", - "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", + "

\n", + "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] @@ -292,8 +292,8 @@ "id": "8a1823930f0346e5", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:44.328229Z", - "start_time": "2024-10-28T10:50:44.255314Z" + "end_time": "2024-10-29T13:54:15.598545Z", + "start_time": "2024-10-29T13:54:15.507558Z" } }, "source": "job.add_experiment_from_file('data/hrpt.xye')", @@ -311,8 +311,8 @@ "id": "f1dfee8a4bee7672", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:44.450097Z", - "start_time": "2024-10-28T10:50:44.332384Z" + "end_time": "2024-10-29T13:54:15.761608Z", + "start_time": "2024-10-29T13:54:15.602677Z" } }, "source": [ @@ -26047,16 +26047,17 @@ "style": "dark" } } - } + }, + "showlegend": true }, "config": { "plotlyServerURL": "https://plot.ly" } }, "text/html": [ - "
", + "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ - "
\n", - "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", + "

\n", + "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] @@ -309,8 +309,8 @@ "id": "8a1823930f0346e5", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:47:38.771405Z", - "start_time": "2024-10-28T10:47:38.677653Z" + "end_time": "2024-10-29T13:54:21.878427Z", + "start_time": "2024-10-29T13:54:21.768040Z" } }, "source": [ @@ -332,8 +332,8 @@ "id": "f1dfee8a4bee7672", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:47:38.921506Z", - "start_time": "2024-10-28T10:47:38.781150Z" + "end_time": "2024-10-29T13:54:22.034253Z", + "start_time": "2024-10-29T13:54:21.883334Z" } }, "source": [ @@ -26068,16 +26068,17 @@ "style": "dark" } } - } + }, + "showlegend": true }, "config": { "plotlyServerURL": "https://plot.ly" } }, "text/html": [ - "
", + "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ - "
\n", - "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", + "

\n", + "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] @@ -294,8 +294,8 @@ "id": "8a1823930f0346e5", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:41.623113Z", - "start_time": "2024-10-28T10:50:41.506845Z" + "end_time": "2024-10-29T13:54:27.996976Z", + "start_time": "2024-10-29T13:54:27.871875Z" } }, "source": "job.add_experiment_from_file('data/wish.xye')", @@ -313,8 +313,8 @@ "id": "f1dfee8a4bee7672", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T10:50:42.003456Z", - "start_time": "2024-10-28T10:50:41.848993Z" + "end_time": "2024-10-29T13:54:28.190874Z", + "start_time": "2024-10-29T13:54:28.001227Z" } }, "source": [ @@ -31169,16 +31169,17 @@ "style": "dark" } } - } + }, + "showlegend": true }, "config": { "plotlyServerURL": "https://plot.ly" } }, "text/html": [ - "
", + "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ - "
\n", - "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", + "

\n", + "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] @@ -380,8 +380,8 @@ "id": "8a1823930f0346e5", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T12:19:43.910726Z", - "start_time": "2024-10-28T12:19:43.769946Z" + "end_time": "2024-10-29T13:54:35.309082Z", + "start_time": "2024-10-29T13:54:35.151756Z" } }, "source": "job.add_experiment_from_file('data/sepd.xye')", @@ -399,8 +399,8 @@ "id": "f1dfee8a4bee7672", "metadata": { "ExecuteTime": { - "end_time": "2024-10-28T12:19:44.135261Z", - "start_time": "2024-10-28T12:19:43.914956Z" + "end_time": "2024-10-29T13:54:35.548920Z", + "start_time": "2024-10-29T13:54:35.314412Z" } }, "source": "job.show_experiment_chart(show_legend=False)", @@ -46157,9 +46157,9 @@ } }, "text/html": [ - "