Skip to main content
Filter by
Sorted by
Tagged with
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. ...
jcnvx's user avatar
  • 119
0 votes
1 answer
118 views

Does python 3.12 allows to append items from the list to tuple, I am trying this but getting error TYPEERROR: 'tuple' object is not callable

Please find the below code, once I execute this code I am getting 'tuple' object is not callable error please give the solution, thanks in advance. `mytuple = ("apple", "banana", &...
Lakshmi's user avatar
0 votes
2 answers
88 views

How can a Callable return a value from a predefined void callback?

I am using a data-related API interface which has a key void callback function that is automatically invoked to mark the end of some IO operations. I want to make the class Callable<String> and ...
limestreetlab's user avatar
-1 votes
1 answer
103 views

Make a `Callable` of my `Runnable` in Java

I have some tasks defined as Runnable objects. I want to invoke those tasks by using the invokeAll or invokeAny methods on ExecutorService. The problem is that those methods take a collection of ...
Basil Bourque's user avatar
0 votes
0 answers
126 views

CompletableFuture supplyAsync, thenApplyAsync, thenAcceptAsync working incorrect

I made Async CompletableFuture so that I would first make a payment and then sleep for 10 minutes. And this was repeated endlessly. But sleep once doesn't work anymore public class PaymentWorker ...
Nodirbek Sirojiddinov's user avatar
-1 votes
1 answer
76 views

Spring Boot Asynchronous Controller via Callable not working

I want to make an endpoint that is asynchronous with Spring Boot. I want to avoid Futures and thus @Async because it forces the use of futures. I read and applied the code from this article : https://...
Genku's user avatar
  • 39
-1 votes
2 answers
108 views

How to pass a callable object as runnable object? Can we type cast Callable to Runnable?

How is the below structure possibly working? Please explain. Thanks in advance. public abstract class AbstractCallableClass { protected abstract V getCallable(); public void passRunnable() { ...
Utkarsh's user avatar
0 votes
0 answers
230 views

Haversine, module not callable

I want to use a function from haversine. I installed the Haversine package (terminal: pip install haversine) but I can't run it. import gurobipy as gp from gurobipy import GRB import random import ...
R.B. Soomers's user avatar
0 votes
0 answers
13 views

'int' is not callable on my Object with a custom Function

I'm learning Objects & Classes and am doing some practice. I've essentially done the exact same thing before but now with different names for my Classes and Objects. Here's my code (the error ...
J_D's user avatar
  • 1
-2 votes
1 answer
140 views

Best way to call common methods from a Callable class?

I use java classes of type Callable (up to 200 in parallel), which call a method of a tool class (centralizing common methods), and I notice that if this method is not 'synchronized', I get errors. I'...
vinsse2001's user avatar
0 votes
3 answers
130 views

C++17: pass multiple callable objects together with their parameters

I would like to write a function (C++17 if that matters) that accepts multiple callable objects together with their arguments and executes them in a loop. I would also like to avoid any intermediate ...
TruLa's user avatar
  • 1,137
0 votes
1 answer
131 views

How to apply a (potentially) different callable to each row in a pandas DataFrame

I have a number of DataFrames, each with the same number of rows. input_df contains input data, param_df contains the parameters used for calculations, and output_df contains output data. One of the ...
dg0802's user avatar
  • 3
2 votes
2 answers
144 views

How to access $this in the context of a callable outside of class scope?

class foo { function bar(callable $callable) { $callable(); } function printStr() { echo "hi"; } } $foo = new foo(); $foo->bar(function () { $this-&...
Basil's user avatar
  • 61
1 vote
1 answer
2k views

OpenAI is not callable

When I try to run the following code: import os from langchain.llms import OpenAI from apikey import apikey import streamlit as st os.environ["OPENAI_API_KEY"] = apikey st.title("...
Mrinmoy's user avatar
  • 31
8 votes
1 answer
360 views

How do you create a callable variable to call a class method with arguments?

I'm trying to create a callable variable for a class method. class Person { method walk(Str $direction) { say "Walking $direction"; } } I can create a callable variable for ...
Jim Bollinger's user avatar
-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":...
ludo's user avatar
  • 1
1 vote
0 answers
56 views

Can we pass a basic operator "<" as a callable argument? [duplicate]

My low-level routine needs a argument, to specify it should compare data with LessThan(<) or GreatThan(>) operator. Like this: using CompOp_f = std::function<bool( double, double )>; ...
Leon's user avatar
  • 2,059
5 votes
2 answers
512 views

Differences between Protocol.__call__ vs Callable?

I have a function def run_thing(cb: Callback) -> Result: w: Widget = make_widget() res: Result = cb(w) return res I can imagine two ways to define the Callback type. # Option 1: Callable # ...
LudvigH's user avatar
  • 4,645
0 votes
0 answers
84 views

Java Callable Attempts to Complete Prematurely

I have a method that is called with multi threading and runs to around 99% completion. At this point it runs the next method which needs the first method to of finished running before attempting as it ...
PondleDondle's user avatar
-1 votes
1 answer
351 views

Need help for CompletableFuture or Callable Future

I am facing issue for finding out which will be the best way for my below scenario. I wanted to call 1 API by using multiple threads at a time and wanted to merge their response to make a list. First ...
mohan's user avatar
  • 457
0 votes
0 answers
152 views

"Callable[list, Dict]: has too many arguments in its declaration; expected 2 but 3 argument(s) declared" when using Typeguard runtime type checker

Context The (typed) get_next_actions function below returns a (typed) function, called actions_0 (or None). The actions_0 function takes in 3 arguments, and returns a Dict. from typing import ...
a.t.'s user avatar
  • 2,738
1 vote
1 answer
363 views

Vaadin abnormal memory consumption (memoryLeak?)

for a project I'm working on (Spring Boot 2.7.9 + Vaadin 14.9.7) I'm experiencing a strange heap memory usage. Attached to this post you can find the first objects by top memory usage in my ...
Giuseppe Di Luca's user avatar
0 votes
1 answer
29 views

I have created a module named get_squares. I have import the module successfully but when I try to run it I get the error "Module object not Callable"

The file get_squares.py includes the following function: def get_squares(numbers): squares = [number**2 for number in numbers] print(squares) I can import the module get_squares but when trying to ...
shiggyg123's user avatar
0 votes
0 answers
261 views

How to declare callable variable in python without typing module?

Since version 3.9 python supports many native builtin types. How to declare class variable that can be called in future according to PyLint rules without 'import types'? In this example PyLint hints a ...
VladVons's user avatar
0 votes
1 answer
72 views

Creating objects and overriding their method constructors from java to kotlin

PaintBuilder.newBuilder() .addString("Method: ", new Callable<String>() { @Override public String call() throws Exception { return userMethod; } ...
TheDeverino's user avatar
0 votes
1 answer
150 views

Python: Object not callable - runs in Notebook but not in PyCharm

EDIT: I could solve it (hopefully it does what I want). But I don't understand why it works now. I put my workaround at the bottom. Would be great, if somebody could enlighten me, why it works (or why ...
Alex's user avatar
  • 368
0 votes
0 answers
427 views

Not callable pylint error but no problems at runtime

I'm trying to debug a pylint error in an existing codebase. Here's a minimal reproducible example of the issue I'm seeing: from cytoolz import curry @curry def get_generator(val): if val == 0: ...
structuralengin's user avatar
0 votes
1 answer
312 views

how to type a custom callable type in Python

I have a class called Foo: class Foo: def __init__(self, callable): self.my_attr = "hi" self.callable = callable def __call__(self, *args, **kwargs): # call ...
Bashir Abdelwahed's user avatar
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 ...
user21193451's user avatar
1 vote
3 answers
2k views

python typing: callback protocol and keyword arguments

For example, mypy accepts this: class P(Protocol): def __call__(self, a: int)->int: ... def call(a: int, f: P)->int: return f(a) def add_one(a: int)->int: return a+1 call(1,...
Vince's user avatar
  • 4,361
2 votes
1 answer
404 views

How to return value from Callable with CountDownLatch?

I want to use CountDownLatch with Callabe interface. I have Person class implements Callable interface which has CountDownLatch and Integer, Person#call() method returns integer value and within ...
stewie's user avatar
  • 33
2 votes
1 answer
159 views

How to interface this DFS code with a Boost Graph DFS?

Background I have defined formatting operations on trees that work pretty well when they are used a pre/in/post order operators with the following structure and DFS definition (it works also on k-ary ...
WaterFox's user avatar
  • 1,046
3 votes
1 answer
133 views

Delphi: Using generics to accept any "callable" (e.g. procedure, procedure of object, lambda)

In C++ duck typing there is the concept of a callable, e.g. a symbol that can be called like a function. I'd like to emulate this with Delphi generics. I have a problem where I need a procedure that ...
jpo234's user avatar
  • 431
1 vote
0 answers
239 views

Why does this error occur when I remove these unused variables? Matplotlib animation: self._frames[0].save( > IndexError: list index out of range

I am animating a 360 rotation of a figure to get a full view of the 3D graph, saving it as a GIF. The problem lies within my function that updates the viewing angle of the figure, which is an input to ...
PJD's user avatar
  • 11
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 ...
VisCCelludamtan's user avatar
2 votes
4 answers
767 views

chaining callables in C++

I come from the python world where I could define a chain of operations and call them in a for loop: class AddOne: def __call__(self, x, **common_kwargs): return x+1 class Stringify: ...
Jav's user avatar
  • 1,587
1 vote
1 answer
845 views

Does callable also gets executed in a thread?

When we pass a runnabble to an executorService like Future future = executorService.submit(runnable); // As here executorService maps the object into instance of new FutureTask(runnable); and after ...
Adarsh Verma's user avatar
1 vote
1 answer
120 views

Facing issue while using invokeAll to fetch Future object in ExecutorService

Facing below error while fetching Future object by using invokeAll Method. Iam trying to implement ExecutorService to call parallelly. ERROR>>>>>>>>>>>>>>>&...
Monojit's user avatar
  • 157
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 ...
Steven-Carrot's user avatar
4 votes
4 answers
40k views

How to fix TypeError: 'str' object is not callable?

pic Try to simplfy the my question here, so used a,b, & c instead. Even though I copied the tutorial's answer and run it through Colaboratoy, it still show TypeError:'str' object is not callable. ...
Joan's user avatar
  • 51
0 votes
1 answer
220 views

Should I use Thread and .join or Callable along with Future and .get?

I am writing a simple thread that simply run a process and reads the InputStream. While reading the input, if it finds a certain string it sets a boolean to true. Then when I need to check that ...
zaxunobi's user avatar
  • 930
0 votes
1 answer
127 views

How to wait until for few callable tasks complete and then execute

I want to execute some processors in two threads.. few of them are independent and could run anytime but few of them have dependency.. whenver order of execution reaches to that processor i want to ...
Dungeon Master's user avatar
0 votes
0 answers
173 views

TypeError: 'str' object is not callable

This is my code: import scapy.all from scapy.all import * def create_ip_packet(my_req): ip_packet = IP(dst=my_req) return ip_packet my_req is a simple string as "www.google.com" ...
adi's user avatar
  • 33
1 vote
1 answer
95 views

Dynamically call staticmethod in Python

I have a python object that has various attrs, one of them is check=None. class MenuItem: check: bool = True During the __init__() process, it parses it's own attrs and looks if they are callable....
nerdoc's user avatar
  • 1,073
1 vote
1 answer
46 views

How to multiply value's occurence time by the key to get the new value?

The goal: I want to coune the letters in a sentence, and pprint it as a dictionary, where the value is the occurence of the letters in the sentence, not just its time. import pprint from collections ...
littlebeauty's user avatar
0 votes
1 answer
3k views

TypeError: 'Series' object is not callable in Python?

I am performing model selection in Python. Unfortunately, I got error "TypeError: 'Series' object is not callable". I don't understand what this means and how I could solve this issue. Any ...
TFT's user avatar
  • 231
1 vote
0 answers
36 views

Mockito - verify a method with Callable<> as parameter [duplicate]

I have a following class: public class Task { public <V> V run(Callable<V> callable) { //... callable.call() } } And I have a class that uses the above: public ...
Tirlipirli's user avatar
0 votes
1 answer
209 views

I get this error called 'Button' is not callable:

This is the code: class ticket_launcher(discord.ui.View): def __init__(self) -> None: super().__init__(timeout=None) @discord.ui.Button(label='Create a ticket', style = ...
ImCurrentlyLearningPython's user avatar
0 votes
0 answers
54 views

Assert MagicMock inside of callable parameter

In order to prevent calls to external resources. For example via requests.get while running unit tests I want to have a function that looks like this: def call_external_resource(call: typing.Callable[[...
crlsktr's user avatar
  • 105
-1 votes
1 answer
277 views

When is start method invoked by ExecutorService in Java?

I'm learning about ExecutorService in a simple Spring Boot project. And I know that ExecutorService uses submit method to submit tasks and it will uses different threads for every task. And I don't ...
elvis's user avatar
  • 1,118

1
2 3 4 5
16