File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
src/pyearthtools/data/transforms/normalisation
tests/data/transform/normalisation Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 2121def format_class_name (class_to_find : object ) -> list [str ]:
2222 """
2323 Format class name for use in normalisation caching
24+ Strip out 'pyearthtools.data' from class names and use the rest
25+ as the identifiers
2426
2527 Args:
2628 class_to_find (str): Class to find name for
2729
2830 Returns:
2931 list[str]: Components of class name
3032 """
33+
34+ # e.g. "<class 'pyearthtools.data.time.Petdt'>"
3135 class_str = str (class_to_find .__class__ ).split ("'" )[1 ]
3236 class_str = class_str .replace (CLASS_NAME_TO_TRIM , "" )
3337 class_str_list = class_str .strip ().split ("." )
3438
35- if "" in class_str_list :
36- class_str_list . remove ( "" )
37- return []
39+ class_str_list = [ e for e in class_str_list if e != "" ]
40+
41+ return class_str_list
Original file line number Diff line number Diff line change 1+ # Copyright Commonwealth of Australia, Bureau of Meteorology 2025.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ from pyearthtools .data .transforms .normalisation import _utils
16+ import pyearthtools .data .time
17+
18+ def test_format_class_name ():
19+
20+ obj = pyearthtools .data .time .Petdt ('2010-01-01' )
21+ result = _utils .format_class_name (obj )
22+ assert result == ['time' , 'Petdt' ]
You can’t perform that action at this time.
0 commit comments