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

Check attribute exists using hasattr() and anchor SQLAlchemy version. #341

Merged
merged 8 commits into from
Feb 6, 2023
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
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ keywords =

[options]
install_requires =
sqlalchemy<2.0.0
hrshdhgd marked this conversation as resolved.
Show resolved Hide resolved
pyparsing
bioregistry
click
Expand Down
1 change: 0 additions & 1 deletion sssom/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def split_file(input_path: str, output_directory: Union[str, Path]) -> None:


def _get_prefix_map(metadata: Metadata, prefix_map_mode: str = None):

if prefix_map_mode is None:
prefix_map_mode = PREFIX_MAP_MODE_METADATA_ONLY

Expand Down
5 changes: 3 additions & 2 deletions sssom/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,11 @@ def _init_mapping_set(meta: Optional[MetadataType]) -> MappingSet:
def _get_mdict_ms_and_bad_attrs(
row: pd.Series, ms: MappingSet, bad_attrs: Counter
) -> Tuple[dict, MappingSet, Counter]:

mdict = {}
sssom_schema_object = (
SSSOMSchemaView.instance if SSSOMSchemaView.instance else SSSOMSchemaView()
SSSOMSchemaView.instance
if hasattr(SSSOMSchemaView, "instance")
hrshdhgd marked this conversation as resolved.
Show resolved Hide resolved
else SSSOMSchemaView()
)
for k, v in row.items():
if v and v == v:
Expand Down
12 changes: 6 additions & 6 deletions sssom/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,16 @@ def assign_default_confidence(
"""
# Get rows having numpy.NaN as confidence
if df is not None:
if CONFIDENCE not in df.columns:
df[CONFIDENCE] = np.NaN
nan_df = pd.DataFrame(columns=df.columns)
new_df = df.copy()
if CONFIDENCE not in new_df.columns:
new_df[CONFIDENCE] = np.NaN
nan_df = pd.DataFrame(columns=new_df.columns)
else:
df = df[~df[CONFIDENCE].isna()]
new_df = df[~df[CONFIDENCE].isna()]
nan_df = df[df[CONFIDENCE].isna()]
else:
ValueError("DataFrame cannot be empty to 'assign_default_confidence'.")
return df, nan_df
return new_df, nan_df


def remove_unmatched(df: pd.DataFrame) -> pd.DataFrame:
Expand Down Expand Up @@ -1496,7 +1497,6 @@ def are_params_slots(params: dict) -> bool:


def _get_sssom_schema_object() -> SSSOMSchemaView:

sssom_sv_object = (
SSSOMSchemaView.instance
if hasattr(SSSOMSchemaView, "instance")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_collapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_collapse(self):
def test_filter(self):
"""Test the row count after filtering redundant rows."""
df = filter_redundant_rows(self.df)
self.assertEqual(len(df), 91)
self.assertEqual(len(df), 92)
matentzn marked this conversation as resolved.
Show resolved Hide resolved

def test_ptable(self):
"""Test the row count of the ptable export."""
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ description = Run code formatters and linters.
[testenv:flake8]
skip_install = true
commands =
flake8 sssom/ tests/ setup.py
hrshdhgd marked this conversation as resolved.
Show resolved Hide resolved
flake8 sssom/ tests/
deps =
flake8<5.0.0
flake8-black
Expand Down