Skip to content

Conversation

@rolan701
Copy link
Contributor

Added a number of things to ensure safe building with the --ANN flag

rolan701 and others added 9 commits October 30, 2025 17:23
added ANN support
fixed keras versioning causing issues with loading ANN
fixed keras versioning, made it safer, accepts more errors with ease and grace
Updated to better handle keras 3 and safer
added enhanced structgen ANN functionality
new_true = np.where((~prev) & curr)[0] + 1 # +1 for 1-based indexing
batslist.append(list(new_true))
# Update stored state
prev = curr.copy()

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'prev' is unnecessary as it is
redefined
before this value is used.
"""
# initialize ANN
globs = globalvars()

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable globs is not used.
[f"{float(i):.2f}" for i in r_ls[0]]) + ' angstrom')
print('ANN high spin bond length (ax1/ax2/eq) is predicted to be: ' + " /".join(
[f"{float(i):.2f}" for i in r_hs[0]]) + ' angstrom')
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
# fix OB bug: https://github.com/openbabel/openbabel/issues/1983
import sys
import os
import numpy as np

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'np' is not used.
parseCLI)
from molSimplify.Scripts.generator import startgen
from molSimplify.Classes.globalvars import globalvars
from molSimplify.Classes.globalvars import globalvars, geometry_vectors

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'geometry_vectors' is not used.
mod_name = "sklearn.grid_search"
if mod_name not in sys.modules:
sys.modules[mod_name] = _ms
except Exception:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
mod_name = "sklearn.cross_validation"
if mod_name not in sys.modules:
sys.modules[mod_name] = _ms2
except Exception:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
try:
loaded_model = load_keras_ann(predictor)
result = data_rescale(loaded_model.predict(excitation, verbose=0), train_mean_y, train_var_y, debug=debug)
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
loaded_model = load_keras_ann(predictor)
try:
loaded_model = load_keras_ann(predictor)
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
try:
latent_train_row = get_layer_outputs(loaded_model, len(loaded_model.layers) - 2,
[np.array([scaled_row])], training_flag=False)
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
try:
from keras.saving.legacy.model_config import model_from_json as _legacy_model_from_json
except Exception:
_legacy_model_from_json = None

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable _legacy_model_from_json is not used.
except Exception:
_legacy_model_from_json = None
except Exception:
_legacy_model_from_json = None

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable _legacy_model_from_json is not used.
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 10.35503% with 303 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.75%. Comparing base (7304fd4) to head (409e053).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
molSimplify/python_nn/tf_ANN.py 13.52% 179 Missing ⚠️
molSimplify/Scripts/enhanced_structgen.py 0.00% 84 Missing ⚠️
molSimplify/__main__.py 9.09% 30 Missing ⚠️
molSimplify/Scripts/tf_nn_prep.py 28.57% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #482      +/-   ##
==========================================
- Coverage   40.12%   39.75%   -0.37%     
==========================================
  Files          93       93              
  Lines       29560    29886     +326     
==========================================
+ Hits        11861    11882      +21     
- Misses      17699    18004     +305     
Flag Coverage Δ
unittests 39.75% <10.35%> (-0.37%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rolan701 rolan701 merged commit bd92d20 into hjkgrp:main Oct 30, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant