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

Pickling issue with Python 3.7 #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.idea/
.DS_Store

# datasets
_datasets/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
37 changes: 36 additions & 1 deletion mlgeo/datasets.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# -- Imports ------------------------------------------------------------------
import sys
import os
import pickle
if sys.version_info.minor <= 7:
import pickle5 as pickle
else:
import pickle
import urllib.request
import mlgeo
import pandas as pd



# -- Main Functions -----------------------------------------------------------
Expand Down Expand Up @@ -31,3 +37,32 @@ def load_slt():
data = pickle.load(handle)

return data

def load_isfogpiledriving(kind="featurematrix"):
"""
Loads the ISFOG2020 pile driving dataset from the module directory (if previously downloaded)
or from the remote repository.

:param kind: Kind of data to download. If equal to ``"featurematrix"`` the featurematrix with pile dimensions, hammer performance and CPT data is downloaded. If equal to ``"fullcpt"`` the full CPT data is downloaded.

:returns: Pandas dataframe with the data loaded from csv
"""
if kind == "featurematrix":
filename = "all_data_withnormalised.csv"
elif kind == "fullcpt":
filename = "full_cpt_data_withnormalised.csv"
else:
raise IOError("Argument kind must be one of 'featurematrix' or 'fullcpt'")

if not os.path.isfile(os.path.join(mlgeo.dataset_path, filename)):
print('-- Downloading dataset... Do not forget to cite authors. --')

url = 'https://mlgeo-datasets.s3.eu-central-1.amazonaws.com/isfog-piledriving/' + filename
urllib.request.urlretrieve(
url, os.path.join(mlgeo.dataset_path, filename))

print('-- Done --')

data = pd.read_csv(os.path.join(mlgeo.dataset_path, filename))

return data
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
],
python_requires='>=3.7',
install_requires=[
'numpy>=1.19'
'numpy>=1.19',
'pickle5',
'pandas'
]
)