(dataset)
| 167 | |
| 168 | |
| 169 | def _load_example_data(dataset): |
| 170 | dataset_path = DATA_DIR.joinpath(dataset) |
| 171 | if not dataset_path.is_file(): |
| 172 | if not DATA_DIR.is_dir(): |
| 173 | DATA_DIR.mkdir() |
| 174 | _download_example_data(dataset_path) |
| 175 | |
| 176 | try: |
| 177 | geo_data = pickle.loads(dataset_path.read_bytes()) |
| 178 | except Exception as e: |
| 179 | raise HypertoolsIOError( |
| 180 | f"Failed to load '{dataset}' data. Try deleting cached file at" |
| 181 | f"{dataset_path} and reloading." |
| 182 | ) from e |
| 183 | |
| 184 | if dataset == 'mushrooms': |
| 185 | # format mushrooms dataset as a pandas DataFrame |
| 186 | geo_data.data = pd.DataFrame(geo_data.data) |
| 187 | return geo_data |
| 188 | |
| 189 | |
| 190 | def _download_example_data(dataset_path): |
no test coverage detected