2,204,553 questions
Score of 0
0 answers
57 views
sklearn.learning_curve(n_jobs=-1) crashes with TerminatedWorkerError in Quarto but not Jupyter
When rendering a Quarto document with jupyter: python3, calling sklearn's learning_curve() with n_jobs=-1 crashes with a TerminatedWorkerError. The same code runs fine in a plain Jupyter notebook.
...
Score of 0
1 answer
85 views
Python curve_fit with multiple independent variables in integral function
I am trying to fit a curve with curve_fit() in scipy using a function with multiple independent variables and multiple fitting parameters. However, the function is the integral of a single-variable ...
Score of 1
1 answer
105 views
What does annotating a variable do in the Python REPL?
In Python 3.13 I can do this:
>>> x: int
>>>
Which passes. But this raises NameError:
>>> x
Traceback (most recent call last):
File "<stdin>", line 1, in &...
Score of -3
1 answer
69 views
What is this square bracket notation in Python class? [duplicate]
What is the function of '[T]' in this code?
class Box[T]:
def __init__(self, content: T):
self.content = content
And here, why is Box subscripted?
str_box = Box[str]('Python')
Score of -4
1 answer
138 views
When and how should __all__ be defined?
When should a module define __all__ vs using the underscore invention? Should this be done manually or dynamically?
Ideally, we could answer this once and for all with 'write it all out manually' and '...
Score of -11
0 answers
126 views
Differentiate between a string and an expression [closed]
Is there a way to differentiate between a variable containing a plain string and one containing an expression, like an isexpression function? For example how can I establish between these two:
test1 =...
Score of 0
0 answers
30 views
How to use pydicom auto_format config option
I am trying to use pydicom to store a float as a field DS. It appears that it should be working automagically since issue 1264 has been closed:
https://github.com/pydicom/pydicom/issues/1264
However I ...
Score of 0
1 answer
35 views
NiceGui Upload CSV Error 'UploadEventArguments' object has no attribute 'content'
I am brand-new to NiceGUI and I am trying to learn it for Python by following some tutorials to learn basic features. I have been trying to replicate the CSV file upload and show content by ...
Score of 0
2 answers
93 views
When and why should a class break the UpperCamelCase naming convention?
According to PEP 8, class names should use the UpperCamelCase (CapWords) convention. However, I have seen classes use lowercase names. For example, in the standard library:
class socket(_socket.socket)...
Score of -5
0 answers
121 views
How to reinstall the 'py' launcher on Windows?
The (now deprecated) 'py' launcher can be installed via an option in the (also deprecated) Python Installer. It then appears as its own entry in Windows Settings > Apps > Installed Apps.
I ...
Score of -4
0 answers
114 views
How to configure a python installation in Python Install Manager?
Starting from Python 3.16, traditional executable installers will be phased out in favour of the Python Install Manager. I tried using the Manager to install a Python 3.13 runtime via py install 3.13. ...
Score of 4
2 answers
74 views
How do threading scripts work when Tkinter is involved?
This script is trying to thread both the root.mainloop() function for the window and the UpdateBoard() function to do logic in for the game.
It is currently throwing an incoherent error about some ...
Score of 2
2 answers
104 views
How to use isinstance on functools.cache cached classes?
After working on this answer, I have a cached class to have simple singleton behavior:
import functools
from dataclasses import dataclass
@functools.cache
@dataclass(frozen=True)
class Person:
...
Score of 0
1 answer
58 views
ImportError: cannot import name 'GradientBaseModelLLM' from 'llama_index.llms'
I am trying to run a script which uses GradientBaseLLM. Apparently the script was written by someone else couple of years back and I having tough time upgrading. I am importing
from llama_index.llms ...
Score of -6
0 answers
158 views
NumPy neural network from scratch for regression: is my implementation correct, and what hyperparameters or feature engineering should I try next? [closed]
I am implementing a 3-layer dense neural network from scratch using NumPy for a regression problem. I am not using TensorFlow, PyTorch, Keras, or any neural-network library because I want to ...