Skip to content

Commit

Permalink
Fix conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest committed Mar 1, 2019
1 parent 8aa875b commit 9d288ed
Show file tree
Hide file tree
Showing 735 changed files with 184,316 additions and 4,771 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Thanks goes to these ❤️ wonderful people who made this possible:
| [<img src="https://avatars3.githubusercontent.com/u/23060327?v=4" width="100px;"/><br /><sub>Navendu Gupta</sub>](https://github.com/navendu29)<br /> | [<img src="https://avatars1.githubusercontent.com/u/22820957?v=4" width="100px;"/><br /><sub>Sirjanpreet Singh Banga</sub>](https://github.com/sirjan13)<br /> | [<img src="https://avatars0.githubusercontent.com/u/11931391?v=4" width="100px;"/><br /><sub>Daniela Ruz</sub>](https://github.com/druzmieres)<br /> | [<img src="https://avatars1.githubusercontent.com/u/32430978?v=4" width="100px;"/><br /><sub>aman-mi</sub>](https://github.com/aman-mi)<br /> | [<img src="https://avatars3.githubusercontent.com/u/6378532?v=4" width="100px;"/><br /><sub>Anurag El Dorado</sub>](https://github.com/aedorado)<br /> | [<img src="https://avatars2.githubusercontent.com/u/23054280?v=4" width="100px;"/><br /><sub>charul97</sub>](https://github.com/charul97)<br /> |
[<img src="https://avatars1.githubusercontent.com/u/26293279?v=4&s=460" width="100px;"/><br /><sub>Manan Manwani</sub>](https://github.com/manan904)<br /> | [<img src="https://avatars3.githubusercontent.com/u/22936570?v=4&s=400" width="100px;"/><br /><sub>Bhavesh Anand</sub>](https://github.com/bhaveshAn)<br /> | [<img src="https://avatars2.githubusercontent.com/u/24618078?v=4&s=400" width="100px;"/><br /><sub>Prashant Nigam</sub>](https://github.com/prashant0598)<br /> | [<img src="https://avatars2.githubusercontent.com/u/20587669?v=4&s=460" width="100px;"/><br /><sub>Vítor Gomes Chagas</sub>](https://github.com/Vitorvgc)<br /> | [<img src="https://avatars3.githubusercontent.com/u/12906090?v=4&s=460" width="100px;"/><br /><sub>Amit Singh</sub>](https://github.com/amitsin6h)<br /> | [<img src="https://avatars0.githubusercontent.com/u/6058114?v=4&s=400" width="100px;"/><br /><sub>Alabhya Vaibhav</sub>](https://github.com/AlabhyaVaibhav)<br /> |
[<img src="https://avatars1.githubusercontent.com/u/30810402?s=460&v=4" width="100px;"/><br /><sub>Arnav Borborah</sub>](https://github.com/arnavb)<br /> | [<img src="https://avatars2.githubusercontent.com/u/28451366?s=400&v=4" width="100px;"/><br /><sub>Yatharth Shah</sub>](https://github.com/yatharthshahjpr)<br /> | [<img src="https://avatars2.githubusercontent.com/u/16862997?v=4" width="100px;"/> <br /><sub>David Wu</sub>](https://github.com/Pl4gue)<br /> | [<img src="https://avatars3.githubusercontent.com/u/16002727?v=4" width="100px;"/> <br /><sub>Mohit Khare</sub>](https://github.com/mkfeuhrer)<br /> | [<img src="https://avatars0.githubusercontent.com/u/14811383?v=4" width="100px"/><br /><sub>Saif Ahmad</sub>](https://github.com/the-saif-ahmad)<br /> | [<img src="https://avatars0.githubusercontent.com/u/22833885?v=4" width="100px"/><br /><sub>Sanchit Jalan</sub>](https://github.com/Sanchit-20)<br /> |
[<img src="https://avatars3.githubusercontent.com/u/4724181?v=4" width="100px;"/><br /><sub>Yogesh Badhe</sub>](https://github.com/warlockz)<br /> |
[<img src="https://avatars3.githubusercontent.com/u/4724181?v=4" width="100px;"/><br /><sub>Yogesh Badhe</sub>](https://github.com/warlockz)<br /> | [<img src="https://avatars2.githubusercontent.com/u/31393258?s=460&v=4" width="100px;"/><br /><sub>Garvit Kothari</sub>](https://github.com/Garvit-k)<br /> |
<!-- ALL-CONTRIBUTORS-LIST:END -->
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.vscode
.vscode

.DS_Store
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ matrix:
- pip install namanager
- namanager -s third_party/namanager_settings.json --required

# Autoformat Python code
- os: linux
language: python
python: 3.6
script:
- pip install black
- ./scripts/python_code_style_checker.sh

before_install:
- eval "${MATRIX_EVAL}"

Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
UNCLASSIFIED = False
NOISE = None

def _dist(p,q):
return math.sqrt(np.power(p-q,2).sum())

def _eps_neighborhood(p,q,eps):
return _dist(p,q) < eps
def _dist(p, q):
return math.sqrt(np.power(p - q, 2).sum())


def _eps_neighborhood(p, q, eps):
return _dist(p, q) < eps


def _region_query(m, point_id, eps):
n_points = m.shape[1]
seeds = []
for i in range(0, n_points):
if _eps_neighborhood(m[:,point_id], m[:,i], eps):
if _eps_neighborhood(m[:, point_id], m[:, i], eps):
seeds.append(i)
return seeds


def _expand_cluster(m, classifications, point_id, cluster_id, eps, min_points):
seeds = _region_query(m, point_id, eps)
if len(seeds) < min_points:
Expand All @@ -36,14 +40,17 @@ def _expand_cluster(m, classifications, point_id, cluster_id, eps, min_points):
if len(results) >= min_points:
for i in range(0, len(results)):
result_point = results[i]
if classifications[result_point] == UNCLASSIFIED or \
classifications[result_point] == NOISE:
if (
classifications[result_point] == UNCLASSIFIED
or classifications[result_point] == NOISE
):
if classifications[result_point] == UNCLASSIFIED:
seeds.append(result_point)
classifications[result_point] = cluster_id
seeds = seeds[1:]
return True


def dbscan(m, eps, min_points):
"""Implementation of Density Based Spatial Clustering of Applications with Noise
See https://en.wikipedia.org/wiki/DBSCAN
Expand All @@ -65,22 +72,29 @@ def dbscan(m, eps, min_points):
n_points = m.shape[1]
classifications = [UNCLASSIFIED] * n_points
for point_id in range(0, n_points):
point = m[:,point_id]
point = m[:, point_id]
if classifications[point_id] == UNCLASSIFIED:
if _expand_cluster(m, classifications, point_id, cluster_id, eps, min_points):
if _expand_cluster(
m, classifications, point_id, cluster_id, eps, min_points
):
cluster_id = cluster_id + 1
return classifications


# def test_dbscan():
# m = np.matrix('1 1.2 0.8 3.7 3.9 3.6 10; 1.1 0.8 1 4 3.9 4.1 10')
# eps = 0.5
# min_points = 2
# assert dbscan(m, eps, min_points) == [1, 1, 1, 2, 2, 2, None]


def main():
m = np.matrix('-0.99 -0.98 -0.97 -0.96 -0.95 0.95 0.96 0.97 0.98 0.99; 1.1 1.09 1.08 1.07 1.06 1.06 1.07 1.08 1.09 1.1')
eps = 1
min_points = 3
print(dbscan(m, eps, min_points))
m = np.matrix(
"-0.99 -0.98 -0.97 -0.96 -0.95 0.95 0.96 0.97 0.98 0.99; 1.1 1.09 1.08 1.07 1.06 1.06 1.07 1.08 1.09 1.1"
)
eps = 1
min_points = 3
print(dbscan(m, eps, min_points))


main()
Loading

0 comments on commit 9d288ed

Please sign in to comment.