This lab has two parts: part I is here.
I am calling it
Create a new directory with your chosen package name. You can
create a directory in Linux as
Move into the newly created directory. Create subdirectories for each major class of functions we have coded so far. In Linux, we can create all the subdirectories at once as
In each directory, starting from the package directory (in my
example,
Move into the directory above
Try the code in the cells below: if it works, you are done! Of course, don't forget to replace the names with your directory and file names. The output may also be different - it will match your code output, not mine!
import numpy as np
# cbnm2023.utils refers to the directory name containg all the
# IEEE floating point operations.
# cbnm2023.roots is the name of the directory containing all the
# root-finding programs. My programs are in the file:
# root_finder.py
# We import it as in Line 10 below. See how we use the names
# of the Python files without the .py extension
from cbnm2023.utils import IEEEUtils as iu
from cbnm2023.roots import root_finder as rf
from cbnm2023.syseq import eqn_gauss_eliminate as eg
from cbnm2023.syseq import LUD
np.set_printoptions(precision=2, suppress=True)
def f1(x) :
return x ** 5 - 100.
ans = rf.root_bisection(f1, -10., 10., eps=1e-8)
print(ans[0], '(Verification: ', ans[0]**5, ')')
Before doing anything, make the following changes to the python code written if you have used your own functions in any other functions. I am sure that you did! Very likely, you used your
##### I have my package code in the top directory cbnm2023. The
##### gauss_eliminate code is in a sub-directory syseq containing
##### the Python file eqn_gauss_eliminate.py. Modify the import
##### statement according to your naming of files and directories.
import numpy as np
import cbnm2023.syseq.eqn_gauss_eliminate as eg
There are three more steps to make your package public. First, move into the directory (folder)
After running the above command, make sure there is
a directory called
from setuptools import setup, find_packages
VERSION = '1.0'
DESCRIPTION = 'Computer Based Numerical Methods(CBNM 2023) '
LONG_DESCRIPTION = 'Commonly used numerical methods for scientific applications'
# Setting up
setup(
# the name must match the folder name 'verysimplemodule'
name='cbnm2023',
version=1.0,
author='Chakravarthy Bhagvati',
author_email="chakravarthybhagvati@uohyd.ac.in",
description='Computer Based Numerical Methods (CBNM 2023)',
long_description='CBNM 2023 provides numerical methods for scientific applications',
packages=find_packages(),
install_requires=[], # add any additional packages that
# needs to be installed along with your package.
keywords=['python', 'numerical methods'],
classifiers= [
"Development Status :: 1 - Alpha",
"Intended Audience :: UG Students",
"Programming Language :: Python :: 3",
"Operating System :: Ubuntu :: Linux",
]
)