Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/v4_docs_review' into fea…
Browse files Browse the repository at this point in the history
…ture/v4_docs_review

# Conflicts:
#	docs/source/utilities/distances/euclidean_distances.rst
#	src/UQpy/utilities/distances/euclidean_distances/__init__.py
  • Loading branch information
dimtsap committed Apr 8, 2022
2 parents 2fdc01b + 823e331 commit 5401a7c
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 402 deletions.
313 changes: 97 additions & 216 deletions docs/source/utilities/distances/euclidean_distances.rst

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/UQpy/utilities/distances/baseclass/Distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

class Distance(ABC):
"""
This class serves as a baseclass under which the distance implementations for all spaces exist.
This is the baseclass for all distances in :py:mod:`UQpy`.
This serves as a blueprint to show the methods for distances implemented in the :py:mod:`.distances` module .
"""
def __init__(self):
self.distance_matrix: np.ndarray = None
Expand All @@ -24,7 +26,7 @@ def calculate_distance_matrix(self, points):
@abstractmethod
def compute_distance(self, xi, xj) -> float:
"""
Given a two points, this method calculates their distance. Each concrete distance implementation
Given two points, this method calculates their distance. Each concrete distance implementation
must override this method and provide its own implementation.
:param xi: First point.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EuclideanDistance(Distance, ABC):
@beartype
def calculate_distance_matrix(self, points: list[NumpyFloatArray]):
"""
Given a list of cartesian points calculates a matrix that contains the distances between them.
Given a list of cartesian points, calculates a matrix that contains the distances between them.
:param points: A list of cartesian points.
:return: :class:`.ndarray`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@

class BrayCurtisDistance(EuclideanDistance):
def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the Bray-Curtis distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""

return pdist([xi, xj], "braycurtis")[0]
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@
class CanberraDistance(EuclideanDistance):

def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the Canberra distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""

return pdist([xi, xj], "canberra")[0]
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
class ChebyshevDistance(EuclideanDistance):

def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the Chebyshev distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""
return pdist([xi, xj], "chebyshev")[0]
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@
class CityBlockDistance(EuclideanDistance):

def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the City Block (Manhattan) distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""

return pdist([xi, xj], "cityblock")[0]
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
class CorrelationDistance(EuclideanDistance):

def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the Correlation distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""
return pdist([xi, xj], "correlation")[0]
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@
class CosineDistance(EuclideanDistance):

def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the Cosine distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""

return pdist([xi, xj], "cosine")[0]
11 changes: 0 additions & 11 deletions src/UQpy/utilities/distances/euclidean_distances/DiceDistance.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@
class L2Distance(EuclideanDistance):

def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the Euclidean distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""

return pdist([xi, xj], "euclidean")[0]

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@


class MinkowskiDistance(EuclideanDistance):
def __init__(self, p=2):
def __init__(self, p: float = 2):
"""
:param p: Order of the norm.
"""
self.p = p


def compute_distance(self, xi: NumpyFloatArray, xj: NumpyFloatArray) -> float:
"""
Given two points, this method calculates the Minkowski distance.
:param xi: First point.
:param xj: Second point.
:return: A float representing the distance between the points.
"""
return pdist([xi, xj], "minkowski", p=self.p)[0]

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions src/UQpy/utilities/distances/euclidean_distances/YuleDistance.py

This file was deleted.

17 changes: 1 addition & 16 deletions src/UQpy/utilities/distances/euclidean_distances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,5 @@
from UQpy.utilities.distances.euclidean_distances.CityBlockDistance import CityBlockDistance
from UQpy.utilities.distances.euclidean_distances.CorrelationDistance import CorrelationDistance
from UQpy.utilities.distances.euclidean_distances.CosineDistance import CosineDistance
from UQpy.utilities.distances.euclidean_distances.DiceDistance import DiceDistance
from UQpy.utilities.distances.euclidean_distances.L2Distance import EuclideanDistance
from UQpy.utilities.distances.euclidean_distances.HammingDistance import HammingDistance
from UQpy.utilities.distances.euclidean_distances.JaccardDistance import JaccardDistance
from UQpy.utilities.distances.euclidean_distances.JensenShannonDistance import JensenShannonDistance
from UQpy.utilities.distances.euclidean_distances.KulczynskiDistance import KulczynskiDistance
from UQpy.utilities.distances.euclidean_distances.KulsinkiDistance import KulsinksiDistance
from UQpy.utilities.distances.euclidean_distances.MahalanobisDistance import MahalanobisDistance
from UQpy.utilities.distances.euclidean_distances.MatchingDistance import MatchingDistance
from UQpy.utilities.distances.euclidean_distances.L2Distance import L2Distance
from UQpy.utilities.distances.euclidean_distances.MinkowskiDistance import MinkowskiDistance
from UQpy.utilities.distances.euclidean_distances.RogersTanimotoDistance import RogersTanimotoDistance
from UQpy.utilities.distances.euclidean_distances.RussellRaoDistance import RussellRaoDistance
from UQpy.utilities.distances.euclidean_distances.SokalMichenerDistance import SokalMichenerDistance
from UQpy.utilities.distances.euclidean_distances.SokalSneathDistance import SokalSneathDistance
from UQpy.utilities.distances.euclidean_distances.SquaredEuclideanDistance import SquaredEuclideanDistance
from UQpy.utilities.distances.euclidean_distances.StandardizedEuclidean import StandardizedEuclideanDistance
from UQpy.utilities.distances.euclidean_distances.YuleDistance import YuleDistance
2 changes: 1 addition & 1 deletion src/UQpy/utilities/kernels/baseclass/Kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Kernel(ABC):
"""
This is the baseclass for all kernels in :py:mod:`UQpy`.
This serves a blueprint to show the methods for kernels implemented in the :py:mod:`.kernels` module .
This serves as a blueprint to show the methods for kernels implemented in the :py:mod:`.kernels` module .
"""
def __init__(self):
self.kernel_matrix: np.ndarray = None
Expand Down

0 comments on commit 5401a7c

Please sign in to comment.