(Fixed) TypeError: FigureBase.gca() got an unexpected keyword argument ‘projection’

When trying to plot a 3D normal distribution recently, I encountered the following error: TypeError Traceback (most recent call last) <ipython-input-10-ee1b0cd4b744> in <cell line: 32>() 30 fig = plt.figure() 31 —> 32 ax = fig.gca(projection=’3d’) 33 34 # create a 3D surface plot of the multivariate normal distribution πŸ‘‰ TypeError: FigureBase.gca() got an unexpected keyword … Read more

(Fix) ValueError: Argument Z must be 2-dimensional

Problem Formulation The output when running this code is as follows Warning (from warnings module): File “C:\Users\xcent\Desktop\code.py”, line 10 ax = fig.gca(projection=’3d’) MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current … Read more

How Do I Make a 3D Waterfall Plot with Colored Heights in Python?

To generate a 3D waterfall plot with colored heights create a 2D sine wave using the NumPy meshgrid() function, then apply a colormap to the heights using Matplotlib’s Normalize function. The plot_surface() function generates the 3D plot, while the color gradient is added using a ScalarMappable object. Here’s a code example for copy and paste: … Read more

3 Easy Ways to Check Your Internet Speed in Python

Method 1: Speedtest-cli To measure your Internet speed with Python, you can use the Speedtest-cli method. This Python library provides a command-line interface for testing internet bandwidth using speedtest.net. It performs a comprehensive test, providing download speed, upload speed, and latency data. First, install the speedtest-cli library using: pip install speedtest-cli The following example can … Read more

Python Sleep For Less Than a Second

πŸ’‘ Problem Formulation: Chances are you’ve already figured out that you can get your Python program to sleep for one second using time.sleep(1). But how do you sleep for less than a second, e.g., for half a second (0.5s), milliseconds, or even microseconds? Method 1: Use time.sleep() The time.sleep(seconds) function halts the Python program for … Read more

No, GPT-4 Doesn’t Get Worse Over Time (FUD Debunked)

There has been a lot of drama on Twitter about the new Stanford UC Berkely collab paper titled “How Is ChatGPT’s Behavior Changing over Time?” (source) The paper’s authors selectively provide examples where newer versions of GPT-4 seem to perform “worse” and have “formatting mistakes” than older versions. The first evaluation they provide is the … Read more

Python OpenAI Streaming Completions

Set stream=True when calling the chat completions or completions endpoints to stream completions. This returns an object that streams back the response as data-only server-sent events. Streaming completion is an essential functionality offered by OpenAI, particularly useful in the implementation of real-time applications like live text generation or interactive conversational bots. Traditionally, this feature has … Read more

The Scarcest Resource on Earth

What is the scarcest desirable resource on Earth? Before you read on, I want you to commit to an answer. Is human time the scarcest resource? No. You can always produce more humans. Your human time might be limited but human time in general is a renewable resource. Is energy the scarcest resource? Well, no. … Read more

Llama 2: How Meta’s Free Open-Source LLM Beats GPT-4!

Meta (formerly Facebook) has released Llama 2, a new large language model (LLM) that is trained on 40% more training data and has twice the context length, compared to its predecessor Llama. Llama 2 is open-source so researchers and hobbyist can build their own applications on top of it. Llama 2 is trained on a … Read more

Pandas DataFrame Object: A Beginner’s Guide

When working with data in Python, one of the most powerful tools at your disposal is the pandas DataFrame. πŸ’‘ A DataFrame is a two-dimensional data structure, which essentially looks like a table with rows and columns. This versatile data structure is widely used in data science, machine learning, and scientific computing, among other data-intensive … Read more