StackOverflow.com

VN:F [1.9.22_1171]
Rating: 8.5/10 (13 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

String print format specifier does not work for numpy string array

3 December 2025 @ 3:28 am

I am trying to use numpy sort for numpy string array. But, when I try to print them element-wise with string print format specifier '{:s}' it is giving me the following error. print("{0:s} {1:2d}".format(lth_str[j],lth_arr[j])) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unsupported format string passed to numpy.ndarray.__format__ I don't understand this. Why is this happening and how can I work around this issue? Am I missing something? Data-type mismatch maybe? The following is the code. import numpy as np arr = np.array([ [0,19,20,39], [1,18,21,38], [2,17,22,37], [3,16,23,36], [9,15,24,35], [8,14,25,34], [7,13,26,33], [6,12,27,32], [5,11,28,31], [4,10,29,30], ]) starr = np.array(["a","b","c","d","e","f","g","h","i","j"]) for i in range(4): lth_idx = np.argsort(arr[:,i]) lth_arr

When to choose PolarDB for vector search vs. a dedicated vector database like Pinecone or Weaviate?

3 December 2025 @ 3:24 am

My team is building a new feature that requires vector similarity search. We already have a large, well-maintained PolarDB infrastructure, so using it for vector storage is very appealing as it would simplify our tech stack. We've proven that it's possible to do vector search in PolarDB, either with UDFs and full scans, or possibly with workarounds like quantization or clustering. However, we are debating the long-term viability of this approach versus adopting a dedicated vector database like Pinecone, Weaviate, Milvus, etc. What are the key technical trade-offs? I'm looking for specific scenarios or thresholds where PolarDB becomes a poor choice. For instance: At what dataset size (e.g., >10 million vectors) does the lack of native ANN indexing in PolarDB Community become a deal-breaker? How does the performance (latency and QPS) of a tuned PolarDB solution compare to a dedicated DB? Are we talking 2x slower or 100x slower? What features (e.g., real-

Error running Python script: 'utf-8' codec can't decode byte 0xed in position 79: invalid continuation byte

3 December 2025 @ 3:12 am

C:\inetpub\wwwroot\proyecto_transporte>python conexion.py Unexpected error: 'utf-8' codec can't decode byte 0xed in position 79: invalid continuation byte I already tried saving the file as ANSI, verified that it is saved as UTF-8, and nothing seems to work. I don't know what else to try. If anyone has had a similar issue, I would really appreciate your help. Here is the content of my script: import psycopg2 def verificar_conexion(): try: conexion = psycopg2.connect( host="10.240.0.96", database="transporte_dev", user="postgres", password="***********", port="5432" ) print("Conexion exitosa a PostgreSQL") cursor = conexion.cursor() cursor.execute("SELECT version();") version = cursor.fetchone() print(f"Version de PostgreSQL: {version[0]}&q

RISC vs CISC for low-power autonomous drone processors: technical differences? [closed]

3 December 2025 @ 2:59 am

I am working on an autonomous drone project that requires real-time computer vision and sensor fusion while keeping power consumption very low. I’m comparing RISC-based processors (like ARM Cortex-M/A series) with CISC-based processors (like x86) for this application. Specifically, I want to understand: How the processor architecture affects power efficiency and performance for embedded systems. Any technical considerations for real-time tasks in drones (sensor fusion, image processing). Situations where RISC or CISC would have a measurable advantage.

AzureClientFactory BlobServiceClient Variables

3 December 2025 @ 2:54 am

I couldn't find a complete working example of uploading a file to Azure Blob with .NET Core, so I'm confused with the different snippets that I saw. This is what my code looks like: My Secrets: { "ConnectionStrings:DatabaseConnection": Server=tcp:xxx.database.windows.net;Authentication=Active Directory Default;Initial Catalog=xxxdatabase;", "StorageConnection:blobServiceUri": "https://xxxxxxxx.blob.core.windows.net/", "StorageConnection:queueServiceUri": "https://xxxxxxxx.queue.core.windows.net/", "StorageConnection:tableServiceUri": "https://xxxxxxxx.table.core.windows.net/" I have the standard AzureClientFactoryBuilderExtensions.cs that VS creates when you add Azure Storage to the connected services. I have the Azure Client Service in Program.cs: builder.Services.AddAzureClients(clientBuilder => { clientBuilder.Add

Python/VSCode: Recursive Function Skips elif & Runs else (Works Next Day)

3 December 2025 @ 2:40 am

I encountered an issue with a recursive Python function in VSCode + Python 3.13.1: The function has an if-elif-else structure with self-recursion. After fixing bugs, I passed an input_val that clearly meets the elif condition (e.g., 10 satisfies 5 < x < 15), but the code consistently skipped elif and executed else. I tried re-saving the file, restarting VSCode, clearing the cache, etc.—no luck. Strangely, running the exact same code the next day worked as expected. Code example: def my_function(input_val): if isinstance(input_val, str) and len(input_val) == 1: return input_val.upper() elif isinstance(input_val, int) and 5 < input_val < 15: # 10 should trigger this return my_function(input_val * 2) # Recursive call else: return my_function(input_val - 3) # Recursi

How to fix the error: multiple definition of 'GuiEnable'?

3 December 2025 @ 2:38 am

I am having some trouble configuring raygui.h with cmake using two targets, a library and a executable. There is a repository here with the exact files that causes errors of multiple definition of SomeFunction during the build. The errors are like below: /usr/bin/ld: libgame-lib.a(hello_world.cpp.o): in function `GuiEnable': hello_world.cpp:(.text+0x0): multiple definition of `GuiEnable'; CMakeFiles/exe.dir/src/main.cpp.o:main.cpp:(.text+0x0): first defined here It's like raygui.h declaration were all made twice. The problem does not occurs in the master branch, where only one target is linked directly with raygui.h. These are the files in the

DDD: Is missing entity a domain concern or an application concern?

3 December 2025 @ 2:12 am

I’m working on a DDD-based application and I’m unsure where “Entity Not Found” should be modeled. In many cases, the application layer loads an aggregate via a repository: const warehouse = repository.findById(id); Now there are two possibilities: The entity is not found because of a technical issue (e.g., database connection failure, SQL error, timeout). This is clearly an infrastructure exception. The entity is not found because it does not exist in the domain (e.g., the requested Warehouse should exist according to business rules). Some people model this as a domain exception, e.g. WarehouseNotFoundException. Others treat it as an application exception instead. I’ve seen conflicting guidance: Some argue that “not found” is a domain error because the doma

Get image paths from tfds food101

3 December 2025 @ 2:04 am

I'm working on food101 tensorflow dataset and want to know the most wrong predictions of my efficientnet model, for that purpose I'd need to get image paths of test data, but I don't know how I can get the paths as the dataset is from tfds, not my own data (or downloaded in my computer).. Can anyone tell how can I get image paths from food101 test data.. This is what I've done so far: train_data, test_data), ds_info = tfds.load(name="food101", split=["train", "validation"], shuffle_files=False, as_supervised=True, with_info=True) builder = tfds.builder("food101") data_dir = builder.data_dir_root

Function sequence error with 2 statement handles

3 December 2025 @ 12:18 am

I tried the following (error handling omitted for clarity): query1 = "SELECT a,b,c FROM foo;"; query2 = "INSERT INTO bar VALUES( ?, ?, ? );"; SQLAllocHandle( SQL_HANDLE_STMT, m_hdbx, &stmt1 ); SQLAllocHandle( SQL_HANDLE_STMT, m_hdbc, &stmt2 ); SQLTables( stmt1, dBName, SQL_NTS, "%", SQL_NTS, "%", SQL_NTS, "%", SQL_NTS ); SQLExecDirect( stmt2, "BEGIN TRANSACTION", SQL_NTS ); SQL Prepare( stmt2, query2, SQL_NTS ); for( ret = SQLFetch( stmt1 ); ( ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO ) && ret != SQL_NO_DATA; ret = SQLFetch( stmt1 ) ) { SQLBindParameter( stmt2, 1, .. ); SQLBindParameter( stmt2, 2, .. ); SQLBindParameter( stmt2, 3, .. ); SQLExecute( stmt2 ); } I thought since I'm running 2 different statement handles everything will be good, bit I got Function sequence error on the SQLExecute. Is there any workaround or