Skip to content

Commit

Permalink
[0003-crash-development2-major-1] (PR #15)
Browse files Browse the repository at this point in the history
Merge pull request #15 from syedalimohsinbukhari/0003-crash-development2
  • Loading branch information
syedalimohsinbukhari authored Sep 15, 2024
2 parents 9cb877e + 52042da commit 2084df8
Show file tree
Hide file tree
Showing 40 changed files with 659 additions and 483 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,7 @@ dmypy.json
# Pyre type checker
.pyre/
.idea/
.vscode/
.vscode/
main.py
/**/*.sh
/**/*.csv
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ignored-modules=
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
# avoid hangs.
jobs=1
jobs=3

# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Syed Ali Mohsin Bukhari, Astrophysics and Python
Copyright (c) 2022 Syed Ali Mohsin Bukhari

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
82 changes: 50 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,58 @@ implementations for details).

## Modules

### Current implementations
### Current Implementations

1. `misc`
1. `is_numeric` : To check if the input is numeric or not.
2. `os_`
1. `ListOfFilesFromExtensions` : To pick files of specific extensions
---

1. `os_`
1. `ListOfFilesFromExtensions`: To pick files of specific extensions.
2. `ListOfFilesFromNames`: To pick files matching a specific name pattern.
3. `list_`
1. `numeric_list_to_string` : To convert a list of numeric values to string.
2. `string_list_to_numeric` : To convert a list of string number values to numeric.
3. `nested_list_to_list` : To convert a nested list to 1D list.
4. `list_to_nested_list` : To convert a simple 1D list to a nested list.
5. `join_lists` : To join multiple lists into a single one
6. `Replace` : To replace values in a list, either by given value or by the index.
7. `is_contained` : To check if a given list is contained within another list.
8. `get_object_count`: To get an object count from the list. Has an added capability of returning sorted list of
objects or top N objects.
9. `sort_`: To sort a list. Can also return the sort indices.
10. `remove_`: To remove a value from a given list. Can also remove `tuple`, `str`, or a nested `list`.
11. `move_element_in_list`: To move a given element present in the list to a new location within the list.
4. `read_files`
1. `read_text_file_in_a_list`: Reads an entire `txt` file.
2. `read_specific_lines_from_a_file`: Reads specific lines (index based) from a given `txt` file.

### Future implementations
3. `move_directory_contents`: To move directory contents to a new location.

2. `list_`
1. `difference_between_lists`: To get the difference between two lists.
2. `equal_lists`: To check if two lists are equal.
3. `get_object_count`: To get an object count from the list.
4. `index`: To get the index of an element in the list.
5. `is_contained`: To check if a list is contained within another list.
6. `join_lists`: To join multiple lists into a single one.
7. `list_to_nested_list`: To convert a list to a nested list.
8. `move_element_in_list`: To move a list element to a new position.
9. `nested_list_to_list`: To convert a nested list to a flat list.
10. `remove_`: To remove a value from a list.
11. `replace_at_index`: To replace values at a specific index in the list.
12. `replace_with_value`: To replace values with a given value in the list.
13. `sort_`: To sort a list.
14. `string_list_to_numeric`: To convert string values in a list to numeric.

3. `read_files`
1. `read_txt_file`: To read an entire text file.
2. `get_lines_from_txt_file`: To read specific lines from a text file.

4. `dict_`
1. `get_key_index`: To get the index of a key in a dictionary.
2. `merge_dictionaries`: To merge dictionaries.
3. `pretty_print`: To print a dictionary in a readable format.
4. `sort_dictionary`: To sort a dictionary.

5. `array_`
1. `moving_average`: To calculate the moving average for an array.
2. `reshape_with_padding`: To reshape an array with padding.
3. `transpose1d`: To transpose a 1D array.

6. `plotting_`
1. `plot_two_column_file`: To plot data from a two-column file.
2. `plot_xy`: To plot x vs. y data.
3. `plot_with_dual_axes`: To plot with dual axes for two datasets.

---

### Future Implementations

1. `read_files`
1. Whole files using generator to reduce memory issues,
2. Implementation of reading other files, especially `.csv`.
2. `dict_`
1. For handling dictionary manipulations methods easily. For example,
1. updating dictionaries,
2. index retrieval, and/or
3. dictionary comparisons.
3. And more
1. Implementation of reading other file formats, especially `.csv`.
2. Whole file reading using generators to reduce memory issues.

### Documentation: IN PROGRESS
2. `dict_`
1. Additional dictionary manipulation methods such as updating, retrieval, and comparisons.
5 changes: 0 additions & 5 deletions do_tests.sh

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[build-system]
requires = ["setuptools==70.0.0", "numpy==1.26.4", "matplotlib==3.9.1"]
requires = ["setuptools", "numpy==1.26.4", "matplotlib"]

build-backend = "setuptools.build_meta:__legacy__"
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
setuptools==70.0.0
numpy==1.26.4

matplotlib==3.9.1
matplotlib
setuptools
11 changes: 0 additions & 11 deletions run_all_sh.sh

This file was deleted.

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = mpyez
version = 0.0.5
version = 0.0.6
url = https://github.com/syedalimohsinbukhari/mypyez
author = Syed Ali Mohsin Bukhari, Astrophysics and Python
author_email = [email protected], [email protected]
Expand Down
20 changes: 9 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@

setup(
name='mpyez',
version='0.0.5',
version='0.0.6',
packages=find_packages(where="src", exclude=['*tests*']),
url='https://github.com/syedalimohsinbukhari/mpyez',
license='MIT',
author='Syed Ali Mohsin Bukhari, Astrophysics and Python',
author_email='[email protected], [email protected]',
description='Common use utilities for python done easy.',
author='Syed Ali Mohsin Bukhari',
author_email='[email protected]',
description='Common use backend for python done easy.',
long_description=readme,
long_description_content_type="text/markdown",
python_requires=">=3.9, <3.12",
install_requires=["setuptools==70.0.0", "numpy==1.26.4", "matplotlib==3.9.1"],
install_requires=["numpy==1.26.4", "matplotlib", "setuptools"],
include_package_data=True,
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
],
classifiers=["License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"],
)
3 changes: 0 additions & 3 deletions shell_scripts/build_wheel.sh

This file was deleted.

3 changes: 0 additions & 3 deletions shell_scripts/linting.sh

This file was deleted.

2 changes: 0 additions & 2 deletions src/mpyez/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
"""Created on Jul 18 23:26:06 2022."""

from . import dict_, list_, misc, os_, read_files
3 changes: 3 additions & 0 deletions src/mpyez/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Created on Jul 20 00:17:08 2022."""

from . import uDict as d_utils, uList as l_utils
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@


class EzFileErrs(Exception):
"""Base class for exceptions in EzFile."""
pass


class LineNumberOutOfBounds(EzFileErrs):
"""Exception raised when a line number is out of bounds."""
pass
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions src/mpyez/backend/uIO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Created on Jul 23 18:38:52 2022."""

from .eIO import LineNumberOutOfBounds


def check_for_errors(open_file: list, lines_to_read: list):
"""
Checks if the requested lines to read are within the valid range for the file.
Parameters
----------
open_file : list
A list of file content lines.
lines_to_read : list
A list of line numbers requested to be read.
Raises
------
LineNumberOutOfBounds
If any line number is out of the bounds of the file.
"""

file_length = len(open_file)
err = False

# Check if all line numbers are non-negative
if all(line >= 0 for line in lines_to_read):
if max(lines_to_read) >= file_length:
err = True

# Check if any negative line numbers are present
elif any(line < 0 for line in lines_to_read):
if abs(min(lines_to_read)) > file_length:
err = True
else:
# Adjust negative indices to correspond to positive ones (from the end)
for idx, line in enumerate(lines_to_read):
if line < 0:
lines_to_read[idx] += file_length

if err:
raise LineNumberOutOfBounds("The line number specified is outside the line numbers of the file.")
Loading

0 comments on commit 2084df8

Please sign in to comment.