Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plot.py #89

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -17,6 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint
- name: Analysing the code with pylint
run: |
Expand Down
83 changes: 9 additions & 74 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extension-pkg-whitelist=

# Specify a score threshold to be exceeded before program exits with error.
fail-under=10.0
fail-under=8.0

# Add files or directories to the blacklist. They should be base names, not
# paths.
Expand Down Expand Up @@ -60,86 +60,21 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape

consider-using-f-string,
too-many-lines,
missing-function-docstring,
line-too-long,
trailing-whitespace,
duplicate-code,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
Expand Down
23 changes: 12 additions & 11 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__authors__ = ["Frédéric-Emmanuel Picca", "Jérôme Kieffer"]
__contact__ = "[email protected]"
__license__ = "MIT"
__date__ = "03/03/2023"
__date__ = "12/07/2024"

import sys
import os
Expand All @@ -23,6 +23,7 @@
logging.basicConfig()
logger = logging.getLogger("bootstrap")

LIBPATH = ""

def get_project_name(root_dir):
"""Retrieve project name by running python setup.py --name in root_dir.
Expand Down Expand Up @@ -116,14 +117,14 @@ def run_file(filename, argv):
# Providing globals() as locals will force to feed the file into
# globals() (for examples imports).
# Without this any function call from the executed file loses imports
old_argv = sys.argv
sys.argv = full_args
logger.info("Patch the sys.argv: %s", sys.argv)
logger.info("Executing %s.main()", filename)
print("########### EXECFILE ###########")
module_globals = globals().copy()
module_globals['__file__'] = filename
try:
old_argv = sys.argv
sys.argv = full_args
logger.info("Patch the sys.argv: %s", sys.argv)
logger.info("Executing %s.main()", filename)
print("########### EXECFILE ###########")
module_globals = globals().copy()
module_globals['__file__'] = filename
execfile(filename, module_globals, module_globals)
finally:
sys.argv = old_argv
Expand Down Expand Up @@ -154,10 +155,10 @@ def run_entry_point(target_name, entry_point, argv):
logger.info("Execute target %s (function %s from module %s) using importlib", target_name, function_name, module_name)
full_args = [target_name]
full_args.extend(argv)
old_argv = sys.argv
sys.argv = full_args
print("########### IMPORTLIB ###########")
try:
old_argv = sys.argv
sys.argv = full_args
print("########### IMPORTLIB ###########")
module = importlib.import_module(module_name)
if hasattr(module, function_name):
func = getattr(module, function_name)
Expand Down
1 change: 1 addition & 0 deletions src/freesas/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ def alignment_2models(self, save=True):

:return dist: NSD after alignment
"""
dist = None
models = self.models
reference = models[0]
molecule = models[1]
Expand Down
17 changes: 8 additions & 9 deletions src/freesas/app/cormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
__author__ = "Jérôme Kieffer"
__license__ = "MIT"
__copyright__ = "2015, ESRF"
__date__ = "20/04/2020"
__date__ = "12/07/2024"

import os
import logging
import freesas
from freesas.cormap import gof

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("cormap")
import numpy
import glob
from itertools import combinations
from collections import namedtuple
import numpy
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("cormap")
import freesas
from freesas.cormap import gof
from freesas.sasio import load_scattering_data
from freesas.sas_argparser import SASParser

Expand All @@ -24,8 +24,7 @@
import platform

operatingSystem = platform.system()
if operatingSystem == "Windows":
import glob



def parse():
Expand Down
6 changes: 4 additions & 2 deletions src/freesas/dnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ def linear(x):

# Parse config.json
def parse_config(config_path):
config = {}
if isinstance(config_path, io.IOBase):
config = json.load(config_path)
elif os.path.exists(config_path):
with open(config_path, 'r') as f:
config = json.load(f)

else:
raise RuntimeError(f"config_path type {type(config_path)} not handled, got {config_path}")
layer_dims = []
activations = []

for layer in config['config']['layers']:
for layer in config.get('config',{}).get('layers', {}):
if layer['class_name'] == 'InputLayer':
layer_dims.append(layer['config']['batch_shape'][1])
elif layer['class_name'] == 'Dense':
Expand Down
2 changes: 1 addition & 1 deletion src/freesas/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, molecule=None):
self.header = "" # header of the PDB file
self.rfactor = None
self.radius = 1.0 # unused at the moment
self.com = []
self.com = numpy.array([])
self._fineness = None
self._Rg = None
self._Dmax = None
Expand Down
8 changes: 4 additions & 4 deletions src/freesas/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def scatter_plot(
ax.errorbar(
q,
I,
err,
numpy.maximum(0,err),
label=label_exp,
capsize=0,
color=exp_color,
Expand All @@ -100,7 +100,7 @@ def scatter_plot(
ax.errorbar(
q,
I,
err,
numpy.maximum(0,err),
label=label_exp,
capsize=0,
color=exp_color,
Expand Down Expand Up @@ -210,7 +210,7 @@ def kratky_plot(
xdata = q * Rg
ydata = xdata * xdata * I / I0
if err is not None:
dy = xdata * xdata * err / I0
dy = xdata * xdata * numpy.maximum(0,err) / abs(I0)
dplot = ax.errorbar(
xdata,
ydata,
Expand Down Expand Up @@ -302,7 +302,7 @@ def guinier_plot(
else:
fig, ax = subplots(figsize=(12, 10))
if err is not None:
dlogI = err[mask] / logI
dlogI = err[mask] / I[mask]
ax.errorbar(
q2,
logI,
Expand Down
Loading