Skip to main content

Several small functions for classroom instruction.

Project description

Classroom Gizmos

This is a collection of functions for classroom instruction in introductory physics. This is basically using ipython as a calculator that displays the calculation and the results.
Typical usage to make a set of useful functions available in ipython:

from classroom_gizmos.handies import *
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

handies

classroom_gizmos.handies is a collection of small functions that are useful from an ipython prompt.
Note: Imports from astropy, PyQt5, and func_timeout
Certain functions and functionality are not available when some of the imported packages are unavailable.
The mine() function lists all the user functions defined in handies.py.

handies defines or imports:

cdbn(), osname(), getCCode()
hostname(), call(), rad(), deg(), sinD(), cosD(), tanD(),
asinD(), acosD(), atanD(), atan2D(), atan2P(), nCr(), comb(),
pltsize(), select_file(), select_file_timeout(), getTS(), timeStampStr(),
isInstalled(), randomLetter(), randomElement(), count_down()
mine()

Clear screen functions:

cls  (iPython magic %cls) outputs 23 blank lines.
clsall() deletes previous text using ascii control character.

Trig Functions in Degrees
    'D' and 'P' trig functions work with degrees.
    'P' inverse functions return only positive angles.

greeks ⟶ a string with greek alphabet.
pltsize( w, h, dpi=150) ⟶ resizes plots in matplotlib.
getTS() ⟶ returns a readable time stamp string.
isInstalled( pkgNameStr) ⟶ returns package or None if pkg is not installed.
timeStampStr() ⟶ returns a readable, timestamp string.
From random imports randint and defines randomLetter

mine() ⟶ lists what handies.py defines.

If PyQt5 package is available defines:

select_file and select_file_timeout

From math imports these functions:

pi, sqrt, cos, sin, tan, acos, asin, atan, atan2, degrees, radians, log, log10, exp

When astropy is available:

Defines nowMJD(); mjd2date(), date2mjd().
Imports astropy.units as "u", i.e. u.cm or u.GHz

Misc.

The variable IsInteractive is True if in interpreter, False if running from command line.
Line magic cls is defined, outputs 23 blank lines to 'clear' screen.<
Sets ipython numeric format to %.5g

jupyter_file_browser

This module implements a file browser that can be used in a Jupyter Notebook. (Not usable in Jupyter lab.)
Typical Usage:

from classroom_gizmos.jupyter_file_browser import box, get_file_path
box

A file select widget will be created below that cell.

In a following notebook cell:

path = get_file_path()  ## returns path of currently selected file in
the file select cell.

import_install

importInstall()

pkg = importInstall( 'pkg_name')
OR
pkg = importInstall( 'pkg_name, 'PyPI_name')

This function tries to import a specified package and if that fails, it tries to install the package and then import it.
importInstall was written so that python programs can be distributed to students without detailed instructions on checking if packages are installed and information on installing the needed packages.
The function returns the package or None.

Warning: importInstall can not install all packages. It is less likely to install a package that is not pure python.

BestByMinBefore

functions

decCredit() returns perl code for use in WebAssign answer credit calculations. Convenience functions:

BBPdecCredit(), InCdecCredit(),
HWdecCredit(), getCCode()

getCCode() is an interactive 'wizard' that has no parameters, but steps through options needed to produce the Perl conditional code for various question types.

All functions should have doc strings that give more information about usage and parameters.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

classroom_gizmos-0.0b2.dev32.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

classroom_gizmos-0.0b2.dev32-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file classroom_gizmos-0.0b2.dev32.tar.gz.

File metadata

  • Download URL: classroom_gizmos-0.0b2.dev32.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for classroom_gizmos-0.0b2.dev32.tar.gz
Algorithm Hash digest
SHA256 f5e574556f3a3d0f9acb1d56e226ed31f27c174679cc05e2cdae55a9298e9e42
MD5 90005a8a31f8a71bfbcb6b38397445dc
BLAKE2b-256 db410c1a65e979caa9522cecba301bf1b0579bc6ec0de54137e3642a55494ea4

See more details on using hashes here.

File details

Details for the file classroom_gizmos-0.0b2.dev32-py3-none-any.whl.

File metadata

  • Download URL: classroom_gizmos-0.0b2.dev32-py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for classroom_gizmos-0.0b2.dev32-py3-none-any.whl
Algorithm Hash digest
SHA256 e6cda3cb1f81ee28af07dc6215678bd96ee7934c42b45e1627ce8fc972ac91aa
MD5 468a017aa94de19ab7b43d68360cd783
BLAKE2b-256 77c1604b4ce4b32094b722f1b848063fdcaf3fce1d93d2d1ba4f35a0741760c7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page