How can I apply a decorator to an imported function? [duplicate]
Suppose I have imported a function:from random import randintand then want to apply a decorator to it. Is there some syntactic sugar for this, perhaps something like so?@decoratorrandintOr do I have...
View ArticleHow to filter rows of a numpy array
I am looking to apply a function to each row of a numpy array. If this function evaluates to True I will keep the row, otherwise I will discard it. For example, my function might be:def f(row): if...
View ArticleHaving trouble escaping quotes and braces
I am trying to execute the following line in Command Prompt:curl -X POST -d '{ "method" : "account_info", "params" : [ { "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"} ] }'...
View ArticleProgrammatically get current IPython notebook cell output?
I have an imported function that runs in an IPython notebook (input cell X) which produces an output (in output cell X). After the function runs, I have some more code (also in input cell X); is there...
View ArticlePandas - Writing an excel file containing unicode - IllegalCharacterError
I have the following code:import pandas as pdx = [u'string with some unicode: \x16']df = pd.DataFrame(x)If I try to write this dataframe as an excel file:df.to_excel("test.xlsx")Or, if I try to write...
View ArticleUsing multiprocessing with a decorated function results in a PicklingError
I am trying to write a convenience function based on the multiprocessing library, that takes any function and argument, and runs that function using multiple processes. I have the following file...
View Articlepython exec command does not pick up globals with custom scope?
Consider the following code:code = '''s = "hi"def x(): print(s)x()'''# does not workexec(code, {}, {})# worksexec(code, globals(), locals()) # worksWhen we use exec with custom globals and locals it...
View ArticleTensorflow - replicating model over multiple GPUs and sharing variables?
I am trying to run a simple feed-forward network on multiple GPUs (to asynchronously updated shared weights).However, I am unable to get the weights to be shared.From the research I've done I just need...
View ArticleDisplay "long" pandas dataframe in jupyter notebook with "foldover" (wrapping)?
Let's say I have a pandas dataframe with many columns:I can view all of the columns by scrolling left/right. However, this is a bit inconvenient and I was wondering if there was an elegant way to...
View ArticleWhat is the right cloud service(s) for real-time streaming and backtesting...
I wish to record time series data at a very high frequency. I am wondering if there is a elegant serverless solution that allows me to store, and react to real-time data.I want to use stored data to...
View Articletensorflow tensor operations - tiling with dimension object does not work?
I Have a matrix M:[[101, 51, 12], [101, 19, 18]]Long story short, I need to create the following with tensorflow syntax:[[0, 0, 101], [0, 1, 51], [0, 2, 12], [1, 0, 101], [1, 1, 19], [1, 2, 18]]My...
View ArticleTensorflow, how to ensure that everything runs purely in the GPU?
My understanding is that tensorflow will take a computation graph and run it on both the gpu and cpu to max usage. How can I ensure that my code runs on the gpu only?
View ArticleRecursive regex in python regex module?
I would like to capture all [[A-Za-z].]+ in my string, that is, all repeats of a alphabetic character followed by a dot.So for example, in "ABC A.B.C. UVWX U.V.W.X. XYZ XY.Z."I would like to pull out...
View ArticleWordpress - How can I allow authors/contributors to edit only a specific...
I created a simple wordpress plugin today which is essentially an options page. It is based on the instructions at this link: http://codex.wordpress.org/Creating_Options_Pages (there is example code at...
View ArticleRegex - require a specific digit to be contained in \d+?
Consider the python code:import rere.findall('[0-9]+', 'XYZ 102 1030')which returns:['102', '1030']Can one write a regex that requires at least one occurance of the digit 3, i.e. I am interested in...
View ArticleIs it possible to include multiple custom js files for Jupyter notebook?
I know I can add custom javascript to Jupyer notebooks by adding them to:.jupyter/custom/custom.jsHowever, is there a way to have multiple javascript files that are all loaded,...
View ArticleHow to specify difftool_args for git-difftool?
I am trying to use a custom diff tool for git diff. The following command does the job:git difftool --tool nbdime "file.ipynb"This starts up a diff viewer on the web, with the following...
View ArticlePython multiprocessing apply_async never returns result on Windows 7
I am trying to follow a very simple multiprocessing example:import multiprocessing as mpdef cube(x): return x**3pool = mp.Pool(processes=2)results = [pool.apply_async(cube, args=x) for x in...
View ArticleCelery - Completes task but never returns result
I've just installed Celery and am trying to follow the tutorial:I have a file called tasks.py with the following code:from celery import Celeryapp = Celery('tasks', backend='amqp',...
View ArticleParsing numerical data using Prolog?
I am new to prolog and am considering using it for a small data analysis application. Here is what I am seeking to accomplish:I have a CSV file with some data of the following...
View Article