Skip to content

Commit

Permalink
updated hash and eq methods for point and cleaned unix build script
Browse files Browse the repository at this point in the history
Signed-off-by: Debasish Kanhar <[email protected]>
  • Loading branch information
debasishdebs committed Mar 27, 2019
1 parent 76a19a4 commit 0f1c223
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
19 changes: 0 additions & 19 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ if [ -z "${PYTHON_PATH+x}" ]; then
fi
fi

#if command -v python3 --version &>/dev/null; then
# echo "Pre-requisite Python already installed. 'python3' command works"
#else
# echo "Pre-requisite python isn't installed on system. \
# Please check and make sure that 'python3' command works in shell"
# exit 1
#fi

if command -v virtualenv --version &>/dev/null; then
echo "Pre-requisite virtualenv already installed."
else
Expand All @@ -71,17 +63,6 @@ fi
echo "Creating virtualenv with -p=${PYTHON_PATH}"
virtualenv -p "${PYTHON_PATH}" "${ENV_NAME}"

# Create virtualenv now
#if [ -z "${PYTHON_PATH+x}" ]; then
# # When -p parameter is not provided
# echo "Creating virtualenv with -p python3"
# virtualenv -p python3 "${ENV_NAME}"
#else
# # When -p parameter for Python Path is provided.
# echo "Creating virtualenv with -p=${PYTHON_PATH}"
# virtualenv -p "${PYTHON_PATH}" "${ENV_NAME}"
#fi

chmod +x before-script.sh
./before-script.sh "${ENV_NAME}"

Expand Down
11 changes: 5 additions & 6 deletions src/main/python/janusgraph_python/core/datatypes/Point.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def __are_coordinates_valid(self):

return abs(self.getLatitude()) <= 90.0 and abs(self.getLongitude()) <= 180.0

def __key(self):
return tuple(self.getCoordinates())

def __eq__(self, other):
"""
Overrides the default class equality method.
Expand All @@ -82,14 +85,10 @@ def __eq__(self, other):
bool
"""

if type(other) is Point:
return (other.getLatitude().__eq__(self.getLatitude())) and \
(other.getLongitude().__eq__(self.getLongitude()))

return False
return isinstance(self, type(other)) and self.__key() == other.__key()

def __hash__(self):
return hash(self.getLatitude()) ^ hash(self.getLongitude())
return hash(self.__key())

def __str__(self):
return "POINT(lat: {}, lon: {})".format(self.getLatitude(), self.getLongitude())
Expand Down

0 comments on commit 0f1c223

Please sign in to comment.