Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yapf 0.24.0, 0.25.0 and 0.26.0 are producing flake8 incompatible formatting. #694

Closed
KelSolaar opened this issue Mar 21, 2019 · 6 comments
Closed

Comments

@KelSolaar
Copy link

KelSolaar commented Mar 21, 2019

Hi,

I recently updated Yapf from 0.23.0 to 0.26.0 and my code once formatted is not flake8 friendly anymore, e.g.:

/usr/local/anaconda3/envs/colour-2.7/bin/python /usr/local/anaconda3/envs/colour-2.7/bin/flake8 colour
colour/colorimetry/dataset/lefs.py:2367:80: E501 line too long (80 > 79 characters)
colour/colorimetry/dataset/cmfs.py:3209:80: E501 line too long (80 > 79 characters)
colour/colorimetry/dataset/cmfs.py:3220:80: E501 line too long (80 > 79 characters)
colour/colorimetry/dataset/light_sources/sds.py:4866:80: E501 line too long (80 > 79 characters)
colour/models/hunter_lab.py:89:5: E131 continuation line unaligned for hanging indent
colour/models/hunter_lab.py:91:5: E129 visually indented line with same indent as next logical line
colour/models/hunter_lab.py:165:5: E131 continuation line unaligned for hanging indent
colour/models/hunter_lab.py:167:5: E129 visually indented line with same indent as next logical line
colour/models/hunter_rdab.py:44:5: E131 continuation line unaligned for hanging indent
colour/models/hunter_rdab.py:46:5: E129 visually indented line with same indent as next logical line
colour/models/hunter_rdab.py:122:5: E131 continuation line unaligned for hanging indent
colour/models/hunter_rdab.py:124:5: E129 visually indented line with same indent as next logical line
colour/notation/munsell.py:1035:80: E501 line too long (80 > 79 characters)
colour/volume/rgb.py:75:5: E131 continuation line unaligned for hanging indent
colour/volume/rgb.py:193:5: E131 continuation line unaligned for hanging indent

Two examples:

colour/volume/rgb.py:193:5: E131 continuation line unaligned for hanging indent

 def RGB_colourspace_volume_MonteCarlo(
         colourspace,
         samples=10e6,
         limits=np.array([[0, 100], [-150, 150], [-150, 150]], dtype=np.float),
-        illuminant_Lab=ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][
-            'D65'],
+        illuminant_Lab=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
+    ['D65'],
         chromatic_adaptation_method='CAT02',
         random_generator=random_triplet_generator,
         random_state=None,
         processes=None):
     """

colour/notation/munsell.py:1035:80: E501 line too long (80 > 79 characters)

         phi_differences_indexes = phi_differences.argsort()
 
         phi_differences = phi_differences[phi_differences_indexes]
-        hue_angles_differences = hue_angles_differences[
-            phi_differences_indexes]
+        hue_angles_differences = hue_angles_differences[phi_differences_indexes]
 
         hue_angle_difference_new = Extrapolator(
             LinearInterpolator(phi_differences,
                                hue_angles_differences))(0) % 360
         hue_angle_new = (hue_angle_current + hue_angle_difference_new) % 360

So the first question is, any reason why this is happening, e.g. defaults changed? And second one, what can I do to fix that?

Cheers,

Thomas

@KelSolaar
Copy link
Author

Actually, this happens also with Yapf 0.24.0, so I will try to isolate when it started to occur.

@KelSolaar KelSolaar changed the title Yapf 0.25.0 and 0.26.0 are producing flake8 incompatible formatting. Yapf 0.24.0, 0.25.0 and 0.26.0 are producing flake8 incompatible formatting. Mar 21, 2019
@KelSolaar
Copy link
Author

Confirming it started with 0.24.0, 0.23.0 was fine!

KelSolaar added a commit to colour-science/colour that referenced this issue Mar 21, 2019
KelSolaar added a commit to colour-science/colour-demosaicing that referenced this issue Mar 21, 2019
KelSolaar added a commit to colour-science/colour-hdri that referenced this issue Mar 21, 2019
KelSolaar added a commit to colour-science/colour-checker-detection that referenced this issue Mar 21, 2019
@bwendling
Copy link
Member

The second example looks like it's fixed in top-of-tree. The first one is weird. I'll need to look into it a bit more.

@bwendling
Copy link
Member

I think these are both fixed in top-of-tree:

def RGB_colourspace_volume_MonteCarlo(
    colourspace,
    samples=10e6,
    limits=np.array([[0, 100], [-150, 150], [-150, 150]], dtype=np.float),
    illuminant_Lab=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65'],
    chromatic_adaptation_method='CAT02',
    random_generator=random_triplet_generator,
    random_state=None,
    processes=None):
    def _():
        phi_differences_indexes = phi_differences.argsort()

        phi_differences = phi_differences[phi_differences_indexes]
        hue_angles_differences = hue_angles_differences[
            phi_differences_indexes]

        hue_angle_difference_new = Extrapolator(
            LinearInterpolator(phi_differences,
                               hue_angles_differences))(0) % 360
        hue_angle_new = (hue_angle_current + hue_angle_difference_new) % 360

@KelSolaar
Copy link
Author

Hi,

Unfortunately, I tried with 0.28.0 and I still have similar issues. Running yapf -ri on https://github.com/colour-science/colour/tree/46917f2b3ffefd7dd140384141302e3f87a69e99/colour/volume:

(colour-3.7) Kali:colour kelsolaar$ yapf -v
yapf 0.28.0
(colour-3.7) Kali:colour kelsolaar$ yapf -ri colour/volume/
(colour-3.7) Kali:colour kelsolaar$ flake8 colour
colour/volume/rgb.py:75:5: E131 continuation line unaligned for hanging indent
colour/volume/rgb.py:194:5: E131 continuation line unaligned for hanging indent

And here is the diff:

diff --git a/colour/volume/pointer_gamut.py b/colour/volume/pointer_gamut.py
index 3c3acacc..d4e7fa23 100644
--- a/colour/volume/pointer_gamut.py
+++ b/colour/volume/pointer_gamut.py
@@ -64,7 +64,7 @@ def is_within_pointer_gamut(XYZ, tolerance=None):
     array([ True, False], dtype=bool)
     """
 
-    XYZ_p = Lab_to_XYZ(
-        LCHab_to_Lab(POINTER_GAMUT_DATA), POINTER_GAMUT_ILLUMINANT)
+    XYZ_p = Lab_to_XYZ(LCHab_to_Lab(POINTER_GAMUT_DATA),
+                       POINTER_GAMUT_ILLUMINANT)
 
     return is_within_mesh_volume(XYZ, XYZ_p, tolerance)
diff --git a/colour/volume/rgb.py b/colour/volume/rgb.py
index 1ad9d1b3..b5aa7ee1 100644
--- a/colour/volume/rgb.py
+++ b/colour/volume/rgb.py
@@ -71,8 +71,8 @@ def sample_RGB_colourspace_volume_MonteCarlo(
         colourspace,
         samples=10e6,
         limits=np.array([[0, 100], [-150, 150], [-150, 150]]),
-        illuminant_Lab=ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][
-            'D65'],
+        illuminant_Lab=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
+    ['D65'],
         chromatic_adaptation_method='CAT02',
         random_generator=random_triplet_generator,
         random_state=None):
@@ -190,8 +190,8 @@ def RGB_colourspace_volume_MonteCarlo(
         colourspace,
         samples=10e6,
         limits=np.array([[0, 100], [-150, 150], [-150, 150]], dtype=np.float),
-        illuminant_Lab=ILLUMINANTS['CIE 1931 2 Degree Standard Observer'][
-            'D65'],
+        illuminant_Lab=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
+    ['D65'],
         chromatic_adaptation_method='CAT02',
         random_generator=random_triplet_generator,
         random_state=None):
diff --git a/colour/volume/spectrum.py b/colour/volume/spectrum.py
index 5b4c84b7..ca6f68c5 100644
--- a/colour/volume/spectrum.py
+++ b/colour/volume/spectrum.py
@@ -207,8 +207,10 @@ def XYZ_outer_surface(
             values.append(
                 NearestNeighbourInterpolator(wavelengths, wave)(domain))
 
-        XYZ = multi_sds_to_XYZ_integration(
-            values, cmfs, illuminant, shape=DEFAULT_SPECTRAL_SHAPE)
+        XYZ = multi_sds_to_XYZ_integration(values,
+                                           cmfs,
+                                           illuminant,
+                                           shape=DEFAULT_SPECTRAL_SHAPE)
 
         XYZ = XYZ / np.max(XYZ[-1, 1])
 
diff --git a/colour/volume/tests/test_macadam_limits.py b/colour/volume/tests/test_macadam_limits.py
index 2c678261..a248e782 100644
--- a/colour/volume/tests/test_macadam_limits.py
+++ b/colour/volume/tests/test_macadam_limits.py
@@ -27,7 +27,6 @@ class TestIsWithinMacadamLimits(unittest.TestCase):
     Defines :func:`colour.volume.macadam_limits.is_within_macadam_limits`
     definition unit tests methods.
     """
-
     def test_is_within_macadam_limits(self):
         """
         Tests :func:`colour.volume.macadam_limits.is_within_macadam_limits`
diff --git a/colour/volume/tests/test_mesh.py b/colour/volume/tests/test_mesh.py
index 79e91676..3932df58 100644
--- a/colour/volume/tests/test_mesh.py
+++ b/colour/volume/tests/test_mesh.py
@@ -27,7 +27,6 @@ class TestIsWithinMeshVolume(unittest.TestCase):
     Defines :func:`colour.volume.mesh.is_within_mesh_volume` definition unit
     tests methods.
     """
-
     def setUp(self):
         """
         Initialises common tests attributes.
@@ -47,20 +46,20 @@ class TestIsWithinMeshVolume(unittest.TestCase):
         """
 
         self.assertTrue(
-            is_within_mesh_volume(
-                np.array([0.0005, 0.0031, 0.0010]), self._mesh))
+            is_within_mesh_volume(np.array([0.0005, 0.0031, 0.0010]),
+                                  self._mesh))
 
         self.assertFalse(
-            is_within_mesh_volume(
-                np.array([0.3205, 0.4131, 0.5100]), self._mesh))
+            is_within_mesh_volume(np.array([0.3205, 0.4131, 0.5100]),
+                                  self._mesh))
 
         self.assertTrue(
-            is_within_mesh_volume(
-                np.array([0.0025, 0.0088, 0.0340]), self._mesh))
+            is_within_mesh_volume(np.array([0.0025, 0.0088, 0.0340]),
+                                  self._mesh))
 
         self.assertFalse(
-            is_within_mesh_volume(
-                np.array([0.4325, 0.3788, 0.1034]), self._mesh))
+            is_within_mesh_volume(np.array([0.4325, 0.3788, 0.1034]),
+                                  self._mesh))
 
     def test_n_dimensional_is_within_mesh_volume(self):
         """
diff --git a/colour/volume/tests/test_pointer_gamut.py b/colour/volume/tests/test_pointer_gamut.py
index ef7e1d47..eceb85b1 100644
--- a/colour/volume/tests/test_pointer_gamut.py
+++ b/colour/volume/tests/test_pointer_gamut.py
@@ -27,7 +27,6 @@ class TestIsWithinPointerGamut(unittest.TestCase):
     Defines :func:`colour.volume.pointer_gamut.is_within_pointer_gamut`
     definition unit tests methods.
     """
-
     def test_is_within_pointer_gamut(self):
         """
         Tests :func:`colour.volume.pointer_gamut.is_within_pointer_gamut`
diff --git a/colour/volume/tests/test_rgb.py b/colour/volume/tests/test_rgb.py
index f047b9a1..23b94b25 100644
--- a/colour/volume/tests/test_rgb.py
+++ b/colour/volume/tests/test_rgb.py
@@ -53,7 +53,6 @@ class TestRGB_colourspaceLimits(unittest.TestCase):
     Defines :func:`colour.volume.rgb.RGB_colourspace_limits` definition unit
     tests methods.
     """
-
     def test_RGB_colourspace_limits(self):
         """
         Tests :func:`colour.volume.rgb.RGB_colourspace_limits` definition.
@@ -96,7 +95,6 @@ class TestRGB_colourspaceVolumeMonteCarlo(unittest.TestCase):
     ----------
     :cite:`Laurent2012a`
     """
-
     @disable_multiprocessing()
     def test_RGB_colourspace_volume_MonteCarlo(self):
         """
@@ -104,12 +102,11 @@ class TestRGB_colourspaceVolumeMonteCarlo(unittest.TestCase):
         definition.
         """
 
-        self.assertAlmostEqual(
-            RGB_colourspace_volume_MonteCarlo(
-                BT709_COLOURSPACE, 10e3, random_state=np.random.RandomState(2))
-            * 1e-6,
-            821700.0 * 1e-6,
-            places=1)
+        self.assertAlmostEqual(RGB_colourspace_volume_MonteCarlo(
+            BT709_COLOURSPACE, 10e3, random_state=np.random.RandomState(2)) *
+                               1e-6,
+                               821700.0 * 1e-6,
+                               places=1)
 
 
 class TestRGB_colourspace_volume_coverage_MonteCarlo(unittest.TestCase):
@@ -121,7 +118,6 @@ RGB_colourspace_volume_coverage_MonteCarlo` definition unit tests methods.
     ----------
     :cite:`Laurent2012a`
     """
-
     def test_RGB_colourspace_volume_coverage_MonteCarlo(self):
         """
         Tests :func:`colour.volume.rgb.\
@@ -148,7 +144,6 @@ RGB_colourspace_pointer_gamut_coverage_MonteCarlo` definition unit tests
     ----------
     :cite:`Laurent2012a`
     """
-
     def test_RGB_colourspace_pointer_gamut_coverage_MonteCarlo(self):
         """
         Tests :func:`colour.volume.rgb.\
@@ -173,7 +168,6 @@ RGB_colourspace_visible_spectrum_coverage_MonteCarlo` definition unit tests
     ----------
     :cite:`Laurent2012a`
     """
-
     def test_RGB_colourspace_visible_spectrum_coverage_MonteCarlo(self):
         """
         Tests :func:`colour.volume.rgb.\
diff --git a/colour/volume/tests/test_spectrum.py b/colour/volume/tests/test_spectrum.py
index f7aeb67a..2328321e 100644
--- a/colour/volume/tests/test_spectrum.py
+++ b/colour/volume/tests/test_spectrum.py
@@ -31,7 +31,6 @@ class TestGeneratePulseWaves(unittest.TestCase):
     Defines :func:`colour.volume.spectrum.generate_pulse_waves`
     definition unit tests methods.
     """
-
     def test_generate_pulse_waves(self):
         """
         Tests :func:`colour.volume.spectrum.generate_pulse_waves`
@@ -71,7 +70,6 @@ class TestXYZOuterSurface(unittest.TestCase):
     Defines :func:`colour.volume.spectrum.XYZ_outer_surface`
     definition unit tests methods.
     """
-
     def test_XYZ_outer_surface(self):
         """
         Tests :func:`colour.volume.spectrum.XYZ_outer_surface`
@@ -122,7 +120,6 @@ class TestIsWithinVisibleSpectrum(unittest.TestCase):
     Defines :func:`colour.volume.spectrum.is_within_visible_spectrum`
     definition unit tests methods.
     """
-
     def test_is_within_visible_spectrum(self):
         """
         Tests :func:`colour.volume.spectrum.is_within_visible_spectrum`

Another thing I notice is that some line returns are being removed which produces rather unelegant formatting, I will open a new issue for that.

@KelSolaar
Copy link
Author

@gwelymernans : Btw is it possible to re-open the issue please?

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants