This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
a = (np.random.rand(1,10)) #create a random (1,10) array | |
result = np.zeros(10) #create an array of zeros to hold the result | |
result = (b.reshape(1,10))# reshape b to make sure its a (1,10) array and not (10,) | |
print ("a: \n" + str(a)) | |
for i in range(10): | |
if a[0,i]>0.5: | |
result[0,i] = 1 | |
else: | |
result[0,i] = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
a = (np.random.rand(1,10)) #create a random (1,10) array | |
print ("a: \n" + str(a)) | |
result = (np.where(a>0.5,1,0)) | |
print ("result: \n" +str(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a: | |
[[ 0.76456104 0.75182292 0.11825977 0.97635566 0.3220488 0.44064402 | |
0.08142387 0.65055208 0.88407891 0.40323535]] | |
result: | |
[[1 1 0 1 0 0 0 1 1 0]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
array = [[True, False], [True, True]] # (2,2) array of boolean values | |
array_cond_true = [[1, 2], [3, 4]] # (2,2) array of where to pick values if array at position is true | |
array_cond_false = [[9, 8], [7, 6]] # (2,2) array of where to pick values if array at position is false | |
print ("result: \n" + str(np.where(array, | |
array_cond_true, | |
array_cond_false))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result: | |
[[1 8] | |
[3 4]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import time | |
a = (np.random.rand(1,1000000)) #create a random (1,10) array | |
result1 = np.zeros((1,1000000),dtype=np.int) #create an array of zeros to hold the result | |
#print ("a: \n" + str(a)) | |
tic = time.time() | |
for i in range(1000000): | |
if a[0,i]>0.5: | |
result1[0,i] = 1 | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time passed for result1: 1.2310867309570312ms | |
time passed for result2: 0.014905214309692383ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.rideon.user.activities; | |
import android.content.Context; | |
import android.os.Bundle; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.ImageView; | |
import android.widget.TextView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class CompletableUseCase<in Params> constructor( | |
private val postExecutionThread: PostExecutionThread) { | |
private val disposables = CompositeDisposable() | |
protected abstract fun buildUseCaseCompletable(params: Params? = null): Completable | |
open fun execute(observer: DisposableCompletableObserver, params: Params? = null) { | |
val completable = this.buildUseCaseCompletable(params) | |
.subscribeOn(Schedulers.io()) |
OlderNewer