|
394 | 394 | " f_jkl = ...\n",
|
395 | 395 | "```\n",
|
396 | 396 | "and collect these `f_jkl` values in a list of 27 values. Additionally, in Python, [`2j` produces a value with `real` and `imag` attributes](https://docs.python.org/3.7/library/cmath.html). Each element `f_jkl` should have these components. If you concatenate the `real` and `imag` parts of all the `f_jkl`, you will have a 54-dimensional representation, as in the paper. Remember to start with an HSV representation, and with $h$ in $[0, 360]$, $s$ in $[0, 200]$, and $v$ in $[0, 200]$ (or else do the scaling differently). Note that the values in our corpus are in HLS format, [which are easily converted to HSV](https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL).\n",
|
397 |
| - "\n" |
| 397 | + "\n", |
| 398 | + "The following test seeks to ensure only that the output of your `represent_color_context` will be compatible with the models we are creating:" |
| 399 | + ] |
| 400 | + }, |
| 401 | + { |
| 402 | + "cell_type": "code", |
| 403 | + "execution_count": null, |
| 404 | + "metadata": {}, |
| 405 | + "outputs": [], |
| 406 | + "source": [ |
| 407 | + "def test_represent_color_context(func):\n", |
| 408 | + " \"\"\"`func` should be `represent_color_context`\"\"\"\n", |
| 409 | + " example = [\n", |
| 410 | + " [0.786, 0.58, 0.87],\n", |
| 411 | + " [0.689, 0.44, 0.92],\n", |
| 412 | + " [0.628, 0.32, 0.81]]\n", |
| 413 | + " result = func(example)\n", |
| 414 | + " assert len(result) == len(example), \\\n", |
| 415 | + " (\"Color context representations need to represent each color \"\n", |
| 416 | + " \"separately. (We assume the final color is the target.)\")\n", |
| 417 | + " for i, color in enumerate(result):\n", |
| 418 | + " assert all(isinstance(x, float) for x in color), \\\n", |
| 419 | + " (\"All color representations should be lists of floats. \"\n", |
| 420 | + " \"Color {} is {}\".format(i, color))" |
| 421 | + ] |
| 422 | + }, |
| 423 | + { |
| 424 | + "cell_type": "code", |
| 425 | + "execution_count": null, |
| 426 | + "metadata": {}, |
| 427 | + "outputs": [], |
| 428 | + "source": [ |
| 429 | + "test_represent_color_context(represent_color_context)" |
398 | 430 | ]
|
399 | 431 | },
|
400 | 432 | {
|
|
0 commit comments