No more use of _ to mark private variables.

This commit is contained in:
2023-08-01 14:02:12 +00:00
parent c8c126962d
commit f0aa9413e1
8 changed files with 87 additions and 94 deletions

View File

@ -4,26 +4,26 @@ namespace DNW\Skills\FactorGraphs;
abstract class FactorGraphLayer
{
private array $_localFactors = [];
private array $localFactors = [];
private array $_outputVariablesGroups = [];
private array $outputVariablesGroups = [];
private $_inputVariablesGroups = [];
private $inputVariablesGroups = [];
protected function __construct(private readonly FactorGraph $_parentFactorGraph)
protected function __construct(private readonly FactorGraph $parentFactorGraph)
{
}
protected function getInputVariablesGroups()
{
return $this->_inputVariablesGroups;
return $this->inputVariablesGroups;
}
// HACK
public function getParentFactorGraph()
{
return $this->_parentFactorGraph;
return $this->parentFactorGraph;
}
/**
@ -31,17 +31,17 @@ abstract class FactorGraphLayer
*/
public function &getOutputVariablesGroups(): array
{
return $this->_outputVariablesGroups;
return $this->outputVariablesGroups;
}
public function getLocalFactors(): array
{
return $this->_localFactors;
return $this->localFactors;
}
public function setInputVariablesGroups(array $value): void
{
$this->_inputVariablesGroups = $value;
$this->inputVariablesGroups = $value;
}
protected function scheduleSequence(array $itemsToSequence, string $name): ScheduleSequence
@ -51,7 +51,7 @@ abstract class FactorGraphLayer
protected function addLayerFactor(Factor $factor): void
{
$this->_localFactors[] = $factor;
$this->localFactors[] = $factor;
}
abstract public function buildLayer();

View File

@ -7,21 +7,21 @@ namespace DNW\Skills\FactorGraphs;
*/
class FactorList
{
private array $_list = [];
private array $list = [];
public function getLogNormalization()
{
$list = $this->_list;
$list = $this->list;
foreach ($list as &$currentFactor) {
$currentFactor->resetMarginals();
}
$sumLogZ = 0.0;
$listCount = count($this->_list);
$listCount = count($this->list);
for ($i = 0; $i < $listCount; $i++) {
$f = $this->_list[$i];
$f = $this->list[$i];
$numberOfMessages = $f->getNumberOfMessages();
@ -41,12 +41,12 @@ class FactorList
public function count()
{
return count($this->_list);
return count($this->list);
}
public function addFactor(Factor $factor)
{
$this->_list[] = $factor;
$this->list[] = $factor;
return $factor;
}