sciware

Sciware

Summer Sciware 1

Setting up a laptop for scientific computing

https://sciware.flatironinstitute.org/40_SummerIntro

https://github.com/flatironinstitute/sciware/tree/main/40_SummerIntro

Who We Are

Summer Sciware Sessions

Where to Find Sciware

Today’s Agenda

Prerequisite Software

Put up your green sticky 🟩 when you’re done this slide, or your yellow sticky 🟨 if you get stuck!

More detailed instructions here: https://learn.microsoft.com/en-us/windows/wsl/install

Install VS Code

Windows Only: VS Code Setup

Open a Terminal in VS Code

Install uv Python

Put up your green sticky 🟩 when you’re done this slide, or your yellow sticky 🟨 if you get stuck!

Start a Python Project

These instructions are adapted from uv’s “Working on projects” documentation.

uv Cheatsheet

| Traditional Command | uv Equivalent | Description | |—————————-|———————–|———————————————| | pip install <package> | uv add <package> | Add a package as a dependency | | pip uninstall <package> | uv remove <package> | Remove a package from dependencies | | python script.py | uv run script.py | Run a Python script using project env | | python | uv run python | Get an interactive Python prompt |

Add a Dependency

Run a Script

For more advanced projects (like packages for GitHub or PyPI), see uv’s project concepts.

Put up a green sticky 🟩 if running a script works, or your yellow sticky 🟨 if you get stuck!

Using Notebooks

These instructions are adapted from uv’s “Using Jupyter from VS Code” documentation.

Exercise: Create a New Project

Put up your green sticky 🟩 when you’re done this slide, or your yellow sticky 🟨 if you get stuck!

  1. Create a new project called sciware-exercise in your home directory (not in the sciware-2025 project that we already created).
  2. Open the project in VS Code.
  3. Add numpy and matplotlib as dependencies.
  4. Add ipykernel as a development dependency.
  5. Create a new notebook in the project.
  6. Make a colorful scatter plot from a 2D Gaussian distribution!
    1. Use NumPy to generate 100 random points from a 2D Gaussian distribution with mean [0, 0] and covariance [[1, 0.5], [0.5, 1]].
    2. Use Matplotlib to create a scatter plot of the points, with each point colored by a random value between 0 and 1.

Exercise: Solution

import numpy as np
import matplotlib.pyplot as plt

N = 100
rng = np.random.default_rng()
mean = [0, 0]
cov = [[1, 0.5], [0.5, 1]]  # Covariance matrix for some correlation
x, y = rng.multivariate_normal(mean, cov, N).T
colors = rng.random(N)  # Random color for each point

plt.scatter(x, y, c=colors, cmap='viridis', s=60)
plt.title('Random Colorful Gaussian Scatter Plot')
plt.xlabel('x')
plt.ylabel('y')
plt.colorbar(label='Color value')
plt.show()

Resources

Survey

Please give us some feedback!