Skip to content

Commit

Permalink
Merge pull request #109 from mtralka/master
Browse files Browse the repository at this point in the history
 Add str return to model results
  • Loading branch information
TaylorOshan committed Nov 11, 2021
2 parents 47af2ac + cb135b3 commit 69bbba1
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions mgwr/gwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
__author__ = "Taylor Oshan Tayoshan@gmail.com"

import copy
from typing import Optional
import numpy as np
import numpy.linalg as la
from scipy.stats import t
Expand Down Expand Up @@ -1247,13 +1248,29 @@ def predictions(self):
predictions = np.sum(P * self.params, axis=1).reshape((-1, 1))
return predictions

def summary(self):
def summary(self, as_str: bool = False) -> Optional[str]:
"""
Print out GWR summary
Parameters
----------
as_str : bool
optional parameters to specify that summary results
should be returned as str and not printed to stdout
Returns
-------
summary : Optional[str]
optional GWR summary string if `as_str` is True
"""
summary = summaryModel(self) + summaryGLM(self) + summaryGWR(self)

if as_str:
return summary

print(summary)
return
return None


class GWRResultsLite(object):
Expand Down Expand Up @@ -2116,10 +2133,26 @@ def tqdm(x, desc=''): # otherwise, just passthrough the range
p_vals = (np.sum(np.array(SDs) > init_sd, axis=0) / float(n_iters))
return p_vals

def summary(self):
def summary(self, as_str: bool=False) -> Optional[str]:
"""
Print out MGWR summary
Parameters
----------
as_str : bool
optional parameters to specify that summary results
should be returned as str and not printed to stdout
Returns
-------
summary : Optional[str]
optional MGWR summary string if `as_str` is True
"""
summary = summaryModel(self) + summaryGLM(self) + summaryMGWR(self)

if as_str:
return summary

print(summary)
return

0 comments on commit 69bbba1

Please sign in to comment.