Python Definition and 661 Threads

PYTHON was a Cold War contingency plan of the British Government for the continuity of government in the event of nuclear war.

View More On Wikipedia.org
  1. M

    How can you modify Python code for effective graph plotting?

    TL;DR Summary: How to understand the code determining the plot Hi; this is the code I have been given for a H-R diagram of M35; I understand the inversion concept.. The plot is below. I am trying to understand the code that creates its position and size and how to alter it to a more...
  2. ergospherical

    Trying to run a big python job with AWS (EC2), is there a better way?

    I've got some code in a public repo with a module containing my model and a python script which runs the model and returns a .parquet file with data. I've parallelized all of the important processes with Joblib, and the underlying code is written in pure C so I can't make it much faster (at...
  3. S

    Unsolvable python code bug? (finding the difference between two input strings)

    All day I have been trying to find a method of finding the difference between two input (body of text), and get the difference but in order. I have tried breaking down the text into separate lines, then try to find the difference between both lines, but somehow this doesn't solve the problem and...
  4. K

    A How to use the Newton-Raphson method while keeping the sum constant?

    Question: How to find solutions using Newton-Raphson method with keeping the sum of solutions? I am currently working on solving a high-dimensional equation to obtain accurate solutions using the Newton-Raphson method, which I have implemented in Python. However, my problem requires that the...
  5. B

    A Efficient cone searches with Healpix-alchemy

    I am trying to implement a cone search for a catalog with the HEALPix-alchemy package. I have the following models set up, based on the examples here: https://arxiv.org/pdf/2112.06947 class Field(Base): """ Represents a collection of FieldTiles making up the area of...
  6. dieon

    A Problem using Gutzwiller-RVB theory for high-temperature superconductivity

    I'm currently working on reproducing a graph from the Gutzwiller-RVB theory of high-temperature superconductivity using Python. The graph plots χ_BBxy versus Δ, where Δ ranges from 16 to 26. I've implemented the theory's iterative parameter update scheme but encountered discrepancies in the...
  7. F

    Learning about Python application deployment - possible recommendations

    Hello, I want to learn about servers and deploying Python applications simply (without going to AWS, Azure, etc. but something a little more complicated than deploying my app to streamlit Cloud). I would like to get some recommendations given the multitude of options. My goal is to create a...
  8. J

    Python Python scipy.optimize.minimize: ‘trust-constr’ and Hessian output

    Hello, does anyone know how to retrieve the Hessian at the minimum when using method = ‘trust-constr’?
  9. F

    Iterators and generators and the data they generate

    Hello, I have been focusing on iterators and generators and I understood a lot but still have some subtle questions... An iterator, which is a Python object with both the __iter__ and the __next__ methods, saves its current state. Applying the next() method to an iterator gives us one item of...
  10. ergospherical

    How Can You Draw from a PDF in Python Without the CDF?

    Some python function f(x) defines an (unnormalised) pdf between x_min and x_max and say we want to draw x randomly from this distribution if we had the CDF F(x) and its inverse F^{-1}(x), we could take values y uniformly in [0,1], and then our random values of x would be x = F^{-1}(y). but...
  11. F

    Python Python Socket library to create a server and client scripts

    Hello, I have been experimenting with the socket library in python creating small scripts, one called server.py and the other client.py, that can communicate with each other using a TCP protocol. The server script has an infinite loop that listens for request from the client.py script and...
  12. S

    Python Stop current Python REPL command, but keep REPL session open?

    If you just typed in a command into the Python repl, and it is stuck in a synchronous "waiting-for-something-to-happen", how can we terminate just that command and return to the same repl session? For example, say we typed websocket.recv() and the websocket is waiting for a message... how can...
  13. ergospherical

    Python How to store a large data-set in a "grid" in Python/NumPy

    Say I have n parameters X1, X2, ..., Xn, and to each "grid-point" X = (X1, X2, ..., Xn) I want to associate a value f(X). So in the end I will have a structure like an n-dimensional matrix. Assume this data-set is going to be very large, i.e. each parameter Xi ranges over hundreds or thousands...
  14. H

    35 years in technology as programmer/engineer

    I'm working on a Python-based project to simulate fission energy containment. Details and GitHub link for collaboration coming soon. Looking forward to contributions.
  15. robotkid786

    Intro Physics Learn Python: Top Book Recommendations for Beginners

    I'm looking at a book called python crash course for beginners (eric mathes), does anyone have experience of using this book or any other book that you would recommend for learning python if not that, is there a specific course you'd suggest that isn't in book form? I'm completely new to...
  16. robotkid786

    Physics How important is python for theoretical physics?

    Hey guys, I'm a first year student studying theoretical physics in England. My physics modules include a fair bit of python programming and I want to apply to ICGs cosmology PhD in England. Can I escape learning python by choosing maths modules?
  17. tehsportsmaen

    I Two-Mass Oscillator: Plotting Amplitudes Over Frequency in Hertz

    Idea: Given a system of two coupled oscillators in which 2 masses are connected to a spring in the middle. Each of the two masses is coupled to another spring on the left and right, which have fixed ends but are not connected to each other. So we have 3 springs, two masses and the springs also...
  18. F

    Docker and Containers: Understanding the Basics and Common Doubts Explained

    Hello, anyone on Physics Forums using Docker? I have understood the overarching idea behind Docker (packaging code, dependencies, etc. into a container that can be shared across OSs) but I have some doubts: I am confused about the base image line of code in the Dockerfile (which is simple text...
  19. D

    Is there a quick way to put quotation marks around strings in an array?

    Hi everyone I'd like to cut and paste a list of words into an array. I'll need to put quotation marks around them all. Is there a way to do this other than to go through each word one by one? Thanks
  20. Eclair_de_XII

    Job Skills I know that this is about the hundredth topic I've made about this, but...

    t I'm feeling lost. Currently, I'm trying to learn how to do web-development stuff in Python, so that I can have a project to show-off to prospective employers. I'm also aware that I may be deluding myself into thinking that one project is all it takes to get noticed. Moreover, I just lack...
  21. R

    How to Convert TMESH Data to Text Files in MCNP6 Using Python"

    I would like to analyse mdata of tmesh in MCNP6 by python, but I am struggling how to convert mdata (unformatted binary) to any text file in python. I used GRIDCONV but it's not suitable for automations. I also used scipy.io.Fortrunfile but could not convert the file because I was not sure...
  22. F

    I Is there a better way to calculate time-shifted correlation matrices?

    Hello everyone. I have four thermometers which measure the temperature in four different positions. The data is distributed as a matrix, where each column is a sensor, and each row is a measurement. All measurements are made at exactly the same times, one measurement each hour. I have...
  23. F

    How do Jupyter notebook components work together?

    Hello everyone, As mentioned in past threads, jupyter notebook is a popular application that is used to code in Python (and other languages as well). The jupyter notebook installation includes 3 software components working together: 1) kernel: it interact with the web server 2) server: web...
  24. F

    Python Clarification about dir() in Python

    Hello, Simple clarification about the built-in function dir() if possible: if we don't provide any argument, i.e. we use the function simply as dir(), the function displays the namespace of the function, of the module, etc. However, if we provide an input, the function dir() displays a list...
  25. B

    What programming languages does Bartb7 specialize in?

    There's stuff on here relevant to my day-to-day, which means I may also be able to contribute. I'm primarily focused on programming in C, C++, Python and Perl. Nothing now, just introducing myself - hello all!
  26. VVS2000

    I Finding the difference in Helmholtz free energy using thermodynamic integration

    If there any solved papers or even python simulations to find this please share I understood the process of thermodynamic integration but computationally I want to see how this integration of average of derivative of coupled potential energy is done
  27. J

    I JC Model in Python: Advice & Feedback Needed - Jon Poplett

    Good afternoon! I am fumbling my way through setting up a JC model in python, I was hoping I could get some feedback on it please. I just want to make sure everything looks good and the data I am collecting is valid. Any advice or feedback would be very welcome...
  28. Leo_Chau_430

    Python Why Use Python for Web Scraping Instead of Excel?

    My code is as follow: import pandas as pd from bs4 import BeautifulSoup import requests import os url = 'https://www.goodschool.hk/ss' response = requests.get(url) html = response.content soup = BeautifulSoup(html, 'html.parser') school_items = soup.find_all('div', {'class'...
  29. person123

    Python My Python Library For Finite Difference Method

    I recently made a Python library for modelling (very basic) finite difference problems. The Github readme goes into details of what it does and how it works, and I put together a Google Colab with some examples (diffusion, advection, water wave refraction) with interactive visuals. I'd love to...
  30. M

    Python Can Fortran 77 Code Be Used to Debug Python Code for Solving ODEs Using Radau5?

    Hi, I have a piece of Fortran code but I'm not Fortran literate. I'm trying to translate it into Python. I have already made it, but I need someone who can run the Fortran code to compare the values of the variables.
  31. F

    Python Create a Mask-RCNN Model in Python for Smart Parking Systems

    Homework Statement: I am trying to write a Python code to do a project about smart parking system. I want to create a Mask RCNN model to detect the vehicles in the parking slots. My code is attached below, I got an error in the last line (creating Mask_RCNN model) and do not know how to solve...
  32. M

    Python Graphing a piecewise function (Python)

    I am trying to write a python script to plot the function, Where ##V_0 = 5~V## ##t_0 = 10~ms## ##\tau = 5~ms## My script that I have written to try to do this is, Which plots, However, the plot is meant to look like this with the horizontal line. Can someone please give me some guidance to...
  33. S

    Python Help with Histogram and Boxplot in Python

    I could really use some help here, I am a transfer student so my course load is all out of order. I have a statistics course that requires me to use Python to solve this one question (the 2 parts shown below). I never took any sort of coding before, I don't know where to even start. Can anyone...
  34. ergospherical

    Python Speed of function vs lambda calls in python

    An observation I made earlier- something like def f(...): ... return ... def g: ... = f(...) was quite a bit slower than doing def g: f = lambda ... : ... ... = f(...) any reasons why?
  35. B

    Python FineTune the Pixel2Style2Pixel model with my custom data set

    I want to fine-tune the Pixel2Style2Pixel model with my custom data set, but I keep getting an error when I'm trying to load in the pre-train weights. Here is my code : # Load the pre-trained model os.chdir("/content/pixel2style2pixel") from models.psp import pSp config = { "lr": 0.0001...
  36. Gwen

    Python Thermal lattice Boltzmann model ignoring source term -- python code help please

    LBM model for phase change- relevant equations found here. Also here. #Thermal LBM #solves 1D 1 phase phase-change #D2Q5 Lattice nx=100 # the number of nodes in x direction lattice direction ny=5 # the number of nodes in y...
  37. F

    Python Automatic parking slots detection using Python

    TL;DR Summary: How to automatically detect the parking slots using Python? I have a Deep Machine Learning course and would like to do my course project about "Available Parking Slots Detection using Deep Machine Learning Based on Image Processing". My plan is to split the project into two...
  38. jim mcnamara

    Python What are the limitations of Codon, the new Python compiler?

    See this story here in a press release from MIT: https://news.mit.edu/2023/codon-python-based-compiler-achieve-orders-magnitude-speedups-0314 Basically, any working Python module can be compiled one time only, and then run 10+ times faster than interpreted code, with no further changes to...
  39. Arman777

    Python GTRPy - A python package for General Relativity Related Calculations

    Hello, everyone I am now working on this project quite a while now and I just wanted to share it with this forum, which I was a member for a long time. I am working on a python application about GR and I believe I managed to create a very user-friendly layout. It's called GTRPy, and it allows...
  40. S

    Comp Sci Plot periodic function with Fourier coefficients

    I have plotted the function for ##T=15## and ##\tau=T/30## below with the following code in Python: import numpy as np import matplotlib.pyplot as plt def p(t,T,tau): n=np.floor(t/T) t=t-n*T if t<(2*np.pi*tau): p=np.sin(t/tau) else: p=0 return p...
  41. alpha

    Python Solving Linear Programming problems in python PulP

    Okay so far I have come up with the following: The objective function is: 30LADA + 40LAHO + 50SADA + 40SAHO + 110DANY + 125DACH + 105HONY + 115HOCH (to read this please see the table above as I have just used the first two letters of each except NY which I have represented by NY). In these I...
  42. B

    Python Pix2pix: Image-to-image translation with a conditional GAN

    So I am trying to do this tutorials but I want to use my own dataset. I am having problems "Build an input pipeline with tf.data." My question is about their code: def load_image_train(image_file): input_image, real_image = load(image_file) input_image, real_image =...
  43. Grinkle

    Python Are Python strings truly immutable?

    I am using "Introducing Python" (Lubanovic) to teach myself Python. I read that Python strings are immutable, then I see code like this - string1 = 'base_val' string1= 'new_val' not throw up an error. A little investigation shows me that the interpreter created two strings and string1 is a...
  44. A

    A How to Plot the Light Path in a Space-Time Diagram Using Python?

    I am trying to replicate the space time plot (the 2nd plot with Proper distance vs Time) as in this thread: space-time I wrote everything in python using the astropy cosmology package. Everything went smooth, but I am stuck at plotting the light path on the 'purple path', as per the above...
  45. M

    Python Does this python script match the math?

    Hi PF! I've posted a bunch lately and you have been SO helpful (seriously, thank you all). Can you corroborate if my python script below matches the math? I'd seriously appreciate it! The math: $$\max_{x\in [0.7,1)}F(x) : F(x) := \sum_{t = 250}^{750} \log\left( P_{\nu=3} \left(...
  46. Sciencemaster

    I Calculate Gaussian Curvature from 4D Metric Tensor

    I've been trying to find a way to calculate Gaussian curvature from a 4D metric tensor. I found a program that does this in Mathematica using the Brioschi formula. However, this only seems to work for a 2D metric or formula (I would need to use something with more dimensions). I've found...
  47. M

    MATLAB Can I run sections of code independently in Python and C++ like in MATLAB?

    Hi PF! I typically code in MATLAB. Here, if I run the following program %% Section 1 x = 5; y = 2; %% Section 2 z = x + y; everything works. But now let's say I wanted to change line 5 to z = x - y. In MATLAB this is simple: I can simply change line 5 and rerun section 2. Is there a way to...
  48. M

    Should users confirm their account deletion before it is processed?

    Hey! 😊 I have written a code in Python for a server to search for movies. At the site for the user I have added at the html template the options to change the password and to delete the account. For this do I have to write a separate html or a separate endpoint for these ones or can I write...
  49. TheJP78

    Python Building a Solar System simulation with python

    Hey'all. First of all, I'm not fluent in English, so forgive me for the spelling mistakes. So, I'm trying to make a simulation of a solar system using python 3.9. It's not complicated, but my teacher wants me to do it using the Basic Verlet method, and that's what is bugging me. He told me do do...
  50. M

    Python One-line Python Code that returns a sequence of integers

    Hey! 😊 I want to write a one-line Python generator or iterator expression that returns the sequence of integers generated by repeatedly adding the ascii values of each letter in the word “Close” to itself. The first 10 integers in this sequence are: 67, 175, 286, 401, 502, 569, 677, 788, 903...
Back
Top