Repository: vincentsarago/color-operations (language: python)

Issue:
[Bug] test_rgb2lch fails with AssertionError on ARM
The following test fails on the latest stable version (0.1.3) **only on ARM platforms** (`aarch64-linux` and `aarch64-darwin`):
```
=================================== FAILURES ===================================
_____________________________ test_rgb2lch[pair0] ______________________________

pair = ((0, 0, 0), (0, 0, 0))

    @pytest.mark.parametrize("pair", tests)
    def test_rgb2lch(pair):
        rgb, lch = pair
        alch = convert(*rgb, src=cs.rgb, dst=cs.lch)
>       assert alch[0] >= 0
E       assert -2.220446049250313e-16 >= 0

tests/test_colorspace.py:101: AssertionError
=========================== short test summary info ============================
FAILED tests/test_colorspace.py::test_rgb2lch[pair0] - assert -2.220446049250313e-16 >= 0
======================== 1 failed, 1443 passed in 0.74s ========================
```



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ac0f7f6..86e74cc 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -81,7 +81,7 @@ jobs:
           CIBW_ARCHS_MACOS: x86_64 arm64 universal2
           CIBW_ARCHS_LINUX: auto aarch64
           # CIBW_TEST_REQUIRES: pytest colormath==2.0.2
-          # CIBW_TEST_COMMAND: python -m pytest {project}/tests -v -s
+          # CIBW_TEST_COMMAND: python -m pytest {project}/tests
 
       - uses: actions/upload-artifact@v3
         with:
@@ -120,7 +120,7 @@ jobs:
           name: artifact
           path: dist
 
-      - uses: pypa/gh-action-pypi-publish@master
+      - uses: pypa/gh-action-pypi-publish@release/v1
         with:
           user: ${{ secrets.PYPI_USERNAME }}
           password: ${{ secrets.PYPI_PASSWORD }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 5bc6d99..b4fb583 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -4,27 +4,22 @@ repos:
     hooks:
       - id: validate-pyproject
 
-  - repo: https://github.com/psf/black
-    rev: 22.12.0
-    hooks:
-      - id: black
-        language_version: python
-
   - repo: https://github.com/PyCQA/isort
-    rev: 5.12.0
+    rev: 5.13.2
     hooks:
       - id: isort
         language_version: python
 
-  - repo: https://github.com/charliermarsh/ruff-pre-commit
-    rev: v0.0.238
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+    rev: v0.3.5
     hooks:
       - id: ruff
         args: ["--fix"]
         exclude: tests/.*
+      - id: ruff-format
 
   - repo: https://github.com/pre-commit/mirrors-mypy
-    rev: v0.991
+    rev: v1.9.0
     hooks:
       - id: mypy
         language_version: python
diff --git a/CHANGES.md b/CHANGES.md
index 5db9151..99416ad 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,9 @@
 
+## 0.1.4 (2024-06-18)
+
+* limit numpy to **~1.0**
+* relaxes tests scenario, failing on some ARM arch
+
 ## 0.1.3 (2024-03-13)
 
 * no changes since `0.1.2`
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..4556d12
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,25 @@
+# Contributing
+
+Issues and pull requests are more than welcome.
+
+### dev install
+
+```bash
+git clone https://github.com/vincentsarago/color-operations.git
+cd color-operations
+python -m pip install -e ".[test,dev]"
+```
+
+You can then run the tests with the following command:
+
+```sh
+python -m pytest --cov color_operations --cov-report term-missing
+```
+
+### pre-commit
+
+This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.
+
+```bash
+$ pre-commit install
+```
diff --git a/pyproject.toml b/pyproject.toml
index 2bbf8d3..e7552ca 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -31,8 +31,11 @@ default_section = "THIRDPARTY"
 no_strict_optional = "True"
 
 [tool.ruff]
+line-length = 90
+
+[tool.ruff.lint]
 select = [
-    "D1",  # pydocstyle errors
+    "D1", # pydocstyle errors
     "E",  # pycodestyle errors
     "W",  # pycodestyle warnings
     "F",  # flake8
@@ -44,3 +47,6 @@ ignore = [
     "B008",  # do not perform function calls in argument defaults
     "B905",  # ignore zip() without an explicit strict= parameter, only support with python >3.10
 ]
+
+[tool.ruff.lint.mccabe]
+max-complexity = 14
diff --git a/setup.py b/setup.py
index 74d0aa0..047268c 100644
--- a/setup.py
+++ b/setup.py
@@ -91,7 +91,7 @@
     packages=find_packages(exclude=["tests"]),
     include_package_data=True,
     zip_safe=False,
-    install_requires=["numpy"],
+    install_requires=["numpy~=1.0"],
     ext_modules=ext_modules,
     include_dirs=include_dirs,
     extras_require={
@@ -100,5 +100,8 @@
             "colormath==2.0.2",
             "pytest-cov",
         ],
+        "dev": [
+            "pre-commit",
+        ],
     },
 )


Test patch:
diff --git a/tests/test_colorspace.py b/tests/test_colorspace.py
index b5f8c29..8d8de97 100644
--- a/tests/test_colorspace.py
+++ b/tests/test_colorspace.py
@@ -79,7 +79,6 @@ def test_fixtures(pair):
 
 
 def _near(a, b, tol):
-
     if not isinstance(tol, Iterable):
         tol = [tol] * len(a)
 
@@ -98,7 +97,7 @@ def _make_array(x, y, z, dtype="float64"):
 def test_rgb2lch(pair):
     rgb, lch = pair
     alch = convert(*rgb, src=cs.rgb, dst=cs.lch)
-    assert alch[0] >= 0
+    assert round(alch[0], 8) >= 0
     assert _near(alch, lch, (1.0, 1.0, 0.25))
 
 
diff --git a/tests/test_operations.py b/tests/test_operations.py
index e2ca3e9..99b50b7 100644
--- a/tests/test_operations.py
+++ b/tests/test_operations.py
@@ -37,7 +37,6 @@
 
 @pytest.fixture
 def arr():
-
     return to_math_type(
         np.array(
             [