Skip to content

Commit

Permalink
fixed flake8 errors identified in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stuchalk committed Dec 18, 2023
1 parent 4d14c6d commit 9cc6386
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
4 changes: 1 addition & 3 deletions examples/example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ def convert_rruff():
'name': name,
'formula': formula
}
meta = requests.get(
'https://opsin.ch.cam.ac.uk/opsin/' +
name).json() # get metadata from OPSIN
meta = requests.get('https://opsin.ch.cam.ac.uk/opsin/' + name).json() # get metadata from OPSIN
ignore = ['status', 'message', 'cml', 'inchi']
for key, value in meta.items():
if key not in ignore:
Expand Down
14 changes: 7 additions & 7 deletions scidatalib/io/jcamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def _read_parse_dataset_duplicate_characters(line: str) -> str:
# NOTE: subtract one since we will already have one character from
# the original one we are duplicating from.
nduplicates = DUP_digits[char] - 1
new_line += line[i-1] * nduplicates
new_line += line[i - 1] * nduplicates
else:
new_line += char
return "".join(new_line)
Expand Down Expand Up @@ -451,16 +451,16 @@ def _read_post_process_data_xy(
if jcamp_dict.get(_DATA_XY_TYPE_KEY) == _DATA_FORMAT_XYYY:
xstart.append(jcamp_dict['lastx'])
x = np.array([])
for n in range(len(xnum)-1):
dx = (xstart[n+1] - xstart[n]) / xnum[n]
x = np.append(x, xstart[n]+(dx*np.arange(xnum[n])))
for n in range(len(xnum) - 1):
dx = (xstart[n + 1] - xstart[n]) / xnum[n]
x = np.append(x, xstart[n] + (dx * np.arange(xnum[n])))

if xnum[len(xnum) - 1] > 1:
numerator = (jcamp_dict['lastx'] - xstart[len(xnum)-1])
denominator = (xnum[len(xnum)-1] - 1.0)
denominator = (xnum[len(xnum) - 1] - 1.0)
dx = numerator / denominator

xnext = xstart[len(xnum)-1]+(dx*np.arange(xnum[len(xnum)-1]))
xnext = xstart[len(xnum) - 1] + (dx * np.arange(xnum[len(xnum) - 1]))
x = np.append(x, xnext)
else:
x = np.append(x, jcamp_dict['lastx'])
Expand Down Expand Up @@ -660,7 +660,7 @@ def _read_get_aspects_section(jcamp_dict: dict) -> dict:
"@id": "measurement/1",
"@type": "sdo:measurement",
"techniqueType": "cao:spectroscopy",
"instrument": f'{jcamp_dict.get("spectrometer/data system")}',
"instrument": f'{jcamp_dict.get("spectrometer/data system")}',
}

settings = []
Expand Down
10 changes: 5 additions & 5 deletions scidatalib/io/rruff.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ def _read_translate_rruff_to_scidata(rruff_dict: dict) -> dict:

if "url" in rruff_dict:
sources.append({
"@id": f"source/{len(sources) + 1}",
"@type": "dc:source",
"citation": "RRUFF project database entry",
"url": f'https://{rruff_dict.get("url")}',
})
"@id": f"source/{len(sources) + 1}",
"@type": "dc:source",
"citation": "RRUFF project database entry",
"url": f'https://{rruff_dict.get("url")}',
})
scidata.sources(sources)

# Discipline and sub-discipline
Expand Down
18 changes: 9 additions & 9 deletions scidatalib/scidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, uid: str):
},
"sources": [], # def sources
"rights": [] # def rights
}
}
}
self.contexts = []
self.nspaces = {}
Expand Down Expand Up @@ -457,19 +457,19 @@ def ids(self, ids: [str, list]) -> list:
for idee in ids:
if ':' in idee:
if idee.split(':')[0] not in self.nspaces.keys():
print('Note: Namespace <'
+ idee.split(':')[0]
+ "> not set. A crosswalk "
"url prefix is likely not "
"matched with it's linked namespace")
print('Note: Namespace <' +
idee.split(':')[0] +
"> not set. A crosswalk "
"url prefix is likely not "
"matched with it's linked namespace")
# raise EnvironmentError
curr_ids.append(idee)
elif isinstance(ids, str):
if ':' in ids:
if ids.split(':')[0] not in self.nspaces.keys():
print('Note: Namespace <' + ids.split(':')[0]
+ "> not set. A crosswalk url prefix is "
"likely not matched with it's linked namespace")
print('Note: Namespace <' + ids.split(':')[0] +
"> not set. A crosswalk url prefix is "
"likely not matched with it's linked namespace")
# raise EnvironmentError
curr_ids.append(ids)
self.meta['@graph']['ids'] = sorted(set(curr_ids))
Expand Down
3 changes: 2 additions & 1 deletion tests/test_scidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ def test_datagroup_with_datapoints(sd):
"datapoint/3/",
"datapoint/4/"
]
}]
}
]
assert sd.datagroup([datagrp1, datagrp2]) == out


Expand Down

0 comments on commit 9cc6386

Please sign in to comment.