All Questions
33 questions
0
votes
1
answer
59
views
Passing multiple callable to odeint
I want to write a python script for the following mechanical system :
Where
Which can be rewritten as below :
For example, we define the following Python function to solve this kind of ODE problem.
...
-1
votes
1
answer
147
views
Transform a non callable function into a callable function
To explain: I use optuna on 5 classifier who are store in a dictionary.
To select one model, I use this:
models={"CatBoostClassifier":CatBoostClassifier,"DecisionTreeClassifier":...
0
votes
2
answers
76
views
How to write isEven() function as callable function?
I am learning PHP using reviewing some complete PHP projects. (I know that this is a bad way, but my goal is not to be a PHP programmer!) Anyway, I faced with the following function that is weird a ...
0
votes
0
answers
44
views
Python: Passing a function with arguments as argument of another function
In the code below, inside WKB, I'm trying to pass the function "integrand" as an argument of the function int_gauss (like this: int_gauss(integrand(E,x0,m1,x),xp,wp)) and it returns me an ...
0
votes
1
answer
179
views
How to make a struct that uses Callable (callAsFunction()) works with protocol?
I'm trying to make the callAsFunction() works when working directly with protocol or dependency injection, but it seems like the protocol instance is not aware of the Callable feature. I tried adding ...
2
votes
1
answer
60
views
why fct.__call__() is not the same as fct()?
the __call__ dunder method of a class is supposed to represent the operator (), correct?
if so, why the following code is not working as expected?
def f():
print("hello world")
f()
>...
1
vote
3
answers
282
views
Can I pre-specify all but one of the arguments in python function to return a callable in python
Let's say I define a function in python
def f(x,y):
return(x+y)
Now I want to define a function g( __ )=f( __ ,y), i.e. a function for which I already specified a value y and want it to be a ...
1
vote
1
answer
1k
views
Python Pydantic Callable with default function argument [duplicate]
I have a function that returns another function. Example:
from typing import Callable, Optional
def create_object() -> Callable[[str, Optional[int]], str]:
def create(name: str, length: int = ...
1
vote
3
answers
196
views
How does one use an object as a function or how does one best create a custom callable object/type?
I have two file index.js and actor.js
Index.js
const {Actors} = import("./Actors");
const act1= new Actors({
name: 'Tony Stark',
alias: 'Iron Man',
gender: 'man',
age: 38,
powers: ...
0
votes
1
answer
448
views
Firebase callable functions fail
Many functions have started to fail intermittently with the following error even before the first line of code is executed:
FIREBASE WARNING: {"code":"app/invalid-credential",&...
0
votes
0
answers
42
views
Is there a way to modify the function of an argument after it has already been specified in Python?
I'm working with ML regression algorithms, and I'd like to know if there is a way to state a function with specific arguments, and then add extra arguments to those already specified in another line ...
0
votes
2
answers
1k
views
C++ Array of different functions
It's easy to do something like that in Python, but implementing it in C++ seems to be more challenging.
I actually have some solution to this, but I'd like to see if you can see any better solution.
...
-2
votes
1
answer
66
views
Python, user input as a function argument not working: TypeError: 'str' object is not callable
I just started learning Python yesterday, so this is probably a stupid question. Nonetheless I have been searching for the solution for a while and couldn't find it!
Here is my very basic program:
...
1
vote
1
answer
54
views
How to use a function as an argument of another function in php using callable pseudo type?
I just read about callable type from php.net and assume using callable keyword should allow passing the function as the argument to another function. But, I am getting warning. Here's what I've tried: ...
1
vote
2
answers
310
views
Is is possible to callAsFunction() variable that is Any?
Recently I have encountered a need of creating an Array of Functions. Unfortunately, Swift language does not provide a top level type for functions, but instead they must be declared by their specific ...
0
votes
1
answer
399
views
What and which are the PHP functions that are not callable?
Some PHP functions such as echo and empty are not callable. You can't, for example, filter an array as follows:
$array = array_filter($array, 'empty');
What are other functions in PHP that are not ...
0
votes
2
answers
80
views
Python specifying function as input [duplicate]
import math
def g(x):
return x**2+3
def Integrate(f, a , b, n):
h=(b-a)/n
result=0
for k in range(n):
x=k*h+h/2
result+=f(x)*h
return result
F=input("f:")
A=...
2
votes
2
answers
1k
views
Firebase Promises Issue - "Maximum call stack size exceeded"
I'm having an issue with Callable Functions. Here's my Firebase function:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const request = require('request-...
6
votes
2
answers
16k
views
Python: Pass extra arguments to callable
I have the following python code:
import networkx as nx
def cost(i, j, d, value1, value2):
# some operation involving all these values
return cost
# graph is a networkx graph
# src, dst ...
0
votes
0
answers
134
views
Callable function not really callable?
I am using ParaView-5.4.1 under Ubuntu 16.04LTS.
I have an object r of class PVDReader (in pvpython, but this is likely irrelevant).
For the method TimestepValues of that class
>>> callable(...
0
votes
1
answer
17
views
What's the appropriate way of passing arguments to the static class method when it's made callable?
I tried below code :
<?php
class A {
public static function who($simba) {
echo "A\n";
echo $simba;
}
}
class B extends A {
public static function who() {
echo "...
-2
votes
2
answers
99
views
Reduce() with a regular function
I want to calculate the product sum of two lists using reduce() and a regular function.
The regular function to return the product is defined as:
def func(maturity, weight):
return ...
-2
votes
2
answers
131
views
Are Python "function objects" functions?
We all know that functions are objects as well. But how do function objects compare with functions? What are the differences between function objects and functions?
By function object I mean g so ...
0
votes
0
answers
41
views
Why does a callable function output a closure object in this instance?
The way I undestand it, callable is just a typehint, and we pass it via a function/method parameters to enforce whatever passed after it should be a typecallable (in otherwords a function) see this ...
25
votes
3
answers
14k
views
How to pass a parameter to Scikit-Learn Keras model function
I have the following code, using Keras Scikit-Learn Wrapper, which work fine:
from keras.models import Sequential
from keras.layers import Dense
from sklearn import datasets
from keras.wrappers....
1
vote
2
answers
94
views
How to determine number of function/builtin/callable parameters programmatically?
I want to be able to classify an unknown function/builtin/callable based on its number of arguments.
I may write a piece of code like that:
if numberOfParameters(f) == 0:
noParameters.append(f)
...
0
votes
1
answer
300
views
How to execute function when parameter is array or callable?
Look this example code:
I'm getting the error:
Fatal error: Uncaught Error: Cannot use object of type Closure as array in C:\xampp\htdocs\dermaquality\test.php:11 Stack trace: #0 C:\xampp\htdocs\...
0
votes
0
answers
127
views
Is C++ function belonging to "callable type"
The C++11 standard says:
20.8.1 Definitions [func.def]
1 The following definitions apply to this Clause:
2 A call signature is the name of a return type followed by a parenthesized comma-separated ...
0
votes
1
answer
46
views
Using a variable in a function in another function in python
I returned the variable and I still get the variable is still undefined. Can someone help?
def vote_percentage(s):
'''(string) = (float)
count the number of substrings 'yes' in
the ...
6
votes
2
answers
10k
views
How to call the callable function in PHP?
I've one array titled $post_data. I want to pass this array to some function as an argument. Along with this array I've to pass another argument the callable 'function name' as second argument in a ...
2
votes
1
answer
2k
views
JDBC Postgres stored function call returning setof 'myType'
I'm trying to protect my database from SQL Injection. I have many stored functions that return SETOF my predefined data types. For example:
create type userLoginUserIdPasswordReturnType as
(
userId ...
3
votes
1
answer
2k
views
How to send a function to a remote Pyro object
I am trying to set up some code using Pyro to process python code functions on a remote host and get results back. After starting the name server, i would execute this code on the remote host (...
20
votes
1
answer
7k
views
What is the difference between a function object and a callable object?
I recently saw the presentation about the changes in ECMAScript 5. And there was a slide with this statement:
Function vs Callable
typeof f === 'function' // → f is Callable
(...