Skip to content

Instantly share code, notes, and snippets.

View kevinavery's full-sized avatar
📈
Trending

Kevin Avery kevinavery

📈
Trending
View GitHub Profile
import numpy as np
def loadSparseMatrix(filename):
"""
Loads the sparse matrix in text file `filename` assuming the
Matlab format.
Each row of the file should specify the non-zero value
at a particular location, using 1 based indexes, formatted as follows:

Keybase proof

I hereby claim:

  • I am kevinavery on github.
  • I am kevinavery (https://keybase.io/kevinavery) on keybase.
  • I have a public key whose fingerprint is 26E7 4974 94DB FA04 6D14 1290 8163 3BC4 0346 03D4

To claim this, I am signing this object:

import akka.stream.{Attributes, Outlet, Inlet, FlowShape}
import akka.stream.stage.{OutHandler, InHandler, GraphStageLogic, GraphStage}
import akka.util.ByteString
/**
* Converts a stream of ByteString into a stream of Strings based on newlines.
*/
class BytesToLinesFlow extends GraphStage[FlowShape[ByteString, String]] {
val in = Inlet[ByteString]("BytesToLinesFlow.in")
val out = Outlet[String]("BytesToLinesFlow.out")