Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Docs First: Use Scientific Python Documentation Efficiently

Python reference | A course rule for reliable code

San Diego State University

The hard rule

Docs First is a hard rule in COMP 521. Before copying code from a search result, asking an AI assistant, or guessing how an unfamiliar function behaves, check the primary documentation for the exact tool you are using.

Documentation is the closest authority on an API’s inputs, defaults, returned object, exceptions, and version-specific behavior. It does not prove that your model is scientifically adequate. It tells you what the software promises, so you can test whether that behavior serves the scientific question.

Official documentation routes

Python

NumPy

Matplotlib

A fast documentation workflow

When you encounter np.mean(flux, axis=0) or ax.set_xlim(0, 10), do this before changing code.

  1. Name the exact question. Example: “What does axis=0 mean for an array with shape (stars, times)?”

  2. Check your environment and version. Record sys.version and, where relevant, np.__version__ or matplotlib.__version__. Online docs may be newer than your installed release.

  3. Read signature, parameters, returns, and exceptions. Do not stop at the first example that appears to work.

  4. Read one conceptual guide when an option changes meaning: axis, shape, broadcasting, copying, normalization, and scale are not parameters to guess.

  5. Run a smallest possible experiment. Use a tiny array or toy figure whose answer you can predict, then compare the behavior with the documentation.

  6. Ask a precise follow-up. Say what you read, expected, observed, and show the smallest code and full traceback or output.

What to read on a reference page

Read thisWhy it matters
SignatureWhat inputs are permitted and their order
Parameters and defaultsWhich choices occur if you omit an argument
Return value and shapeWhat object comes back, including dimensions/dtype when relevant
Exceptions and warningsHow invalid inputs or questionable behavior are reported
ExamplesA pattern to adapt, never a substitute for understanding
Version notesWhether the behavior changed between releases

Docs before AI or search results

AI assistants, Q&A sites, tutorials, and code snippets can help generate questions and alternatives. They are not the authority for API behavior: they can omit version context, use deprecated behavior, invent parameters, or solve a different problem.

  1. Read the official docs first.

  2. Use outside help to clarify or compare approaches.

  3. Verify every suggested function, parameter, and claimed behavior against the docs and a small runnable check.

  4. Keep a documentation link or a short note in your notebook when library behavior is consequential to an analysis.

A small documentation check

Look up math.isclose, identify its tolerance parameters, then run this predictable example:

True
False

The first call states an allowed absolute difference; the second demands exact floating-point equality. A valid tolerance depends on quantity, units, and claim—not a magic constant.