Skip to content

Commit

Permalink
Merge pull request #302 from dmgav/debug-pyqt
Browse files Browse the repository at this point in the history
Compatibility with PyQT 5.15
  • Loading branch information
dmgav authored Mar 19, 2023
2 parents 1835ba5 + f5d5ec0 commit 3ab1c99
Show file tree
Hide file tree
Showing 82 changed files with 583 additions and 570 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check Code Style - ISORT

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install Dependencies
run: |
# These packages are installed in the base environment but may be older
# versions. Explicitly upgrade them because they often create
# installation problems if out of date.
python -m pip install --upgrade pip setuptools numpy
pip install isort
- name: Run ISort
run: |
isort . -c
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Install Conda packages
run: |
set -vxeuo pipefail
set -vxeo pipefail
conda install -y \
python=${{ matrix.python-version }} \
Expand All @@ -91,7 +91,7 @@ jobs:
- name: Install Conda packages (Windows and OSX)
if: runner.os != 'Linux'
run: |
set -vxeuo pipefail
set -vxeo pipefail
# There are issues in building wheels for pystackreg>0.2.2 on OSX, so install pystackreg from CF
conda install -y pystackreg -c conda-forge
Expand Down
5 changes: 5 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[settings]
line_length = 115
multi_line_output = 3
include_trailing_comma = True
profile = black
14 changes: 5 additions & 9 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ The easiest way to install PyXRF is to load it into a Conda environment from
``conda-forge`` Anaconda channel. Installation instructions are
identical for all supported OS.

PyXRF is currently not working properly with ``PyQt5`` v5.15, which is the latest available
version. The instructions show how to install earlier version of ``PyQt5`` from PyPI.

.. note::

**Installation on Windows**: PyXRF can be installed from *conda-forge* only in the environments
Expand All @@ -36,15 +33,13 @@ version. The instructions show how to install earlier version of ``PyQt5`` from
$ conda install mamba -n base -c conda-forge
Then use `mamba` instead of `conda` in all commands. Mamba may not respect pinned versions of
packages. Since PyXRF currently does not work with `pyqt` v5.15, explicitly specify the version
`"pyqt<5.15"` during installation, for example
Then use `mamba` instead of `conda` in all the following commands, for example

.. code:: bash
$ mamba create -n pyxrf-env python=3.9 pip -c conda-forge
$ mamba activate pyxrf-env
$ mamba install pyxrf "pyqt<5.15" -c conda-forge
$ mamba install pyxrf -c conda-forge
You may still use `conda` where it works well, e.g. to activate an existing environment.

Expand Down Expand Up @@ -119,14 +114,15 @@ version. The instructions show how to install earlier version of ``PyQt5`` from

.. code:: bash
$ pip install pyxrf 'PyQt5<5.15'
$ pip install pyxrf PyQt5
$ pip install pyxrf 'PyQt5<5.15' # Older version of PyQT
or from source (editable installation):

.. code:: bash
$ cd <root-directory-of-the-repository>
$ pip install 'PyQt5<5.15'
$ pip install PyQt5
$ pip install -e .
Starting PyXRF
Expand Down
1 change: 1 addition & 0 deletions pyxrf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from logging import NullHandler

from ._version import get_versions

__version__ = get_versions()["version"]
Expand Down
3 changes: 2 additions & 1 deletion pyxrf/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# Use 'pyxrf.api_dev' if you are importing PyXRF API into a custom script.


from .api_dev import * # noqa: F401, F403
from pyxrf import __version__ as pyxrf_version

from .api_dev import * # noqa: F401, F403


def pyxrf_api():
r"""
Expand Down
28 changes: 13 additions & 15 deletions pyxrf/api_dev.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# Use this file if you need to import PyXRF APIs into a custom script.
# Use 'pyxrf.api' if you are interactively importing APIs into an IPython session.

from .model.fileio import stitch_fitted_results # noqa: F401
from .model.fileio import spec_to_hdf # noqa: F401
from .model.fileio import create_movie # noqa: F401
import logging

from .core.map_processing import dask_client_create # noqa: F401
from .gui_support.gpc_class import autofind_emission_lines # noqa: F401, E402
from .model.command_tools import fit_pixel_data_and_save, pyxrf_batch # noqa: F401
from .model.fileio import combine_data_to_recon # noqa: F401
from .model.fileio import h5file_for_recon # noqa: F401
from .model.fileio import create_movie # noqa: F401
from .model.fileio import export_to_view # noqa: F401
from .model.fileio import h5file_for_recon # noqa: F401
from .model.fileio import make_hdf_stitched # noqa: F401

from .model.load_data_from_db import make_hdf, export1d # noqa: F401
from .model.command_tools import fit_pixel_data_and_save, pyxrf_batch # noqa: F401
from .xanes_maps.xanes_maps_api import build_xanes_map # noqa: F401
from .simulation.sim_xrf_scan_data import gen_hdf5_qa_dataset, gen_hdf5_qa_dataset_preset_1 # noqa: F401
from .core.map_processing import dask_client_create # noqa: F401

from .model.load_data_from_db import save_data_to_hdf5 # noqa: F401, E402
from .model.fileio import read_data_from_hdf5 # noqa: F401, E402

from .gui_support.gpc_class import autofind_emission_lines # noqa: F401, E402
from .model.fileio import spec_to_hdf # noqa: F401
from .model.fileio import stitch_fitted_results # noqa: F401
from .model.load_data_from_db import save_data_to_hdf5 # noqa: F401, E402
from .model.load_data_from_db import export1d, make_hdf # noqa: F401
from .simulation.sim_xrf_scan_data import gen_hdf5_qa_dataset, gen_hdf5_qa_dataset_preset_1 # noqa: F401
from .xanes_maps.xanes_maps_api import build_xanes_map # noqa: F401

# Note: the statement '# noqa: F401' is telling flake8 to ignore violation F401 at the given line
# Violation F401 - the package is imported but unused

import logging

logger = logging.getLogger("pyxrf")

Expand Down
19 changes: 10 additions & 9 deletions pyxrf/core/map_processing.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import numpy as np
import getpass
import logging
import math
import os
import h5py
import dask
import dask.array as da
import tempfile
import platform
import getpass
import tempfile
import time as ttime
from numba import jit

import dask
import dask.array as da
import h5py
import numpy as np
from dask.distributed import Client, wait
from numba import jit
from progress.bar import Bar
from .fitting import fit_spectrum

import logging
from .fitting import fit_spectrum

logger = logging.getLogger(__name__)

Expand Down
22 changes: 12 additions & 10 deletions pyxrf/core/quant_analysis.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import copy
import json
import logging
import math
import os
import yaml
import time as ttime

import jsonschema
import numpy as np
import math
import json
import copy
import time as ttime
import yaml

from .utils import convert_time_to_nexus_string, normalize_data_by_scaler
from .xrf_utils import (
split_compound_mass,
generate_eline_list,
compute_atomic_scaling_factor,
check_if_eline_supported,
compute_atomic_scaling_factor,
generate_eline_list,
split_compound_mass,
)
from .utils import normalize_data_by_scaler, convert_time_to_nexus_string
import logging

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions pyxrf/core/tests/test_fitting.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
import numpy as np
import numpy.testing as npt
import pytest

from pyxrf.core.fitting import rfactor_compute, _fitting_nnls, _fitting_admm, fit_spectrum
from pyxrf.core.fitting import _fitting_admm, _fitting_nnls, fit_spectrum, rfactor_compute

# ------------------------------------------------------------------------------
# useful functions for generating of datasets for testing of fitting algorithms
Expand Down
34 changes: 16 additions & 18 deletions pyxrf/core/tests/test_map_processing.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
import pytest
import numpy as np
import dask.array as da
import numpy.testing as npt
import h5py
import logging
import os
import uuid
from pyxrf.core.fitting import fit_spectrum

import dask.array as da
import h5py
import numpy as np
import numpy.testing as npt
import pytest
from skbeam.core.fitting.background import snip_method

from pyxrf.core.fitting import fit_spectrum
from pyxrf.core.map_processing import (
dask_client_create,
RawHDF5Dataset,
TerminalProgressBar,
wait_and_display_progress,
_compute_optimal_chunk_size,
_chunk_numpy_array,
_array_numpy_to_dask,
RawHDF5Dataset,
prepare_xrf_map,
_chunk_numpy_array,
_compute_optimal_chunk_size,
_compute_roi,
_fit_xrf_block,
_prepare_xrf_mask,
compute_selected_rois,
compute_total_spectrum,
compute_total_spectrum_and_count,
_fit_xrf_block,
dask_client_create,
fit_xrf_map,
_compute_roi,
compute_selected_rois,
prepare_xrf_map,
snip_method_numba,
wait_and_display_progress,
)

from pyxrf.core.tests.test_fitting import DataForFittingTest

import logging

logger = logging.getLogger(__name__)


Expand Down
32 changes: 17 additions & 15 deletions pyxrf/core/tests/test_quant_analysis.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import copy
import os
import pytest
import re
import time as ttime

import jsonschema
import copy
import numpy as np
import numpy.testing as npt
import time as ttime
import re
from pyxrf.core.utils import convert_time_from_nexus_string
from pyxrf.core.xrf_utils import validate_element_str, generate_eline_list, split_compound_mass
import pytest

from pyxrf.core.quant_analysis import (
save_xrf_standard_yaml_file,
load_xrf_standard_yaml_file,
ParamQuantEstimation,
ParamQuantitativeAnalysis,
_xrf_quant_fluor_schema,
_xrf_standard_schema,
load_included_xrf_standard_yaml_file,
compute_standard_element_densities,
_xrf_quant_fluor_schema,
save_xrf_quant_fluor_json_file,
load_xrf_quant_fluor_json_file,
get_quant_fluor_data_dict,
fill_quant_fluor_data_dict,
get_quant_fluor_data_dict,
load_included_xrf_standard_yaml_file,
load_xrf_quant_fluor_json_file,
load_xrf_standard_yaml_file,
prune_quant_fluor_data_dict,
save_xrf_quant_fluor_json_file,
save_xrf_standard_yaml_file,
set_quant_fluor_data_dict_optional,
set_quant_fluor_data_dict_time,
ParamQuantEstimation,
ParamQuantitativeAnalysis,
)
from pyxrf.core.utils import convert_time_from_nexus_string
from pyxrf.core.xrf_utils import generate_eline_list, split_compound_mass, validate_element_str

# Short example of XRF standard data
_standard_data_sample = [
Expand Down
22 changes: 12 additions & 10 deletions pyxrf/core/tests/test_xrf_utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import pytest
import re

import numpy as np
import numpy.testing as npt
import pytest

from pyxrf.core.xrf_utils import (
get_element_atomic_number,
validate_element_str,
parse_compound_formula,
split_compound_mass,
get_supported_eline_list,
check_if_eline_supported,
check_if_eline_is_activated,
generate_eline_list,
check_if_eline_supported,
compute_atomic_scaling_factor,
compute_atomic_weight,
compute_cs,
compute_cs_ratio,
compute_atomic_weight,
compute_atomic_scaling_factor,
generate_eline_list,
get_element_atomic_number,
get_supported_eline_list,
parse_compound_formula,
split_compound_mass,
validate_element_str,
)


Expand Down
3 changes: 2 additions & 1 deletion pyxrf/core/tests/test_yaml_param_files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os

import jsonschema
import numpy as np
import pytest
import os

from pyxrf.core.yaml_param_files import (
_parse_docstring_parameters,
Expand Down
6 changes: 3 additions & 3 deletions pyxrf/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
import scipy
import logging
import time as ttime

import logging
import numpy as np
import scipy

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion pyxrf/core/xrf_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import xraylib
from distutils.version import LooseVersion

import xraylib
from skbeam.core.constants import XrfElement as Element
from skbeam.core.fitting.xrf_model import K_LINE, L_LINE, M_LINE

Expand Down
Loading

0 comments on commit 3ab1c99

Please sign in to comment.