Displaying 20 results from an estimated 3115 matches for "fn".
Did you mean:
mfn
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
...insertions(+), 82 deletions(-)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index c5cc4bd..5ece97a 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -209,7 +209,6 @@ py_config (const char *key, const char *value)
FILE *fp;
PyObject *modname;
PyObject *fn;
- PyObject *args;
PyObject *r;
if (!script) {
@@ -258,17 +257,8 @@ py_config (const char *key, const char *value)
/* Other parameters are passed to the Python .config callback. */
PyErr_Clear ();
- args = PyTuple_New (2);
-#ifdef HAVE_PYSTRING_FROMSTRING
- PyTuple_SetItem...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...a0e9 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -389,51 +389,66 @@ py_config_complete (void)
return 0;
}
+/* All per-connection state */
+typedef struct ConnHandle {
+ PyObject *obj;
+ int fua;
+} ConnHandle;
+
static void *
py_open (int readonly)
{
PyObject *fn;
- PyObject *handle;
+ ConnHandle *h = malloc (sizeof *h);
+ if (!h) {
+ nbdkit_error ("%s: %m", script);
+ return NULL;
+ }
if (!callback_defined ("open", &fn)) {
nbdkit_error ("%s: missing callback: %s", script, "open");
+ free (h)...
2019 Aug 13
0
[PATCH libnbd 3/4] lib: Add FREE_CALLBACK macro.
...00644
--- a/generator/states-reply-simple.c
+++ b/generator/states-reply-simple.c
@@ -69,9 +69,7 @@
cmd->offset, LIBNBD_READ_DATA,
&error) == -1)
cmd->error = error ? error : EPROTO;
- if (cmd->cb.fn.chunk.free)
- cmd->cb.fn.chunk.free (cmd->cb.fn.chunk.user_data);
- cmd->cb.fn.chunk.callback = NULL; /* because we've freed it */
+ FREE_CALLBACK (cmd->cb.fn.chunk);
}
SET_NEXT_STATE (%^FINISH_COMMAND);
diff --git a/generator/states-reply-structured.c b...
2010 Apr 27
1
suggestion on method dispatch
Dear all, I have define a function and its methods as follows:
######## beginning of code
fn <- function(x,...){
UseMethod("fn")
}
fn.foo1 <- function(x, commonA=1, ...){
print("fn.foo1 is called.")
}
fn.foo2 <- function(x, uniqueFoo2, common=1, ...){
## uniqueFoo2 is a unique argument in fn.foo2
x <- uniqueFoo2; class(x) <- "foo1"
## use uniq...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...c
> @@ -389,51 +389,66 @@ py_config_complete (void)
> return 0;
> }
>
> +/* All per-connection state */
> +typedef struct ConnHandle {
> + PyObject *obj;
> + int fua;
> +} ConnHandle;
> +
> static void *
> py_open (int readonly)
> {
> PyObject *fn;
> - PyObject *handle;
> + ConnHandle *h = malloc (sizeof *h);
>
> + if (!h) {
> + nbdkit_error ("%s: %m", script);
> + return NULL;
> + }
> if (!callback_defined ("open", &fn)) {
> nbdkit_error ("%s: missing callback: %s&qu...
2018 Apr 06
6
[nbdkit PATCH 0/2] Python cleanups
I noticed these while working on adding fua support into python,
these are independent enough to push now (and I'll have to rebase
my 'optional may_trim' patch on top of this).
Eric Blake (2):
python: Use Py_XDEFREF()
python: Simplify calling into plugin
plugins/python/python.c | 106 ++++++++----------------------------------------
1 file changed, 18 insertions(+), 88
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for
reference, I added 'zero' support for python, perl, and ruby
back in 1.1.13, then Rich had to add it for ocaml in 1.1.20).
I tested this heavily under python 2, but for now only compile
tested under python 3; I plan to do further testing there and
make any tweaks if necessary.
I wrote patch 5 early on, but then realized I
1999 Mar 29
3
problems with formals and get (PR#151)
With 0.63.3, try
test <- function(){
fn <- function(a) print("hello")
print(is.function(fn))
print(names(formals("fn")))}
test()
if fn is not quoted in the last line of test, it works properly.
test <- function(){
fn <- function() print("hello")
formals(fn) <- alist(a=,b=)
return(fn)}
form...
2007 Apr 25
4
How to solve difficult equations?
This below is not solvable with uniroot to find "a":
fn=function(a){
b=(0.7/a)-a
(1/(a+b+1))-0.0025
}
uniroot(fn,c(-500,500)) gives
"Error in uniroot(fn, c(-500, 500)) : f() values at end points not of
opposite sign"
I read R-help posts and someone wrote a function:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/92407.html
but it is not ver...
2009 Sep 21
3
Create directory and copy files in R
HI, All R users,
My problem is:
> fn
[1] "C:/Documents and Settings/lma/Desktop/FamilyAEntrepreneurs/Entrepreneurs/Juha/book_log-20041210T095019.txt"
> dpath
[1] "C:/Documents and Settings/lma/My Documents/Juha/book"
I want to make a function "cyfun" to copy all files in "dir" to "des...
2019 May 03
2
R optim(method="L-BFGS-B"): unexpected behavior when working with parent environments
Yes, I think you are right. I was at first confused by the fact that after the optim() call,
> environment(fn)$xx
[1] 10
> environment(fn)$ret
[1] 100.02
so not 9.999, but this could come from x being assigned the final value without calling fn.
-pd
> On 3 May 2019, at 11:58 , Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>
> Your results below make it look like a bug in optim(...
2019 Jun 13
4
Need help on identifying a patch which fixed lld on linux platform
...st.o
${AR} cq static/libst.a static/st.o
${CC} ${CFLAGS} -c main.c -o main.o
${CC} ${CFLAGS} ${LDFLAGS} -o main -Lshared -lsh -Lstatic -lst main.o
-Wl,-rpath=shared
[[ main.c ]]
void gn();
int main()
{
gn();
return 0;
}
[[ shared/sh.c ]]
#include <stdio.h>
void gn(void);
void fn(void);
void gn()
{
printf("Calling gn...\n");
fn();
}
[[ static/st.c ]]
#include <stdio.h>
void fn(void);
void fn()
{
printf("Calling fn...\n");
}
Code flow:
main -> gn (shared library) -> fn (part of the static lib)
Result:
With llvm 5.0
./main...
2019 May 06
2
R optim(method="L-BFGS-B"): unexpected behavior when working with parent environments
Optim's Nelder-Mead works correctly for this example.
> optim(par=10, fn=fn, method="Nelder-Mead")
x=10, ret=100.02 (memory)
x=11, ret=121 (calculate)
x=9, ret=81 (calculate)
x=8, ret=64 (calculate)
x=6, ret=36 (calculate)
x=4, ret=16 (calculate)
x=0, ret=0 (calculate)
x=-4, ret=16 (calculate)
x=-4, ret=16 (memory)
x=2, ret=4 (calculate)
x=-2, ret=4 (calculate...
2019 Jun 11
3
[nbdkit PATCH 0/2] Few rust plugin fixups/nitpicks
There are few more things that could be cleaned up related to the coding style
and other things, like explicitly specifying the abi style after "extern"
(i.e. `extern "C" fn` instead of `extern fn`), but since those are configurable
in rustfmt config, I'm not sure whether the config needs to be added or
complying with the defaults should be the priority. But this was just something
I stumbled upon when I saw some warnings during build, nothing more.
Martin Kletza...
2019 Jun 13
2
Need help on identifying a patch which fixed lld on linux platform
...t; -Wl,-rpath=shared
>>
>> [[ main.c ]]
>>
>> void gn();
>>
>> int main()
>> {
>> gn();
>> return 0;
>> }
>>
>> [[ shared/sh.c ]]
>>
>> #include <stdio.h>
>>
>> void gn(void);
>> void fn(void);
>>
>> void gn()
>> {
>> printf("Calling gn...\n");
>> fn();
>> }
>>
>> [[ static/st.c ]]
>>
>> #include <stdio.h>
>>
>> void fn(void);
>>
>> void fn()
>> {
>> printf(&q...
2019 May 02
2
R optim(method="L-BFGS-B"): unexpected behavior when working with parent environments
Dear all,
when using optim() for a function that uses the parent environment, I
see the following unexpected behavior:
makeFn <- function(){
??? xx <- ret <- NA
??? fn <- function(x){
?????? if(!is.na(xx) && x==xx){
?????????? cat("x=", xx, ", ret=", ret, " (memory)", fill=TRUE, sep="")
?????????? return(ret)
?????? }
?????? xx <<- x; ret <<- sum(x^2)...
2019 May 03
2
R optim(method="L-BFGS-B"): unexpected behavior when working with parent environments
On 03/05/2019 10:31, Serguei Sokol wrote:
> On 02/05/2019 21:35, Florian Gerber wrote:
>> Dear all,
>>
>> when using optim() for a function that uses the parent environment, I
>> see the following unexpected behavior:
>>
>> makeFn <- function(){
>> ???? xx <- ret <- NA
>> ???? fn <- function(x){
>> ??????? if(!is.na(xx) && x==xx){
>> ??????????? cat("x=", xx, ", ret=", ret, " (memory)", fill=TRUE, sep="")
>> ??????????? return(ret)
>...
2019 Aug 13
8
[PATCH libnbd 0/4] Add free function to callbacks.
Patches 1 & 2 are rather complex, but the end result is that we pass
closures + user_data + free function in single struct parameters as I
described previously in this email:
https://www.redhat.com/archives/libguestfs/2019-August/msg00210.html
Patch 3 adds a convenient FREE_CALLBACK macro which seems a worthwhile
simplification if you buy into 1 & 2.
Patch 4 adds another macro which is
2012 Mar 29
1
Error, Variable is Missing
Hi, I am writing a function to plot a pdf of a distribution,
GNL.pdf.fn = function(x,mu,sigma,alpha,beta,rho)
{
y = x-rho*mu
cf.fn = function(s){
cplex = complex(1,0,1)
temp1 = alpha*beta*exp(-sigma*s^2/2)
temp2 = (alpha-cplex*s)*(beta+cplex*s)
out = (temp1/temp2)^rho
out
}
temp.fn = function(s){
(Mod(cf.fn(s)))*cos(Arg(cf.fn(s))-s*y)
}
int.f...
2002 Dec 16
1
applying a different function to rows of a dataframe
Here is a simple example of what I would like to do:
Given a data frame foo with variables x and fn. Suppose fn is a vector of
characters which correspond to names of previously defined functions
which have only one argument. I would like a vector returned where fn is
applied to x
foo <- data.frame(x=c(2,5,7), fn = letters[c(6,7,6)])
foo$fn <- as.character(foo$fn)
"f" <-...