Skip to content

Commit bd16994

Browse files
authored
Merge pull request #3 from NRCan/dev
small bug fixes and initial review updates
2 parents ecf25ff + 4fc8dbc commit bd16994

31 files changed

+1429
-205
lines changed

CONTRIBUTING.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# CanCurve development
2+
3+
## Installation
4+
Typically, development should employ a virtual environment with pyqgis bindings.
5+
We usually develop to target the most recent QGIS LTR.
6+
Some additional packages for testing are specified in `./requirements.txt`
7+
8+
### PYTHONPATH
9+
only the source directory should be included (`./CanCurve` not `./CanCurve/cancurve`)
10+
11+
## Tests
12+
pytests are in `./tests`
13+
14+
## Compiling
15+
the only compiling typically requied is when the qt `resources.qrc` file is changed. This needs to be ported to a python module (typically using `pyrcc5 -o resources.py resources.qrc` as in `./dev_tools/plug_compile.bat`)
16+
17+
18+
19+
## Deploying Plugin
20+
21+
### Active Development
22+
Typically a `dev` QGIS profile is maintained with a custom `QGIS_PLUGINPATH` pointed to the project source directory. This facilitates plugin updating with the `plugin reload` (ie no real deployment)
23+
24+
### Pre-Release testing
25+
Pre-release testing (and full deployment) employ a zip of the plugin directory (see `./dev_tools/plug_zip.bat`):
26+
1) remove all `__pychace__`
27+
2) zip/archive the plugin directory
28+
29+
This zip file can then be distributed using a git-hub release (upload the zip file to the github release... NOT the git repo tracking)
30+
31+
32+
### Full QGIS Repository release
33+
- [ ] create the plugin zip as above
34+
35+
- [ ] in git-hub, create a new release tag (e.g., v1.2.0), summarize new features for developers. upload the zip file.
36+
37+
- [ ] login to [plugins.qgis.org](https://plugins.qgis.org/accounts/login/?next=/plugins/my) using the CanFlood credentials (ask Nicky). Navigate to **Upload a plugin** and select the zip file.
38+
39+
- [ ] In QGIS, refresh the repository and ensure that the new version is available (may take ~10mins for the version to be available). Upgrade and check that it works.
40+
41+
- [ ] notify project team
42+
43+
## Developing an Update
44+
45+
the dev branch is where new features and fixes are collected and tested before release. The following should be executed on the dev branch in preparation for pushing to the main branch:
46+
47+
- [ ] add/update documentation where applicable
48+
49+
- [ ] backwards merge master into dev to capture any upstream changes (these should be minor and limited to documentation tweaks as all development is done on the dev branch)
50+
51+
- [ ] ensure the version tag is updated on `.\cancurve\__init__.py`
52+
53+
- [ ] update the README.md to summarize any new features for users
54+
55+
- [ ] similarly update cancurve\metadata.txt
56+
57+
- [ ] execute all tests. investigate warnings. fix errors.
58+
59+
- [ ] perform a 'person test' by having a non-developer follow relevant tutorials. investigate warnings and fix errors.
60+
61+
- [ ] Once these tests are complete **and passing**, a pull request should be completed and the dev branch merged into the main.
62+
63+
- [ ] Follow the above **Deploying Plugin/Full QGIS Repository Release** on the main branch

LICENSE_TBD

Whitespace-only changes.

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ CanCurve is an open-source tool which can develop depth-damage (stage-damage) fu
55
<img src="./cancurve/img/icon.png" alt="CanCurve Icon">
66
</p>
77

8+
9+
## Updates
10+
- 2024-05-09: small fixes and updates based on initial comments
11+
- 2024-05-01: initial working release (un tested) [v0.0.1](https://github.com/NRCan/CanCurve/releases/tag/v0.0.1)
12+
813

914
## Installation
1015
- Install [QGIS 3.34.5](https://download.qgis.org/downloads/) (with Qt 5.15.13)
1116
- download the `cancurve.zip` file from the latest release to your local machine
1217
- in QGIS, `Manage and Install Plugins...` > `Install from ZIP` > select the downloaded file
1318
- it is recommended to also install the **First Aid** plugin for more detailed error messages.
1419
- it is recommended to set up the QGIS Debug Log file as shown [here](https://stackoverflow.com/a/61669864/9871683)
20+
- CanCurve backend and project data is implemented in SQLite relational databases. For enhanced customization and debugging, it is recommended to install a SQLite viewer + editor like [DB Browser for SQLite](https://sqlitebrowser.org/) for working with these files.
1521

1622

1723

cancurve/__init__.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
#===============================================================================
2+
# plugin metadata
3+
#===============================================================================
4+
__version__='0.0.2'
15

2-
__version__='0.0'
3-
6+
#===============================================================================
7+
# plugin entry point
8+
#===============================================================================
49
# noinspection PyPep8Naming
510
def classFactory(iface): # pylint: disable=invalid-name
611
"""Load CanCurve class from file CanCurve.
@@ -10,4 +15,23 @@ def classFactory(iface): # pylint: disable=invalid-name
1015
"""
1116
#
1217
from .plugin import CanCurve
13-
return CanCurve(iface)
18+
return CanCurve(iface)
19+
20+
#===============================================================================
21+
# dependency check
22+
#===============================================================================
23+
24+
25+
26+
import importlib, warnings
27+
28+
def check_package(package_name):
29+
spec = importlib.util.find_spec(package_name)
30+
if spec is not None:
31+
print(f'module {package_name} is installed')
32+
else:
33+
warnings.warn(f'module \'{package_name}\' not installed')
34+
35+
36+
check_package('openpyxl')
37+

cancurve/bldgs/assertions.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pandas as pd
1010

1111
from .parameters import colns_index, colns_dtypes, bldg_meta_rqmt_df
12+
from ..hp.basic import view_web_df as view
1213

1314

1415
expected_tables_base = ['project_meta','project_settings','c00_bldg_meta', 'c00_cost_items','c00_drf']
@@ -39,9 +40,10 @@ def assert_ci_df(df):
3940
# Check data types
4041
for coln, dstr in df.dtypes.items():
4142
if coln not in colns_dtypes:
42-
raise IOError(f'Unrecognized column name in estimate data: \'{coln}\'')
43-
if dstr != colns_dtypes[coln]: # More specific check
44-
raise AssertionError(f"Incorrect data type for column '{coln}'. Expected: {colns_dtypes[coln]}, Found: {dstr}")
43+
print(f'Unrecognized column name in estimate data: \'{coln}\'')
44+
else:
45+
if dstr != colns_dtypes[coln]: # More specific check
46+
raise AssertionError(f"Incorrect data type for column '{coln}'. Expected: {colns_dtypes[coln]}, Found: {dstr}")
4547

4648

4749
#===============================================================================
@@ -118,6 +120,8 @@ def assert_drf_df(df):
118120
Raises:
119121
TypeError: If the input is not a DataFrame or columns have non-float types.
120122
KeyError: If the DataFrame's index names are incorrect.
123+
124+
view(df)
121125
"""
122126

123127
# Check if it's a DataFrame
@@ -128,14 +132,15 @@ def assert_drf_df(df):
128132
if not set(df.index.names).difference(['cat', 'sel', 'bldg_layout']) == set():
129133
raise KeyError("Incorrect index names in DataFrame")
130134

131-
# Check data types
135+
# Check the columns all conform to float depths
132136
if not 'float' in df.columns.dtype.name:
133-
raise TypeError('bad type on columns')
137+
raise TypeError(f'DRF column headers expected as dtype float. instead got \'{df.columns.dtype.name}\'')
134138

135139
# Check data types (more accurate)
136-
for col in df.columns:
137-
if df[col].dtype != 'float64': # Assuming you want specifically float64
138-
raise TypeError(f"Column '{col}' is not a float type")
140+
141+
for i, col in enumerate(df.columns):
142+
if not 'float' in df[col].dtype.name: # Assuming you want specifically float64
143+
raise TypeError(f'DRF column \'{col}\' ({i}) expected as dtype float. instead got \'{df[col].dtype}\'')
139144

140145
def assert_bldg_meta_d(bldg_meta):
141146
"""check the bldg_meta_d meets expectations"""

cancurve/bldgs/bldg_meta_rqmts.csv

+38-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
varName_core,varName_ui,varName_canflood,type,required_core,required_canflood,default_canflood,widgetName,case1,case2
2-
,,tag,str,FALSE,TRUE,?,,test_case1,test_case2
3-
,,location,str,FALSE,FALSE,?,,,
4-
,,date,str,FALSE,FALSE,?,,,
5-
,,source,str,FALSE,FALSE,?,,,
6-
,currency,impact_units,str,FALSE,TRUE,$CAD,currency_ComboBox,,
7-
,costBasis,impact_var,str,FALSE,FALSE,damage,costBasis_ComboBox,,
8-
,,exposure_units,str,FALSE,FALSE,m,comboBox_tab3dataInput_expoUnits,,
9-
,,exposure_var,str,FALSE,FALSE,flood depth above floor,,,
10-
,,scale_var,str,FALSE,FALSE,building footprint,,,
11-
bldg_layout,buildingLayout,,str,TRUE,FALSE,,buildingLayout_ComboBox,default,default
12-
,basementHeight,,float,FALSE,FALSE,,basementHeight_DoubleSpinBox,1.8,2.1
13-
,basementHeightUnits,,str,FALSE,FALSE,,basementHeightUnits_ComboBox,m,m
14-
basement_height_m,,,float,TRUE,FALSE,,,1.8,2.1
15-
,sizeOrAreaValue,,float,FALSE,FALSE,,sizeOrAreaValue_DoubleSpinBox,232.1,232.2
16-
,sizeOrAreaUnits,scale_units,str,FALSE,FALSE,m2,sizeOrAreaUnits_ComboBox,m2,m2
17-
scale_value_m2,,,float,TRUE,FALSE,,,232.1,232.2
18-
,,exposure,str,FALSE,TRUE,impact,,,
19-
,occupancyClassification,,str,FALSE,FALSE,,occupancyClassification_ComboBox,,
20-
,subClassification,,str,FALSE,FALSE,,subClassification_ComboBox,,
21-
,storeys,,str,FALSE,FALSE,,storeys_ComboBox,,
22-
,heatingType,,str,FALSE,FALSE,,heatingType_ComboBox,,
23-
,coolingType,,str,FALSE,FALSE,,coolingType_ComboBox,,
24-
,garageType,,str,FALSE,FALSE,,garageType_ComboBox,,
25-
,garageSize,,str,FALSE,FALSE,,garageSize_ComboBox,,
26-
,buildingLayout,,str,FALSE,FALSE,,buildingLayout_ComboBox,,
27-
,foundationType,,str,FALSE,FALSE,,foundationType_ComboBox,,
28-
,qualityOfBuildingMaterials,,str,FALSE,FALSE,,qualityOfBuildingMaterials_ComboBox,,
29-
,provinceTerritory,,str,FALSE,FALSE,,provinceTerritory_ComboBox,,
30-
,taxesIncluded,,str,FALSE,FALSE,,taxesIncluded_ComboBox,,
31-
,priceListSource,,str,,,,,,
32-
,country,,str,,,,,,
33-
,BathroomCount,,int,,,,,,
34-
,pricingDate,,str,,,,,,
35-
,BedroomCount,,int,,,,,,
36-
,basementFinish,,str,,,,,,
37-
,createdBy,,str,,,,,,
38-
,locationCityTownRegion,,str,,,,,,
39-
,yearOfBuildingConstruction,,int,,,,,,
1+
varName_core,varName_ui,varName_canflood,type,required_core,required_canflood,default_canflood,widgetName,case1,case2,case3
2+
,,tag,str,FALSE,TRUE,?,,test_case1,test_case2,heather_0509
3+
,,location,str,FALSE,FALSE,?,,,,
4+
,,date,str,FALSE,FALSE,?,,,,
5+
,,source,str,FALSE,FALSE,?,,,,
6+
,currency,impact_units,str,FALSE,TRUE,$CAD,currency_ComboBox,,,
7+
,costBasis,impact_var,str,FALSE,FALSE,damage,costBasis_ComboBox,,,Depreciated Costs
8+
,,exposure_units,str,FALSE,FALSE,m,comboBox_tab3dataInput_expoUnits,,,
9+
,,exposure_var,str,FALSE,FALSE,flood depth above floor,,,,
10+
,,scale_var,str,FALSE,FALSE,building footprint,,,,
11+
bldg_layout,buildingLayout,,str,TRUE,FALSE,,buildingLayout_ComboBox,default,default,default
12+
,basementHeight,,float,FALSE,FALSE,,basementHeight_DoubleSpinBox,1.8,2.1,0
13+
,basementHeightUnits,,str,FALSE,FALSE,,basementHeightUnits_ComboBox,m,m,m
14+
basement_height_m,,,float,TRUE,FALSE,,,1.8,2.1,0
15+
,sizeOrAreaValue,,float,FALSE,FALSE,,sizeOrAreaValue_DoubleSpinBox,232.1,232.2,344
16+
,sizeOrAreaUnits,scale_units,str,FALSE,FALSE,m2,sizeOrAreaUnits_ComboBox,m2,m2,m2
17+
scale_value_m2,,,float,TRUE,FALSE,,,232.1,232.2,344
18+
,,exposure,str,FALSE,TRUE,impact,,,,
19+
,occupancyClassification,,str,FALSE,FALSE,,occupancyClassification_ComboBox,,,Commercial
20+
,subClassification,,str,FALSE,FALSE,,subClassification_ComboBox,,,Construction
21+
,storeys,,str,FALSE,FALSE,,storeys_ComboBox,,,1
22+
,BedroomCount,,int,FALSE,FALSE,,BedroomCount_QSpinBox,,,0
23+
,BathroomCount,,float,FALSE,FALSE,,BathroomCount_DoubleSpinBox,,,1
24+
,heatingType,,str,FALSE,FALSE,,heatingType_ComboBox,,,Forced Air - Gas
25+
,coolingType,,str,FALSE,FALSE,,coolingType_ComboBox,,,Central air
26+
,garageType,,str,FALSE,FALSE,,garageType_ComboBox,,,None
27+
,garageSize,,str,FALSE,FALSE,,garageSize_ComboBox,,,
28+
,foundationType,,str,FALSE,FALSE,,foundationType_ComboBox,,,other
29+
,qualityOfBuildingMaterials,,str,FALSE,FALSE,,qualityOfBuildingMaterials_ComboBox,,,Average
30+
,taxesIncluded,,str,FALSE,FALSE,,taxesIncluded_ComboBox,,,
31+
,priceListSource,,str,FALSE,FALSE,,priceListSource_LineEdit,,,exactimate
32+
,country,,str,FALSE,FALSE,Canada,country_ComboBox,,,Canada
33+
,provinceTerritory,,str,FALSE,FALSE,,provinceTerritory_ComboBox,,,ON
34+
,pricingDate,,str,FALSE,FALSE,,,,,
35+
,basementFinish,,float,FALSE,FALSE,,basementFinish_DoubleSpinBox,,,100
36+
,createdBy,,str,FALSE,FALSE,,createdBy_LineEdit,,,hmcgrath
37+
,locationCityTownRegion,,str,FALSE,FALSE,,,,,
38+
,yearOfBuildingConstruction,,int,FALSE,FALSE,,yearOfBuildingConstruction_SpinBox,,,2500

0 commit comments

Comments
 (0)