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,602,803 | 453,851 | Is there a way to get the python package distribution (wheel) name for a given module? | <p>Is there a way to get the python package distribution (wheel) name for a given module (python object given by <code>import ...</code>)?</p>
<p>I know that it's possible to get meta-information about installed packages via <code>importlib.metadata</code> (as mentioned <a href="https://stackoverflow.com/a/32965521/453... | <python><python-importlib> | 2024-06-10 14:09:13 | 0 | 15,219 | Philip Couling |
78,602,675 | 9,506,773 | Error in Azure Cognitive Search Service when storing document page associated to each chunk extracted from PDF in a custom WebApiSkill | <p>I have the following <a href="https://learn.microsoft.com/en-us/azure/search/cognitive-search-custom-skill-web-api" rel="nofollow noreferrer">custom WebApiSkill</a>:</p>
<pre class="lang-py prettyprint-override"><code>@app.route(route="CustomSplitSkill", auth_level=func.AuthLevel.FUNCTION)
def CustomSplit&... | <python><azure-cognitive-services> | 2024-06-10 13:43:49 | 1 | 3,629 | Mike B |
78,602,526 | 7,949,129 | Execute callback when django.cache.set timeout is exceeded | <p>I use Django cache with <code>django-redis==5.0.0</code> like this:</p>
<pre><code>cache.set(f'clean_me_up_{id}', timeout=10)
</code></pre>
<p>Storing an entry into cache, which will be cleared after <code>timeout</code>, works perfectly for me.</p>
<p>What I´m trying to acheive, is to execute also some cleanup code... | <python><django><redis><django-redis> | 2024-06-10 13:13:53 | 1 | 359 | A. L |
78,602,509 | 14,004,008 | How to use cookies generated from one command/request into another command/request using python's request module? | <p>How to use cookies generated from one command/request into another command/request using python's request module like we do with curl commands?</p>
<p>Below are the two curl requests in which cookies generated from first command are used in the second curl command and also cookie_jar file is updated with new paramet... | <python><python-requests> | 2024-06-10 13:10:28 | 1 | 2,043 | devops-admin |
78,602,457 | 673,600 | Turning list of key value into canonical python quickly | <p>I have an application that can only work with the following type of data (Cassandra and some custom SDK):</p>
<pre><code>{'key': 'key Name', 'value': 123}
</code></pre>
<p>I typically want this as:</p>
<pre><code>{'key Name': 123}
</code></pre>
<p>Is there a rapid and smart way to convert between these two formats i... | <python><dictionary><cassandra> | 2024-06-10 13:00:30 | 0 | 6,026 | disruptive |
78,602,249 | 4,704,969 | IntelliJ - microservice setup with Python | <p>I have the following folder structure:</p>
<ul>
<li>ProjectName
<ul>
<li>main
<ul>
<li>components
<ul>
<li>component_one (package)</li>
<li>component_two (package)</li>
<li>component_three (package)</li>
</ul>
</li>
<li>libraries
<ul>
<li>core
<ul>
<li>common (package)</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
... | <python><intellij-idea><python-poetry> | 2024-06-10 12:18:12 | 1 | 602 | kjanko |
78,601,696 | 2,384,642 | facing issues with python module installation | <p>i am gettinig error as : <code>ModuleNotFoundError: No module named 'currency_converter'</code></p>
<p>i installed by command: <code>pip3 install currency_converter</code></p>
<p>after instaltion show succesfull, even showing madule as exit on checking by: <code>pip3 show currency_converter</code></p>
<p>after that ... | <python><django><pip> | 2024-06-10 10:13:04 | 1 | 7,281 | Shiv Singh |
78,601,684 | 1,200,751 | NotNullViolation when commiting after explicitly setting FK column for relationship | <p>I am saving an object in SQl Alchemy using:</p>
<pre><code>def save_reply(self, reply: PostgresReplyTable) -> PostgresReplyTable:
"""
Save a reply
Args:
job: The job to save the reply for
text: The text of the reply
Returns:
PostgresReplyTable: The reply
... | <python><postgresql><sqlalchemy> | 2024-06-10 10:10:39 | 1 | 1,188 | wachichornia |
78,601,579 | 3,358,488 | asyncio.create_task executed even without any awaits in the program | <p>This is a followup question to <a href="https://stackoverflow.com/a/62529343/3358488">What does asyncio.create_task() do?</a></p>
<p>There, as well in other places, <code>asyncio.create_task(c)</code> is described as "immediately" running the coroutine <code>c</code>, when compared to simply calling the co... | <python><python-asyncio> | 2024-06-10 09:48:45 | 2 | 5,872 | user118967 |
78,601,417 | 5,257,286 | Order PySpark Dataframe by applying a function/lambda | <p>I have a PySpark DataFrame which needs ordering on a column ("Reference").
The values in the column typically look like:</p>
<pre><code>["AA.1234.56", "AA.1101.88", "AA.904.33", "AA.8888.88"]
</code></pre>
<p>I have a function already which sorts this list:</p>
<pre>... | <python><dataframe><apache-spark><pyspark><rdd> | 2024-06-10 09:13:28 | 1 | 1,192 | pymat |
78,601,383 | 1,591,921 | How to debug Chalice route handlers in VSCode | <p>Using the following launch.json, I'm able to hit breakpoints in the module level code, but not in route-handlers.</p>
<p>launch configuration (the last three lines may not be needed, but are just some things I've tried)</p>
<pre><code>{
"name": "Chalice: Local",
"type": "py... | <python><visual-studio-code><chalice><debugpy> | 2024-06-10 09:05:42 | 3 | 11,630 | Cyberwiz |
78,601,332 | 12,829,151 | Separate DB Schema from Endpoint | <p>I have a file <code>app.py</code> like this:</p>
<pre><code>import os
from dotenv import load_dotenv
from flask import Flask, jsonify, request
from flask_jwt_extended import JWTManager, jwt_required, get_jwt_identity, create_access_token, create_refresh_token
from flask_sqlalchemy import SQLAlchemy
from werkzeug.sec... | <python><database><flask><flask-sqlalchemy> | 2024-06-10 08:55:34 | 1 | 1,885 | Will |
78,601,319 | 3,906,713 | Why is my basic Gekko ODE solver much slower than Scipy? | <p>In this minimal example I want to solve the basic integrator ODE <code>dT/dt = k[F(t) - T(t)]</code> where <code>F(t)</code> is a forcing vector, which is selected to be a square wave. I have implemented two procedures to solve the ODE: Using Scipy's <code>solve_ivp</code> and using Gekko. The former takes 6 millise... | <python><optimization><ode><gekko> | 2024-06-10 08:52:50 | 1 | 908 | Aleksejs Fomins |
78,601,089 | 18,159,603 | Define beaming within tuplet in music21 | <p>Using music21, I'm trying to create a measure with the following rhythm and beaming:</p>
<p><a href="https://i.sstatic.net/IxtQ1RWk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IxtQ1RWk.png" alt="Expected result" /></a></p>
<p>However, no matter what I try, I can't get the beaming right. Here is my... | <python><music21><musicxml> | 2024-06-10 07:54:07 | 0 | 1,036 | leleogere |
78,600,371 | 19,850,415 | How can I programmatically capture the output from the current cell in a function called from Jupyter / ipython? | <p>I am trying to implement an ipython's magic cell function that takes the code from the current cell, runs it, and caches its output (in rich format) to a file. The final objective of my magic function is a bit more elaborate but I hope this description suffices.</p>
<p>In order to achieve this, I want my magic funct... | <python><jupyter><ipython> | 2024-06-10 03:38:04 | 2 | 507 | Jau A |
78,600,352 | 4,309,647 | Cannot Read Parquet File of Multi-Level Complex Index Data Frame | <p>I can create a sample data frame with the following code and save it as parquet. When I try to read it throws "TypeError: unhashable type: 'numpy.ndarray'". Is it possible to save an index comprised of tuples or do I have to reset the index before saving to parquet? Thanks</p>
<pre><code>import pandas as p... | <python><pandas><dataframe><parquet> | 2024-06-10 03:26:55 | 1 | 315 | fmc100 |
78,600,227 | 21,540,734 | selenium.webdriver.Firefox not working properly on the login page of nbc.com | <p>I'm using this to auto login on nbc.com, and nbc.com login page is responding with <code>Sorry, we had a problem. Please try again.</code> instead of redirecting to the link provider page. Other than that the page is successfully login me into the site. I'm wandering if this is something in the source of the site th... | <python><authentication><selenium-webdriver><firefox> | 2024-06-10 02:04:10 | 1 | 425 | phpjunkie |
78,600,088 | 2,588,860 | Mocking PySpark in unit tests | <p>I have a python method along the lines of this:</p>
<pre class="lang-py prettyprint-override"><code>def my_big_method():
# stuff happens before this
df = (
spark.read
.format("jdbc")
.option("url", f"jdbc:postgresql://{host}:{port}/{database}")
.... | <python><unit-testing><pyspark> | 2024-06-10 00:32:57 | 1 | 2,159 | rodrigocf |
78,600,003 | 14,044,445 | My implementation for reproducing a paper | <p>I'm trying to reproduce <a href="https://www.nature.com/articles/s41598-018-36058-z" rel="nofollow noreferrer">this paper</a>. I've basically done everything and I've obtained the final expression of page 3. My only problem is that my implementation gets slow for larger numbers really fast.</p>
<pre><code>from sympy... | <python><sympy> | 2024-06-09 23:44:18 | 1 | 364 | Amirhossein Rezaei |
78,599,946 | 13,517,174 | ipywidgets: Why does the checkbox have an offset towards the left in when being placed inside of a HBox container | <p>I have the following script</p>
<pre><code>from ipywidgets import Checkbox, Text, HBox, VBox, Layout, HTML
from IPython.display import display
checkbox = Checkbox(layout=Layout(width='8%', align_self='center'))
text_field = Text(layout=Layout(width='20%'))
header_row = HBox([
HTML(value="<b>Checkbox&... | <python><jupyter-notebook><widget><ipython><ipywidgets> | 2024-06-09 22:58:17 | 1 | 453 | Yes |
78,599,924 | 48,956 | How to diagnose an 28x slowdown in containerized vs host python+numpy execution | <p>I'm doing some number-crunching in a docker container. On an 8 cpu machine the dockerized execution is around 28x slower than the host?
I've examined:</p>
<ul>
<li>warm-up costs: I've tried running the test on the second execution in the same process (below the warmup costs appear negligble anyway)</li>
<li>numpy op... | <python><docker><numpy><optimization> | 2024-06-09 22:46:22 | 1 | 15,918 | user48956 |
78,599,865 | 1,048,486 | How to install missing python modules on distroless Image? | <p>I am trying to install some missing modules on a python distroless image however I am getting below error</p>
<pre><code> => ERROR [3/7] RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --upgrade pip ... | <python><docker><containers><distroless> | 2024-06-09 22:15:23 | 1 | 1,347 | Rob Wilkinson |
78,599,804 | 1,194,864 | No module named 'torch' when I run my code | <p>I have tried to install PyTorch using <code>pip install torch</code> command. When, however, I am trying to run some Python code I am receiving the following error:</p>
<pre><code>ModuleNotFoundError: No module named 'torch'
</code></pre>
<p>When I am checking the packages with <code>pip list</code> the <code>torch<... | <python><torch> | 2024-06-09 21:41:07 | 1 | 5,452 | Jose Ramon |
78,599,500 | 7,959,890 | Count days from calendar dataframe based on dates from another dataframe | <p>I have two dataframes:</p>
<p>df_tasks:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>User</th>
<th>Start_Date</th>
<th>End_Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2024-05-03</td>
<td>2024-05-15</td>
</tr>
<tr>
<td>2</td>
<td>2024-03-12</td>
<td>2024-04-27</td>
</tr>
</tbod... | <python><pandas> | 2024-06-09 19:19:55 | 2 | 391 | Jaol |
78,599,364 | 9,185,511 | Filling value in a pandas dataframe based on grouping | <p>This is the result I get:
<a href="https://i.sstatic.net/pbkBomfg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pbkBomfg.png" alt="enter image description here" /></a></p>
<p>This is the result I want to get:
<a href="https://i.sstatic.net/3GXjRBfl.png" rel="nofollow noreferrer"><img src="https://i.... | <python><pandas><dataframe> | 2024-06-09 18:17:42 | 1 | 824 | user9185511 |
78,599,266 | 8,547,986 | Checking which overload function mypy matches | <p>When using type hints in Python with mypy, I often encounter the error <code>Overload function overlap with incompatible return types</code>. I am trying to better understand, how mypy matches which overload function and in that regards, I have the following piece of code:</p>
<pre class="lang-py prettyprint-overrid... | <python><mypy><python-typing> | 2024-06-09 17:34:04 | 0 | 1,923 | monte |
78,599,218 | 1,472,433 | Using a dictionary to modify xtick labels in a matplotlib/seaborn box plot | <p>I am trying to determine how to change the default categorical xtick labels in a seaborn box plot. Note that I do not want to change the column names in the data frame.</p>
<p>Here is my code:</p>
<pre><code>import matplotlib
import seaborn as sns
import numpy as np
import pandas as pd
from matplotlib import pyplot ... | <python><matplotlib><seaborn> | 2024-06-09 17:15:25 | 0 | 347 | xbot |
78,599,045 | 11,748,924 | PHP proc_open with Python script causes UnicodeEncodeError | <p>I'm trying to run a Python script from a PHP script using proc_open. The Python script works fine when run directly from the command line, but raises a UnicodeEncodeError when run from PHP. I suspect the issue might be related to how the output is captured and handled in PHP, but I'm not sure how to fix it.</p>
<p>I... | <python><php><tensorflow><machine-learning><keras> | 2024-06-09 16:06:09 | 1 | 1,252 | Muhammad Ikhwan Perwira |
78,598,980 | 15,835,642 | How to get the xcom pull as dictionary | <p>I have a dag where i have pushed a dictionary to xcom and wnat to pull it in BigQuery Operator, i have also defined render_template_as_native_obj=True, but still it is giving error as</p>
<pre><code>time partitioning argument must have a class type dict not class str error
</code></pre>
<p>code :</p>
<pre><code>def ... | <python><airflow><google-cloud-composer><airflow-2.x><airflow-xcom> | 2024-06-09 15:34:31 | 0 | 1,552 | Sandeep Mohanty |
78,598,823 | 5,053,559 | Add same meta data for a class each time an instance of class is created in Pydantic | <p>I have three <code>Pydantic</code> classes like so:</p>
<pre class="lang-py prettyprint-override"><code> class Meta(BaseModel):
"""Meta data attached to parent objects"""
description: str = Field(description="description of the parent object")
type:... | <python><metadata><pydantic><pydantic-v2> | 2024-06-09 14:19:47 | 1 | 3,954 | Davtho1983 |
78,598,732 | 1,295,422 | Picamera2 does not display correctly | <p>I've bought an Arducam Eagle Eye 64Mpx camera to connect to my Raspberry Pi 5 (Bookworm).
I've installed the required drivers and everything seems to be working using the <code>libcamera-still</code> command line.</p>
<p>I'd like to read the preview as a CV2 image to be loaded to a texture on my application. I also ... | <python><raspberry-pi><raspberry-pi5><picamera2><libcamera> | 2024-06-09 13:38:52 | 0 | 8,732 | Manitoba |
78,598,458 | 2,811,496 | Celery: attach custom logger to default celery handler (logfile) | <p>I would like to have a logger that can be used both in django and in celery.</p>
<p>When used by django it should print to console, while when used from a celery task, I would like it to output using the default celery handler (in my case, it dumps to a file specified by the --logfile cmd line argument).</p>
<p>This... | <python><django><celery><python-logging> | 2024-06-09 11:38:00 | 0 | 746 | hornobster |
78,598,170 | 21,935,028 | Extract JOIN conditions from SQL using Antlr4 and Python | <p>I would like to use Antrl4 in Python to process SQL/PLSQL scripts and extract JOIN conditions.</p>
<p>In order to do I am trying, first, to understand how these are represented in the parser tree returned by <code>PlSqlParser.sql_script</code>.</p>
<p>I have a simple SQL:</p>
<pre><code>SELECT ta.col1, tb.col5
FROM ... | <python><antlr4> | 2024-06-09 09:41:44 | 2 | 419 | Pro West |
78,598,087 | 2,988,730 | Creating blended transform with identical data-dependent scaling | <p>I am trying to create a circle that displays a circle regardless of axis scaling, but placed in data coordinates and whose radius is dependent on the scaling of the y-axis. Based on the <a href="https://matplotlib.org/stable/users/explain/artists/transforms_tutorial.html" rel="nofollow noreferrer">transforms tutoria... | <python><matplotlib><transform><affinetransform> | 2024-06-09 09:03:34 | 2 | 115,659 | Mad Physicist |
78,597,887 | 84,196 | how to add a timer to a Toga app (python) running a task every interval, using Toga's event loop? | <p>My toga app needs to run a task every X seconds.
I prefer a multi-platform solution where possible.</p>
<p>I asked an AI and its solution used an external dependency ("schedule") + additional loop + threading:</p>
<pre class="lang-py prettyprint-override"><code>def create_timer(self, interval, callback):
... | <python><timer><toga> | 2024-06-09 07:29:22 | 1 | 16,908 | Berry Tsakala |
78,596,741 | 21,935,028 | Antlr4 PLSQLParser in Python giving mismatched input '<EOF>' with all SQL | <p>I am using Antlr4 Python for PLSQL.</p>
<p>The grammar is from here:</p>
<p><a href="https://github.com/antlr/grammars-v4/tree/master/sql/plsql" rel="nofollow noreferrer">https://github.com/antlr/grammars-v4/tree/master/sql/plsql</a></p>
<p>Here is the input - a very simple SQL script:</p>
<pre><code>SELECT col1, co... | <python><sql><antlr4> | 2024-06-08 19:30:33 | 1 | 419 | Pro West |
78,596,567 | 1,894,388 | Aggregating multiple columns in polars with missing values | <p>I am trying to perform some aggregations, while I loved polars, there are certain things, which I am unable to perform. Here are my approach and question for reference.</p>
<pre><code>import polars as pl
import polars.selectors as cs
import numpy as np
data = pl.DataFrame({'x': ['a', 'b', 'a', 'b', 'a', 'a', 'a', ... | <python><dataframe><python-polars> | 2024-06-08 18:18:59 | 3 | 11,116 | PKumar |
78,596,413 | 8,121,824 | How do I get my dash tabs to be side by side on separate pages rather than going to one page? | <p>I am trying to add two tabs in Dash which I thought should be fairly simple. I thought I was following the documentation, but keep getting something strange. My code is below, along with an image. Rather than have all the tab data on one page, I'm expecting side by side tabs that you can select.</p>
<pre><code>impor... | <python><plotly><plotly-dash> | 2024-06-08 17:11:42 | 1 | 904 | Shawn Schreier |
78,595,738 | 2,846,161 | Discrepancy in EDGAR data | <p>My question is about the source of truth regarding EDGAR.</p>
<p>I am developing a simple service for myself to choose stocks based on fundamental data. Therefore I went to the EDGAR site and downloaded all company facts. Testing I realize that there are discrepancies between the json and the xbrl viewer:</p>
<ul>
<... | <python><json><xbrl><edgar> | 2024-06-08 12:53:49 | 1 | 1,668 | Leonardo Lanchas |
78,595,632 | 13,227,420 | Extracting and joining nested values using JMESPath | <p>Given the input:</p>
<pre><code> data = [{'leagues': [{'id': 2294162, 'sport': 'S'}, {'id': 8541851, 'sport': 'S'}]},
{'leagues': []},
{'leagues': [{'id': 2228013, 'sport': 'B'}]}]
</code></pre>
<p>I want to generate the following output:</p>
<pre><code>result = ['2294162%238541851&ttgIds=S@', ... | <python><jmespath> | 2024-06-08 12:05:45 | 1 | 394 | sierra_papa |
78,595,583 | 11,141,816 | How to parallelize a Jupyter notebook processing? | <p>I'm a researcher and use Jupyter notebooks to study concepts.</p>
<p>However, once it's done, I need to parallelize the Jupyter notebook processing, to run for multiple different inputs</p>
<pre><code>input_variable_1 = ...
input_variable_2 = ...
</code></pre>
<p>In the Jupyter notebook, most of the code was written... | <python><jupyter-notebook><parallel-processing> | 2024-06-08 11:43:18 | 1 | 593 | ShoutOutAndCalculate |
78,595,207 | 363,663 | Pandasonic way to combine multiple columns with expected format | <p>There's a dataframe <em>X</em> with "Year", "Month" and "Day" as integer below,</p>
<pre><code> Year Month Day A B C ...
0 2020 10 10 ...
1 2021 1 1 ...
2 2022 1 10 ...
3 2023 10 1 ...
...
</code></pre>
<p>There's another dataframe <em>Y</em> with "Date" ... | <python><pandas><dataframe> | 2024-06-08 09:16:53 | 1 | 9,757 | sof |
78,594,894 | 4,082,270 | Facing issue with flask server where one of the endpoints writes to a common file | <p>For some reasons, I cannot post the actual code; I will try my best to explain the issue I am facing clearly.
In my dev setup, I am running ansible play to configure 3 or more nodes.
Also, locally I am running flask server app which has few endpoints and one of them is for writing to a "common file".</p>
<... | <python><flask><concurrency><ansible> | 2024-06-08 06:32:58 | 1 | 353 | Harsha |
78,594,843 | 2,381,279 | Modifying numpy array with `numpy.take`-like function | <p>I know that in numpy, I can use <code>numpy.take</code> to get the subarray at a particular axis value instead of using fancy indexing.</p>
<p>So, if I have a 2D array <code>a=np.array([[1,2],[3,4]])</code>, then I can write <code>a[0, :]</code> or <code>np.take(a, 0, axis=0)</code> to get the same result.</p>
<p>Ho... | <python><arrays><numpy> | 2024-06-08 05:50:24 | 3 | 5,575 | 5xum |
78,594,803 | 2,706,344 | How to cancel sql query after some time in python | <p>Look at this code:</p>
<pre><code>import pyodbc
cnxn = pyodbc.connect(connection_string)
cursor = cnxn.cursor()
cursor.execute(query)
cnxn.commit()
</code></pre>
<p>Usually this code works fine. But there are certain querys which take an infinite time to be executed. This is not a python problem. When I execute them... | <python><sql><python-3.x><pyodbc> | 2024-06-08 05:21:23 | 1 | 4,346 | principal-ideal-domain |
78,594,728 | 7,272,310 | Panoramic camera calibration without chessboard method | <p>I have an image of a panoramic video camera (dual lens) in which there is a visible distortion. As the camera it's in a fixed position, and without any zoom or any other movement, and I have a lot of real world points from the soccer pitch witch is recording(and known distances, for example from google maps), as far... | <python><opencv><computer-vision><camera-calibration> | 2024-06-08 04:27:41 | 0 | 339 | DLara |
78,594,420 | 2,927,555 | Positional arguments in nested functions | <p>This question relates to this video: <a href="https://www.youtube.com/watch?v=jXugs4B3lwU" rel="nofollow noreferrer">https://www.youtube.com/watch?v=jXugs4B3lwU</a></p>
<p>The piece I'm missing is somewhat simpler than the concept the video is covering overall. In the example code below:
<strong>Why does the inner f... | <python><python-3.x><scope><nested-function> | 2024-06-08 00:42:34 | 1 | 443 | Chris |
78,594,412 | 10,500,957 | Providing a list to a function | <p>I've never come across this problem until now and can't think how to proceed.
I would like to know how to provide each element of a tuple to a function that wants individual parameters:</p>
<pre><code>myTuple = (1,2,3,4)
def myFunction(w, x, y, z):
</code></pre>
<p>but calling it with:</p>
<pre><code>u = myFunction... | <python><list><function><tuples><qpainter> | 2024-06-08 00:37:39 | 1 | 322 | John |
78,593,700 | 1,911,652 | langchain_community & langchain packages giving error: Missing 1 required keyword-only argument: 'recursive_guard' | <p>All of sudden <code>langchain_community</code> & <code>langchain</code> packages started throwing error:
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'</p>
<p>The error getting generated somewhere in <code>pydantic</code></p>
<p>I strongly suspect it is version mism... | <python><pydantic><langchain><langsmith> | 2024-06-07 19:21:12 | 6 | 4,558 | Atul |
78,593,659 | 11,608,962 | Unable to place text on a rectangle object with fill color using the borb library in Python | <p>I am currently working on creating PDFs using the <code>borb</code> library in Python. I have successfully created a rectangle object using <code>borb</code> and filled it with a desired colour. However, when I try to place text on top of this rectangle object, the text seems to be hidden behind the bounding box of ... | <python><pdf><borb> | 2024-06-07 19:08:32 | 1 | 1,427 | Amit Pathak |
78,593,549 | 8,588,743 | Python version in my VSCode notebook differs from the version of the virtual environment | <p>Python environments confuse me very much. I had just formatted my PC and now I'm installing Anaconda+Python+VScode. First thing I did was to simply install Anaconda, with it Python version <code>3.11.7</code> was preinstalled. Then I created a virtual <code>env conda create --name fbprophet</code>. After which I ins... | <python><visual-studio-code><anaconda> | 2024-06-07 18:37:35 | 1 | 903 | Parseval |
78,593,260 | 9,779,999 | "You have a version of `bitsandbytes` that is not compatible with 4bit inference and training" | <p>I am now trying to finetune a llama3 model.
I am using unsloth,</p>
<pre><code>from unsloth import FastLanguageModel
</code></pre>
<p>Then I load Llama3 model.</p>
<pre><code>model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "unsloth/llama-3-8b-bnb-4bit",
max_seq_length = max_seq_l... | <python><large-language-model><fine-tuning><8-bit><llama3> | 2024-06-07 17:08:30 | 1 | 1,669 | yts61 |
78,593,193 | 11,163,122 | Refactor from requests HTTPAdapter to httpx HTTPTransport | <p>Previously, we were using <code>requests.adapters.HTTPAdapter</code> per <a href="https://stackoverflow.com/a/77740153">this answer</a> with <code>requests==2.32.3</code> and <code>google-cloud-storage==2.16.0</code>:</p>
<pre class="lang-py prettyprint-override"><code>from google.cloud import storage
from requests.... | <python><python-requests><google-cloud-storage><httpx> | 2024-06-07 16:52:04 | 1 | 2,961 | Intrastellar Explorer |
78,593,047 | 16,813,096 | tcl issue while running a python script from another python app (converted to exe) | <p>I made an app in tkinter which helps creating tkinter app/scripts, (when I export the file it is stored as a .py)</p>
<p>I want to run this .py script from my app so that we can preview it immediately after export.</p>
<p>I used <code>subprocess.run</code> method and it works perfectly within the python app.
But whe... | <python><python-3.x><tkinter><tkinter-canvas><tkinter-entry> | 2024-06-07 16:16:23 | 1 | 582 | Akascape |
78,592,958 | 782,011 | Not receiving data from WebSocket proxy | <p>I have 3 servers. On Server A (172.16.2.5), the following Python application creates a WebSocket connection to Server B (172.16.2.6) and repeatedly sends a message:</p>
<pre><code>from time import sleep
from websocket import create_connection
ws = create_connection("ws://172.16.2.6:80/")
while True:
pr... | <python><websocket><websockify> | 2024-06-07 15:56:32 | 0 | 3,901 | pacoverflow |
78,592,945 | 13,800,566 | Use Jenkins credentials in Python script withEnv | <p>I have the following code where I define environmental variables and use them in python script:</p>
<p>groovy script:</p>
<pre><code>withEnv(["USERNAME=${username}",
"PASSWORD=${password}",
"CERTIFICATE=/path/to/cert.pem"]) {
email = sh(script: "python3.9 -u g... | <python><jenkins> | 2024-06-07 15:53:23 | 0 | 565 | anechkayf |
78,592,851 | 1,039,860 | hello world flask app on apache in a subdomain - getting python import errors on page access | <p>I have a domain and subdomain registered and when accessing them, they go to the correct IP address and host. The main domain is working fine, but its a static group of pages (pretty hard to mess that up, although God knows I have tried!)<br />
The subdomain is supposed to be the flask app and that is where I am ha... | <python><flask><apache2><subdomain><wsgi> | 2024-06-07 15:34:04 | 0 | 1,116 | jordanthompson |
78,592,648 | 183,315 | PySpark and Docker image amazon/aws-glue-libs | <p>I know very little about Java, but I have a Java question. I’ve got a Docker container for an image called amazon/aws-glue-libs. This lets me run and test AWS Glue ETL code locally on my Mac without having to use the AWS Console. It also lets me debug and single-step through the ETL code, which is fantastic. However... | <python><java><amazon-web-services><pyspark><jdbc> | 2024-06-07 14:54:00 | 2 | 1,935 | writes_on |
78,592,631 | 11,618,586 | Groupby and shift without using lambda function | <p>I have a dataframe like so:</p>
<pre><code>data = {
'ID': [1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1],
'timestamp': pd.date_range(start='1/1/2023', periods=14, freq='D'),
'value': [11, 22, 33, 44, 55, 66, 77, 88, 99, 11, 22, 33, 44, 55]
}
</code></pre>
<p>My actual dataframe contains millions of rows.
I s... | <python><python-3.x><pandas> | 2024-06-07 14:50:22 | 2 | 1,264 | thentangler |
78,592,492 | 13,800,566 | Capture the return value from python script ran in Jenkins sh | <p>I have the following python script myscript.py:</p>
<pre><code>#!/usr/bin/python
def main():
return "hello"
if __name__ == '__main__':
main()
</code></pre>
<p>And I run that script from the Jenkins groovy:</p>
<pre><code>returnValue = sh(returnStdout: true, script: "python3.9 -u scripts/myscr... | <python><jenkins> | 2024-06-07 14:22:37 | 1 | 565 | anechkayf |
78,592,406 | 7,346,706 | Group Pandas DataFrame on criteria from another DataFrame to multi-index | <p>I have the following two DataFrames:</p>
<pre><code>df
100 101 102 103 104 105 106 107 108 109
0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
2 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
3 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
4... | <python><pandas><dataframe><group-by><multi-index> | 2024-06-07 14:03:34 | 1 | 1,415 | NicoH |
78,592,354 | 188,331 | Seq2SeqTrainer produces incorrect EvalPrediction after changing another Tokenizer | <p>I'm using <code>Seq2SeqTrainer</code> to train my model with a custom tokenizer. The base model is BART Chinese (<code>fnlp/bart-base-chinese</code>). If the original tokenizer of BART Chinese is used, the output is normal. Yet when I swap the tokenizer with another tokenizer that I made, the output of <code>compute... | <python><huggingface-transformers><huggingface-tokenizers> | 2024-06-07 13:54:34 | 0 | 54,395 | Raptor |
78,592,260 | 5,269,892 | Pandas assign group ID including unambiguous NaNs | <p>Suppose we have a dataframe with several columns, where missing values (NaN) are encoded as empty strings. Given a set of columns, I want to create an ID number such that:</p>
<ul>
<li><strong>Rule 1</strong>: the ID is the same for all rows having identical or NaN values in that column set</li>
<li><strong>Rule 2</... | <python><pandas><dataframe><grouping> | 2024-06-07 13:34:06 | 0 | 1,314 | silence_of_the_lambdas |
78,592,178 | 2,359,430 | Plot Rectangles Denoting Sections | <p>How do I plot "rectangles" with some level of transparency (alpha value) to be overlaid on a line plot? Each rectangle would denote a section or phase. I have the x-axis indices where each section starts and ends. I'd like the rectangle to vertically fill the figure within its horizontal range. See example... | <python><matplotlib> | 2024-06-07 13:21:45 | 1 | 1,501 | Bruno |
78,592,148 | 1,422,477 | How to pip install a package from a Gitlab PyPI package repository within a Dockerfile? | <p>I run the following command to install a package from a private Gitlab repo:</p>
<p><code>pip install -r requirements.txt --index-url https://username:password@private.gitlab.internal --cert /usr/local/share/ca-certificates/cert.crt</code></p>
<p>This works, but now I want to do it in a Dockerfile so that it can wor... | <python><docker><gitlab><pypi><python-packaging> | 2024-06-07 13:15:38 | 1 | 2,919 | Lewistrick |
78,591,729 | 1,393,161 | Invalid request timestamp in slackeventsapi.server.SlackEventAdapterException | <p>I'm trying to create my first slack bot that uses Flask as a server to generate responses to the messages in the bot's channel. Briefly, my steps were:</p>
<ul>
<li>create a Slack app, create events subscriptions (mentions, messages etc), acquire all necessary keys</li>
<li>create an event subscription using <code>n... | <python><flask><slack-api> | 2024-06-07 11:45:45 | 1 | 359 | Rail Suleymanov |
78,591,704 | 7,841,304 | Is it possible to execute a test case that passes solely when the Test Setup is executed? | <p>I have added the following two Keywords to my Test Setup:</p>
<pre class="lang-py prettyprint-override"><code>Test Setup Navigate to Home Page Home Page Card Is Visible
</code></pre>
<p>I navigate to the Home Page and verify that the Home Page Card is visible at the start of every test case. However, I have on... | <python><automated-tests><robotframework> | 2024-06-07 11:41:36 | 1 | 371 | Kieran M |
78,591,577 | 1,678,780 | mypy error "Source file found twice under different module names" when using editable install | <p>mypy throws an error when I have an editable installation (<code>pip install -e .</code>) of my library. It works fine with the non-editable installation (<code>pip install .</code>).</p>
<p>I was able to reproduce it with a toy example, so here are the files:</p>
<pre><code>.
├── src
│ └── my_ns
│ └── mylib... | <python><mypy> | 2024-06-07 11:14:23 | 1 | 1,216 | GenError |
78,591,465 | 968,132 | Unexpected string validation error in Langchain Pydantic output parser | <p>I do not understand why the below use of the <code>PydanticOutputParser</code> is erroring.</p>
<p>The docs do not seem correct - If I follow <a href="https://python.langchain.com/v0.2/docs/how_to/structured_output" rel="nofollow noreferrer">this</a> exactly (i.e. use <code>with_structured_output</code> exclusively,... | <python><pydantic><langchain><large-language-model> | 2024-06-07 10:53:49 | 1 | 1,148 | Peter |
78,591,458 | 962,190 | How to prevent third party libraries from configuring logging | <p>I'm writing an application in which I'm configuring logging in this way:</p>
<pre class="lang-py prettyprint-override"><code>import logging.config
loglevel = "INFO"
logging.config.dictConfig({
"version": 1,
"disable_existing_loggers": False,
"formatters": {
... | <python><logging> | 2024-06-07 10:53:05 | 2 | 20,675 | Arne |
78,591,150 | 21,099,067 | Type annotation for multiple inheritance | <p>Consider the following minimal example:</p>
<pre class="lang-py prettyprint-override"><code>class A:
def f(self): pass
class B(A): pass
class C(A): pass
class D:
def g(self): pass
class E(B,D): pass
class F(C,D): pass
AandD = ...
def h(obj: AandD): pass
</code></pre>
<p>The class <code>A</code> in my example... | <python><python-typing> | 2024-06-07 09:50:15 | 0 | 337 | V T |
78,591,123 | 7,908,077 | How to extract Python Function Using C#? | <p>I have a C# code snippet that reads a Python file and prints the function specified by the functionName variable. Here's the code:</p>
<p>Please find the provided C# code:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
var pythonFilePath = @"C:\\Users\\batchus\\source\\repos\\a... | <python><c#><.net><nuget> | 2024-06-07 09:43:51 | 1 | 1,893 | akhil |
78,590,903 | 265,521 | Get default instance of random.Random | <p>How can I get the global instance of Python's <code>random.Random</code> class? The one that is used by the global <code>random.choice()</code> functions etc.</p>
| <python><random> | 2024-06-07 09:00:08 | 1 | 98,971 | Timmmm |
78,590,690 | 625,396 | Numpy/torch: Reindexing batch of vectors by batch of indexes | <p>In numpy/torch - for vector v and another vector of indices we can reindex :</p>
<pre><code>v[IX]
</code></pre>
<p>How to do the same when I have batch of vectors v and batch of indexes ?</p>
<p>I mean v - is 2d array of v[i,:] - i-th vector, it should be reindexed by IX[i,:].
Slow Python way is just:</p>
<pre><c... | <python><numpy><torch> | 2024-06-07 08:12:24 | 1 | 974 | Alexander Chervov |
78,590,536 | 729,120 | Can an object be garbage collected if one of its members is a running thread? | <p>I have a custom thread subclass that calls repeatedly a method on a "bound" object. The goal is to automatically join this thread whenever the "bound" object gets GC'ed:</p>
<pre class="lang-py prettyprint-override"><code>from threading import Thread, Event
from weakref import ref, WeakSet
from t... | <python><multithreading><garbage-collection><weak-references> | 2024-06-07 07:42:54 | 1 | 12,575 | m_x |
78,590,532 | 12,314,521 | match to the closest pattern in regex | <p>Hiii,</p>
<p>I have an example here:</p>
<pre><code>(e1) - [:(Causal|Result|SubEvent)*0..1] -> ()
(e:Type1|Type2) - [:Next] -> (e2)
</code></pre>
<p>I want to extract <code>(e1)</code>, <code>()</code> in first example and <code>(e:Type1|Type2)</code>, <code>(e2)</code> in example 2.</p>
<p>there are just so... | <python><regex> | 2024-06-07 07:42:37 | 0 | 351 | jupyter |
78,590,453 | 6,930,340 | Type hinting a Hypothesis composite strategy | <p>I am using the <code>hypothesis</code> library and I would like to annotate my code with type hints. The <a href="https://hypothesis.readthedocs.io/en/latest/details.html#writing-downstream-type-hints" rel="nofollow noreferrer">docs</a> are mentioning the <code>hypothesis.strategies.SearchStrategy</code> as the type... | <python><mypy><python-typing><python-hypothesis> | 2024-06-07 07:26:53 | 1 | 5,167 | Andi |
78,590,224 | 6,803,114 | Traverse elements of nested sections list python | <p>I have a list of dictionarys named "sections" in this format:</p>
<pre><code> [{
"elements": [
"/sections/1",
"/sections/5",
"/sections/6",
"/sections/7"
]
},
{
"elements": [
"... | <python><python-3.x><algorithm><traversal> | 2024-06-07 06:27:43 | 1 | 7,676 | Shubham R |
78,590,213 | 9,542,989 | Stepping into Library Code Appears in Green Pointer and Keeps Stepping Out | <p>I am trying to debug a Flask app with VS Code using the following configuration in my launch.json:</p>
<pre><code>{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
... | <python><visual-studio-code><vscode-debugger> | 2024-06-07 06:23:09 | 1 | 2,115 | Minura Punchihewa |
78,590,050 | 7,812,273 | Dataframe write failing in Databricks with error 'ValueError: can not serialize object larger than 2G' | <p>I am trying to process and parse the data from xml file to delta table in azure databricks using python script.</p>
<p>We receive files in xml format and we parse it as structured format using dataframes.
But while writing the dataframe to the table it is throwing the serialization error and failing.</p>
<p><code>or... | <python><azure><apache-spark><azure-databricks> | 2024-06-07 05:20:08 | 1 | 1,128 | Antony |
78,589,762 | 1,537,366 | Can I modify VSCode syntax highlighting so that a python parameter variable's color is different from function call keyword parameter names? | <p>I was able to modify both the color of parameter variables and function call keyword parameter names at the same time, but I cannot seem to modify them separately.</p>
<p>For example the following:</p>
<pre class="lang-json prettyprint-override"><code>{
"editor.tokenColorCustomizations": {
&quo... | <python><visual-studio-code><syntax-highlighting> | 2024-06-07 02:53:14 | 1 | 1,217 | user1537366 |
78,589,623 | 8,968,801 | Type Annotations and Docstrings for Decorator | <p>I'm trying to add type annotations for my python decorator, but its proving to be really difficult to get right.</p>
<p>Here is my decorator:</p>
<pre class="lang-py prettyprint-override"><code>RT = TypeVar('RT')
P = ParamSpec('P')
def meraki_dashboard_setup(function: Callable[P, RT]):
"""
Ad... | <python><python-typing><python-decorators><pyright> | 2024-06-07 01:34:23 | 1 | 823 | Eddysanoli |
78,589,412 | 3,620,725 | Change wallpaper for specific monitor on Windows with Python? | <p>The code below takes an image and sets it as the desktop wallpaper for all my monitors, but how can I set the wallpaper for just one specific monitor?</p>
<pre><code>import os
import ctypes
path = os.path.abspath("wallpaper3.jpg")
assert os.path.exists(path)
ctypes.windll.user32.SystemParametersInfoW(20,... | <python><windows><winapi><ctypes><windows-11> | 2024-06-06 23:24:25 | 0 | 5,507 | pyjamas |
78,589,342 | 14,695,280 | Kill open Popen handles on Flask dev server restart | <p>I have a Flask app that I'm using to serve a webapp, whose frontend is built using <code>esbuild</code>.<br />
I've managed to configure the Flask server to start the <code>esbuild</code> process in development mode, and to ensure that <code>esbuild</code> is killed when the Flask app is killed, with help from <a hr... | <python><python-3.x><flask><subprocess><popen> | 2024-06-06 22:53:06 | 0 | 479 | JMA |
78,589,335 | 3,952,424 | Best way to make an animated line plot in streamlit? | <p>I'm new to Streamlit and am trying to create an animated line plot. However, my data is quite heavy: I have 40 data points on the x-axis, and at each time instance, I am plotting 50 lines (the animation goes forward in time).</p>
<p>The parameters of the figure are selected on the sidebar, and each time the user cha... | <python><matplotlib><animation><plotly><streamlit> | 2024-06-06 22:48:32 | 1 | 1,801 | ValientProcess |
78,589,225 | 8,278,075 | How to mock a function which is not part of a class in Pytest? | <p>I have a dependency in my target code called <code>target/dep.py</code> which should return "PATCHED" when I mock in the Pytest function. But after research, I can't seem to find how to patch a stand alone function in <code>target/dep.py</code>.</p>
<p>The answers I've seen say to use <code>MagicMock()</co... | <python><unit-testing><mocking><pytest> | 2024-06-06 21:58:23 | 0 | 3,365 | engineer-x |
78,589,200 | 8,877,284 | Pandas compare() how to iterate over rows | <p>I am comparing two <code>dfs</code> using pandas <code>compare()</code></p>
<pre><code>updated_records = out['df1'].compare(out['df2'])
userid amount
self other self other
0 122 121 NaN NaN
2 NaN NaN 3.0 4.0
</code></pre>
<p>how to efficiently iterate over those rows to have output some thi... | <python><pandas><compare> | 2024-06-06 21:48:37 | 2 | 1,655 | Exc |
78,589,155 | 2,142,338 | Clamping Daily Temperature Plot with Altair on Colab | <p>I'm trying to use altair to recreate the world temperature plot from Climate Reanalyzer: <a href="https://climatereanalyzer.org/clim/t2_daily/?dm_id=world" rel="nofollow noreferrer">https://climatereanalyzer.org/clim/t2_daily/?dm_id=world</a>. The data is pretty easy to load:</p>
<pre><code>import pandas as pd
impor... | <python><google-colaboratory><altair><clamp> | 2024-06-06 21:36:37 | 1 | 888 | Don |
78,589,127 | 3,919,277 | json_normalize from pandas (Python) - how to keep variables high in the parse tree? | <p>I need to convert a .json file to .csv. This file has an extremely complex structure:</p>
<pre><code>"lineItemSourcedId": 218410938,
"ext_inspera_assessmentRunTitle": "SPE1053 Inspera Digital Exam 20 May 2024",
"ext_inspera_assessmentRunExternalId": "EmOkVON97XbA8UczrBcjC... | <python><json> | 2024-06-06 21:28:31 | 1 | 421 | Nick Riches |
78,589,104 | 968,132 | Why does with_structured_output ignore optional params in Pydantic models | <p>I am experimenting with Langchain's ability to take a Pydantic model and return a structured JSON-like output from an LLM. I guess I don't understand how <code>Optional</code> is being interpreted.</p>
<p>Example using the Pydantic model directly vs its JSON cousin in <code>with_structured_output</code>:</p>
<pre><c... | <python><pydantic><langchain><large-language-model> | 2024-06-06 21:18:46 | 1 | 1,148 | Peter |
78,589,015 | 21,935,028 | Python re search replace not fidning a match | <p>This is the input:</p>
<pre><code>BEGIN^M
DBMS_SCHEDULER.create_job ( ^M
job_name => 'MY_JOB',^M
job_type => 'PLSQL_BLOCK',^M
job_action => 'begin
run_this_proc;
end;',^M
start_date => TO_TIMESTAMP( '2023-03-26 06:00:00.0 Europe/London' ),^M
repeat... | <python><python-re> | 2024-06-06 20:54:17 | 0 | 419 | Pro West |
78,588,992 | 8,479,386 | Unsanitized input from an HTTP parameter flows into django.http.HttpResponse | <p>In my python (django) project, I have following code snippet</p>
<pre><code> someError = request.GET.get('error', None)
if someError is not None:
self.logger.exception(f'Authorization failed with error: {someError}')
return HttpResponse(f'Authorization failed with error: {someError}... | <python><django><snyk> | 2024-06-06 20:47:33 | 1 | 866 | Karan |
78,588,730 | 2,820,579 | Function to build back a function when using fft? | <p>In python and in numpy, there are several packages to obtain the FFTs. However, is there a function in numpy or in another package such that, if one feeds the Fourier coefficients from the FFT, it gives back the original "fitted" function?</p>
<p>For instance, if I sample a $\sin(x_j)$ in, say, 50 points, ... | <python><numpy><fft> | 2024-06-06 19:37:24 | 1 | 3,541 | user2820579 |
78,588,570 | 156,285 | Any HTTP/2 Server support interleaving between HEADERS & CONTINUATION frame? | <p>In RFC 9113, Section 6.10:</p>
<blockquote>
<p>"Any number of CONTINUATION frames can be sent, as long as the preceding frame is on the same stream and is a HEADERS, PUSH_PROMISE, or CONTINUATION frame without the END_HEADERS flag set."</p>
</blockquote>
<p>So, it means we can insert a frame from another s... | <python><http2> | 2024-06-06 18:55:13 | 1 | 1,095 | lidaobing |
78,588,549 | 2,954,547 | Creating a histogram using the Snowpark Python API | <p>In Snowflake SQL, there is the <a href="https://docs.snowflake.com/en/sql-reference/functions/width_bucket" rel="nofollow noreferrer"><code>WIDTH_BUCKET</code> function</a> which can be used to create a histogram:</p>
<pre class="lang-sql prettyprint-override"><code>with hist as (
select
width_bucket(
x,... | <python><snowflake-cloud-data-platform><histogram> | 2024-06-06 18:51:21 | 1 | 14,083 | shadowtalker |
78,588,425 | 5,244,415 | FastAPI + SQLAlchemy trying to create schema during startup | <p>I am working with Postgres, FastAPI and SQL Alchemy.</p>
<p>I want my application to create the schema and tables from my models during startup. I have the tables from models working fine:</p>
<pre><code>async def migrate_tables() -> None:
engine = create_async_engine(api_config.DB_URI)
async with engine... | <python><sqlalchemy><fastapi> | 2024-06-06 18:19:02 | 3 | 895 | Estevao Santiago |
78,588,402 | 7,802,354 | How to assert an exception that is logged and is not affecting the Response | <p>I'm testing an API that can raise an exception, but eventually returns a response based on other calculations, not related to the exception that is raised (it only logs the exception):</p>
<pre><code>def get(self, request):
#some code here
try:
#do something and create the response value
except E... | <python><django><pytest> | 2024-06-06 18:13:30 | 1 | 755 | brainoverflow |
78,588,301 | 2,977,256 | jax complaining about static start/stop/step | <p>Here is a very simple computation in jax which errors out with complaints about static indices:</p>
<pre><code>def get_slice(ar, k, I):
return ar[i:i+k]
vec_get_slice = jax.vmap(get_slice, in_axes=(None, None, 0))
arr = jnp.array([1, 2,3, 4, 5])
vec_get_slice(arr, 2, jnp.arange(3))
</code></pre>
<pre><code>----... | <python><jax> | 2024-06-06 17:46:25 | 1 | 4,872 | Igor Rivin |
78,588,269 | 6,622,697 | Can a Python program find orphan processes that it previously created? | <p>I'm using <code>popen()</code> to create potentially long-running processes in Python. If the parent program dies and then restarts, is there a way to retrieve the previously created processes that are still running? I'd probably have to use <code>start_new_session=True</code>, which I'm not doing now.</p>
<p>Esse... | <python><popen> | 2024-06-06 17:36:45 | 1 | 1,348 | Peter Kronenberg |
78,588,071 | 4,612,370 | Numpy slicing gives unexpected result | <p>Does anybody have an explanation for the unexpected numpy slicing results dislplayed below ?</p>
<h2>Unexpected behavior demo</h2>
<pre class="lang-py prettyprint-override"><code>import torch
import numpy as np
some_array = np.zeros((1, 3, 42))
chooser_mask = np.zeros((42))
# mask will pick 2 values
chooser_mask[13... | <python><numpy><pytorch><array-broadcasting><numpy-slicing> | 2024-06-06 16:49:16 | 0 | 838 | n0tis |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.