211 questions from the last 7 days
5
votes
2
answers
279
views
Why are C++ and Python giving me different answers, when given (I think) the same precision?
I have this code in C++:
#include <iostream>
#include <iomanip>
#include <limits>
#include <boost/multiprecision/mpfr.hpp>
using namespace boost::multiprecision;
template<...
3
votes
2
answers
117
views
Cannot get command line code to run via python
I am running python 3.13.5 via PowerShell in windows 10. I can successfully run the folowing command, and now want to run it with a python script
& 'D:\realesrgan\realesrgan-ncnn-vulkan.exe' -i 'D:...
3
votes
2
answers
88
views
How do I Download Poppler and Tesseract Programmatically with PowerShell
In Python, there are two libraries which are often used in tandem, Poppler and Tesseract. They both need external downloads to function:
Poppler, Tesseract. The general recommendation for Windows is ...
3
votes
1
answer
49
views
PaddleOCR is leaking extracted data from a previous document
I've implemented an OCR queue using PaddleOCR and noticed that some documents are receiving the same extracted data as the previously processed document.
So far, this behaviour seems to be isolated to ...
3
votes
0
answers
67
views
Communicating with two devices over BLE UART in python using bleak
Unfortunately, I don't have any experience with async programming, so it took me quite some time to get my code running on a Raspberry Pi 5 4GB (with bookworm 2025-05-13 OS) to communicate with one ...
3
votes
1
answer
74
views
Why the initial figure dimensions are wrong in this matplotlib script?
This Python 3.13 script with Matplotlib 3.10.3 run on 1200x1600 display:
import matplotlib.pyplot as plt, numpy as np
fig, ax = plt.subplots()
plt.tight_layout(pad=0.01)
fig.canvas.manager....
2
votes
1
answer
56
views
Can't use lock around gather in Python asyncio
For some reason, this code doesn't work on Ubuntu 20, Python 3.8.10, unless the .gather line is commented out.
It works on Ubuntu 24, Python 3.12.3 and Windows 11, Python 3.13.9.
It doesn't work on ...
Advice
2
votes
2
replies
42
views
Chapel-Python interopability - export records (or interface with Python dataclasses)
I have the following use case. My main program is written in Python, and I want to accelerate some parts of it. The Python program makes use of dataclasses (~structures) to store parameters, arrays, ...
2
votes
1
answer
63
views
Change color of single line in altair line chart based on other indicator column
Imagine having the following polars dataframe "df" that contains the temperature of a machine that is either "active" or "inactive":
import polars as pl
from datetime ...
2
votes
1
answer
27
views
How do I fix a "TypeError: bad number of pixels" in a healpy.fitsfunc.write_map call?
I have downloaded the HEALPix5 DECaPS 3D dust extinction map (from arXiv:2503.02657) and imported it as a numpy array meanmap. The array gives an expected result (51415400, 1, 120) to the meanmap....
2
votes
1
answer
43
views
NiceGUI Fits with Hight and Width of a Web Page
In following Python script I would like to know why horizontal and vertical scroll appear after the script run. I try all widgets just fit into a web page not exceed the page size. Here is my script:
...
2
votes
1
answer
61
views
problem on the x-axis of the graph, doesn't render the time
I am working on a dashboard using Shiny for Python and Plotly Express. I am trying to create a Gantt chart (using px.timeline) to visualize the operating periods of different boilers (ON/OFF states).
...
2
votes
1
answer
48
views
Transformers LlamaForCasualLM class: base_model Attribute Mystery
Question:
I'm experiencing a question with the transformers library, specifically with the pipeline initialization. When I access the base_model attribute of a LlamaForCausalLM model, it seems to ...
2
votes
1
answer
51
views
Why does a nearest join_asof() return exact matches despite allow_exact_matches=False?
I am looking for the nearest non exact match on the dates column:
import polars as pl
df = pl.from_repr("""
┌─────┬────────────┐
│ uid ┆ dates │
│ --- ┆ --- │
│ i64 ┆ date ...
2
votes
0
answers
75
views
How to annotate with the generic type of self?
I have classes like this:
class TensorLike(ABC):
@property
@abstractmethod
def conj(self) -> 'TensorLike': ...
class Tensor(TensorLike):
_conj: 'Conjugate|None'=None
@property
...
2
votes
0
answers
46
views
Issue Replicating TF-Lite Conv2D Quantized Inference Output
I am trying to reproduce the exact layer-wise output of a quantized EfficientNet model (TFLite model, TensorFlow 2.17) by re-implementing Conv2D, DepthwiseConv2D, FullyConnected, Add, Mul, Sub and ...
2
votes
0
answers
44
views
libstdc++.so links error when try to use pybind11/3.0.1 of conan-2 and cpp23 in wsl
In WSL (Ubuntu 24.04), when using Conan to create a package that links pybind11/3.0.1, the resulting executable in the test_package fails to run.
Even if the executable doesn't directly call any ...
1
vote
2
answers
54
views
Scipy.fsolve | Reconstruct the Jacobian from QR
I am trying to understand if its possible to reconstruct full jacobian or atleast one element of the jacobian from the infodict of scipy.fsolve
To make the request concrete, Lets say im trying to ...
1
vote
1
answer
55
views
PostgreSQL SQLAlchemy index NULLS NOT DISTINCT [duplicate]
I have a table (TA) on which I want to have a composite unique index on two columns (col1 and col2).
col2 can be NULL.
I know Postgres treats NULLs as distinct.
In SQL I would therefore do:
CREATE ...
1
vote
1
answer
81
views
Python, parse nested JSON to make it flat for CSV
I'm trying to store API output into CSV/db and can not figure out how I can make for those Key in "tierList". One row in my case should be on bin and I need key as a columns in my output.
Is ...
1
vote
1
answer
75
views
Why does my Python solution for selecting 2 points from each interval give incorrect results for overlapping intervals?
I’m trying to solve the following Leetcode problem:
You are given a 2D integer array intervals where intervals[i] = > [starti, endi] represents all the integers from starti to endi
inclusively.
A ...
Advice
1
vote
3
replies
44
views
Python library recommendation for the implementation of a neural network modification algorithm
I want to implement in python some algorithms from a paper that allow for a pre-trained neural network to be modified (adding or removing neurons or layers) conserving (theoretically) the outputs of ...
1
vote
1
answer
49
views
Can't find HBO Max sign-in, "unable to locate element" error
I'm trying to make a automation that logs into https://auth.hbomax.com/login, however I keep getting the below error as the code can't locate the sign-in element.
selenium.common.exceptions....
1
vote
1
answer
52
views
how to make socket server propagate exceptions up to TaskGroup where they're started from?
How to make exceptions thrown from a socket server running in a task group task be propagated up to its parent TaskGroup? With given example, I'd expect to see the error raised from ...
1
vote
1
answer
40
views
No module named 'ttkbootstrap'
Running anaconda and VSCode.
At the anaconda prompt I ran
conda install conda-forge::bootstrap
It returned
Channels:
- defaults
- conda-forge
Platform: win-64
Collecting package metadata (repodata....