Skip to content

Commit 0f5ccd5

Browse files
committed
add support for serialization
1 parent 462d0ce commit 0f5ccd5

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

pod_rbf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .pod_rbf import *
22

3-
__version__ = "1.2.1"
3+
__version__ = "1.3.0"

pod_rbf/pod_rbf.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import numpy as np
99
from tqdm import tqdm
10-
from numba import jit, njit, prange
10+
import pickle
1111

1212

1313
class pod_rbf:
@@ -311,3 +311,39 @@ def buildSnapshotMatrix(mypath_pattern,
311311
i += 1
312312

313313
return snapshot
314+
315+
316+
def save_model(filename, model):
317+
"""Save the model. Uses Pythons pickle module.
318+
319+
Parameters
320+
----------
321+
filename_pattern : string
322+
The full path of the model to be saved.
323+
324+
Returns
325+
-------
326+
None
327+
"""
328+
file = open(filename, 'ab')
329+
pickle.dump(model, file)
330+
file.close()
331+
332+
333+
def load_model(filename):
334+
"""Load the model.
335+
336+
Parameters
337+
----------
338+
filename_pattern : string
339+
The full path of the file that has the model saved.
340+
341+
Returns
342+
-------
343+
object
344+
The model object.
345+
"""
346+
file = open(filename, 'rb')
347+
model = pickle.load(file)
348+
file.close()
349+
return model

0 commit comments

Comments
 (0)