|
1016 | 1016 | " if not isinstance(self.__jitter, (int, float)):\n", |
1017 | 1017 | " raise ValueError(\"`jitter` must be a scalar or float.\")\n", |
1018 | 1018 | " if not isinstance(self.__palette, (str, Iterable)):\n", |
1019 | | - " raise ValueError(\"`palette` must be either a string or an Iterable.\")\n", |
| 1019 | + " raise ValueError(\"`palette` must be either a string indicating a color name or an Iterable.\")\n", |
1020 | 1020 | " if self.__hue is not None and not isinstance(self.__hue, str):\n", |
1021 | 1021 | " raise ValueError(\"`hue` must be either a string or None.\")\n", |
1022 | 1022 | " if self.__order is not None and not isinstance(self.__order, Iterable):\n", |
|
1041 | 1041 | " group_i, self.__x\n", |
1042 | 1042 | " )\n", |
1043 | 1043 | " raise IndexError(err)\n", |
| 1044 | + "\n", |
| 1045 | + " if isinstance(self.__palette, str) and self.__palette.strip() == \"\":\n", |
| 1046 | + " err = \"`palette` cannot be an empty string. It must be either a string indicating a color name or an Iterable.\"\n", |
| 1047 | + " raise ValueError(err)\n", |
1044 | 1048 | " if isinstance(self.__palette, dict):\n", |
1045 | | - " for group_i in self.__palette.keys():\n", |
| 1049 | + " # TODO: to add detection of when dict length is less than size of unique_items\n", |
| 1050 | + " for group_i, color_i in self.__palette.items():\n", |
1046 | 1051 | " if group_i not in pd.unique(data[color_col]):\n", |
1047 | 1052 | " err = (\n", |
1048 | 1053 | " \"{0} in `palette` is not in the '{1}' column of `data`.\".format(\n", |
1049 | 1054 | " group_i, color_col\n", |
1050 | 1055 | " )\n", |
1051 | 1056 | " )\n", |
1052 | 1057 | " raise IndexError(err)\n", |
| 1058 | + " if isinstance(color_i, str) and color_i.strip() == \"\":\n", |
| 1059 | + " err = \"The color mapping for {0} in `palette` is an empty string. It must contain a color name.\".format(group_i)\n", |
| 1060 | + " raise ValueError(err) \n", |
1053 | 1061 | "\n", |
1054 | 1062 | " if side.lower() not in [\"center\", \"right\", \"left\"]:\n", |
1055 | 1063 | " raise ValueError(\n", |
|
0 commit comments