Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymatlib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rahil Doshi
pymatlib
Commits
13abde1e
Commit
13abde1e
authored
3 months ago
by
Rahil Doshi
Browse files
Options
Downloads
Patches
Plain Diff
Extend check_strictly_increasing with warning option instead of hard errors
parent
9d3da812
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pymatlib/core/data_handler.py
+14
-5
14 additions, 5 deletions
src/pymatlib/core/data_handler.py
with
14 additions
and
5 deletions
src/pymatlib/core/data_handler.py
+
14
−
5
View file @
13abde1e
...
@@ -276,18 +276,21 @@ def check_equidistant(temp: np.ndarray, rtol: float = 1e-5, atol: float = 1e-10)
...
@@ -276,18 +276,21 @@ def check_equidistant(temp: np.ndarray, rtol: float = 1e-5, atol: float = 1e-10)
return
0.0
return
0.0
def
check_strictly_increasing
(
arr
,
name
=
"
Array
"
,
threshold
=
0.1
):
def
check_strictly_increasing
(
arr
,
name
=
"
Array
"
,
threshold
=
1e-10
,
raise_error
=
True
):
"""
"""
Check if array is strictly monotonically increasing
and raise ValueError if not
.
Check if array is strictly monotonically increasing.
Args:
Args:
arr: numpy array to check
arr: numpy array to check
name: name of array for reporting
name: name of array for reporting
threshold: minimum required difference between consecutive elements
threshold: minimum required difference between consecutive elements
raise_error: if True, raises ValueError; if False, returns False on failure
Returns:
bool: True if array is strictly increasing, False otherwise (if raise_error=False)
Raises:
Raises:
ValueError: If array is not strictly increasing, with detailed information
ValueError: If array is not strictly increasing and raise_error=True
about where the violation occurs
"""
"""
for
i
in
range
(
1
,
len
(
arr
)):
for
i
in
range
(
1
,
len
(
arr
)):
diff
=
arr
[
i
]
-
arr
[
i
-
1
]
diff
=
arr
[
i
]
-
arr
[
i
-
1
]
...
@@ -306,7 +309,13 @@ def check_strictly_increasing(arr, name="Array", threshold=0.1):
...
@@ -306,7 +309,13 @@ def check_strictly_increasing(arr, name="Array", threshold=0.1):
f
"
Difference:
{
diff
:
.
10
e
}
\n
"
f
"
Difference:
{
diff
:
.
10
e
}
\n
"
f
"
{
context
}
"
f
"
{
context
}
"
)
)
raise
ValueError
(
error_msg
)
if
raise_error
:
raise
ValueError
(
error_msg
)
else
:
print
(
f
"
Warning:
{
error_msg
}
"
)
return
False
print
(
f
"
{
name
}
is strictly monotonically increasing
"
)
print
(
f
"
{
name
}
is strictly monotonically increasing
"
)
return
True
return
True
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment