QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
78,970,384 | 2,362,196 | How to build Azure AI endpoint and deployments of models using pipelines | <p>Using Azure Portal and AI Studio, I created the deployment of two models selected on AI Studio, an endpoint and a workspace. I don't really know what I'm doing and try to learn by doing. Now I need to create all these by scripts in pipelines with YAML and BICEP so I can teardown at night and rebuild in the morning... | <python><azure><azure-pipelines><azure-ai> | 2024-09-10 16:10:52 | 1 | 533 | ClaudeVernier |
78,970,312 | 22,466,650 | Supabase python client returns an empty list when making a query | <p>My configuration is very basic. A simple supabase database with one table.</p>
<p>I use <a href="https://github.com/supabase/supabase-py" rel="nofollow noreferrer">supabase-py</a> to interact with it. The problem is that I always get an empty list :</p>
<pre class="lang-py prettyprint-override"><code>from supabase i... | <python><postgresql><supabase> | 2024-09-10 15:52:18 | 1 | 1,085 | VERBOSE |
78,970,190 | 4,727,280 | Python Protocols and Mutability | <p>I'm confused by a Pylance type-checking error I'm getting:</p>
<pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass
from enum import StrEnum
from typing import Protocol
class A(Protocol):
x: str
# @property
# def x(self)->str: ...
class S(StrEnum):
FOO="foo"... | <python><python-typing><pyright><structural-typing> | 2024-09-10 15:19:01 | 0 | 945 | fmg |
78,970,161 | 3,025,555 | How to set a formatter for file handler that will replace unwanted characters? | <p>I have python logger set, which has 2 handlers - 1 for stdout, 1 for file.</p>
<p>Some of the logs i have, contains ANSI Escape characters for colorizing logs in stdout, e.g.</p>
<pre><code>SomeExampleText.... [32mPASS[0m....
</code></pre>
<p>I would like to utilize solution in following thread:</p>
<p><a href="http... | <python><logging><ansi-escape> | 2024-09-10 15:11:46 | 1 | 1,225 | Adiel |
78,970,132 | 1,250,463 | Pandas rank to Excel rank | <p>I have a sample data from which i am calculating the rank</p>
<pre><code>import pandas as pd
df = pd.DataFrame({"value": [500,500,200,101,100,72,63,55,50,30,30,20,1]})
print(df)
print(df["value"].rank())
print(df["value"].rank(pct=True))
</code></pre>
<p>The results are as follows</... | <python><excel><pandas> | 2024-09-10 15:03:40 | 1 | 3,028 | srinath |
78,969,962 | 1,472,048 | Human segmentation fails with Pytorch, not with Tensorflow Keras | <p>I probably missed something, but here is the same workflow with Pytorch and Tensorflow Keras.</p>
<p>The results are here:</p>
<p>The PyTorch version</p>
<p><a href="https://i.sstatic.net/V4n1bSth.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/V4n1bSth.png" alt="With pytorch" /></a></p>
<p>The Keras ... | <python><image><tensorflow><machine-learning><pytorch> | 2024-09-10 14:18:33 | 1 | 2,951 | Metal3d |
78,969,937 | 1,360,979 | plotnine geom_histogram wrong bin placement | <p>I'm trying to define very specifically the bins of my histogram so that their size is <em>exactly</em> 10.</p>
<p>Here is an example. I defined a list of numbers. The list contains 10 numbers with 1 digit, and then 50 numbers between 50 and 59, 60 numbers between 60 and 69, and so on.</p>
<pre class="lang-py prettyp... | <python><plotnine><geom-histogram> | 2024-09-10 14:13:00 | 1 | 505 | vaulttech |
78,969,843 | 638,366 | How to unit-test / mock code with beanie queries | <p>So my concrete problem is that I am trying to create a unit test for something like this:</p>
<pre class="lang-py prettyprint-override"><code>from mongo_models import Record
async def do_something(record_id: str):
record = await Record.find_one(Record.id == record_id)
if record is None:
record = R... | <python><mocking><pytest><beanie> | 2024-09-10 13:52:18 | 1 | 1,347 | Nordico |
78,969,815 | 3,405,291 | AttributeError: module 'numpy' has no attribute 'int' ---> ValueError: Buffer dtype mismatch, expected 'float32_t' but got 'double' | <h1>Code</h1>
<p>I'm running a Python code which has the following statements:</p>
<pre class="lang-py prettyprint-override"><code> # do NMS
dets = np.hstack((boxes, scores[:, np.newaxis])).astype(np.float32, copy=False)
keep = nms(dets, 0.3) # -> *** Error is thrown here :(
... | <python><numpy><attributeerror> | 2024-09-10 13:45:40 | 1 | 8,185 | Megidd |
78,969,782 | 13,023,224 | Run all jupyter notebooks inside folder and subfolders in an ordered manner and displaying process | <p>I want to run (in an alphabetical order, not in parallel) all jupyter notebooks inside a folder that contain many subfolders.</p>
<ul>
<li>Each subfolder may contain other folders.</li>
<li>Folders contain jupyter notebooks and the resulting outcome (csv, json, excel, jpg files).</li>
<li>It is important that files ... | <python><jupyter-notebook> | 2024-09-10 13:39:58 | 1 | 571 | josepmaria |
78,969,691 | 1,942,868 | How to filter the one-to-many relationship from both side | <p>I have two tables which has relationship.</p>
<pre><code>class Parent(SafeDeleteModel):
name = models.CharField(max_length=1048,null=True,blank=True)
class Child(SafeDeleteModel):
name = models.CharField(max_length=1048,null=True,blank=True)
parent = models.ForeignKey(Parent,blank=True, null=True, on_de... | <python><django> | 2024-09-10 13:17:36 | 3 | 12,599 | whitebear |
78,969,678 | 1,762,051 | Timed Hash Verification based web api call in Lindane Scripting Language | <p>I am trying to call a web api which is secred by Timed Hash Verification system.</p>
<p>I am able to call that API using python</p>
<pre class="lang-py prettyprint-override"><code>import hmac
import hashlib
import time
import requests
import json
def generate_timed_hash(secret_key, data):
timestamp = str(int(ti... | <python><http><http-headers><sha256><linden-scripting-language> | 2024-09-10 13:16:09 | 1 | 10,924 | Alok |
78,969,301 | 7,228,014 | Loading a pipeline with a dense-array conversion step | <p>I trained and saved the following model using joblib:</p>
<pre><code>def to_dense(x):
return np.asarray(x.todense())
to_dense_array = FunctionTransformer(to_dense, accept_sparse=True)
model = make_pipeline(
TfidfVectorizer(),
to_dense_array,
HistGradientBoostingClassifier()
)
est = model.fit(texts... | <python><numpy><scikit-learn><numpy-ndarray><joblib> | 2024-09-10 11:36:52 | 1 | 309 | JCF |
78,969,272 | 1,820,665 | How can I correctly implement a Python daemon which could fail to start? | <p>I have a Python daemon using the <code>python-daemon</code> package to daemonize. It can also be run to stay in foreground (by not using the <code>-d</code> command line parameter). It recurrently runs a function and also starts a minimal HTTP server that can be used to communicate with it (the full code can be foun... | <python><python-daemon><openrc> | 2024-09-10 11:28:43 | 1 | 1,774 | Tobias Leupold |
78,968,974 | 8,950,119 | How to remove the accessibility item from the userbar | <p>Is there a way to remove the accessibility item from the Wagtail userbar?</p>
| <python><django><wagtail> | 2024-09-10 10:10:27 | 1 | 2,090 | JJaun |
78,968,894 | 893,254 | How to plot `datetime.time` type on an axis? | <p>I am trying to plot a dataframe which has a <code>datetime.time</code> index type.</p>
<p>Matplotlib does not appear to support plotting an axis using a <code>datetime.time</code> type, and attempting to do so produces the following error message:</p>
<pre><code>TypeError: float() argument must be a string or a real... | <python><pandas><matplotlib> | 2024-09-10 09:51:21 | 1 | 18,579 | user2138149 |
78,968,834 | 857,662 | tensorflow back compatibility: KerasTensor and tf-keras tensor | <p>I have some code written with tensorflow 2.3 in which tensors are constructed using tf.keras.</p>
<p>As moving to tensorflow > 2.16, tf.keras is retired an tf calls keras >= 3.0.</p>
<p>The type of the tensors in my code changes from tf.Tensor to Keras.Tensor. As a consequence, my code is largely affected, mos... | <python><tensorflow><keras> | 2024-09-10 09:35:24 | 0 | 331 | newbie |
78,968,643 | 2,386,113 | VS Code reopens closed Python script and matplotlib figures after restart | <p>I'm facing a strange issue with VS Code on my Windows 11 machine. A few days ago, I ran a simple Python program that generates matplotlib figures in a for loop. The code does not involve any multiprocessing or multithreading; it simply iterates 8 times, creates a figure using matplotlib, and shows it.</p>
<p>I close... | <python><matplotlib><visual-studio-code> | 2024-09-10 08:45:25 | 1 | 5,777 | skm |
78,968,636 | 9,827,438 | Running Blender python script outside of blender error message calculate_object_volumes.poll() failed, context is incorrect | <p>I try to run a python script outside blender headless via <strong>blender -b --python import_ifc_model.py</strong> command</p>
<p>I have installed Blender 4.2.1, the add-on Bonsai (new name before it was blenderbim) and the idea is to import an ifc file and calculate the volume of all the objects. (source code <a hr... | <python><blender><ifc><bim> | 2024-09-10 08:44:12 | 0 | 371 | ana maria |
78,968,621 | 256,965 | How to define a nested generic type in Python? | <p>I have a function that (should) flatten arbitrarily many times nested list</p>
<pre class="lang-py prettyprint-override"><code>T = TypeVar("T")
type Nested[T] = Sequence[T | Sequence[Nested]]
def flatten(seq: Nested[T]) -> list[T]:
flattened: list[T] = []
for elem in seq:
if isinstance(... | <python><python-typing> | 2024-09-10 08:41:01 | 1 | 1,869 | zaplec |
78,968,459 | 13,224,216 | How to pass custom arguments into Config file (for generating client-side assets)? | <p>Often projects generate some client-side artifacts before running automations.
So, in our case we'd like to generate some build files, then push them to remote servers by Pyinfra automation.</p>
<p>In order to achieve that we use:</p>
<ul>
<li><a href="https://docs.pyinfra.com/en/2.x/examples/client_side_assets.html... | <python><pyinfra> | 2024-09-10 07:58:21 | 1 | 428 | mdraevich |
78,968,419 | 17,580,381 | Querying a pandas dataframe efficiently | <p>Here's the MRE that produces expected results:</p>
<pre><code>import pandas as pd
data = {
"A": [1, 2, 3],
"B": [100, 200, 300]
}
s = {100, 300, 500}
df = pd.DataFrame(data)
for _, row in df.query("B in @s").iterrows():
print(row["A"])
</code></pre>
<p>Output:<... | <python><pandas> | 2024-09-10 07:47:15 | 0 | 28,997 | Ramrab |
78,968,135 | 1,349,673 | Is it possible to raise an exception on FutureWarning (pandas)? | <p>I am seeing a <code>FutureWarning</code> in the output of my code, coming from the <code>pandas</code> library.</p>
<p>I would like to catch when this is occurring in the code execution. The natural way would be to request <code>pandas</code> to raise an exception rather than printing a warning message.</p>
<p>Is th... | <python><pandas> | 2024-09-10 06:22:32 | 1 | 8,126 | James Hirschorn |
78,968,073 | 22,213,065 | Detect only left-most boxes in image | <p>I have a JPG image that contain mobile brand names:<br />
<a href="https://i.sstatic.net/f2LDnB6t.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/f2LDnB6t.jpg" alt="enter image description here" /></a></p>
<p><strong>Now I want to detect each word first character by python script</strong><br />
I wrot... | <python><opencv><computer-vision><ocr> | 2024-09-10 05:57:21 | 1 | 781 | Pubg Mobile |
78,968,035 | 11,431,038 | SQLAlchemy: to_sql create empty table after inspect | <p>I have strange behavior here. After I init inspect(cn), to_sql writes an empty table to the database.</p>
<pre><code> def save_data_to_sql(df, table_name, cn):
df.to_sql(con=cn, name='test_1', if_exists='replace', index=False) << Table with data
# Check if the table exists
inspector = inspect(cn)... | <python><python-3.x><pandas><sqlalchemy><mariadb> | 2024-09-10 05:41:43 | 1 | 332 | Mike |
78,967,951 | 17,889,492 | Changing variables in sympy | <p>According to the documentation one can make substitutions as:</p>
<pre><code>expr = sin(2*x) + cos(2*x)
expr.subs(sin(2*x), 2*sin(x)*cos(x))
</code></pre>
<p>But say <code>x = y + 2</code>. How do I convert the expression from a function of <code>x</code> to a function of <code>y</code> without having to give the su... | <python><sympy> | 2024-09-10 04:57:50 | 2 | 526 | R Walser |
78,967,779 | 2,392,192 | Subclassing random.Random produces different results with same seed | <p>I've run into something I don't understand. This code:</p>
<pre class="lang-py prettyprint-override"><code>import random
class MyRandom(random.Random):
pass
r = random.Random()
r.seed(10)
print(r.randint(0, 20))
print(r.randint(0, 20))
print(r.randint(0, 20))
print("------------")
r2 = MyRandom()... | <python><random><random-seed> | 2024-09-10 03:23:09 | 0 | 563 | MarcTheSpark |
78,967,533 | 825,227 | Is there a way to add lines across subplots in Python | <p>I have a simple plot, to which I've added lines as below:</p>
<pre><code>mid = d[d.Position==0].Price.mean()
b_a = d[(d.Position==0) & (d.Side == 0)].Price.values
b_b = d[(d.Position==0) & (d.Side == 1)].Price.values
f, ax = plt.subplots()
sns.set_color_codes('muted')
sns.barplot(data = d[d.Side==0], x = '... | <python><matplotlib><seaborn> | 2024-09-10 00:21:35 | 2 | 1,702 | Chris |
78,966,995 | 4,611,374 | How to write to the Flask Session from a child process | <p>I have a flask web app that does image processing. The parent application calls a function that creates several temporary images, writes them to disk, and stores their paths in the flask Session. That workflow is leaking memory -- the RAM allocated to the function call is not released until the webserver is restarte... | <python><flask><session><multiprocess> | 2024-09-09 19:46:42 | 1 | 309 | RedHand |
78,966,976 | 3,173,062 | How to fix Stripe webhook integration signature failure error with aws api gateway, lambda using python? | <p>I'm integrating the stripe webhook with my aws lambda function written in python using the api gateway. It seems I'm getting the signature error. I have tested the code locally using flask server which works perfectly fine. I checked the cloudwatch logs as well to check the similarity of the type of data for differe... | <python><amazon-web-services><aws-lambda><stripe-payments><aws-api-gateway> | 2024-09-09 19:38:58 | 0 | 599 | forhadmethun |
78,966,924 | 4,541,104 | How do I check if a listed Gio schema is good? GLib-GIO-ERROR attempting to create schema ... without a path | <p>I would like to list the schemas for the purpose of making a setting search tool.</p>
<p>However, some schemas make <code>Gio.Settings.new</code> cause a core dump.</p>
<p>This script requires linux and the "python3-gi" package (such as via <code>sudo apt install python3-gi</code>; recent pip versions won'... | <python><gnome><gio> | 2024-09-09 19:18:32 | 1 | 1,156 | Poikilos |
78,966,883 | 2,071,807 | Assert that unittest Mock has these calls and no others | <p><code>Mock.assert_has_calls</code> asserts that the specified calls exist, but not that these were the only calls:</p>
<pre class="lang-py prettyprint-override"><code>from unittest.mock import Mock, call
mock = Mock()
mock("foo")
mock("bar")
mock("baz")
mock.assert_has_calls([call(&q... | <python><python-unittest><python-unittest.mock> | 2024-09-09 19:02:10 | 2 | 79,775 | LondonRob |
78,966,835 | 219,153 | How to clear contours and retain pan and zoom with Matplotlib? | <p>This snippet:</p>
<pre><code>plt.get_current_fig_manager().full_screen_toggle()
for img in imgs:
plt.clf()
plt.imshow(img, origin='upper', interpolation='None', aspect='equal', cmap='gray')
plt.gca().contour(img, np.arange(0, 255, 8), colors='r')
while not plt.waitforbuttonpress():
pass
</code></pre>... | <python><matplotlib> | 2024-09-09 18:44:22 | 1 | 8,585 | Paul Jurczak |
78,966,793 | 702,948 | python: how to import a module that references another file in the same directory? | <p>Here's my folder structure</p>
<pre><code>/
├── package
│ ├── __init__.py
│ ├── mod1.py
│ └── mod2.py
</code></pre>
<p>the contents of <code>mod1.py</code>:</p>
<pre><code>class MyClass(object):
pass
</code></pre>
<p>and <code>mod2.py</code>:</p>
<pre><code>from mod1 import MyClass
</code></pre>
<p>This is a... | <python><import><module> | 2024-09-09 18:28:19 | 0 | 21,657 | ewok |
78,966,709 | 21,692,833 | How to Send Email via Python's smtplib with Gmail Signature Automatically Included? | <p>I am trying to send an email through Python's <code>smtplib</code> using my Gmail account, and I have already configured a signature in my Gmail settings. However, when the email is sent from my Python script, the signature that I registered in Gmail does not appear in the sent email.</p>
<p>Here’s the Python script... | <python><email><gmail> | 2024-09-09 17:58:07 | 0 | 494 | Dustin Lee |
78,966,499 | 18,769,241 | Determine the object distance from the ground given head pitch angle? | <p>I want to determine the distance from a detected object (as spotted by a robot/camera) to the ground through the head pitch angle and the distance between the object and the robot/camera (which is a known fixed distance).</p>
<p>I want to do that because I want the robot to grab the object at the requested specific ... | <python><opencv><image-processing><computer-vision><robotics> | 2024-09-09 16:54:07 | 1 | 571 | Sam |
78,966,321 | 1,572,469 | Camera is not detecting chessboard corners using Python and OpenCV | <p>My code looks like this:</p>
<pre><code>def find_corners(images, camera_name):
imgpoints = []
for idx, img in enumerate(images):
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.001)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Find the chessboard corners
... | <python><opencv><computer-vision> | 2024-09-09 16:00:47 | 0 | 1,952 | Eric Snyder |
78,966,219 | 16,815,358 | Smoothing out the sharp corners and jumps of a piecewise regression load-displacement curve in python | <p>I am having a stubborn problem with smoothing out some sharp corners that the simulation software does not really like.</p>
<p>I have the following displacement/ load/ damage vs step/time:</p>
<p><a href="https://i.sstatic.net/pzXKjLMf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pzXKjLMf.png" alt=... | <python><pandas><matplotlib><curve-fitting><smoothing> | 2024-09-09 15:36:16 | 2 | 2,784 | Tino D |
78,966,184 | 14,720,380 | How can I inverse a slice of an array? | <p>I want to do something along the lines of...</p>
<pre><code>import numpy as np
arr = np.linspace(0, 10, 100)
s = slice(1, 10)
print(arr[s])
print(arr[~s])
</code></pre>
<p>How could I apply the "not" operator to a slice, so that in this case <code>arr[~s]</code> would be the concatenation of <code>arr[0]<... | <python><numpy><slice> | 2024-09-09 15:26:08 | 1 | 6,623 | Tom McLean |
78,966,115 | 3,156,085 | How to (correctly) use `ctypes.get_errno()`? | <p>I'm trying to test some binary library with <code>ctypes</code> and some of my tests involve <code>errno</code>.</p>
<p>I'm therefore trying to retrieve it to check the error cases handling but when trying to use <a href="https://docs.python.org/3/library/ctypes.html#ctypes.get_errno" rel="nofollow noreferrer"><code... | <python><ctypes><errno> | 2024-09-09 15:07:31 | 1 | 15,848 | vmonteco |
78,966,048 | 12,466,687 | How to change background color of st.text_input() in streamlit? | <p>I am trying to <strong>change the background color</strong> of <code>st.text_input()</code> box but unable to do so.</p>
<p>I am not from web/app development background or with any html css skills so please excuse my naive or poor understanding in this field.</p>
<p>So far I have tried:
<a href="https://discuss.stre... | <python><html><css><streamlit> | 2024-09-09 14:49:34 | 1 | 2,357 | ViSa |
78,965,913 | 11,154,841 | How do I sort "SELECT INTO" queries that are built on top of each other by their "INTO" / "FROM" table links? | <p>I need to migrate a dozen MS Access databases with 500+ queries to SSIS and therefore, I changed the code to TSQL, see <a href="https://stackoverflow.com/questions/78942252/how-can-i-get-tsql-from-easy-ms-access-sql-with-little-to-no-handiwork">How can I get TSQL from easy MS Access SQL with little to no handiwork?<... | <python><sql><excel><t-sql><ms-access> | 2024-09-09 14:17:05 | 1 | 9,916 | questionto42 |
78,965,901 | 16,374,636 | How to make ray task async | <p>I want to run a function (Ray Task) that may trigger another request afterward.</p>
<p>For example, if I have 10 tasks but only 1 CPU, the system will process one task at a time since each task requires 1 CPU.</p>
<p>However, each of these tasks makes an external API call.</p>
<pre><code>@ray.remote
def fetch():
... | <python><ray> | 2024-09-09 14:12:32 | 2 | 407 | zacko |
78,965,783 | 19,218,671 | Problem when I try export '.svg' file in Transitions library in python | <p>I just try a simple example from <a href="https://github.com/pytransitions/transitions?tab=readme-ov-file" rel="nofollow noreferrer">this source</a> to learn library :</p>
<pre><code>from transitions.extensions import GraphMachine
from functools import partial
class Model:
def clear_state(self, deep=False, f... | <python><svg><graph><dot><pytransitions> | 2024-09-09 13:46:02 | 1 | 453 | irmoah80 |
78,965,763 | 23,260,297 | logging/print statements not being captured when running script with Runas command | <p>I am running a python script as a different user with the <code>runas</code> command but I cannot see my output/errors anywhere. I am trying to debug my script, but I cannot see any logging info so it is near impossible to for me to tell what is happening.</p>
<p>Here is what my script looks like:</p>
<pre><code>def... | <python><windows><pyodbc><python-logging><runas> | 2024-09-09 13:40:40 | 1 | 2,185 | iBeMeltin |
78,965,183 | 6,930,340 | How to transform polars expression into ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | <p>According to the documentation for <a href="https://docs.pola.rs/api/python/stable/reference/lazyframe/api/polars.LazyFrame.unpivot.html" rel="nofollow noreferrer">polars.LazyFrame.unpivot</a>, the <code>on</code> or <code>index</code> argument should be of type</p>
<p><code>ColumnNameOrSelector | Sequence[ColumnNam... | <python><python-polars> | 2024-09-09 11:12:46 | 0 | 5,167 | Andi |
78,965,177 | 13,891,321 | QGIS using selectedLayer.getFeatures() but require str for ComboBox | <p>I have written a QGIS plugin to pull features from a layer and then perform various calculations.
The code successfully extracts the full dataset, but I want to populate a ComboBox to be able to select a given row from the data set.</p>
<pre><code> def select_line(self):
"""Load lines from chos... | <python><combobox><qgis><pyqgis> | 2024-09-09 11:10:36 | 0 | 303 | WillH |
78,965,130 | 188,331 | Use added tokens in BertTokenizer with a BartForConditionalGeneration model | <p>I have a <code>BertTokenizer</code> and I added some tokens to it.</p>
<pre><code>from transformers import BertTokenizer, BartForConditionalGeneration
tokenizer = BertTokenizer.from_pretrained("raptorkwok/wordseg-tokenizer")
print(len(tokenizer)) # 245289
print(tokenizer.vocab_size) # 51271
</code></pre>
<... | <python><huggingface-transformers><huggingface-tokenizers> | 2024-09-09 10:59:05 | 0 | 54,395 | Raptor |
78,964,945 | 9,112,151 | How to use AsyncSession.sync_session or how to have both sync and async session with the same scope of objects, single transaction? | <p>I'd like to use <code>AsyncSession.sync_session</code> but the code below fails with error. The code is a simplified version of real case.</p>
<pre class="lang-py prettyprint-override"><code>import sqlalchemy as sa
import uvicorn
from fastapi import FastAPI, Depends
from sqlalchemy import MetaData, select
from sqlal... | <python><sqlalchemy><fastapi> | 2024-09-09 10:09:42 | 1 | 1,019 | Альберт Александров |
78,964,588 | 2,604,247 | Should Polars Enum Datatype Result in More Efficient Storage and Memory Footprint of DataFrame? | <p>I have this dataframe in Python Polars having dimensions (8442x7), basically, 1206 rows for each day of the week. The day of week appears as a simple string.</p>
<p>Thought I would exploit the <code>pl.Enum</code> to encode the <code>ISO_WEEKDAY</code> column, saving space on disk. See the following code.</p>
<pre c... | <python><string><memory-management><enums><python-polars> | 2024-09-09 08:37:12 | 1 | 1,720 | Della |
78,964,577 | 11,555,352 | Pandas concat on resampled data frames results in empty data frame | <p>I have the below code:</p>
<pre><code> raster = "1s"
# Resample data to a shared time raster (e.g. 1s) and combine into a single data frame
dfs_resampled = [df.resample(raster).ffill() for df in dfs]
print("dfs_resampled",dfs_resampled)
# Join resampled data frames into a... | <python><pandas> | 2024-09-09 08:34:43 | 1 | 1,611 | mfcss |
78,964,422 | 8,024,622 | How to substract amount of minutes in Pandas DataFrame datetime with condition? | <p>I have a DataFrame like this (date: datetime64[ns], v: float64)</p>
<pre><code>date v
2024-09-01 22:09:55 1.2
2024-09-01 22:12:08 1.11
2024-09-01 22:59:59 1.7
2024-09-01 23:00:02 1.1
2024-09-01 23:04:00 2.2
</code></pre>
<p>what I want to have is if the minutes in datetime are <code>... | <python><pandas><datetime><timedelta> | 2024-09-09 07:52:44 | 1 | 624 | jigga |
78,964,338 | 296,473 | How do I do server-side default value when using SQLAlchemy 2.0 with dataclass? | <p>I have a column defined as <code>ts timestamp with time zone not null default current_timestamp</code>. I want to SQLAlchemy to not insert this value on the client side when inserting data at the same time passes type checking.</p>
<pre class="lang-py prettyprint-override"><code>class Base(MappedAsDataclass, Declara... | <python><sqlalchemy><python-typing> | 2024-09-09 07:29:46 | 1 | 1,723 | lilydjwg |
78,964,300 | 885,650 | Conditional Multivariate Gaussian with scipy | <p>For a multi-variate Gaussian, it is straight-forward to compute the CDF or PDF given a point. <code>rv = scipy.stats.multivariate_normal(mean, cov)</code> and then <code>rv.pdf(point)</code> or <code>rv.cdf(upper)</code></p>
<p>But I have values for some axis (in these I want the PDF), but upper limits for others (i... | <python><scipy><statistics><normal-distribution> | 2024-09-09 07:16:03 | 1 | 2,721 | j13r |
78,964,171 | 16,611,809 | How to use the input of a field only if it is visible? | <p>How do I manage that an input field value is empty, if it is not shown. In the example the text caption field is empty and not shown. If I show it by ticking "Show text caption field" and enter any text, the text appears in the output field. If I then untick "Show text caption field" the output f... | <python><py-shiny> | 2024-09-09 06:40:34 | 1 | 627 | gernophil |
78,964,104 | 16,611,809 | How to change the value of an ui.input element based on another input? | <p>Is it possible to change the default value of an py-shiny <code>ui.input</code> element based on another input? In the example if I tick "Use uppercase letters" the value should switch from "example text" to "EXAMPLE TEXT".</p>
<pre><code>from shiny import App, Inputs, Outputs, Session,... | <python><py-shiny> | 2024-09-09 06:16:35 | 1 | 627 | gernophil |
78,964,057 | 1,394,353 | Can I perform a bit-wise group by and aggregation with Polars `or_`? | <p>Let's say I have an <code>auth</code> field that use bit flags to indicate permissions (example bit-0 means <code>add</code> and bit-1 means <code>delete</code>).</p>
<p>How do I <code>bitwise-OR</code> them together?</p>
<pre><code>import polars as pl
df_in = pl.DataFrame(
{
"k": ["a&quo... | <python><aggregate><bitwise-operators><python-polars> | 2024-09-09 05:57:05 | 1 | 12,224 | JL Peyret |
78,963,850 | 585,650 | How to patch a function with pytest-mock regardless of path/namespace used to call it? | <p>I am trying to mock a function regardless of how it is imported in the code.
I can't find info on how to do it.</p>
<p>Here is an example, the first assert works as expected but the second fails because path:</p>
<pre><code>import mymodule
from mymodule import test1
def test_mock(mocker):
mocker.patch('mymodul... | <python><mocking><pytest-mock><pytest-mock-patch> | 2024-09-09 04:06:33 | 1 | 597 | Hugo Zaragoza |
78,963,578 | 4,718,221 | Dataclass inheriting using kw_only for all variables | <p>I am practicing on using the super function and dataclass inheritance in general. I have enabled the kw_only attribute for cases when the parent class has default values. I completely understand that super doesn't need to be used in a dataclass if you're just passing variables and I can avoid using super here. My go... | <python><inheritance><python-dataclasses> | 2024-09-09 00:39:01 | 1 | 604 | user4718221 |
78,963,496 | 2,111,390 | Python Floor Division Seems incorrect? | <p>I was noticing that in some situations floor division (the // operator) seems to behave incorrectly. Here is one example:</p>
<pre><code>>>> 59 // 0.2
294.0
</code></pre>
<p>Two things - one, the answer is just wrong. The correct answer is 295 (note that 59 / 0.2 gives the correct result of 295.0). The seco... | <python><floor-division> | 2024-09-08 23:22:05 | 2 | 3,671 | Bryant |
78,963,445 | 15,412,256 | Polars Expression Chaining with Dynamic Number Operations | <p>When dealing with dynamic number of operations, especially with calculations depending on previous steps, the Polars Expression chaining becomes tricky:</p>
<p>here is a demo operator to generate new variables:</p>
<pre class="lang-py prettyprint-override"><code>def demo_operator_addition(var1: str, var2: str) ->... | <python><dataframe><oop><python-polars> | 2024-09-08 22:49:23 | 1 | 649 | Kevin Li |
78,963,347 | 1,316,252 | poisson blending / seamless cloning a head onto a body | <p>I'm trying to paste an image of a human head onto an image of a human body and blend the two together using openCV's seamlessClone (poisson blending). However, the head ends up taking on the color of the surrounding background (green screen) instead of just the neck. I've also tried with a transparent background, ... | <python><opencv><image-processing><computer-vision> | 2024-09-08 21:28:16 | 0 | 3,100 | skunkwerk |
78,963,163 | 3,103,767 | annotate a NamedTuple for storing a function and its args and kwargs | <p>I have a system where i want to store a function along with its arguments for later invocation. I have tried:</p>
<pre class="lang-py prettyprint-override"><code>import typing
P = typing.ParamSpec("P")
class JobPayload(typing.NamedTuple):
fn: typing.Callable[P, None]
args: P.args
kwargs:... | <python><python-typing> | 2024-09-08 19:27:02 | 1 | 983 | Diederick C. Niehorster |
78,963,154 | 11,564,487 | Integral that Sympy cannot solve but Wolfram Alpha can | <p>I am using the following code, which returns the integral itself and not its result:</p>
<pre><code>x = sp.Symbol('x')
integrand = (sp.sqrt(1 - x**2) / (1 + x**2))
sp.integrate(integrand, (x, -1, 1), manual=True)
</code></pre>
<p><a href="https://www.wolframalpha.com/input?i2d=true&i=Integrate%5BDivide%5BSqrt%5B... | <python><sympy> | 2024-09-08 19:21:18 | 3 | 27,045 | PaulS |
78,963,092 | 3,607,022 | How to Determine List Repeats and Item Percentage for Desired Proportion in a New List | <p>Working on a problem where I need to modify a list by adding another item, and I want this item to make up a specific percentage of the new total length of the list. I need help figuring out how to do this. Here’s the situation:</p>
<p>Have:</p>
<p>An existing list with a specific length (<code>list_length</code>).
... | <python><algorithm><discrete-mathematics> | 2024-09-08 18:47:07 | 1 | 482 | user3607022 |
78,962,922 | 19,218,671 | "add_transition() argument after ** must be a mapping, not str" : transitions python library | <p>I just try make simple graph with <code>transitions</code> library :</p>
<pre><code>from transitions.extensions.diagrams import HierarchicalGraphMachine
from IPython.display import display, Markdown
states = ['engoff' , 'poweron' , 'engon' , 'FCCActions' #'emgstatus' , "whevent" , 'new data receive'
... | <python><graph> | 2024-09-08 17:25:45 | 1 | 453 | irmoah80 |
78,962,730 | 6,843,153 | Creating streamlit-altair chart from example renders no data | <p>I'm trying to render the <strong>streamlit-altair</strong> chart from <a href="https://vega.github.io/vega-lite/examples/interactive_bar_select_highlight.html" rel="nofollow noreferrer">this example</a>, so I implemented the following code:</p>
<pre><code>import altair as alt
import streamlit as st
from view.fronte... | <python><streamlit><altair> | 2024-09-08 15:41:36 | 0 | 5,505 | HuLu ViCa |
78,962,681 | 1,097,562 | Adding Oauth 2.0 to Google Fact Check Tools API | <br>
<p>I have a simple Python code to search through Fact Check claims using the Google Fact Check Tools API. I have updated the code to include OAuth flow and here is my code:</p>
<pre><code>import requests
import google.auth
from google.oauth2 import service_account
import os
import json
from google.auth.transport.... | <python><google-cloud-platform><oauth-2.0><google-api><google-oauth> | 2024-09-08 15:15:15 | 1 | 851 | Basith |
78,962,533 | 6,662,425 | Memory Layout for Sparse matrix | <p>I have a very specific sparse matrix layout and I am looking for storage recommendations.</p>
<p>The matrices I consider</p>
<ul>
<li>are symmetric and positive definite</li>
<li>made up of block matrices (all blocks have the same size)</li>
<li>every block is a "KiteMatrix", i.e. it has a dense upper left... | <python><scipy><sparse-matrix><matrix-multiplication> | 2024-09-08 14:01:46 | 1 | 1,373 | Felix Benning |
78,962,239 | 3,806,340 | Define API for multiple concrete implementations | <p>I try to implement multiple concrete classes, which share the same API. The base functionalities between these classes are the same, but they support different types of configuration (among shared ones). I would like to keep the implementation between these concrete classes as separate as possible.</p>
<p>Therefore ... | <python><inheritance><design-patterns><interface> | 2024-09-08 11:23:01 | 1 | 2,728 | Guti_Haz |
78,962,178 | 2,622,368 | How to set the value of os.environ in python using the command line? | <p>OS:Win10</p>
<pre><code>reg add HKCU\Environment /F /V http_proxy /d "http://127.0.0.1:8080"
reg add HKCU\Environment /F /V https_proxy /d "http://127.0.0.1:8080"
</code></pre>
<p>I'm pretty sure this is the only place where the variable is set. http_proxy is no longer in the variables shown by s... | <python><windows><cmd><environment> | 2024-09-08 10:49:53 | 1 | 829 | wgf4242 |
78,961,894 | 13,467,891 | Cannot install ale-py in docker | <p>I'm trying to build dockerfile as below:</p>
<pre><code>FROM python:3.10
RUN pip install ale-py
</code></pre>
<p>If I try to build, I get error msg like:</p>
<pre><code>1.436 ERROR: Could not find a version that satisfies the requirement ale-py (from versions: none)
1.436 ERROR: No matching distribution found for al... | <python><docker><pip> | 2024-09-08 08:17:07 | 2 | 715 | Geonsu Kim |
78,961,813 | 2,118,290 | Using py7zr is there a way to set compression level? | <p>Looking at the documentation there is not much info on this.</p>
<pre><code>import py7zr
with py7zr.SevenZipFile("test.7z", 'w') as archive:
archive.write("somefile.txt")
</code></pre>
<p>Theres a snippet at the bottom of <a href="https://py7zr.readthedocs.io/en/latest/api.html" rel="nofollow... | <python><compression><py7zr> | 2024-09-08 07:22:39 | 0 | 674 | Steven Venham |
78,961,544 | 8,584,998 | Improving TimescaleDB Compression Ratios; Using Brotli Parquet to Compare | <p>I've got about 435 million rows of the form:</p>
<p><code>time, sensor_id, sensor_value</code></p>
<p>where <code>time</code> is a unix timestamp rounded to one decimal point, <code>sensor_id</code> is an integer, and the <code>sensor_value</code> is a float. The timestamps are one second apart, and for each timesta... | <python><postgresql><compression><parquet><timescaledb> | 2024-09-08 03:18:39 | 0 | 1,310 | EllipticalInitial |
78,961,326 | 14,895,716 | Jupyter Lab throws "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" from workspaces handler | <p>I'm on Windows. Have been using Jupyter Lab for a while with no problems. Very recently, every time I launched Jupyter, it errored out as such:</p>
<pre><code>[W 2024-09-08 02:02:06.730 ServerApp] 500 GET /lab/api/workspaces?1725750126696 (::1): Expecting value: line 1 column 1 (char 0)
[W 2024-09-08 02:02:06.731 La... | <python><jupyter-notebook><anaconda><jupyter><jupyter-lab> | 2024-09-07 23:21:10 | 1 | 627 | Shay |
78,961,304 | 1,227,860 | ParaView: How to create a new vector based on an existing vector using Programmable Filter | <p>My VTI file loaded in Paraview has a 3D data array named <code>MyVelocity</code>. I want to create a new velocity vector as follows:</p>
<pre><code>unew = -u
vnew = -v
wnew = w
</code></pre>
<p>I am trying to use a <code>Programmable Filter</code> to create this array.</p>
<pre><code>import numpy
u=inputs[0].Point... | <python><paraview> | 2024-09-07 22:59:47 | 1 | 2,367 | shashashamti2008 |
78,961,298 | 1,196,031 | Django password reset with front end UI | <p>I'm working on a project that uses Django as the backend and next.js/react.js on the front end. The issue I'm running into is trying to reset the password using the UI of my front end. All of the solutions I've found involve creating the UI on the backend server with templates which I would prefer not to do.</p>
<... | <python><django><django-rest-framework> | 2024-09-07 22:54:51 | 2 | 3,363 | DroidT |
78,961,172 | 2,595,546 | Gmail draft attachment reads "noname" | <p>I am using the Gmail API, and have strongly followed the example they show in their documentation, which can be found here: <a href="https://github.com/googleworkspace/python-samples/blob/main/gmail/snippet/send%20mail/create_draft_with_attachment.py" rel="nofollow noreferrer">https://github.com/googleworkspace/pyth... | <python><email><gmail-api> | 2024-09-07 21:22:04 | 1 | 868 | Fly |
78,961,150 | 3,018,860 | Add "+" sign in positive values using astropy and matplotlib | <p>I'm using astropy, matplotlib, skyfield and astroquery to create sky charts with Python. With skyfield I do the stereographic projection of the sky. With astropy I use WCS, something like this:</p>
<pre class="lang-py prettyprint-override"><code>fig = plt.figure(figsize=[600/96, 500/96])
plt.subplots_adjust(left=0.1... | <python><matplotlib><astropy> | 2024-09-07 21:13:46 | 1 | 2,834 | Unix |
78,960,966 | 9,890,027 | Is there a way to specify default dependencies, or dependencies installed only if an extra is not specified, in pyproject.toml? | <p>I have a library mylib that depends on OpenCV. There are 2 distributions of OpenCV, opencv-python and opencv-python-headless. Either one works for mylib but only one can be installed, so for downstream code that uses OpenCV it is important for consumers to be able to choose which they are getting.</p>
<p>This can be... | <python><python-packaging><pyproject.toml> | 2024-09-07 19:47:25 | 0 | 1,899 | Ders |
78,960,741 | 4,181,335 | 'offset points' in matplotlib.pyplot.annotate gives unexpected results | <p>I am using the following code to generate a plot with a sine curve marked with 24 'hours' over 360 degrees. Each 'hour' is annotated, however the arrow lengths decrease (shrivel?) with use and even their direction is incorrect.</p>
<p>The X axis spans 360 degrees whereas the Y axis spans 70 degrees. The <code>print<... | <python><matplotlib> | 2024-09-07 17:38:37 | 1 | 343 | Aendie |
78,960,710 | 6,923,568 | How to optimally stretch and uniformize 1-dimensional integer points? | <p><strong>The data:</strong></p>
<p>Let <code>X</code> be an array of labeled integers roughly in the domain <code>[0, 2000000]</code>. The size <code>|X|</code> is around 3000 elements. The labels are in the domain <code>[A, B, C]</code>.</p>
<p>For example: <code>[(13, A), (16, B), (32, A), (84, C), ...]</code></p>
... | <python><arrays><optimization><variance> | 2024-09-07 17:27:40 | 1 | 1,509 | Mat |
78,960,708 | 2,950,593 | pipreqs django UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 81: invalid start byte | <p>trying to make a requirements.txt file but get an error
what do i do?</p>
<pre><code> (.venv) root@vm-89f2b1ea:~/code/aigenback# pipreqs ~/code/aigenback
INFO: Not scanning for jupyter notebooks.
<unknown>:165: SyntaxWarning: invalid escape sequence '\S'
<unknown>:166: SyntaxWarning: invali... | <python> | 2024-09-07 17:26:29 | 1 | 9,627 | user2950593 |
78,960,340 | 1,075,374 | How can I follow an HTTP redirect? | <p>I have 2 different views that seem to work on their own. But when I try to use them together with a http redirect then that fails.</p>
<p>The context is pretty straightforward, I have a view that creates an object and another view that updates this object, both with the same form.</p>
<p>The only thing that is a bit... | <python><django><pytest> | 2024-09-07 14:12:25 | 1 | 5,865 | Bastian |
78,960,293 | 7,387,749 | How to Load a ‘Learner’ Model with a Custom Loss Function in a Flask Application | <p>I am currently working on loading a learner model from a <code>pickle</code> file. This model includes a custom loss function and needs to be integrated into a Flask application. The loss function is in the same file as the <code>Flask</code> app.<p>
However, I keep encountering the following error:</p>
<pre><code>C... | <python><flask><pickle><fast-ai> | 2024-09-07 13:53:01 | 0 | 4,980 | Simone |
78,960,111 | 2,754,510 | Singular matrix during B Spline interpolation | <p>According to the literature about B Splines, including <a href="https://mathworld.wolfram.com/B-Spline.html" rel="nofollow noreferrer">Wolfram Mathworld</a>, the condition for Cox de Boor's recursive function states that:</p>
<p><a href="https://i.sstatic.net/TMcrjZZJ.png" rel="nofollow noreferrer"><img src="https:/... | <python><numpy><spline> | 2024-09-07 12:23:41 | 1 | 3,276 | Constantinos Glynos |
78,960,008 | 4,718,221 | Dataclass inheritance variables not working | <p>I have a dataclass subclass that is just inheriting variables. I know the keyword variables need to come last, but even with that, the order of variables in the subclass seems to have changed. I don't understand what the error message is telling me</p>
<pre><code>@dataclass
class ZooAnimals():
food_daily_kg:... | <python><inheritance><python-dataclasses> | 2024-09-07 11:25:54 | 3 | 604 | user4718221 |
78,959,909 | 7,347,925 | Calculate the polygon angle based on point inside? | <p>I have one polygon and want to calculate the wind direction based on the long boundary and point inside. The point is the wind's starting point and the direction follows the long distance to the short edge.</p>
<p>Here's an example of my idea. 1) find the long boundary of polygon 2) find the point of the boundary li... | <python><polygon><shapely><point-in-polygon> | 2024-09-07 10:19:32 | 0 | 1,039 | zxdawn |
78,959,850 | 4,451,315 | Change x-label after chart has already been created | <p>Say I have:</p>
<pre class="lang-py prettyprint-override"><code>import altair as alt
import polars as pl
chart = (
alt.Chart(pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}))
.mark_point()
.encode(x="a", y="b")
)
</code></pre>
<p>Suppose I have a function which rece... | <python><altair> | 2024-09-07 09:46:10 | 2 | 11,062 | ignoring_gravity |
78,959,829 | 3,254,920 | Python Script Works from Command Line but Fails When Called from C# in IIS | <p>I have a MVC application written in C# and hosted on IIS. In my C# code, I am trying to call a Python script to access the Scopus website and retrieve user information. The Python script works perfectly when run from the command line, but when I call it from my C# code, it throws an error. I face some permission pro... | <python><c#><asp.net-mvc><iis><seleniumbase> | 2024-09-07 09:37:05 | 1 | 1,228 | Abdul Hadi |
78,959,746 | 1,516,331 | Python singleton implementation not working | <p>I am trying to implement a singleton pattern for a config class. I have a <code>_Config</code> class which loads the <code>config.yaml</code> file. <code>Config</code> class is a subclass of <code>_Config</code> class, whenever creating an instance of <code>Config</code> class, I expect it always returns the single ... | <python><inheritance><runtime-error><singleton> | 2024-09-07 08:56:09 | 1 | 3,190 | CyberPlayerOne |
78,959,536 | 2,641,825 | Using nbstripout as a filter, the git diff of a jupyter notebook is empty. How to temporarily deactivate nbstripout's git filter? | <p>I am using <a href="https://github.com/kynan/nbstripout" rel="nofollow noreferrer">nbstripout</a> to remove the outpout of jupyter notebook before committing them into git.</p>
<p>I had an issue where git status gave the notebook <code>.ipynb</code> file as changed, but git diff didn't show any change. I solved the ... | <python><git><jupyter-notebook> | 2024-09-07 06:45:54 | 0 | 11,539 | Paul Rougieux |
78,959,447 | 13,379,374 | Efficient PyTorch band matrix to dense matrix multiplication | <p><strong>Problem:</strong> In one of my programs, I need to calculate a matrix multiplication <code>A @ B</code> where both are of size N by N for considerably large N. I'm conjecturing that approximating this product by using <code>band_matrix(A, width) @ B</code> could just suffice the needs, where <code>band_matri... | <python><machine-learning><pytorch> | 2024-09-07 05:46:17 | 1 | 585 | VIVID |
78,959,401 | 1,176,573 | plotly - how to plot multiple categories on by grouping on another criteria | <p>I wish to plot the <code>x-axis</code> as years <code>['10 Years', '5 Years', '3 Years', 'TTM']</code> and group them for each stock. But the for loop is not working as expected.</p>
<pre class="lang-py prettyprint-override"><code>mydict = {
'Compounded Sales Growth' : ['10 Years', '5 Years', '3 Years', 'TTM', '10... | <python><plotly> | 2024-09-07 05:24:22 | 0 | 1,536 | RSW |
78,959,131 | 1,601,580 | VLLM Objects Cause Memory Errors When Created in a Function even when explicitly clearing GPU cache, only sharing ref makes code not crash | <p>I'm encountering an issue when using the VLLM library in Python. Specifically, when I create a VLLM model object inside a function, I run into memory problems and cannot clear the GPU memory effectively, even after deleting objects and using <code>torch.cuda.empty_cache()</code>.</p>
<p>The problem occurs when I try... | <python><machine-learning><pytorch><gpu><vllm> | 2024-09-07 00:58:59 | 1 | 6,126 | Charlie Parker |
78,959,081 | 10,054,520 | Subset columns from pandas dataframe that do not start with "X" | <p>I'm trying to subset a dataframe by not selecting columns that I do not want that all start with the same phrase. In other words I want the entire dataframe, except for columns that start with "death".</p>
<p>Say I have a dataframe with these columns</p>
<div class="s-table-container"><table class="s-tabl... | <python><pandas><dataframe> | 2024-09-07 00:14:16 | 3 | 337 | MyNameHere |
78,959,003 | 1,471,828 | How do I make variable aware of the output of gencache.EnsureModule? | <p><strong>workaround</strong> In the end I just copied the <code>make_py</code> output to my project and imported the entry-point class.</p>
<p>How do I make <code>win32com.client.Dispatch(APPID)</code> aware there is a <code>gencache</code>d version?</p>
<p>Consider the following code and note that <code>%TEMP%\gen_p... | <python><win32com> | 2024-09-06 23:12:46 | 0 | 905 | Rno |
78,958,965 | 11,946,045 | How do I read a struct contents in a running process? | <p>I compiled a C binary on a linux machine and executed it, in that binary I have a struct called <code>Location</code> defined as follows</p>
<pre><code>typedef struct
{
size_t x;
size_t y;
} Location;
</code></pre>
<p>and here is my main function</p>
<pre><code>int main(void)
{
srand(0);
Location lo... | <python><c><memory><stack> | 2024-09-06 22:44:38 | 2 | 814 | Weed Cookie |
78,958,947 | 1,520,291 | TensorFlow custom weights manipulation | <p>So, I'm having difficulty with implementing custom modification of weights, which is not based on any of the standard TF-provided optimizers and doesn't care about gradient tape whatsoever.</p>
<p>Essentially, what I'm trying to achieve is to update weights of the neural network after each training iteration, indepe... | <python><tensorflow><keras> | 2024-09-06 22:36:58 | 0 | 3,301 | Dmytro Titov |
78,958,924 | 3,407,994 | mypy handle type errors once optional type is guaranteed not None | <p>I have some method that returns an optional float/None. I use the output of that conditionally, if <code>None</code> I do one thing, if truthy (a <code>float</code>) I pass through later methods.</p>
<p>Currently mypy raises errors that those later methods don't suport a <code>None</code>. How do I either change the... | <python><python-typing><mypy> | 2024-09-06 22:24:25 | 2 | 1,758 | kuanb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.