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,130,743 | 2,403,672 | Parsing a csv file to add details to xml file | <p>Ned help to parse a csv file which has following details to xml file</p>
<p>csv file is in the following format:</p>
<pre><code>name,ip,timeout
domain\user1,10.119.77.218,9000
domain\user2,2.80.189.26,9001
domain\user3,4.155.10.110,9002
domain\user4,9.214.119.86,9003
domain\user5,4.178.187.27,9004
domain\user6,3.76.... | <python><xml><csv><scripting> | 2024-03-08 23:42:56 | 2 | 736 | deep |
78,130,671 | 4,298,228 | Alembic dependency resolution with depends_on | <p>I'm working on a project with multiple branches, and I'm finding something funny when running my migrations...</p>
<p>I have a <code>main</code> branch that has the following revisions: <code>A --> B --> C</code></p>
<p>And then a dev branch with <code>B' --> C'</code></p>
<p><code>B'</code> depends on <cod... | <python><alembic> | 2024-03-08 23:16:12 | 1 | 341 | Fernando |
78,130,654 | 464,277 | hmmlearn MultinomialHMM emissionprob_ size | <p>I'm using the code below to fit an HMM model with two hidden states, a vocabulary of size 5 (so 5 possible symbols), and a list of sequences, each with 10 observations.
I don't understand why <code>model.emissionprob_</code> has size <code>(2, 10)</code>, when the number of columns should be equal to the number of s... | <python><statistics><probability><hidden-markov-models><hmmlearn> | 2024-03-08 23:10:33 | 1 | 10,181 | zzzbbx |
78,130,460 | 2,727,167 | equidistant points between two points in subarrays | <p>I have following matrix which represents xy points:</p>
<p><a href="https://i.sstatic.net/BqY1L.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BqY1L.png" alt="enter image description here" /></a></p>
<p>First column is <strong>x</strong> coordinate, second column is <strong>y</strong> coordinate, thi... | <python><arrays><numpy> | 2024-03-08 22:03:44 | 1 | 450 | user2727167 |
78,130,401 | 1,561,777 | Python Tensorflow-Intel For Linux Does Not Exist | <p>I am very new to Python. We have an Azure Python Function. We need to update the packages that it uses. Some of the packages are:</p>
<pre><code>tensorflow==2.15.0
tensorflow-estimator==2.15.0
tensorflow-intel==2.15.0
tensorflow-io-gcs-filesystem==0.31.0
</code></pre>
<p>I tested these Windows versions of the packag... | <python><linux><tensorflow><python-packaging><python-3.11> | 2024-03-08 21:45:04 | 1 | 772 | David.Warwick |
78,130,380 | 7,265,114 | Remove white spaces in subplots matplolib | <p>I try to plot the subplots as shown below. It works okay but it still have some white spaces at the end of figure. Is it possible remove white spaces. Any help would be very great.</p>
<p>Here is the code and simulated data.</p>
<pre><code>import numpy as np
import xarray as xr
import geopandas as gpd
import requ... | <python><matplotlib><geopandas><python-xarray> | 2024-03-08 21:38:51 | 0 | 1,141 | Tuyen |
78,130,279 | 10,801,098 | Get ORM class from schema instance in SQL alchemy | <p>In SQL alchemy, you may do something like this to do a query:</p>
<pre><code>model_instance = session.query(SomeModel).filter(SomeModel.value == some_value).first()
</code></pre>
<p>where <code>model_instance</code> is equivalent to some form of this, with data omitted:</p>
<pre><code>model_instance = SomeModel( ...... | <python><sqlalchemy> | 2024-03-08 21:03:32 | 1 | 1,536 | bug_spray |
78,130,371 | 2,925,767 | How to run EdgeOS configuration commands in python fabric | <p>I'm trying to programmatically update configuration in EdgeOS using a python script. I'm using fabric as an ssh client. <a href="https://docs.fabfile.org/en/latest/index.html" rel="nofollow noreferrer">https://docs.fabfile.org/en/latest/index.html</a></p>
<p>Below "---original question---" describes the pr... | <linux><bash><ssh><python> | 2024-03-08 20:53:41 | 2 | 1,085 | icicleking |
78,130,226 | 947,012 | Why does my Azure Function disobey env var logging settings but respect host.json? | <p>I added logging through opentelemetry and now I am getting duplicated entries of logs as they are sent through both Function's handler and opentelemetry handler.</p>
<p>I want to disable Function logging as opentelemetry adds tracer span awareness through OperationID/ParentID, thus making opentelemetry logs more fun... | <python><logging><azure-functions><azure-functions-runtime> | 2024-03-08 20:50:22 | 2 | 3,234 | greatvovan |
78,130,203 | 6,401,403 | Pandas: make list size in a column same as in another column | <p>I have two columns: <code>serial_number</code> and <code>inv_number</code> containing lists. If there is one <code>inv_number</code> for multiple <code>serial_number</code>, I need to make the size of <code>inv_number</code>'s list the same as <code>serial_number</code>'s.</p>
<pre><code> serial_number ... | <python><pandas><list> | 2024-03-08 20:44:12 | 2 | 5,345 | Michael |
78,130,054 | 1,036,582 | Python imports fail when using unittest module | <p>I have the following directory structure:</p>
<pre><code>project/
lambda_functions/
user_plot
user_plot_lib/
├── __init__.py
├── a.py
└── b.py
user_plot_client.py
test/
unit/
├── __init__.py
├── test_... | <python><python-import><python-unittest> | 2024-03-08 20:10:41 | 0 | 373 | Movieboy |
78,129,981 | 23,519,070 | Logging Error: Failed to initialize logging system. Log messages may be missing.? | <blockquote>
<p>Logging Error: Failed to initialize logging system. Log messages may be missing. If this issue persists, try setting IDEPreferLogStreaming=YES in the active scheme actions environment variables.</p>
</blockquote>
<p>Has anyone else encountered this message?</p>
<p>Where is <code>IDEPreferLogStreaming</c... | <python><swift><xcode> | 2024-03-08 19:52:20 | 4 | 945 | James Menkal |
78,129,942 | 13,812,982 | Reading a Protected View Excel file using xlsxwriter | <p>I am trying to read an Excel .xlsx file that has been saved from an Outlook attachment. My security setting (which I cannot change) puts this file into <code>Protected View</code> mode.</p>
<p>If I try and read this file via <code>xlsxwriter</code></p>
<pre><code>import xlsxwriter
xlsx = 'protectedfile.xlsx'
wbWrite... | <python><excel> | 2024-03-08 19:43:08 | 0 | 4,331 | DS_London |
78,129,852 | 1,226,676 | Uploading multiple large files with django on Google App Engine -- how to do multiple requests | <p>I'm trying to figure out how to load multiple large files (like 4K images) to Google Cloud Storage via django using the default admin interface.</p>
<p>For example, I have a model with multiple images:</p>
<pre><code>MyModel(models.Model):
image_1 = models.ImageField(
null=True,
upload_to="m... | <python><django><google-app-engine><google-cloud-storage> | 2024-03-08 19:21:50 | 0 | 5,568 | nathan lachenmyer |
78,129,833 | 4,575,197 | How to add two side slide button to a line chart based on the year using Altair | <p>i have a line chart that has date as X axis. i want to filter this with a double (two) sided slide button for filtering proposes. So i want to be able to filter the data from starting and end date of the dataframe. my date is in YYYY-MM-DD format, so it needs to be transformed.</p>
<p>my data:</p>
<pre><code>data = ... | <python><dataframe><filtering><visualization><altair> | 2024-03-08 19:15:28 | 0 | 10,490 | Mostafa Bouzari |
78,129,823 | 195,540 | Python opentelemetry events in Application Insights | <p>I'm following the guides below trying to setup logging in Azure Application Insights for my django application:</p>
<p><a href="https://uptrace.dev/get/instrument/opentelemetry-django.html" rel="nofollow noreferrer">https://uptrace.dev/get/instrument/opentelemetry-django.html</a>
<a href="https://uptrace.dev/opentel... | <python><django><azure-application-insights><open-telemetry> | 2024-03-08 19:13:19 | 1 | 1,787 | scoopseven |
78,129,351 | 1,744,357 | SOAP Header Invalid Signature on Timestamp | <p>One of our SAML signatures in the SOAP header is invalid. You can confirm it fails at this website: <a href="https://tools.chilkat.io/xmlDsigVerify.cshtml" rel="nofollow noreferrer">https://tools.chilkat.io/xmlDsigVerify.cshtml</a> . We have attempted troubleshooting to no avail. We believe the issue lies somewhere ... | <python><soap><saml><zeep> | 2024-03-08 17:30:41 | 1 | 571 | rocket_boomerang_19 |
78,129,322 | 13,578,682 | datetimes and dates should never be equal | <pre class="lang-py prettyprint-override"><code>from datetime import datetime, date
class MyDate(date):
pass
print(MyDate(2024, 3, 8) == datetime(2024, 3, 8))
print(date(2024, 3, 8) == datetime(2024, 3, 8))
</code></pre>
<p>Expected output:</p>
<pre class="lang-py prettyprint-override"><code>False
False
</code></... | <python> | 2024-03-08 17:23:47 | 1 | 665 | no step on snek |
78,129,071 | 6,197,439 | Break/wrap long text of column names in Pandas dataframe plain text to_string output? | <p>Consider this example:</p>
<pre class="lang-python prettyprint-override"><code>import pandas as pd
df = pd.DataFrame({
"LIDSA": [0, 1, 2, 3],
"CAE": [3, 5, 7, 9],
"FILA": [1, 2, 3, 4], # 2 is default, so table idx 1 is default
"VUAMA": [0.5, 1.0, 1.5, 2.0],
})
df_coln... | <python><pandas><dataframe><word-wrap> | 2024-03-08 16:38:25 | 2 | 5,938 | sdbbs |
78,129,051 | 4,269,851 | Make this python loop algorithm shorter (mathematics invloved) | <p>For sake of learning i opt for not using any additional libraries.</p>
<p>Goal of this algorithm to break lit <code>lst</code> into chunks 8 records each.
And additionally load the values from dictionary <code>dct</code> for records of <code>lst</code> 1-8, 9-16, 17-24.</p>
<p>Trying to avoid unnecessary <code>for l... | <python><loops><mathematical-optimization><mathematical-expressions> | 2024-03-08 16:35:10 | 5 | 829 | Roman Toasov |
78,128,950 | 1,108,872 | Why do I get back different eigenvectors that I put in? | <p>I am trying to build a matrix A from a set of eigenvectors and eigenvalues, and then reverse the operation to get the eigenvectors and eigenvalues back. I am not generally able to recover the eigenvalue-eigenvector combination that I start with, and I'm having trouble understanding why.</p>
<p>I can fully appreciate... | <python><numpy><linear-algebra><eigenvalue><eigenvector> | 2024-03-08 16:12:56 | 1 | 635 | Nordlendingen |
78,128,890 | 6,197,439 | Pandas dataframe title/caption in plain text to_string output? | <p>As an example:</p>
<pre class="lang-python prettyprint-override"><code>import pandas as pd
df = pd.DataFrame({
"Hello World": [1, 2, 3, 4],
"And Some More": [10.0, 20.0, 30.0, 40.0],
})
df_caption = "Table 1: My Table"
df.style.set_caption(df_caption) # only works for HTML; https:/... | <python><pandas><dataframe><pandas-styles> | 2024-03-08 16:02:14 | 2 | 5,938 | sdbbs |
78,128,878 | 20,122,390 | How can I apply a validator with each_item in Pydantic 2? | <p>I'm migrating a microservice from Pydantic 1 to Pydantic 2. Previously I had this:</p>
<pre><code>class ComplementQuery(BaseModel):
imports: List[str] = Field(default_factory=list)
subquery: str = Field(...)
@validator("imports", pre=True, each_item=True)
def complement_imports(cls, value:... | <python><pydantic><pydantic-v2> | 2024-03-08 15:58:27 | 1 | 988 | Diego L |
78,128,775 | 6,435,921 | Leverage broadcasting to make this subtraction more efficient | <p>I have an array <code>x</code> of shape <code>(N, T, d)</code>. I have two functions <code>f</code> and <code>g</code> which both take an array of shape <code>(some_dimension, d)</code> and return an array of shape <code>(some_dimension, )</code>.</p>
<p>I would like to compute <code>f</code> on all of <code>x</code... | <python><arrays><numpy><array-broadcasting> | 2024-03-08 15:36:46 | 1 | 3,601 | Euler_Salter |
78,128,774 | 2,760,194 | Intermittent Redis timeout issues when a Function attempts to connect to the server | <p>I might just be missing something very basic, but please bear with me.</p>
<p>I need to have my Azure Function App connect to an Azure VM that has Redis in it. The following is a simple version of my code with the irrelevant parts removed:</p>
<pre><code># main.py
import logging
import azure.functions as func
from ... | <python><azure><redis><azure-functions><azure-virtual-machine> | 2024-03-08 15:36:32 | 0 | 385 | Cezille07 |
78,128,765 | 5,931,672 | Running SQLAlchemy inside postgres docker container | <p>I have the following <code>Dockerfile</code>:</p>
<pre><code>FROM postgres
RUN apt-get update && \
apt-get install \
--yes \
--no-install-recommends \
python3-pip libpq-dev
RUN pip3 install \
--default-timeout=100 \
sqlalchemy sqlalchemy-utils sqlalchemy-utils psycopg2-binary
COPY... | <python><docker><sqlalchemy><dockerfile> | 2024-03-08 15:35:08 | 1 | 4,192 | J Agustin Barrachina |
78,128,731 | 1,045,704 | How to print a horizontal line on the paper of a thermal printer? | <p>In HTML5 we use the <code><hr></code> tag to draw a horizontal line. Now from <code>Javascript</code> I want to post data to a Python project for printing on a <strong>thermal printer</strong> :</p>
<pre><code>let data = "Prestation : steak \n";
data += "Quantite : 3 \n";
data += // here I ... | <javascript><python><jquery><thermal-printer> | 2024-03-08 15:30:13 | 1 | 19,577 | pheromix |
78,128,694 | 13,328,625 | Huggingface Seq2seqTrainer freezes on evaluation | <p>I'm currently trying to train a Whisper model by following the <a href="https://huggingface.co/blog/fine-tune-whisper#training-and-evaluation" rel="nofollow noreferrer">Fine Tune Whisper Model</a> tutorial. However, during the training phase where I call <code>trainer.train()</code>. I see the progress bar progresse... | <python><huggingface-transformers><huggingface><openai-whisper><huggingface-trainer> | 2024-03-08 15:24:41 | 1 | 478 | InvalidHop |
78,128,662 | 4,212,158 | Converting Pytorch bfloat16 tensors to numpy throws TypeError | <p>When you try to convert a Torch bfloat16 tensor to a numpy array, it throws a <code>TypeError</code>:</p>
<pre class="lang-py prettyprint-override"><code>import torch
x = torch.Tensor([0]).to(torch.bfloat16)
x.numpy() # TypeError: Got unsupported ScalarType BFloat16
import numpy as np
np.array(x) # same error
</... | <python><numpy><pytorch><floating-point><tensor> | 2024-03-08 15:18:42 | 1 | 20,332 | Ricardo Decal |
78,128,397 | 6,779,049 | Ignore Greek Letter Representation in SymPy? | <p>I'm trying to make a variable with the subscript <code>pi</code> on it as follows:</p>
<pre><code>r_pi = sp.symbols('r_pi')
</code></pre>
<p><a href="https://i.sstatic.net/amlfR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/amlfR.png" alt="enter image description here" /></a></p>
<p>When displayed, ... | <python><sympy> | 2024-03-08 14:34:33 | 1 | 398 | Nick-H |
78,128,367 | 8,506,921 | Cross merge by group in pandas | <p>I am trying to cross merge two dataframes but limiting the merge so only combinations within the same group are provided. The pandas documentation says <code>When performing a cross merge, no column specifications to merge on are allowed</code>. At the moment to achieve this I'm using a for loop and concatenating th... | <python><pandas> | 2024-03-08 14:29:21 | 1 | 1,874 | Jaccar |
78,128,366 | 6,779,049 | How to Change String Representation of Sympy Symbol? | <p>Is there a simple way to change the string representation of a SymPy Symbol?</p>
<p>Example:</p>
<pre><code>rpj_g0x = sp.symbols('r_{pj/g0\\,x}')
</code></pre>
<p>This will give me a valid, nicely printed symbol representing the x-component of a position vector.</p>
<p><a href="https://i.sstatic.net/1PRA4.png" rel="... | <python><sympy> | 2024-03-08 14:29:13 | 0 | 398 | Nick-H |
78,128,335 | 4,362,655 | Correlation matrix shrinkage causes matrix multiplication error for monte carlo simulation | <p>I have list of 10 stocks and a correlation 10x10 correlation matrix for these stocks. I have to reduce the size of this matrix to 3x3 and use it for Monte Carlo simulation to simulate possible outcomes. The problem is that reducing the size is causing the matrix multiplication to fail. How can I move forward ?</p>
<... | <python><correlation><matrix-multiplication><pca><montecarlo> | 2024-03-08 14:23:51 | 0 | 1,575 | LuckyStarr |
78,128,310 | 2,175,347 | PySimpleGUI: How to detect overflow of elements beyond the window limits? | <p>In the example below, there is a row with more elements than fit the window. How can I detect the overflow?</p>
<pre class="lang-py prettyprint-override"><code>import PySimpleGUI as sg
layout = [[sg.Text(f"word{i}") for i in range(30)]]
window = sg.Window("Demo", layout, size=(500, 100))
window... | <python><user-interface><pysimplegui> | 2024-03-08 14:20:06 | 1 | 346 | tmalsburg |
78,128,307 | 5,043,301 | How to show data from Database to in Django Templates | <p><strong>I am learning django. My <code>views.py</code> is like below which is inside <code>student</code> app folder.</strong></p>
<pre><code>from django.shortcuts import render
# from .models import Student
from student.models import Student
# Create your views here.
def home(request):
student_data = Student.... | <python><django> | 2024-03-08 14:19:38 | 0 | 7,102 | abu abu |
78,128,206 | 4,930,914 | Return sentences from list of sentences using user specified keyword | <p>I got a list of sentences (roughly 20000) stored in excel file named list.xlsx and sheet named Sentence under column name named Sentence.</p>
<p>My intention is to get words from user and return those sentences where in those exact words matches.</p>
<p>I am currently able to do so with the code i developed using s... | <python><spacy><text-processing> | 2024-03-08 14:02:59 | 1 | 915 | Programmer_nltk |
78,128,203 | 2,092,445 | How to get hold of Warnings in Pandera as objects instead of string? | <p>I am new to Pandera and using it to run some schema validations on my dataframe. I want to use a mix of warnings and errors. The error part is what is working seamlessly. What I am doing is to catch the rows in the original dataframe which failed validations using index column of failure_cases in SchemaErrors and s... | <python><pandera> | 2024-03-08 14:02:52 | 0 | 2,264 | Naxi |
78,127,976 | 5,547,553 | How to add new columns from a list to an existing dataframe in polars? | <br>
I'd like to add new empty columns (elements of mylist) to an existing dataframe.<br>
This code does it:
<pre><code>import polars as pl
df = pl.DataFrame({'a': [1,2,3]})
mylist = [f'col{i}' for i in range(1,4)]
data = [[''] for i in range(1,len(mylist)+1)]
df.join(pl.DataFrame(data=data,schema=mylist),
ho... | <python><dataframe><python-polars> | 2024-03-08 13:25:30 | 2 | 1,174 | lmocsi |
78,127,851 | 3,616,293 | Find neighborhood for torch tensor | <p>I am trying to implement a Self-Organizing Map where for a given input sample, the best matching unit/winning unit is chosen based on (say) L2-norm distance between the SOM and the input. The winning unit/BMU (som[x, y]) has the smallest L2 distance from the given input (z):</p>
<pre><code># Input batch: batch-size ... | <python><numpy><pytorch> | 2024-03-08 13:01:39 | 1 | 2,518 | Arun |
78,127,662 | 1,473,517 | How to remove "exterior" parts of a diagonal line that is clipping a circle | <p>In this <a href="https://stackoverflow.com/a/78120592/1473517">answer</a> it shown how to use <a href="https://matplotlib.org/stable/users/explain/artists/transforms_tutorial.html" rel="nofollow noreferrer">transdata</a> to clip a circle with a diagonal line. The code and images are:</p>
<pre><code> import matplotli... | <python><matplotlib> | 2024-03-08 12:25:46 | 1 | 21,513 | Simd |
78,127,637 | 11,516,350 | Flask babel not workinf since revamped project with blueprints | <p>I have an app working well and translating with flask babel.</p>
<p>Then, I started to split the code in modules and generating blueprints instead of still writing all code inside the same .py file.</p>
<p>This is my project structure:</p>
<p><a href="https://i.sstatic.net/MWkSV.png" rel="nofollow noreferrer"><img s... | <python><flask><internationalization><flask-babel> | 2024-03-08 12:22:01 | 2 | 1,347 | UrbanoJVR |
78,127,593 | 4,575,197 | How to move Altair dropdown to under the legend dynamically (for every screen size) | <p>it's been a while that i have done CSS coding so i need help. i want to move the drop down list from under the chart to under the legend. Dataframe:</p>
<pre><code>data = {
'Adj Close': [1.308934, 2.169581, 2.876765, 2.357847, 2.179156],
'Yahoo Finance return': [0.670226, 1.298566, 0.920492, -0.721652, -0.30... | <python><css><dataframe><visualization><altair> | 2024-03-08 12:13:28 | 0 | 10,490 | Mostafa Bouzari |
78,127,591 | 132,785 | Pandas with pyarrow does not use additional memory when splitting dataframe | <p>When using the <code>float64[pyarrow]</code> dtype in Pandas 2.2.1, it appears that no additional memory is used when splitting a dataframe in two, and then joining it back together again.</p>
<p>When the regular <code>float64</code> dtype is used, this uses 3x the memory of the original dataframe (which is what I'd... | <python><pandas><pyarrow> | 2024-03-08 12:12:40 | 1 | 1,988 | Neil |
78,127,307 | 5,799,799 | How to read parquet files from AWS S3 with polars | <p>Following the <a href="https://docs.pola.rs/user-guide/io/cloud-storage/#reading-from-cloud-storage" rel="nofollow noreferrer">documentation</a> for reading from cloud storage, I have created the below script that fails.</p>
<pre class="lang-py prettyprint-override"><code>import boto3
import polars as pl
import os
... | <python><dataframe><amazon-s3><python-polars> | 2024-03-08 11:16:26 | 1 | 435 | DataJack |
78,127,124 | 2,545,680 | Is module system resolution in Python synchronous or asynchronous | <p>In JavaScript world there are two types of module systems - CommonJS and ES modules. They use different resolution systems - CommonJS is synchronous and ES modules is asynchronous.</p>
<p>Based on this quote from the "Learning Python" book it seems that the module system is synchronous:</p>
<blockquote>
<p... | <python> | 2024-03-08 10:42:42 | 0 | 106,269 | Max Koretskyi |
78,127,052 | 9,640,238 | Grouping a DataFrame containing a JSON column | <p>I want to de-duplicate records in a dataframe by grouping values. My data has a structure such as this:</p>
<pre class="lang-py prettyprint-override"><code>json = {
"employees": [
{"name": "Shyam", "email": "shyamjaiswal@gmail.com"},
{"name&q... | <python><json><pandas><dataframe> | 2024-03-08 10:29:52 | 1 | 2,690 | mrgou |
78,126,729 | 7,848,740 | Clear console to get a single row of logging in terminal Python | <p>I'm trying to display a single line of logging in the console instead of have a bunh of lines for every single update.</p>
<p>I think with an example is easy to understand. I have a while True cycle like:</p>
<pre><code>logging.info("Starting")
while True:
data = checknewdata()
logging.info("D... | <python><logging><console> | 2024-03-08 09:37:42 | 1 | 1,679 | NicoCaldo |
78,126,715 | 10,863,083 | Convert IMU data into trajectory data | <p>I am using IMU data in the next format :
[![enter image description here][1]][1]</p>
<p>Here is the whole file : <a href="https://github.com/badiaamakhlouf/Awesome_Dataset/blob/main/digit7.csv" rel="nofollow noreferrer">https://github.com/badiaamakhlouf/Awesome_Dataset/blob/main/digit7.csv</a></p>
<p>I want to extra... | <python><accelerometer><gyroscope><imu><devicemotion> | 2024-03-08 09:35:06 | 0 | 417 | baddy |
78,126,632 | 3,616,293 | Find winning unit between 2 torch tensors of different shapes | <p>I am trying to implement a Self-Organizing Map where for a given input sample, the best matching unit/winning unit is chosen based on (say) L2-norm distance between the SOM and the input. To implement this, I have:</p>
<pre><code># Input batch: batch-size = 512, input-dim = 84-
z = torch.randn(512, 84)
# SOM shape:... | <python><numpy><pytorch> | 2024-03-08 09:19:26 | 1 | 2,518 | Arun |
78,126,282 | 23,106,915 | How to prevent repeated downloading with HuggingFace | <h4>Description:</h4>
<p>I am confused on how the installation of the packages are performed. Currently I was working on a StableDiffusion model and every-time I run the code its again and again downloading files which are 3 to 4 Gigs big.</p>
<h4>Code:</h4>
<p>This is the code I was trying to run at first:</p>
<pre cl... | <python><pytorch><huggingface><stable-diffusion> | 2024-03-08 08:09:49 | 1 | 546 | AshhadDevLab |
78,126,259 | 7,357,673 | How to use Python package "fastkde" to predict density at each given data point? | <p>I am trying to use the <a href="https://github.com/LBL-EESA/fastkde" rel="nofollow noreferrer">package</a> <code>fastkde</code> to estimate the density from a sample. The authors give an example</p>
<pre><code>""" Demonstrate the first README example. """
import numpy as np
import fastk... | <python><kernel-density><probability-density> | 2024-03-08 08:04:14 | 1 | 2,882 | Akira |
78,126,251 | 2,446,702 | Wxpython Sizer position | <p>I have the below sample application which has a couple of simple sizers which, for some reason, are centered vertically, which I dont want (see attachment). I want the wxchoice sizer to be position at the top of the window, not in the middle vertically, even when resizing the window, it stays in that position, but I... | <python><wxpython><sizer> | 2024-03-08 08:02:06 | 2 | 3,255 | speedyrazor |
78,126,235 | 10,200,497 | Is it possible to exclude first n values in each window when using rolling() to get the maximum value? | <p>This is my DataFrame:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'a': [150, 106, 119, 131, 121, 140, 160, 119, 170]})
</code></pre>
<p>And this is the expected output. I want to create column <code>b</code>:</p>
<pre><code> a b
0 150 140
1 106 160
2 119 160
3 131 161
4 1... | <python><pandas> | 2024-03-08 07:58:50 | 1 | 2,679 | AmirX |
78,125,897 | 2,604,247 | Is Dependency Inversion Necessary to Ensure Decoupling between Caller and Callee? | <p>I am trying to understand the dependency inversion principle (DIP) via some simple, but concrete codes and classes (implemented in python) from <a href="https://www.pythontutorial.net/python-oop/python-dependency-inversion-principle" rel="nofollow noreferrer">this tutorial</a>. I am summarising it (with my own comme... | <python><oop><solid-principles><object-oriented-analysis><dependency-inversion> | 2024-03-08 06:34:57 | 2 | 1,720 | Della |
78,125,825 | 14,256,643 | Django How to save image on my custom path when triggering signals | <p>When I trigger this signal, the image is copied from my ImageModel and uploaded to my OrderItem model in the order_image_file field. The product image is being saved to its original ImageModel destination even though I have defined a custom path in my OrderItem model.</p>
<pre><code>def orderImage_upload_path(instan... | <python><python-3.x><django><django-models> | 2024-03-08 06:15:58 | 1 | 1,647 | boyenec |
78,125,650 | 2,982,323 | pytest two level of parametrization with one parameter dependent on other one | <p>I have to a test a scenario where one parameter is dependent on other. I tried using the pytest hook <code>pytest_generate_test</code> but i'm not sure how to pass a retrieve the value in hook which is parametrized in the test.</p>
<pre><code>import pytest
import logging
logger = logging.getLogger(__name__)
apps = ... | <python><pytest><dynamicparameters> | 2024-03-08 05:10:20 | 2 | 687 | Swaroop Kundeti |
78,125,524 | 9,986,939 | Adding Dynamic PV/C to Airflow pods | <p>Problem: I have airflow on kubernetes and I have an issue with massive disk pressure on the nodes.</p>
<p>Context: There are about 5k pods a day and they are running a Python ETL package. I'm using airflow's KubernetesPodOperator to dynamically generate the pods via a class called "KubernetesPodGenerator".... | <python><kubernetes><airflow> | 2024-03-08 04:24:48 | 0 | 407 | Robert Riley |
78,125,493 | 4,294,028 | Stitching together overlapping arrays in scipy | <p>Given two numpy arrays (matrices)</p>
<pre><code>A = np.linspace(1,9,9).reshape(3,3)
B = np.linspace(10,18,9).reshape(3,3)
</code></pre>
<p>We can combine them into a block diagonal matrix by doing:</p>
<pre><code>from scipy.linalg import block_diag
block_diag(A,B)
array([[ 1., 2., 3., 0., 0., 0.],
[ 4.,... | <python><scipy><sparse-matrix><diagonal> | 2024-03-08 04:08:52 | 1 | 938 | WeakLearner |
78,124,960 | 2,877,552 | Python library to open a file handle to Azure Blob Storage object, similar to s3fs library for AWS S3 | <p>For AWS S3, there is a Python library called <a href="https://github.com/fsspec/s3fs/" rel="nofollow noreferrer">s3fs</a> that can open file handles to S3 objects.</p>
<p>E.g.</p>
<pre><code>import s3fs
s3 = s3fs.S3FileSystem(anon=True)
with s3.open('my-bucket/my-file.txt', 'rb') as f:
print(f.read())
</code></p... | <python><azure-blob-storage> | 2024-03-08 00:07:47 | 2 | 734 | Kevin Tianyu Xu |
78,124,839 | 525,865 | scraper on wikipedia: deprecated methods - removed from pandas in a future version | <p>this is one of my first steps in webscraping so i need to have some hints and tips: note i love to scrape on Wikipage.</p>
<p>btw: probably i gonna make use of this:
<a href="https://stackoverflow.com/questions/7185288/how-can-i-get-wikipedia-content-using-wikipedias-api">How can I get Wikipedia content using Wikipe... | <python><bash><web-scraping> | 2024-03-07 23:19:43 | 0 | 1,223 | zero |
78,124,761 | 4,736,459 | How to properly send response to React Frontend from Django Channels? | <p>I am trying to use Django Channels to implement long-polling for a React frontend web app and Django REST backend. I believe that much of what I have is working to some degree, but some thing(s) must be incorrectly configured or coded to produce unexpected results.</p>
<hr />
<p><strong>UPDATE</strong>: It seems tha... | <python><reactjs><axios><fetch-api><django-channels> | 2024-03-07 22:54:01 | 0 | 703 | Doug Steiert |
78,124,647 | 4,883,262 | How to set scope correctly for a parameterized fixture | <p>Scope of a parameterized fixture is not working.</p>
<p>Here is an example of the fixture and the test:</p>
<pre><code>@pytest.fixture(scope='session')
def my_fixture(request):
# make some API calls
# print API call response
return response
</code></pre>
<p>Tests</p>
<pre><code>@pytest.mark.para... | <python><pytest> | 2024-03-07 22:25:34 | 2 | 362 | gowthamjs23 |
78,124,626 | 4,727,774 | Why dtypes are not changing when updating columns in Pandas 2.x but would change in Pandas 1.x? | <p>When changing the values and/or dtypes of specific columns there is a different behaviour from Pandas 1.x to 2.x.</p>
<p>For example, on column <code>e</code> in the example below:</p>
<ul>
<li>Pandas 1.x: Using <code>pd.to_datetime</code> to update the column will
parse the date and change its dtype</li>
<li>Pandas... | <python><pandas><dataframe><pandas-loc> | 2024-03-07 22:19:25 | 1 | 393 | bpbutti |
78,124,574 | 1,874,170 | Proper way to use KeyboardInterrupt with UDP socket.recv()? | <p>I'm currently using <code>socket.socketpair()</code> with <code>signal.set_wakeup_fd()</code> as a solution to make <code>socket.recv()</code> compatible with <code>KeyboardInterrupt</code> on Windows — particularly when using UDP — see below for example.</p>
<p>I'm also aware of the <a href="https://stackoverflow.c... | <python><sockets><signals> | 2024-03-07 22:02:55 | 1 | 1,117 | JamesTheAwesomeDude |
78,124,421 | 7,758,174 | How to pass a file as hyperparameters for argparse | <p>I am trying to reproduce a pipeline from github. Since the Idea is to reproduce it, I don't want to change the code. Onde of the scripts ask for hyperparameters to be passed as a dictionary, as in
<code> -p {'param1' : 'p1', 'param1' : 'p2' ...}</code> and so forth. These parameters are processed with argparse.</p>
... | <python><argparse> | 2024-03-07 21:26:56 | 2 | 430 | RMelo |
78,124,417 | 3,957,754 | oracledb.exceptions.DatabaseError: DPY-4011: the database or network closed the connection - python oracledb library | <p>I'm trying to connect oracle 11g with python</p>
<pre><code>import oracledb
import os
user = 'system'
password = 'admin123'
port = 1521
service_name = 'xe'
oracle_server_addr = 'localhost'
conn_string = "{oracle_server_addr}:{port}/{service_name}".format(oracle_server_addr=oracle_server_addr, port=port, ... | <python><oracle-database><oracle11g><python-oracledb> | 2024-03-07 21:25:53 | 1 | 16,864 | JRichardsz |
78,124,241 | 23,555,881 | Python to format and create a nested JSON file | <p>I am using pandas "to_json" option to generate some JSON files after filtering DF. The output of these comes as below:</p>
<pre><code>[{"time":1677287760000,"x":0.001,"y":0.001,"z":0.0},{"time":1677632400000,"x":0.0,"y":0.0,"z"... | <python><json><pandas> | 2024-03-07 20:43:38 | 2 | 606 | Halod |
78,124,127 | 4,294,028 | Sampling from a Normal distribution with sparse covariance matrix | <p>To sample from a gaussian distribution with mean zero and covariance matrix S, we can do the following:</p>
<pre><code>from scipy import sparse
from numpy import np
S = sparse.diags([np.full(100,1),0.1*np.ones(99),0.1*np.ones(99)],[0,-1,1])
S.A
array([[1. , 0.1, 0. , ..., 0. , 0. , 0. ],
[0.1, 1. , 0.1, ..., ... | <python><random><sparse-matrix><sample> | 2024-03-07 20:19:52 | 0 | 938 | WeakLearner |
78,124,029 | 2,301,970 | # Computing multiple 1d curves into their 2d array (image) representation | <p>I wonder if anyone could please help me do this operation in python as efficiently as possible. I think numpy fancy indexing is the best approach but I have not been able to make it work (any alternative approach is also welcome)</p>
<p>I have simple data sets which take the shape of curves like this:</p>
<p><a href... | <python><numpy><performance><indexing> | 2024-03-07 19:58:36 | 2 | 693 | Delosari |
78,123,814 | 3,618,604 | Installing pyfftw on mac OSX | <p>I am trying to install <code>pyfftw</code> on mac OSX using <code>pip</code>. Here is what I have already done.</p>
<p>I have installed fftw using <code>brew install fftw</code>, and also tested the linking, by compiling and running the following code:</p>
<pre><code>#include <fftw3.h>
int main() {
printf... | <python><pip><conda><fftw><pyfftw> | 2024-03-07 19:12:20 | 0 | 353 | R.U. |
78,123,702 | 8,652,920 | How to access fixtures from pytest hook pytest_collection_modifyitems? | <pre class="lang-py prettyprint-override"><code>$ ls
conftest.py __pycache__ test.py
$ cat conftest.py
import pytest
@pytest.fixture
def myfixture():
t = 800
yield t
def pytest_collection_modifyitems(config, items):
# I want a reference to myfixture here
pass
$ cat test.py
import pytest
def tes... | <python><python-3.x><pytest><fixtures> | 2024-03-07 18:47:00 | 0 | 4,239 | notacorn |
78,123,684 | 286,034 | running django tests --parallel and splitting log files per test-runner worker | <p>I'm using <code>manage.py test --parallel</code> to run my tests and want to create a separate log file for each test runner.</p>
<p>Currently, all the test runner worker write to the same log file, so I get a single log file with contents "striped" like this:</p>
<pre><code>[ForkPoolWorker-2] ...
[ForkPoo... | <python><django><python-unittest><django-unittest> | 2024-03-07 18:45:28 | 0 | 320 | siebo |
78,123,564 | 7,404,222 | Opencv movement detection without being trigger by random noise | <p>I'm new to image processing and I'm struggling a bit, I'm making my own diy security software and I made a function to detect some movement in order to start recording and notify me.</p>
<p>The idea of this function is to take two images and diff them in order to find some movement, the problem I have is that either... | <python><opencv><image-processing><computer-vision><detection> | 2024-03-07 18:20:46 | 3 | 390 | pipou |
78,123,402 | 51,280 | Ideal Conda and pip workflow to get the latest dependencies | <p>I usually start with this conda environment when I have a dependency called <code>the_dependency</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>name: my_app
channels:
- defaults
- conda-forge
dependencies:
- python=3.11
- pip
- pip:
- the_dependency
</code></pre>
<p>I find that <code>pip... | <python><pip><conda> | 2024-03-07 17:45:43 | 0 | 5,458 | opyate |
78,123,358 | 9,053,942 | What is the best approach to train a pytorch model over large dataset stored in a database? | <p>I have a large dataset, and for convenience, I put it in an sqlite database. It has about 270k rows, each row has 10_000 bp long DNA sequence. It's impossible to load the entire dataset at once, let alone train a model (yeah, I tried, and my laptop's GPU ain't running / making any noise).</p>
<p>So currently I am ru... | <python><sqlite><deep-learning><pytorch> | 2024-03-07 17:36:15 | 2 | 2,226 | Qazi Fahim Farhan |
78,123,245 | 17,617,395 | How can we draw a interactable CIElab Color Space using python and also plot the data points (having color parameters l*,a*, b* , h and C* values)? | <p>I want to measure the color difference between the reference and sample. And also want to show the color shift (difference) on the chart itself. For you reference below is the color space picture. Also Parameters with range and significance:</p>
<ul>
<li>L* [lightness - black to white]:[0 to 100]</li>
<li>a* [green ... | <python><python-3.x><colors><visualization> | 2024-03-07 17:17:15 | 0 | 371 | Abhishek Kashyap |
78,123,239 | 9,322,863 | Ensure trivial solution is found to matrix equation | <p>I'm trying to solve a matrix equation $Ax = b$ with numpy (actually I'm using <code>scipy.sparse</code> but I believe the question remains the same). In my setup, $b$ is the derivative of some function.</p>
<p>In my system, it's possible that the equation may sometimes be $Ax = 0$, in which case I want to get the ze... | <python><numpy><scipy><linear-algebra><differential-equations> | 2024-03-07 17:16:29 | 1 | 323 | TIF |
78,123,222 | 11,516,350 | Error configuring flask-babel method jinja2 not found | <p>This is my babel.cfg file:</p>
<pre><code>[python: **.py]
[jinja2: **/templates/**.html]
</code></pre>
<p>When I execute this command:</p>
<p><code>pybabel extract -F babel.cfg -k _l -o messages.pot .</code></p>
<p>Then return this error:</p>
<pre><code>ValueError: Unknown extraction method 'jinja2'
</code></pre>
<p... | <python><flask><translation><flask-babel> | 2024-03-07 17:13:32 | 1 | 1,347 | UrbanoJVR |
78,123,183 | 20,075,659 | Redis Data Persistance | <p>I want to store the Redis data in memory to Hard or any other in my server if sudden shutdowns or restarts happen and restore after it restarts. Are there a way to do it in Python without slowing the read/write on Redis?</p>
| <python><redis> | 2024-03-07 17:05:24 | 1 | 396 | Anon |
78,123,149 | 7,211,014 | Flask (connexion) app not reloading monitored extra_files when building app as a python package | <p>I have a python flask (using connexion) project that I need to reload if I change any of the files in the project.
This project is built into a python module using <code>setup.py</code>, then run.
I tried using <code>extra_files</code> parameter when running the project but this does not help. I could not tell if th... | <python><flask><package><watchdog><connexion> | 2024-03-07 17:01:31 | 1 | 1,338 | Dave |
78,123,142 | 11,516,350 | Flask babel is marking fuzzy without reason | <p>I have these 2 files:</p>
<pre><code>msgid "Categories"
msgstr "Categories"
msgid "Dashboard"
msgstr "Dashboard"
</code></pre>
<p>And:</p>
<pre><code>msgid "Categories"
msgstr "Categorías"
msgid "Dashboard"
msgstr "Dashboard"
</code><... | <python><flask><internationalization><translation><flask-babel> | 2024-03-07 17:00:45 | 1 | 1,347 | UrbanoJVR |
78,123,062 | 9,025,983 | Python AWS CDK Unable to synthetize stack, Unable to set secret rotation in aws cdk | <p>I've been unable to synth my cdk stack. I need to instantiate a Postgres RDS database instance. I've attempted to add a single user and secrete rotation schedule to no avail. Do you have any ideas of what is required to achieve a secret rotation? The error message received when trying to synth the stack:</p>
<p><co... | <python><aws-cdk><aws-secrets-manager> | 2024-03-07 16:46:24 | 1 | 523 | Francisco |
78,122,985 | 2,989,089 | Test for object callability in match-case construct | <p>For context, I have a function that matches keys in a dictionary to perform certain action; to match item keys, the function accepts either a sequence of keys to match, or a function that recognizes those keys.</p>
<p>I'm wondering if I can use the <code>match-case</code> pattern for it. I try something like:</p>
<p... | <python> | 2024-03-07 16:33:55 | 2 | 884 | Antoine Gallix |
78,122,965 | 13,392,257 | Cognito Pre-SignUp Trigger - Empty Lambda Event | <p>I am trying to trigger AWS lambda code for AWS Cognito signup</p>
<p>My actions</p>
<ol>
<li>Creted a code (AWS lambda)</li>
</ol>
<pre><code>import json
import boto3
client = boto3.client('cognito-idp', region_name='eu-central-1')
def lambda_handler(event, context):
print("DEBUG: register a new user"... | <python><amazon-web-services><aws-lambda><amazon-cognito> | 2024-03-07 16:31:22 | 1 | 1,708 | mascai |
78,122,848 | 7,949,129 | Microsoft Graph-API (graph.microsoft.com/v1.0) returns duplicate or non existing mails | <p>I have an Outlook account and I see <strong>one Mail</strong> in my inbox folder. I can somehow also expand this mail in the overview which will expand it to two entries. (Probably because it was forwarded once and moved into Archive folder and then back to inbox).
But I cannot delete one of them, I can just delete ... | <python><email><python-requests><microsoft-graph-api><office365> | 2024-03-07 16:12:47 | 0 | 359 | A. L |
78,122,836 | 3,385,432 | Difference between numpy power and ** for certain values | <p>I have a numpy array where the entries in <code>f**2</code> differ from <code>f[i]**2</code>, but only for some specific value.</p>
<pre><code>import numpy as np
np.set_printoptions(precision = 16)
f = np.array([ -40709.6555510835, -40708.6555510835, -33467.081758611654, -27653.379955714125])
f2 = f**2
# f2 = np.p... | <python><numpy> | 2024-03-07 16:11:35 | 3 | 988 | jmlarson |
78,122,820 | 7,662,164 | Equivalent of `jax.lax.cond` for multiple boolean conditions | <p>Currently <code>jax.lax.cond</code> works for one boolean condition. Is there a way to extend it to multiple boolean conditions?</p>
<p>As an example, below is an untraceable function:</p>
<pre><code>def func(x):
if x < 0: return x
elif (x >= 0) & (x < 1): return 2*x
else: return 3*x
</code>... | <python><conditional-statements><jit><jax> | 2024-03-07 16:08:51 | 1 | 335 | Jingyang Wang |
78,122,755 | 9,107,502 | PySide GUI freezes during filtering using QSortFilterProxyModel | <p>I'm developing a PySide6/Python3 application, that contains a QTableView with a custom model <code>DataFrameTableModel</code>. I want to support filtering the rendered table. Hence, I'm using <code>QSortFilterProxyModel</code> in addition.</p>
<p>One requirement is to filter based on columns with different operators... | <python><qt><pyqt><pyside><pyside6> | 2024-03-07 15:58:51 | 1 | 1,320 | Constantin Müller |
78,122,677 | 7,631,505 | Matplotlib 3d zoom issue | <p>Here to ask a question about the basic matplotlib 3d plotting tools. Now, let me make some dummy data to explain my issue:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-1, 1, 1000)
y = x
X, Y = np.meshgrid(x, y)
f = np.exp(-(X**2 / 0.5) - Y**2 / 0.5)
</code></pre>
<p>I have ... | <python><matplotlib><matplotlib-3d> | 2024-03-07 15:48:51 | 1 | 316 | mmonti |
78,122,636 | 4,704,335 | How do you cleanly terminate a zmq steerable proxy in python? | <h2>Context</h2>
<p>I am implementing a many-to-many in process Pub/Sub interface with python zmq that can be built up and torn down as needed in a running application. I am using a proxy to connect the <code>XSUB</code> and <code>XPUB</code> sockets and am utilizing the <code>zmq.proxy_steerable</code> variant so tha... | <python><pyzmq> | 2024-03-07 15:42:32 | 1 | 1,066 | Kenneth E. Bellock |
78,122,590 | 8,378,586 | How to preserve type hints despite variable type annotation during assignment | <p>I am writing a <code>Lazy</code> class that works like <code>partial</code>, but has some extra functionalities.
The goal is to pre-initialize an object by wrapping it in the <code>Lazy</code> class and later finish the initialization by calling <code>to_eager</code>, where the user can provide some additional argum... | <python><python-typing><pyright> | 2024-03-07 15:36:05 | 1 | 308 | JAV |
78,122,541 | 2,610,933 | Unexpected keyword argument 'use_dora' when attempting to generate summary from Mistral7B fine-tuned LLM | <p>I have fine-tuned a Mistral7B LLM using LoRA in 16 bit configuration using samsum training set from Hugginggace. The idea is to feed the fine-tuned LLM a conversation an it should generate a summary.</p>
<p>here is my trining script:</p>
<pre><code># set the train & validation data set
from datasets import load_... | <python><machine-learning> | 2024-03-07 15:29:37 | 1 | 2,112 | android enthusiast |
78,122,504 | 86,072 | how can I spot if a callable is a generator? | <p><strong>Context</strong></p>
<p>for testing purposes, I would like to trace all calls to the methods of an object.</p>
<p>right now: I managed to write the following loop:</p>
<pre class="lang-py prettyprint-override"><code>def instrument_obj(obj):
for k in dir(obj):
try:
method = getattr(obj... | <python><python-3.11> | 2024-03-07 15:23:33 | 1 | 53,340 | LeGEC |
78,122,301 | 5,547,553 | How to handle multi-line results of user-defined functions in polars? | <br>
I'd like to parse lines of text to multiple columns and lines in polars, with user defined function.
<pre><code>import polars as pl
df = pl.DataFrame({'file': ['aaa.txt','bbb.txt'], 'text': ['my little pony, your big pony','apple+banana, cake+coke']})
def myfunc(p_str: str) -> list:
res = []
for line i... | <python><dataframe><python-polars> | 2024-03-07 14:55:20 | 2 | 1,174 | lmocsi |
78,122,099 | 10,811,647 | How to display YOLO predictions on Grafana? | <p>I am trying to display my YOLO predictions directly on my grafana dashboard/graph. My model takes a picture of the grafana graph as input and detects the various graph patterns that correspond to different categories. I would like to use the graph shown inside the webpage as input and display the predictions directl... | <python><grafana><yolo><yolov8> | 2024-03-07 14:23:20 | 1 | 397 | The Governor |
78,122,083 | 1,231,450 | Matplotlib strange output with timestamps as index | <p>Given the following dataframe</p>
<pre><code> open close high low timestamp
0 17910.25 17902.75 17910.50 17901.75 2024-02-28 20:46:10.628867+00:00
1 17902.50 17901.75 17906.50 17900.50 2024-02-28 20:46:50.270189+00:00
2 17902.25 17904.50 17905.50 17901.25 2... | <python><pandas><matplotlib> | 2024-03-07 14:20:22 | 1 | 43,253 | Jan |
78,122,031 | 378,386 | Missing cache statistics for cachedmethod decorator in cachetools | <p>I am implementing a cached method with cachetools like this:</p>
<pre class="lang-py prettyprint-override"><code>class CachedNum(object):
def __init__(self, cachesize):
self.cache = LRUCache(maxsize=cachesize)
@cachedmethod(lambda self: self.cache)
def get(self, num):
return num + 1000
... | <python><cachetools> | 2024-03-07 14:13:18 | 1 | 2,557 | aggsol |
78,121,811 | 10,746,224 | How to apply an operator sequentially to all items in a list? | <p>I have an arbitrarily sized list:</p>
<pre><code>l = [1, 2, 3, 4, 5, ...]
</code></pre>
<p>I want to apply the <em>pipe</em> operator to all items in the list, sequentially, like this:</p>
<pre><code>1 | 2 | 3 | 4 | 5 # = 7
</code></pre>
<p>I know there is a function in the stdlib that does this, and that this quest... | <python> | 2024-03-07 13:37:13 | 1 | 16,425 | Lord Elrond |
78,121,764 | 1,088,577 | What should be a type annotation for dataclass descriptor fields? | <p>I'm working on a class for which user should be able to set its fields in the most convenient way, which includes assigning strings to any of the fields. Values assigned by the user should be automatically converted actual data type (so for example <code>"2022-01-02"</code> assigned to a field <code>date</... | <python><python-typing><python-dataclasses><python-descriptors> | 2024-03-07 13:30:00 | 1 | 1,537 | Michał Góral |
78,121,739 | 7,233,155 | Sphinx autodoc if Python method moved to Rust PyO3 | <p>If I have a <strong>Python</strong> module and a method:</p>
<pre class="lang-py prettyprint-override"><code># mymod.py
def func(x):
"""
Return a value.
"""
return x
</code></pre>
<p>And a <strong>Sphinx</strong> autodocument command in an rst file:</p>
<pre><code>API Re... | <python><rust><documentation><python-sphinx><pyo3> | 2024-03-07 13:25:57 | 2 | 4,801 | Attack68 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.