[
https://issues.apache.org/jira/browse/MAHOUT-826?focusedWorklogId=1000331&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1000331
]
ASF GitHub Bot logged work on MAHOUT-826:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 15/Jan/26 16:20
Start Date: 15/Jan/26 16:20
Worklog Time Spent: 10m
Work Description: viiccwen commented on code in PR #832:
URL: https://github.com/apache/mahout/pull/832#discussion_r2695080042
##########
conftest.py:
##########
@@ -0,0 +1,98 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Root pytest configuration for Apache Mahout.
+
+This module provides:
+- Custom pytest markers (gpu, slow)
+- Auto-skip logic for QDP tests when the native extension is not built
+- Shared fixtures for QDP availability checking
+
+QDP tests are automatically skipped if the _qdp extension is not available,
+allowing contributors without CUDA to run the qumat test suite.
+"""
+
+import importlib.util
+
+import pytest
+
+# Check if QDP extension is available at module load time
+_QDP_SPEC = importlib.util.find_spec("_qdp")
+_QDP_AVAILABLE = _QDP_SPEC is not None
+_QDP_IMPORT_ERROR = None if _QDP_AVAILABLE else "No module named '_qdp'"
+
+
+def pytest_configure(config):
+ """Register custom pytest markers."""
+ config.addinivalue_line(
+ "markers", "gpu: marks tests as requiring GPU and _qdp extension"
+ )
+ config.addinivalue_line("markers", "slow: marks tests as slow running")
+
+
+def pytest_collection_modifyitems(config, items):
+ """Auto-skip GPU/QDP tests if the _qdp extension is not available."""
+ if _QDP_AVAILABLE:
+ return
+
+ skip_marker = pytest.mark.skip(
+ reason=f"QDP extension not available: {_QDP_IMPORT_ERROR}. "
+ "Build with: cd qdp/qdp-python && maturin develop"
+ )
+
+ for item in items:
+ # Skip tests explicitly marked with @pytest.mark.gpu
+ if "gpu" in item.keywords:
+ item.add_marker(skip_marker)
+
+ # Skip all tests in testing/qdp/ directory
+ fspath_str = str(item.fspath)
+ if "testing/qdp" in fspath_str or "testing\\qdp" in fspath_str:
Review Comment:
I saw it in [#828](https://github.com/apache/mahout/issues/828) : )
##########
conftest.py:
##########
@@ -0,0 +1,98 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Root pytest configuration for Apache Mahout.
+
+This module provides:
+- Custom pytest markers (gpu, slow)
+- Auto-skip logic for QDP tests when the native extension is not built
+- Shared fixtures for QDP availability checking
+
+QDP tests are automatically skipped if the _qdp extension is not available,
+allowing contributors without CUDA to run the qumat test suite.
+"""
+
+import importlib.util
+
+import pytest
+
+# Check if QDP extension is available at module load time
+_QDP_SPEC = importlib.util.find_spec("_qdp")
+_QDP_AVAILABLE = _QDP_SPEC is not None
+_QDP_IMPORT_ERROR = None if _QDP_AVAILABLE else "No module named '_qdp'"
+
+
+def pytest_configure(config):
+ """Register custom pytest markers."""
+ config.addinivalue_line(
+ "markers", "gpu: marks tests as requiring GPU and _qdp extension"
+ )
+ config.addinivalue_line("markers", "slow: marks tests as slow running")
+
+
+def pytest_collection_modifyitems(config, items):
+ """Auto-skip GPU/QDP tests if the _qdp extension is not available."""
+ if _QDP_AVAILABLE:
+ return
+
+ skip_marker = pytest.mark.skip(
+ reason=f"QDP extension not available: {_QDP_IMPORT_ERROR}. "
+ "Build with: cd qdp/qdp-python && maturin develop"
+ )
+
+ for item in items:
+ # Skip tests explicitly marked with @pytest.mark.gpu
+ if "gpu" in item.keywords:
+ item.add_marker(skip_marker)
+
+ # Skip all tests in testing/qdp/ directory
+ fspath_str = str(item.fspath)
+ if "testing/qdp" in fspath_str or "testing\\qdp" in fspath_str:
Review Comment:
oh, I saw it in [#828](https://github.com/apache/mahout/issues/828) : )
Issue Time Tracking
-------------------
Worklog Id: (was: 1000331)
Time Spent: 40m (was: 0.5h)
> Bayes/CBayes classification on a non-existing feature
> -----------------------------------------------------
>
> Key: MAHOUT-826
> URL: https://issues.apache.org/jira/browse/MAHOUT-826
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.5
> Reporter: Andre-Philippe Paquet
> Assignee: Robin Anil
> Priority: Minor
> Fix For: 0.7
>
> Attachments: mahout-826.patch, mahout-826.patch
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> (see http://comments.gmane.org/gmane.comp.apache.mahout.user/9597)
> Using CBayes or Bayes, when trying to classify a feature/word that doesn't
> exist in the model, instead of returning the default/unknown label, the
> algorithm returns all labels with a constant score (ex: 12.386649147018964).
> After a quick look in CBayesAlgorithm, I found the problem in the
> featureWeight function that returns the theta normalized weight even if the
> feature didn't have any match (result=0).
> As a fix, I overrided the function in a subclass and return 0 if the weight
> of the current feature in the current label is 0.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)