Skip to content

Instantly share code, notes, and snippets.

View Bhoomi17's full-sized avatar

Bhoomika Sharma Bhoomi17

  • Megh Computing
  • Bangalore
View GitHub Profile
import sys
import pandas as pd
import numpy as np
import scipy.sparse as sparse
from scipy.sparse.linalg import spsolve
import random
from sklearn.preprocessing import MinMaxScaler
import implicit
@Bhoomi17
Bhoomi17 / ScalaEnum.scala
Created November 13, 2017 13:28 — forked from viktorklang/ScalaEnum.scala
DIY Scala Enums (with optional exhaustiveness checking)
trait Enum { //DIY enum type
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia
type EnumVal <: Value //This is a type that needs to be found in the implementing class
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal
private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS}
val oldVec = get