Skip to content

Commit

Permalink
Renamed colorsynth.srgb() to colorsynth.sRGB().
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie committed Nov 16, 2023
1 parent c5dd8f2 commit 6db2822
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions colorsynth/_colorsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"XYZcie1931_from_spd",
"xyY_from_XYZ_cie",
"XYZ_from_xyY_cie",
"srgb",
"sRGB",
]


Expand Down Expand Up @@ -368,7 +368,7 @@ def XYZ_from_xyY_cie(
return result


def srgb(
def sRGB(
XYZ: np.ndarray,
axis: int = -1,
) -> np.ndarray:
Expand Down Expand Up @@ -413,7 +413,7 @@ def srgb(
# Convert the tristimulus values into sRGB, the standard used in most
# computer monitors
rgb = colorsynth.srgb(XYZ)
rgb = colorsynth.sRGB(XYZ)
# Plot the result as an image
plt.figure();
Expand All @@ -439,7 +439,7 @@ def srgb(
XYZ = XYZ * np.array([0.9505, 1.0000, 1.0890])[..., np.newaxis]
# Convert the tristimulus values into sRGB
r, g, b = np.clip(colorsynth.srgb(XYZ, axis=0), 0, 10)
r, g, b = np.clip(colorsynth.sRGB(XYZ, axis=0), 0, 10)
plt.figure();
plt.plot(wavelength, r, color="red");
Expand Down Expand Up @@ -467,7 +467,7 @@ def srgb(
]
XYZ = np.stack(XYZ, axis=-1)
rgb = colorsynth.srgb(XYZ, axis=-1)
rgb = colorsynth.sRGB(XYZ, axis=-1)
# rgb = np.clip(rgb, 0, 1)
# rgb[X < 0] = 1
Expand Down
4 changes: 2 additions & 2 deletions colorsynth/_tests/test_colorsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def test_XYZ_from_xyY_cie(

@pytest.mark.parametrize("XYZ", XYZ)
@pytest.mark.parametrize(argnames="axis", argvalues=[-1])
def test_srgb(
def test_sRGB(
XYZ: np.ndarray,
axis: int,
):
result = colorsynth.srgb(XYZ, axis=axis)
result = colorsynth.sRGB(XYZ, axis=axis)
assert isinstance(result, np.ndarray)
assert result.shape[axis] == 3

0 comments on commit 6db2822

Please sign in to comment.