This file contains hidden or 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
# Albert Cardona 2015-06-02 | |
# Test the speed up provided by just-in-time compilation of python code | |
# using the numba JIT framework. | |
# The operation to test is a trivial one: the difference of the logarithm, | |
# pairwise, in two arrays of randomly generated floating-point numbers. | |
# For a far more realistic test involving a python implementation of | |
# the non-uniform fast fourier transform, see: | |
# https://jakevdp.github.io/blog/2015/02/24/optimizing-python-with-numpy-and-numba/ | |
# | |
# To resolve issues with numba compilation (mostly type mismatches), see: |
This file contains hidden or 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
# Albert Cardona 2012-09-06 | |
# Animate an Orthoslice view of an image volume in the 3D Viewer | |
# and record it into an ImageStack. | |
# Assumes that the Orthoslice view is already present in the 3D Viewer | |
# and then the scripts limits itself to iterating through the slices in a specific axis | |
# and to rotate when desired. | |
from ij3d import Image3DUniverse | |
from math import radians |
This file contains hidden or 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
; Albert Cardona, 2012-09-08 | |
; http://albert.rierol.net/clojure-monads.html | |
(ns my.parse.bib5 | |
(:use [clojure.algo.monads :only [domonad with-monad state-t maybe-m fetch-state set-state m-seq m-plus m-result]]) | |
(:use [clojure.string :only [lower-case]]) | |
(:use [clojure.pprint :only [pprint]])) | |
(set! *warn-on-reflection* true) |
This file contains hidden or 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
// Goal: a virtual image (a function, if you want) | |
// with dimensions 512, 512 | |
// and a background of value 0 | |
// and a ROI of dimensions 200, 200 at position 100, 100 | |
// filled with a value 127. | |
// ERROR: the ROI has the right dimensions | |
// but its top-left is positioned with negative coordinates. | |
// A virtual image with a ROI filled with value 127 |
This file contains hidden or 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
(ns my.numeric.test | |
(:import [fiji.scripting Weaver])) | |
(def a (ref nil)) | |
; Compile once | |
(def w (Weaver/inline | |
"int n = ((Number)ref.deref()).intValue(); | |
double sum = 0; | |
for (int i=0; i<n; ++i) { |
This file contains hidden or 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
(ns my.numeric.test) | |
(def a (ref nil)) | |
(defn ^double sum | |
[^double a | |
^double b] | |
(+ a b)) | |
(defn w1 |
This file contains hidden or 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
(ns my.test | |
(:import [javax.swing JFrame JPanel JButton JLabel] | |
[java.awt Dimension] | |
[java.awt.event ActionListener])) | |
(defn parse | |
[^String s] | |
(println (eval (read-string s)))) | |
(let [^JLabel input (JLabel. "[255 255 255]")] |
This file contains hidden or 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
; find-all-to-all returns a lazy list of lists of object instances | |
; and we want a map of instance vs. number of appearances | |
; This one blows up RAM: | |
(apply merge-with + | |
(map #(zipmap % (repeat 1)) | |
(find-all-to-all-paths nodes degrees))) |